mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
respect old versions of glx.h a little better
This commit is contained in:
parent
3413263516
commit
e08d134dba
@ -47,7 +47,9 @@ init_libglxdisplay() {
|
||||
}
|
||||
initialized = true;
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
glxGraphicsBuffer::init_type();
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
glxGraphicsPipe::init_type();
|
||||
glxGraphicsWindow::init_type();
|
||||
glxGraphicsStateGuardian::init_type();
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include "glgsg.h"
|
||||
#include "pStatTimer.h"
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
// This whole class doesn't make sense unless we have the GLXFBConfig
|
||||
// and associated GLXPbuffer interfaces available.
|
||||
|
||||
TypeHandle glxGraphicsBuffer::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -165,3 +169,6 @@ open_buffer() {
|
||||
_is_valid = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
@ -24,6 +24,10 @@
|
||||
#include "glxGraphicsPipe.h"
|
||||
#include "graphicsBuffer.h"
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
// This whole class doesn't make sense unless we have the GLXFBConfig
|
||||
// and associated GLXPbuffer interfaces available.
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : glxGraphicsBuffer
|
||||
// Description : An offscreen buffer in the GLX environment. This
|
||||
@ -68,4 +72,6 @@ private:
|
||||
|
||||
#include "glxGraphicsBuffer.I"
|
||||
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
#endif
|
||||
|
@ -186,15 +186,20 @@ make_gsg(const FrameBufferProperties &properties,
|
||||
|
||||
FrameBufferProperties new_properties = properties;
|
||||
GLXContext context = NULL;
|
||||
|
||||
GLXFBConfig fbconfig = choose_fbconfig(new_properties);
|
||||
XVisualInfo *visual = NULL;
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
GLXFBConfig fbconfig = choose_fbconfig(new_properties);
|
||||
if (fbconfig != None) {
|
||||
context =
|
||||
glXCreateNewContext(_display, fbconfig, GLX_RGBA_TYPE, share_context,
|
||||
GL_TRUE);
|
||||
if (context == NULL) {
|
||||
fbconfig = None;
|
||||
}
|
||||
}
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
if (context == NULL) {
|
||||
// If we couldn't create a context with the fbconfig interface,
|
||||
// try falling back to the older XVisual interface.
|
||||
@ -202,7 +207,6 @@ make_gsg(const FrameBufferProperties &properties,
|
||||
|
||||
if (visual != (XVisualInfo *)NULL) {
|
||||
context = glXCreateContext(_display, visual, None, GL_TRUE);
|
||||
fbconfig = None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,6 +216,7 @@ make_gsg(const FrameBufferProperties &properties,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
if (visual == (XVisualInfo *)NULL) {
|
||||
// If we used the fbconfig to open the context, we still need to
|
||||
// get the associated XVisual.
|
||||
@ -222,7 +227,14 @@ make_gsg(const FrameBufferProperties &properties,
|
||||
// Now we can make a GSG.
|
||||
PT(glxGraphicsStateGuardian) gsg =
|
||||
new glxGraphicsStateGuardian(new_properties, share_gsg, context,
|
||||
fbconfig, visual, _display, _screen);
|
||||
visual, _display, _screen, fbconfig);
|
||||
|
||||
#else
|
||||
PT(glxGraphicsStateGuardian) gsg =
|
||||
new glxGraphicsStateGuardian(new_properties, share_gsg, context,
|
||||
visual, _display, _screen);
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
return gsg.p();
|
||||
}
|
||||
|
||||
@ -252,9 +264,14 @@ make_buffer(GraphicsStateGuardian *gsg, const string &name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
return new glxGraphicsBuffer(this, gsg, name, x_size, y_size, want_texture);
|
||||
#else
|
||||
return NULL;
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
}
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: glxGraphicsPipe::choose_fbconfig
|
||||
// Access: Private
|
||||
@ -471,7 +488,9 @@ choose_fbconfig(FrameBufferProperties &properties) const {
|
||||
|
||||
return fbconfig;
|
||||
}
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: glxGraphicsPipe::try_for_fbconfig
|
||||
// Access: Private
|
||||
@ -596,6 +615,7 @@ try_for_fbconfig(int framebuffer_mode,
|
||||
|
||||
return fbconfig;
|
||||
}
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: glxGraphicsPipe::choose visual
|
||||
|
@ -32,8 +32,6 @@ typedef int Display;
|
||||
typedef int Window;
|
||||
typedef int XErrorEvent;
|
||||
typedef int XVisualInfo;
|
||||
typedef int GLXFBConfig;
|
||||
typedef int GLXPbuffer;
|
||||
typedef int Atom;
|
||||
typedef int Cursor;
|
||||
typedef int XIM;
|
||||
@ -42,10 +40,34 @@ typedef int XIC;
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
#if defined(GLX_VERSION_1_3)
|
||||
// If the system glx version is at least 1.3, then we know we have
|
||||
// GLXFBConfig and GLXPbuffer.
|
||||
#define HAVE_GLXFBCONFIG
|
||||
#endif
|
||||
|
||||
// This must be included after we have included glgsg.h (which
|
||||
// includes gl.h).
|
||||
// includes gl.h), and after we have checked GLX_VERSION_1_3. But we
|
||||
// must also include it before we redefine the GLXFBConfig types,
|
||||
// below.
|
||||
#include "glxext.h"
|
||||
|
||||
#if !defined(HAVE_GLXFBCONFIG) && defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
|
||||
// If the system glx version isn't 1.3, but these were defined as
|
||||
// extensions, we can work with that.
|
||||
#define GLX_RGBA_TYPE GLX_RGBA_TYPE_SGIX
|
||||
#define GLXFBConfig GLXFBConfigSGIX
|
||||
#define GLXPbuffer GLXPbufferSGIX
|
||||
#define glXChooseFBConfig glXChooseFBConfigSGIX
|
||||
#define glXCreateNewContext glXCreateContextWithConfigSGIX
|
||||
#define glXGetVisualFromFBConfig glXGetVisualFromFBConfigSGIX
|
||||
#define glXGetFBConfigAttrib glXGetFBConfigAttribSGIX
|
||||
#define glXCreatePbuffer glXCreateGLXPbufferSGIX
|
||||
#define glXDestroyPbuffer glXDestroyGLXPbufferSGIX
|
||||
|
||||
#define HAVE_GLXFBCONFIG
|
||||
#endif
|
||||
|
||||
#endif // CPPPARSER
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -81,9 +103,11 @@ protected:
|
||||
int x_size, int y_size, bool want_texture);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
GLXFBConfig choose_fbconfig(FrameBufferProperties &properties) const;
|
||||
GLXFBConfig try_for_fbconfig(int framebuffer_mode,
|
||||
int want_depth_bits, int want_color_bits) const;
|
||||
#endif
|
||||
|
||||
XVisualInfo *choose_visual(FrameBufferProperties &properties) const;
|
||||
XVisualInfo *try_for_visual(int framebuffer_mode,
|
||||
|
@ -33,14 +33,20 @@ TypeHandle glxGraphicsStateGuardian::_type_handle;
|
||||
glxGraphicsStateGuardian::
|
||||
glxGraphicsStateGuardian(const FrameBufferProperties &properties,
|
||||
glxGraphicsStateGuardian *share_with,
|
||||
GLXContext context, GLXFBConfig fbconfig,
|
||||
XVisualInfo *visual, Display *display, int screen) :
|
||||
GLXContext context, XVisualInfo *visual,
|
||||
Display *display, int screen
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
, GLXFBConfig fbconfig
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
) :
|
||||
GLGraphicsStateGuardian(properties),
|
||||
_context(context),
|
||||
_fbconfig(fbconfig),
|
||||
_visual(visual),
|
||||
_display(display),
|
||||
_screen(screen)
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
, _fbconfig(fbconfig)
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
{
|
||||
if (share_with != (glxGraphicsStateGuardian *)NULL) {
|
||||
_prepared_objects = share_with->get_prepared_objects();
|
||||
|
@ -37,20 +37,32 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class glxGraphicsStateGuardian : public GLGraphicsStateGuardian {
|
||||
public:
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
glxGraphicsStateGuardian(const FrameBufferProperties &properties,
|
||||
glxGraphicsStateGuardian *share_with,
|
||||
GLXContext context, GLXFBConfig fbconfig,
|
||||
XVisualInfo *visual, Display *display, int screen);
|
||||
GLXContext context, XVisualInfo *visual,
|
||||
Display *display, int screen,
|
||||
GLXFBConfig fbconfig);
|
||||
#else
|
||||
glxGraphicsStateGuardian(const FrameBufferProperties &properties,
|
||||
glxGraphicsStateGuardian *share_with,
|
||||
GLXContext context, XVisualInfo *visual,
|
||||
Display *display, int screen);
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
virtual ~glxGraphicsStateGuardian();
|
||||
|
||||
bool glx_is_at_least_version(int major_version, int minor_version) const;
|
||||
|
||||
GLXContext _context;
|
||||
GLXFBConfig _fbconfig;
|
||||
XVisualInfo *_visual;
|
||||
Display *_display;
|
||||
int _screen;
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
GLXFBConfig _fbconfig;
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
protected:
|
||||
virtual void get_gl_version();
|
||||
virtual void get_extra_extensions();
|
||||
|
@ -525,11 +525,15 @@ open_window() {
|
||||
|
||||
Window root_window = glx_pipe->get_root();
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
if (glxgsg->_fbconfig != None) {
|
||||
setup_colormap(glxgsg->_fbconfig);
|
||||
} else {
|
||||
setup_colormap(visual_info);
|
||||
}
|
||||
#else
|
||||
setup_colormap(visual_info);
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
_event_mask =
|
||||
ButtonPressMask | ButtonReleaseMask |
|
||||
@ -681,6 +685,7 @@ set_wm_properties(const WindowProperties &properties) {
|
||||
sizeof(protocols) / sizeof(Atom));
|
||||
}
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: glxGraphicsWindow::setup_colormap
|
||||
// Access: Private
|
||||
@ -736,6 +741,7 @@ setup_colormap(GLXFBConfig fbconfig) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: glxGraphicsWindow::setup_colormap
|
||||
|
@ -55,7 +55,9 @@ protected:
|
||||
private:
|
||||
void set_wm_properties(const WindowProperties &properties);
|
||||
|
||||
#ifdef HAVE_GLXFBCONFIG
|
||||
void setup_colormap(GLXFBConfig fbconfig);
|
||||
#endif // HAVE_GLXFBCONFIG
|
||||
void setup_colormap(XVisualInfo *visual);
|
||||
void handle_keystroke(XKeyEvent &event);
|
||||
void handle_keypress(XKeyEvent &event);
|
||||
|
@ -327,6 +327,12 @@ typedef struct {
|
||||
|
||||
#ifndef GLX_VERSION_1_3
|
||||
#define GLX_VERSION_1_3 1
|
||||
/* drose: If the system glx.h isn't at least version 1.3, it won't
|
||||
have defined these types, so we need to do so here in order for
|
||||
the following to compile. */
|
||||
typedef struct __GLXFBConfigRec *GLXFBConfig;
|
||||
typedef XID GLXPbuffer;
|
||||
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
extern GLXFBConfig * glXGetFBConfigs (Display *, int, int *);
|
||||
extern GLXFBConfig * glXChooseFBConfig (Display *, int, const int *, int *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user