cgv
|
windows only implementation of functionality to create and draw an RGBA texture representing standard mouse cursor icons. More...
#include <gl_cursor.h>
Public Member Functions | |
void | update_duration () |
void | clear () |
void | add_frame (unsigned tex_id) |
gl_cursor () | |
construct empty gl_cursor instance | |
bool | is_created () const |
check whether cursor has been created | |
bool | create (const std::string &id="arrow") |
Create cursor from textual name of default cursor. | |
bool | create_from_file (const std::string &file_name) |
Create cursor from a file of type .cur or .ani. | |
unsigned | get_width () const |
return the width of the cursor | |
unsigned | get_height () const |
return the height of the cursor | |
int | get_hot_x () const |
return the x-coordinate of the hot spot of the cursor in local pixel coordinates | |
int | get_hot_y () const |
return the y-coordinate of the hot spot of the cursor in local pixel coordinates | |
void | set_hot_spot (int _x, int _y) |
set a new hot spot of the cursor in local pixel coordinates | |
unsigned | get_nr_steps () const |
return the number of animation steps | |
unsigned | get_nr_frames () const |
return the number of animation frames | |
unsigned | get_texture_id (unsigned frame_idx=0) const |
return the gl texture id of the given frame | |
unsigned | get_step_frame (unsigned step_idx) const |
return the frame index of given step | |
void | set_step_frame (unsigned step_idx, unsigned frame_idx) |
set the frame index of given step | |
unsigned | get_step_period (unsigned step_idx) const |
return the period of given step in 1/60th of a second | |
void | set_step_period (unsigned step_idx, unsigned period) |
return the period of given step in 1/60th of a second | |
void | append_step (unsigned frame_idx, unsigned period) |
append an animation step given by frame index and step period | |
unsigned | find_step_index (double elapsed_seconds) const |
find the step index of a given elapsed time in seconds | |
unsigned | get_frame_texture_id (int frame_idx) const |
return the gl texture id of the given frame | |
void | draw (int x, int y, bool use_color=false, unsigned frame_idx=0) |
draw the cursor at the given location | |
Public Attributes | |
int | hot_x |
int | hot_y |
unsigned | w |
unsigned | h |
std::vector< unsigned > | tex_ids |
std::vector< unsigned > | frames |
std::vector< unsigned > | periods |
unsigned | duration |
windows only implementation of functionality to create and draw an RGBA texture representing standard mouse cursor icons.
This class is completely standalone and does not depend on any other file in the cgv framework.
Definition at line 15 of file gl_cursor.h.
cgv::render::gl::gl_cursor::gl_cursor | ( | ) |
construct empty gl_cursor instance
Definition at line 205 of file gl_cursor.cxx.
void cgv::render::gl::gl_cursor::add_frame | ( | unsigned | tex_id | ) |
Definition at line 226 of file gl_cursor.cxx.
void cgv::render::gl::gl_cursor::append_step | ( | unsigned | frame_idx, |
unsigned | period | ||
) |
append an animation step given by frame index and step period
Definition at line 496 of file gl_cursor.cxx.
void cgv::render::gl::gl_cursor::clear | ( | ) |
Definition at line 216 of file gl_cursor.cxx.
bool cgv::render::gl::gl_cursor::create | ( | const std::string & | id = "arrow" | ) |
Create cursor from textual name of default cursor.
This can only be called when the opengl context is active in which this cursor is used. The return value tells whether the creation was successful. Possible values for the cursor id are:
Definition at line 432 of file gl_cursor.cxx.
bool cgv::render::gl::gl_cursor::create_from_file | ( | const std::string & | file_name | ) |
Create cursor from a file of type .cur or .ani.
Definition at line 437 of file gl_cursor.cxx.
void cgv::render::gl::gl_cursor::draw | ( | int | x, |
int | y, | ||
bool | use_color = false , |
||
unsigned | frame_idx = 0 |
||
) |
draw the cursor at the given location
The current opengl transformation must result in a scaling proportional to pixel coordinates. By default the texture color and alpha values are directly drawn to screen. If use_color
is set to true, color and alpha are multiplied with the currently set color.
Definition at line 515 of file gl_cursor.cxx.
unsigned cgv::render::gl::gl_cursor::find_step_index | ( | double | elapsed_seconds | ) | const |
find the step index of a given elapsed time in seconds
Definition at line 504 of file gl_cursor.cxx.
|
inline |
return the height of the cursor
Definition at line 55 of file gl_cursor.h.
|
inline |
return the x-coordinate of the hot spot of the cursor in local pixel coordinates
Definition at line 57 of file gl_cursor.h.
|
inline |
return the y-coordinate of the hot spot of the cursor in local pixel coordinates
Definition at line 59 of file gl_cursor.h.
unsigned cgv::render::gl::gl_cursor::get_nr_frames | ( | ) | const |
return the number of animation frames
Definition at line 459 of file gl_cursor.cxx.
unsigned cgv::render::gl::gl_cursor::get_nr_steps | ( | ) | const |
return the number of animation steps
Definition at line 453 of file gl_cursor.cxx.
unsigned cgv::render::gl::gl_cursor::get_step_frame | ( | unsigned | step_idx | ) | const |
return the frame index of given step
Definition at line 471 of file gl_cursor.cxx.
unsigned cgv::render::gl::gl_cursor::get_step_period | ( | unsigned | step_idx | ) | const |
return the period of given step in 1/60th of a second
Definition at line 483 of file gl_cursor.cxx.
unsigned cgv::render::gl::gl_cursor::get_texture_id | ( | unsigned | frame_idx = 0 | ) | const |
return the gl texture id of the given frame
Definition at line 465 of file gl_cursor.cxx.
|
inline |
return the width of the cursor
Definition at line 53 of file gl_cursor.h.
bool cgv::render::gl::gl_cursor::is_created | ( | ) | const |
check whether cursor has been created
Definition at line 211 of file gl_cursor.cxx.
|
inline |
set a new hot spot of the cursor in local pixel coordinates
Definition at line 61 of file gl_cursor.h.
void cgv::render::gl::gl_cursor::set_step_frame | ( | unsigned | step_idx, |
unsigned | frame_idx | ||
) |
set the frame index of given step
Definition at line 477 of file gl_cursor.cxx.
void cgv::render::gl::gl_cursor::set_step_period | ( | unsigned | step_idx, |
unsigned | period | ||
) |
return the period of given step in 1/60th of a second
Definition at line 489 of file gl_cursor.cxx.
void cgv::render::gl::gl_cursor::update_duration | ( | ) |
Definition at line 445 of file gl_cursor.cxx.
unsigned cgv::render::gl::gl_cursor::duration |
Definition at line 23 of file gl_cursor.h.
std::vector<unsigned> cgv::render::gl::gl_cursor::frames |
Definition at line 21 of file gl_cursor.h.
unsigned cgv::render::gl::gl_cursor::h |
Definition at line 19 of file gl_cursor.h.
int cgv::render::gl::gl_cursor::hot_x |
Definition at line 18 of file gl_cursor.h.
int cgv::render::gl::gl_cursor::hot_y |
Definition at line 18 of file gl_cursor.h.
std::vector<unsigned> cgv::render::gl::gl_cursor::periods |
Definition at line 22 of file gl_cursor.h.
std::vector<unsigned> cgv::render::gl::gl_cursor::tex_ids |
Definition at line 20 of file gl_cursor.h.
unsigned cgv::render::gl::gl_cursor::w |
Definition at line 19 of file gl_cursor.h.