67 #ifndef KJB_GR_OFFSCREEN_H
68 #define KJB_GR_OFFSCREEN_H
74 #ifdef KJB_HAVE_OPENGL
77 #ifdef KJB_HAVE_OSMESA
78 #include <GL/osmesa.h>
86 #include <OpenGL/gl.h>
87 #include <OpenGL/OpenGL.h>
137 virtual
void deactivate() throw(kjb::Exception) = 0;
140 virtual
void reactivate() throw(kjb::Exception) = 0;
155 #if defined KJB_HAVE_X11 && defined KJB_HAVE_OPENGL
156 #ifndef KJB_HAVE_OSMESA
168 GLX_offscreen_buffer(
int iwidth,
int iheight)
172 virtual ~GLX_offscreen_buffer() { }
189 void save_old_context();
192 void open_display(
const char* disp_name=0)
196 virtual void create_drawable_and_context(
int* attrs)
200 virtual void destroy_drawable() = 0;
203 bool has_pbuffer_extension()
const;
206 bool has_pixmap_extension()
const;
217 GLXDrawable drawable;
220 GLXDrawable old_drawable;
226 GLXContext old_context;
237 class GLX_offscreen_pixmap :
public GLX_offscreen_buffer
242 GLX_offscreen_pixmap(
int width,
int height,
int* attrs=0)
243 throw(kjb::Exception);
246 virtual ~GLX_offscreen_pixmap();
251 virtual
void create_drawable_and_context(
int* attrs)
255 virtual
void destroy_drawable();
271 class GLX_offscreen_pbuffer : public GLX_offscreen_buffer
276 GLX_offscreen_pbuffer(
int width,
int height)
280 GLX_offscreen_pbuffer(
int width,
int heigth,
int* attrs)
284 virtual ~GLX_offscreen_pbuffer();
289 virtual void create_drawable_and_context(
int* attrs)
293 virtual void destroy_drawable();
308 CGL_offscreen_pbuffer
313 const CGLPixelFormatAttribute* attrs=0
315 throw (kjb::Exception);
318 virtual ~CGL_offscreen_pbuffer();
321 virtual
void activate() throw(kjb::Exception);
324 virtual
void deactivate() throw(kjb::Exception);
327 virtual
void reactivate() throw(kjb::Exception);
334 virtual
void save_old_context();
337 virtual
void create_pbuffer_and_context
340 const CGLPixelFormatAttribute* attrs
342 throw(kjb::Exception);
347 CGLContextObj context;
350 CGLContextObj old_context;
353 CGLPBufferObj pbuffer;
359 #ifdef KJB_HAVE_OSMESA
370 OSMesa32_offscreen_buffer
374 GLenum format=OSMESA_RGBA,
376 GLint stencil_bits=4,
379 throw (kjb::Exception);
382 virtual ~OSMesa32_offscreen_buffer();
385 virtual
void activate() throw(kjb::Exception);
388 virtual
void deactivate() throw(kjb::Exception);
391 virtual
void reactivate() throw(kjb::Exception);
396 virtual
void create_buffer_and_context
403 throw(kjb::Exception);
408 OSMesaContext context;
415 #ifdef KJB_HAVE_OPENGL
435 bool use_pbuffers_when_available =
true
451 bool use_pbuffers_when_available =
true
Base class of all exceptions in the jwsc++ library.
Definition: l_exception.h:132
bool supports_pbuffers()
DEPRECATED Returns true if pbuffers are available. ONLY FOR DEBUG PURPOSES.
Definition: gr_offscreen.cpp:117
virtual void reactivate()=0
Reactivates an offscreen buffer.
Object thrown when a function cannot generate a valid result.
Definition: l_exception.h:516
Offscreen_buffer(int iwidth, int iheight)
Constructs an offscreen buffer.
Definition: gr_offscreen.h:127
virtual ~Offscreen_buffer()
Deletes an offscreen buffer.
Definition: gr_offscreen.h:131
int width
Width of the offscreen buffer.
Definition: gr_offscreen.h:148
int height
height of the offscreen buffer.
Definition: gr_offscreen.h:151
Offscreen rendering buffer.
Definition: gr_offscreen.h:122
virtual void activate()=0
Activates an offscreen buffer.
bool supports_pixmaps()
DEPRECATED Returns true if pixelmaps are available. ONLY FOR DEBUG PURPOSES.
Definition: gr_offscreen.cpp:146
void retrieve_offscreen_capabilities(bool *_has_gl, bool *_has_osmesa)
Checks what offscreen rendering capabilities are available on the machine.
Definition: gr_offscreen.cpp:99
Support for error handling exception classes in libKJB.
virtual void deactivate()=0
Deactivates an offscreen buffer.
bool active
The offscreen buffer is active.
Definition: gr_offscreen.h:145