IupGLCanvas

IUP - Portable User Interface

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 controls library (iupgl), 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 lua control library (iupluagl).

To link with the OpenGL libraries in Windows add: opengl32.lib. In Motif add before the Motif libraries: -LGL.

The Lua binding does not include OpenGL functions. But you can use any OpenGL binding available. The IupLua console contains the LuaGL binding.

Creation

Ihandle* IupGLCanvas(const char* action); [in C]
iup.glcanvas{} -> (elem: ihandle) [in Lua]
glcanvas(action) [in LED]

action: Name of the action generated when the canvas needs to be redrawn. It can be NULL.

Returns: the identifier of the created element, or NULL if an error occurs.

Attributes

The IupGLCanvas element handle all attributes defined for a conventional canvas, see IupCanvas.

Apart from these attributes, IupGLCanvas handle specific attributes used to define the kind of buffer to be instanced. Such attributes are all creation only attributes and must be set before the element is mapped on the native system. After the mapping, specifying these special attributes has no effect.


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 colors 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".

SHAREDCONTEXT: name of another IupGLCanvas that will share its display lists and textures. That canvas must be mapped before this canvas.

ERROR (read-only): If an error is found, returns a string containing a description of the error in English.

CONTEXT, VISUAL and COLORMAP (read-only): Returns "GLXContext", "XVisualInfo*" and "Colormap" respectively, in UNIX. And "HGLRC", "HDC" and "HPALETTE" respectively, in Win32.

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* ih); [in C]
iup.GLMakeCurrent(ih: ihandle) [in Lua]

Activates the given canvas as the current OpenGL context. All subsequent OpenGL commands are directed to such canvas.

int IupGLIsCurrent(Ihandle* ih); [in C]
iup.GLIsCurrent(ih: ihandle) -> status: number [in Lua]

Returns a non zero value if the given canvas is the current OpenGL context.

void IupGLSwapBuffers(Ihandle* ih); [in C]
iup.GLSwapBuffers(ih: ihandle) [in Lua]

Makes the BACK buffer visible. This function is necessary when a double buffer is used.

void IupGLPalette(Ihandle* ih, int index, float r, float g, float b); [in C]
iup.GLPalette(ih: ihandle, index, r, g, b: number); [in Lua]

Defines a color in the color palette. This function is necessary when INDEX color is used.

Notes

IMPORTANT: An OpenGL canvas when put inside an IupFrame in Win32 will not work.

The IupGLCanvas works with the GTK base driver in Windows and in UNIX (X-Windows).

Examples

Browse Example Files

See Also

IupCanvas