![]() | ![]() | ![]() | Gtk OpenGL Toolkit (gtkogltk) Reference Manual | ![]() |
---|
#include <ogltk/view.h> struct ogltk_view; enum OGLTKConfigMode; enum OGLTKRenderType; enum OgltkFace; enum OgltkMaterialMode; gint ogltk_view_get_width (ogltk_view *view); gint ogltk_view_get_height (ogltk_view *view); gboolean ogltk_view_set_translate_matrix (ogltk_view *view, gfloat x, gfloat y, gfloat z); gboolean ogltk_view_enable_rotate_matrix (ogltk_view *view); gboolean ogltk_view_set_rotate_matrix (ogltk_view *view, gfloat angle, gfloat x, gfloat y, gfloat z); gboolean ogltk_view_set_rotate_matrix_and_enable (ogltk_view *view, gfloat angle, gfloat x, gfloat y, gfloat z); gboolean ogltk_view_disable_rotate_matrix (ogltk_view *view); gboolean ogltk_view_update_rotate_matrix_angle (ogltk_view *view, gfloat angle); const gltTranslate* ogltk_view_get_translate_matrix (ogltk_view *view); const gltRotate* ogltk_view_get_rotate_matrix (ogltk_view *view); gboolean ogltk_view_set_config_mode (ogltk_view *view, OGLTKConfigMode config); gboolean ogltk_view_enable_direct (ogltk_view *view, gboolean enable); gboolean ogltk_view_set_render_type (ogltk_view *view, OGLTKRenderType config); gboolean ogltk_view_update_capability (ogltk_view *view); gboolean ogltk_view_draw_gl_begin (ogltk_view *view); gboolean ogltk_view_draw_gl_end (ogltk_view *view); gboolean ogltk_view_swap_buffers (ogltk_view *view); gboolean ogltk_view_set_scene (ogltk_view *view, ogltk_scene *scene); gboolean ogltk_view_bind_scene (ogltk_view *view, ogltk_scene *scene); ogltk_scene* ogltk_view_get_scene (ogltk_view *view); gboolean ogltk_view_unbind_scene (ogltk_view *view); gboolean ogltk_view_scene_is_bound (ogltk_view *view); gboolean ogltk_view_render (ogltk_view *view); gboolean ogltk_view_set_background_color (ogltk_view *view, gfloat red, gfloat green, gfloat blue, gfloat alpha); gboolean ogltk_view_enable_lighting (ogltk_view *view, gboolean enable); gboolean ogltk_view_lighting_enabled (ogltk_view *view); gboolean ogltk_view_set_color_material (ogltk_view *view, OgltkFace face, OgltkMaterialMode mode);
This base class is not intended to give either a 2D or 3D view projections but an abstract method to provide either. See ogltk_3Dview for a 3D perspective window.
Every OpenGL window has properties which can be shared between perspective or orthographic projections and this base class provides this shared mechanism.
struct ogltk_view { GtkDrawingArea parent_instance; ogltk_scene *scene; OGLTKConfigMode config_mode; OGLTKRenderType render_mode; gboolean direct; /* Should use direct connection to graphics system */ gltTranslate translate; gltRotate rotate; gltColor background; gboolean light_enabled; OgltkFace light_polygon_faces; OgltkMaterialMode light_material; };
typedef enum { OGLTK_CONFIG_RGB = GDK_GL_MODE_RGB, /* 0 */ OGLTK_CONFIG_RGBA = GDK_GL_MODE_RGBA, /* same as RGB */ OGLTK_CONFIG_INDEX = GDK_GL_MODE_INDEX, OGLTK_CONFIG_SINGLE = GDK_GL_MODE_SINGLE, OGLTK_CONFIG_DOUBLE = GDK_GL_MODE_DOUBLE, OGLTK_CONFIG_STERO = GDK_GL_MODE_STEREO, OGLTK_CONFIG_ALPHA = GDK_GL_MODE_ALPHA, OGLTK_CONFIG_DEPTH = GDK_GL_MODE_DEPTH, OGLTK_CONFIG_STENCIL = GDK_GL_MODE_STENCIL, OGLTK_CONFIG_ACCUM = GDK_GL_MODE_ACCUM, OGLTK_CONFIG_MULTISAMPLE = GDK_GL_MODE_MULTISAMPLE } OGLTKConfigMode;
typedef enum { OGLTK_RENDER_RGBA = GDK_GL_RGBA_TYPE, OGLTK_RENDER_INDEX = GDK_GL_COLOR_INDEX_TYPE } OGLTKRenderType;
typedef enum { OGLTK_FACE_FRONT = GL_FRONT, OGLTK_FACE_BACK = GL_BACK, OGLTK_FACE_FRONT_AND_BACK = GL_FRONT_AND_BACK, }OgltkFace;
typedef enum { OGLTK_MAT_NONE = 0, OGLTK_MAT_AMBIENT = GL_AMBIENT, OGLTK_MAT_DIFFUSE = GL_DIFFUSE, OGLTK_MAT_SPECULAR = GL_SPECULAR, OGLTK_MAT_EMISION = GL_EMISSION, OGLTK_MAT_AMBIENT_AND_DIFFUSE = GL_AMBIENT_AND_DIFFUSE, OGLTK_MAT_LAST = (OGLTK_MAT_AMBIENT_AND_DIFFUSE + 1), }OgltkMaterialMode;
gint ogltk_view_get_width (ogltk_view *view);
Gets the width of the view window.
view : | An ogltk view object. |
Returns : | Width of view window in pixels . |
gint ogltk_view_get_height (ogltk_view *view);
Gets the height of the view window.
view : | An ogltk view object. |
Returns : | Height of view window in pixels . |
gboolean ogltk_view_set_translate_matrix (ogltk_view *view, gfloat x, gfloat y, gfloat z);
Set the view location in the 3D world.
view : | An ogltk view object. |
x : | X coordinate. |
y : | Y coordinate. |
z : | Z coordinate. |
Returns : | TRUE if set translation is successful. |
gboolean ogltk_view_enable_rotate_matrix (ogltk_view *view);
Enable the rotation matrix for the view.
view : | An ogltk view object. |
Returns : | TRUE scene is bound. |
gboolean ogltk_view_set_rotate_matrix (ogltk_view *view, gfloat angle, gfloat x, gfloat y, gfloat z);
Rotate the view on the value set in angle and apply this rotation on x,y and z axis'. One or all axis' can be enabled by setting to 1 or disabling with 0. The rotation matrix is disabled by default and either has to be enabled by ogltk_view_set_rotate_matrix_and_enable or ogltk_view_enable_rotate_matrix
view : | An ogltk view object. |
angle : | Angle to rotate |
x : | Rotate on the X Axis |
y : | Rotate on the Y Axis |
z : | Rotate on the Z Axis |
Returns : | TRUE if setting the rotation matrix is successful. |
gboolean ogltk_view_set_rotate_matrix_and_enable (ogltk_view *view, gfloat angle, gfloat x, gfloat y, gfloat z);
Rotate the view on the value set in angle and apply this rotation on x,y and z axis'. One or all axis' can be enabled by setting to 1 or disabling with 0. This function will automatically enable this matrix to be calculated during rendering.
view : | An ogltk view object. |
angle : | Angle to rotate |
x : | Rotate on the X Axis |
y : | Rotate on the Y Axis |
z : | Rotate on the Z Axis |
Returns : | TRUE if setting the rotation matrix is successful. |
gboolean ogltk_view_disable_rotate_matrix (ogltk_view *view);
Disables the rotation matrix for the view.
view : | An ogltk view object. |
Returns : | TRUE scene is bound. |
gboolean ogltk_view_update_rotate_matrix_angle (ogltk_view *view, gfloat angle);
Rotate the view on the value set in angle and apply this rotation to x,y and z axis'. which were previously set by ogltk_view_set_rotate_matrix or ogltk_view_set_rotate_matrix and_enable.
view : | An ogltk view object. |
angle : | Angle to rotate |
Returns : | TRUE if angle applied olgtk_view object |
const gltTranslate* ogltk_view_get_translate_matrix (ogltk_view *view);
Retrive the translation matrix type from the view.
view : | An ogltk view object. |
Returns : | A constant pointer of gltTranslate. |
const gltRotate* ogltk_view_get_rotate_matrix (ogltk_view *view);
Retrieve the rotation matrix type for the view.
view : | An ogltk view object. |
Returns : | A constant pointer of gltRotate |
gboolean ogltk_view_set_config_mode (ogltk_view *view, OGLTKConfigMode config);
view : | |
config : | |
Returns : |
|
gboolean ogltk_view_enable_direct (ogltk_view *view, gboolean enable);
view : | |
enable : | |
Returns : |
|
gboolean ogltk_view_set_render_type (ogltk_view *view, OGLTKRenderType config);
view : | |
config : | |
Returns : |
|
gboolean ogltk_view_update_capability (ogltk_view *view);
view : | |
Returns : |
|
gboolean ogltk_view_draw_gl_begin (ogltk_view *view);
Enables drawing to the view widget.
view : | An ogltk view object. |
Returns : | TRUE if drawing can begin in the view . |
gboolean ogltk_view_draw_gl_end (ogltk_view *view);
Disables drawing to the view widget.
view : | An ogltk view object. |
Returns : | TRUE if drawing is disabled for the view . |
gboolean ogltk_view_swap_buffers (ogltk_view *view);
Swap to the next drawing buffer and render the previous.
view : | An ogltk view object. |
Returns : | TRUE if buffer was swapped. |
gboolean ogltk_view_set_scene (ogltk_view *view, ogltk_scene *scene);
Bind a scene to the ogltk view. DEPRECIATED -> use ogltk_view_bind_scene instead
view : | An ogltk view object. |
scene : | An ogltk scene object. |
Returns : | TRUE scene is bound. |
gboolean ogltk_view_bind_scene (ogltk_view *view, ogltk_scene *scene);
Bind a scene to the ogltk view.
view : | An ogltk view object. |
scene : | An ogltk scene object. |
Returns : | TRUE scene is bound. |
ogltk_scene* ogltk_view_get_scene (ogltk_view *view);
Get the scene bound to the ogltk view.
view : | An ogltk view object. |
Returns : | NULL if no scene is bound otherwise an instance of ogltk_scene |
gboolean ogltk_view_unbind_scene (ogltk_view *view);
UnBind a scene from the ogltk view.
view : | An ogltk view object. |
Returns : | TRUE if no scene is bound. |
gboolean ogltk_view_scene_is_bound (ogltk_view *view);
Checks if a scene is bound to the view.
view : | An ogltk view object. |
Returns : | TRUE if a scene is bound. |
gboolean ogltk_view_render (ogltk_view *view);
Render the view by translating and rotating it's location (view), as well as calling the scene render method if one is bound.
view : | An ogltk view object. |
Returns : | TRUE if successful. |
gboolean ogltk_view_set_background_color (ogltk_view *view, gfloat red, gfloat green, gfloat blue, gfloat alpha);
Set the default background color for the view
view : | An ogltk view object. |
red : | Red component |
green : | Green Component |
blue : | Blue Component |
alpha : | Alpha (color intensity) |
Returns : | TRUE if background color was set. |
gboolean ogltk_view_enable_lighting (ogltk_view *view, gboolean enable);
Set whether or not the view is going to need/use lighting
view : | An ogltk view object. |
enable : | TRUE = enable lighting, FALSE = disable lighting. |
Returns : | TRUE if lighting was enabled. |
gboolean ogltk_view_lighting_enabled (ogltk_view *view);
Check if lighting is enabled.
view : | An ogltk view object. |
Returns : | TRUE lighting is enabled. |
gboolean ogltk_view_set_color_material (ogltk_view *view, OgltkFace face, OgltkMaterialMode mode);
If lighting is enabled, then set the material properites of objects using the face and mode.
view : | An ogltk view object. |
face : | Specify which sides should follow the current color |
mode : | Specify which material property should follow the current color. |
Returns : | TRUE if color material has been set. |
<<< Base Class Reference | ogltk-globject >>> |