Dmitry Karasik > Prima-OpenGL-0.04 > Prima::OpenGL

Download:
Prima-OpenGL-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.04   Source   Latest Release: Prima-OpenGL-0.05

NAME ^

Prima::OpenGL - Prima extension for OpenGL drawing

DESCRIPTION ^

The module allows for programming GL library together with Prima widgets. OpenGL module does a similar jobs using freeglut GUI library.

API ^

Selection of a GL visual

Before a GL area is used, a GL visual need to be selected first. Currently this process is done by system-specific search function, so results differ between win32 and x11. Namely, x11 is less forgiving, and may fail with error. Also, win32 and x11 GL defaults are different.

All attributes are passed to function context_create as a hashref (see description below). If an option is not set, or set to undef, system default is used.

render ( "direct" or "xserver" )

Excerpt from glXCreateContext:

Specifies whether rendering is to be done with a direct connection to the graphics system if possible ("direct") or through the X server ("xserver"). If direct is True, then a direct rendering context is created if the implementation supports direct rendering, if the connection is to an X server that is local, and if a direct rendering context is available. (An implementation may return an indirect context when direct is True.) If direct is False, then a rendering context that renders through the X server is always created. Direct rendering provides a performance advantage in some implementations. However, direct rendering contexts cannot be shared outside a single process, and they may be unable to render to GLX

I here may add that you I needed that option when was testing cygwin implementation of the module in no-X11 environment. I couldn't get my X11 working on windows, and installed one under VirtualBox. However, the only way I could connect to X server there was to tell VirtualBox to forward the port 6000 inside the emulator to the host machine's 6000. GLX was happy finding that the connection was local, and tried to use shared memory or whatever underlies "direct" connection, and failed, instead of doing a soft fall-back to x11 protocol. The only way to make it work in such condition was explicitly setting config to "xserver".

Actual for x11 only.

pixels ( "rgba" or "paletted" )

Selects either paletted or true-color visual representation.

layer INTEGER

x11: Layer zero corresponds to the main frame buffer of the display. Layer one is the first overlay frame buffer, level two the second overlay frame buffer, and so on. Negative buffer levels correspond to underlay frame buffers.

win32: Provides only three layers, -1, 0, and 1 .

double_buffer BOOLEAN

If set, select double buffering.

stereo BOOLEAN

If set, select a stereo visual.

color_bits INTEGER

Indicates the desired color index buffer size. Usual values are 8, 15, 16, 24, or 32.

aux_buffers INTEGER

Indicated the desired number of auxilliary buffers.

depth_bits INTEGER

If this value is zero, visuals with no depth buffer are preferred. Otherwise, the largest available depth buffer of at least the minimum size is preferred.

stencil_bits INTEGER

Indicates the desired number of stencil bitplanes. The smallest stencil buffer of at least the specified size is preferred. If the desired value is zero, visuals with no stencil buffer are preferred.

red_bits green_bits blue_bits alpha_bits INTEGER

If this value is zero, the smallest available red/green/blue/alpha buffer is preferred. Otherwise, the largest available buffer of at least the minimum size is preferred.

accum_red_bits accum_green_bits accum_blue_bits accum_alpha_bits INTEGER

If this value is zero, visuals with no red/green/blue/alpha accumulation buffer are preferred. Otherwise, the largest possible accumulation buffer of at least the minimum size is preferred.

Methods

context_push

Pushes the current GL context on an internal stack; there can be only 32 entries. Returns success flag.

context_pop

Pops the top GL context from the stack, and selects it. Returns success flag.

last_error

Call last_error that returns string representation of the last error, or undef if there was none. Note that X11 errors are really unspecific due to asynchronous mode X server and clients operate; expect some generic error strings there.

Prima::Drawable methods

The module also injects a set of gl_ methods for general use on Widget, Application, DeviceBitmap, Image, and Printer (the latter on win32 only) objects.

gl_create %config

Creates a GL context and prepares it for drawing on the object. If the object is not a widget, it needs to be in begin_paint state. See valid %config values in "Selection of a GL visual" .

gl_destroy

Destroys GL context. Note that it doesn't synchronize GL area content, one should do that manually using gl_flush (and also remember to call glFinish when drawing on bitmaps!). Need to be always called otherwise GL contexts would leak.

gl_begin_paint %config

Shortcut for gl_create and gl_select. See valid %config values in "Selection of a GL visual" .

gl_end_paint

Shortcut for gl_flush and gl_destroy.

gl_paint_state

Returns boolean flag indicating whether the object is within gl_begin_paint/gl_end_paint state.

gl_select

Associates the widget visual with current GL context, so GL functions can be used on the widget.

gl_unselect

Disassociates any GL context.

gl_do &SUB

Executes &SUB within current GL context, restores context after the SUB is finished.

gl_flush

Copies eventual off-screen GL buffer to the screen. Needs to be always called at the end of paint routine.

AUTHOR ^

Dmitry Karasik, <dmitry@karasik.eu.org>.

SEE ALSO ^

Prima, OpenGL

   git clone git@github.com:dk/Prima-OpenGL.git

LICENSE ^

This software is distributed under the BSD License.

NOTES ^

Thanks to Chris Marshall for the motivating me writing this module!

syntax highlighting: