Resolution independent 2D graphics engine
qr::renderer

Class Description

The core of the graphics engine, this class handles graphics engine set up and scene node rendering. There should only ever be one instance of this class at a time.

Public Methods

renderer (vector2d_i viewp_aspr, float project_width, bool fulscr=false, vector2d_i alt_res=vector2d_i(0, 0), bool vsync=false, int multisample=0)
scene_manager * get_scene_manager ()
void main ()
bool run ()
void drop ()
void set_total_layers (unsigned int num_layers)
void set_window_title (const char *title)
float get_time_delta ()
float get_ticks ()
float get_fps ()
void set_camera_location (vector2d_f new_loc)
vector2d_f get_camera_location ()
float get_pix_size ()
vector2d_f get_viewport_size ()
void set_bg_sprite (sprite *ob_sprite)
sprite * get_bg_sprite ()
qr::scene_manager

Class Description

This class manages the sprites and the scene graphs root nodes. It should always be obtained by calling get_scene_manager on the renderer and never created stand alone.

Public Methods

void clear_scene ()
qr::scene_node

Class Description

Scene node base. Scene nodes are the basic building blocks of the scene graph, they can be attached to the scene manager, or other scene nodes. Children are transformed relative to there parents. This class is pure virtual and defines an interface allowing scene nodes to be implemented.

Public Methods

void register_node (scene_manager *scene_man)
void register_node (scene_node *parent)
scene_manager * get_scene_manager ()
renderer * get_renderer ()
void raise_event (event *n_event)
void drop ()
void create_var (T value, std::string name)
void set_var (std::string name, T value)
T & get_var (std::string name)
void delete_var (std::string name)
void set_event_receiver (event_receiver *receiver)
event_receiver * get_event_receiver ()
void set_animator (animator *l_animator)
animator * get_animator ()
void set_sprite (sprite *new_sprite)
sprite * get_sprite ()
void set_frame (int new_frame)
int get_frame ()
void set_location (vector2d_f new_loc)
vector2d_f get_location ()
void set_size (vector2d_f new_size)
void set_scale_base ()
vector2d_f get_size ()
void set_rotation (float angle)
float get_rotation ()
void set_layer (unsigned int new_layer)
unsigned int get_layer ()

Protected Methods

void add_polygon (vector2d_f P1, vector2d_f P2, vector2d_f P3, vector2d_f P1c, vector2d_f P2c, vector2d_f P3c)
void clear_mesh ()
void on_register ()=0
void on_render ()=0
void on_drop ()=0
qr::quad

Class Description

Quadrangle primitive, mainly used for displaying sprites. Inherits qr::scene_node.

Public Methods

quad (scene_manager *scene_man)
quad (scene_node *parent)

Protected Methods

void on_register ()
void on_render ()
void on_drop ()
qr::circle

Class Description

Circle primitive. Inherits qr::scene_node.

Public Methods

circle (scene_manager *scene_man)
circle (scene_node *parent)

Protected Methods

void on_register ()
void on_render ()
void on_drop ()
qr::line

Class Description

Line primitive. Inherits qr::scene_node.

Public Methods

line (scene_manager *scene_man)
line (scene_node *parent)
void set_end_points (vector2d_f nP0, vector2d_f nP1)
void set_sprite_coords (float UV0, float UV1)
void set_width (float n_width)

Protected Methods

void on_register ()
void on_render ()
void on_drop ()
qr::sprite

Class Description

Sprites are objects which store a sequence of images that form an animation. They can be displayed in the scene by attaching them to a scene nodes. The sprites animation frame which is displayed is controlled by the scene node the sprite is attached to.

Public Methods

sprite (scene_manager *scene_man, int num_frames)
void frame_from_raw (char *raw_data, vector2d_i size, int frame)
void create_solid_frame (unsigned char R, unsigned char G, unsigned char B, unsigned char A, unsigned int frame)
void frame_from_bw (char *img_1, int frame_size)
void load_png_frame (const char *name, int frame)
int convert_data ()
void drop ()
char * get_frame_data (int frame)
unsigned int get_total_frames ()
vector2d_i get_frame_size ()
qr::animator

Class Description

Animator base. Animators are objects which can be attached to scene nodes to animate there location, rotation, size, frame and layer. Additionally they can be used to monitor some element of the scene and react by raising events. This class is pure virtual and defines an interface allowing animators to be implemented.

Public Methods

void on_attach (scene_node *node)=0
void on_animate (scene_node *node, float time_delta)=0
void on_detach (scene_node *node)=0
qr::sprite_loop_animator

Class Description

Animator which repeatedly loops through all the frames in a sprite. One instance of this animator can be used to animate many scene nodes. Inherits qr::animator.

Public Methods

sprite_loop_animator (float framerate)

Protected Methods

void on_attach (qr::scene_node *node)
void on_animate (qr::scene_node *node, float time_delta)
void on_detach (qr::scene_node *node)
qr::event_receiver

Class Description

Event receiver base. Event receivers are objects which can be attached to scene nodes to catch events. Uses include the detection of keyboard input and user-created events that were raised by scene_node::raise_event(). This class is pure virtual and defines an interface allowing event receivers to be implemented.

Public Methods

void on_attach (scene_node *node)=0
void on_event (scene_node *node, event *n_event)=0
void on_detach (scene_node *node)=0
qr::quit_on_keypress

Class Description

Event receiver which quits the application if the specified key is pressed. Inherits qr::event_receiver.

Public Methods

quit_on_keypress (KEY keysym)

Protected Methods

void on_event (scene_node *node, event *n_event)
void on_attach (scene_node *node)
void on_detach (scene_node *node)
qr::key_var_mapper

Class Description

Event receiver which maps the current state of the keyboard into a tree variable of type qr::keyarr (std::vector of bool) on the node which the event receiver is attached to. Like any other scene graph variable this array can be accessed using the get_var method on the attached node, or any of its children. The element of the array representing a particular keysym will be true if the key is down and false if it is up. Inherits qr::event_receiver.

Public Methods

key_var_mapper (std::string var_name)

Protected Methods

void on_attach (scene_node *node)
void on_event (scene_node *node, event *n_event)
void on_detach (scene_node *node)
qr::event

Class Description

Event base class. This class is pure virtual and defines an interface allowing events to be implemented.

Public Methods

int get_type ()
void set_type (int type)
qr::quit_event

Class Description

Event that instructs the graphics engine to quit, has event type of qr::EV_QUIT. Inherits qr::event.

Public Methods

quit_event ()
qr::keydown_event

Class Description

Event that indicates that a key has bean pressed, has event type of qr::EV_KEYDOWN. Inherits qr::event.

Public Methods

int get_keysym ()
qr::keyup_event

Class Description

Event that indicates that a key has bean released. has event type of qr::EV_KEYUP. Inherits qr::event.

Public Methods

int get_keysym ()
List of keysyms

Description

List of available keysyms.

qr::vector2d_i

Class Description

Integer 2D vector.

Members

int X
int Y

Methods

vector2d_i (int X, int Y)
qr::vector2d_f

Class Description

Floating point 2D vector.

Members

float X
float Y

Methods

vector2d_f (float X, float Y)
qr::math

Class Description

General math functions.

Public Methods

float smalest_largest (float *values, int total, int sma_lar)
float angle_from_vectors (vector2d_f P0, vector2d_f P1)
vector2d_f lin_interp (vector2d_f P0, vector2d_f P1, float pos)
vector2d_f bezier (vector2d_f P[4], float crv_pos)
qr::qrdd_file_handler

Class Description

Public Methods

void dump_sprite (sprite *sprite_d, const char *filename)
sprite * load_sprite (scene_manager *scene_man, const char *filename, bool convert=true)
Exceptions

Undefined_tree_variable

An exception that gets thrown when a scene graph variable was requested which does not exist.

Members

std::string var_name

Tree_variable_already_exists

An exception that gets thrown when a new scene graph variable was created with the same name as one which already exists.

Members

std::string var_name

Wrong_type_for_tree_variable

An exception that gets thrown when a scene graph variable is accessed with an incorrect type.

Members

std::string var_name