IupGLCanvas
Creates an OpenGL canvas (drawing area for OpenGL). It inherits from IupCanvas.
Initialization and Usage
The IupGLCanvasOpen function must be called after a IupOpen, so that the control can be used. The iupgl.h file must also be included in the source code. The program must be linked to the control’s library (iupgl.lib on Windows and libiupgl.a on Unix), and with the OpenGL library.
To make the control available in Lua, use the initialization function in C, iupgllua_open, after calling iuplua_open. The iupluagl.h file must also be included in the source code. The program must be linked to the control’s libraries (iupluagl[5].lib on Windows and libiupluagl[5].a on Unix).
You will need also to link with the OpenGL libraries. In Windows add: opengl32.lib and optionally glu32.lib or glaux.lib. In Motif add before the Motif libraries: -LGLw -LGLU -LGL (in Linux the GLw library is not available in the system so we include it inside the iupgl library).
Creation
Ihandle* IupGLCanvas(char* action); [in C] iupglcanvas{} -> (elem: ihandle) [in IupLua3] iup.glcanvas{} -> (elem: ihandle) [in IupLua5] glcanvas(action) [in LED]
action: Name of the action generated when the canvas needs to be redrawn.
This function returns the identifier of the created canvas, or NULL if an error occurs.
Attributes
The IupGLCanvas element understands all attributes defined for a conventional canvas, see IupCanvas.
Apart from these attributes, IupGLCanvas understands specific attributes used to define the kind of buffer to be instanced. Such attributes must be set before the element is mapped on the screen. After the mapping, specifying these special attributes has no effect.
The specific IupGLCanvas attributes are:
BUFFER: Indicates if the buffer will be single "SINGLE" or double "DOUBLE". Default is "SINGLE".
COLOR: Indicates the color model to be adopted: "INDEX" or "RGBA". Default is "RGBA".
BUFFER_SIZE: Indicates the number of bits for representing the color indices (valid only for INDEX). Default is “8” (256-color palette).
RED_SIZE, GREEN_SIZE and BLUE_SIZE: Indicate the number of bits for representing each color component (valid only for RGBA). Default is “8” for each component (True Color support).
ALPHA_SIZE: Indicates the number of bits for representing each color’s alpha component (valid only for RGBA and for hardware that store the alpha component). Default is "0".
DEPTH_SIZE: Indicates the number of bits for representing the z coordinate in the z-buffer. Value “0” means the z-buffer is not necessary.
STENCIL_SIZE: Indicates the number of bits in the stencil buffer. Value “0” means the stencil buffer is not necessary. Default is “0”.
ACCUM_RED_SIZE, ACCUM_GREEN_SIZE, ACCUM_BLUE_SIZE and ACCUM_ALPHA_SIZE: Indicate the number of bits for representing the color components in the accumulation buffer. Value “0” means the accumulation buffer is not necessary. Default is “0”.
STEREO: Creates a stereo GL canvas (special glasses are required to visualize it correctly). Possible values: "YES" or "NO". Default: "NO".
"ERROR": If an error is found, returns a string containing a description of it.
"CONTEXT", "VISUAL" and "COLORMAP": [Motif Only] Returns "GLXContext", "XVisualInfo*" and "Colormap".
"PRINTINFO": [Motif Only] If "1" during the canvas initialization some information will be printed on
stderr
.
Callbacks
The IupGLCanvas element understands all callbacks defined for a conventional canvas, see IupCanvas.
Addicionally:
RESIZE_CB: By default the resize callback sets:
glViewport(0,0,width,height);
Auxiliary Functions
void IupGLMakeCurrent(Ihandle* self);Activates the given canvas as the current OpenGL context. All subsequent OpenGL commands are directed to such canvas.
int IupGLIsCurrent(Ihandle* self);Returns a non zero value if the given canvas is the current OpenGL context.
void IupGLSwapBuffers(Ihandle* self);Makes the “BACK” buffer visible. This function is necessary when a double buffer is used.
void IupGLPalette(Ihandle* self, int index, float r, float g, float b);Defines a color in the color palette. This function is necessary when INDEX color is used.
Comments
IMPORTANT: An OpenGL canvas when put inside an IupFrame will not work.