mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
further fixes to two-step context creation
This commit is contained in:
parent
d199a95664
commit
b89595c845
@ -57,6 +57,7 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
_checked_get_proc_address = false;
|
_checked_get_proc_address = false;
|
||||||
_glXGetProcAddress = NULL;
|
_glXGetProcAddress = NULL;
|
||||||
_temp_xwindow = (Window)NULL;
|
_temp_xwindow = (Window)NULL;
|
||||||
|
_temp_colormap = (Colormap)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -235,7 +236,11 @@ choose_pixel_format(const FrameBufferProperties &properties,
|
|||||||
_context = 0;
|
_context = 0;
|
||||||
_fbconfig = 0;
|
_fbconfig = 0;
|
||||||
_visual = 0;
|
_visual = 0;
|
||||||
_visuals = 0;
|
if (_visuals != (XVisualInfo *)NULL) {
|
||||||
|
XFree(_visuals);
|
||||||
|
_visuals = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
_fbprops.clear();
|
_fbprops.clear();
|
||||||
|
|
||||||
// First, attempt to create a context using the XVisual interface.
|
// First, attempt to create a context using the XVisual interface.
|
||||||
@ -343,6 +348,10 @@ choose_pixel_format(const FrameBufferProperties &properties,
|
|||||||
_glXCreateNewContext(_display, _fbconfig, GLX_RGBA_TYPE, _share_context,
|
_glXCreateNewContext(_display, _fbconfig, GLX_RGBA_TYPE, _share_context,
|
||||||
GL_TRUE);
|
GL_TRUE);
|
||||||
if (_context) {
|
if (_context) {
|
||||||
|
if (_visuals != (XVisualInfo *)NULL) {
|
||||||
|
XFree(_visuals);
|
||||||
|
_visuals = NULL;
|
||||||
|
}
|
||||||
_visuals = _glXGetVisualFromFBConfig(_display, _fbconfig);
|
_visuals = _glXGetVisualFromFBConfig(_display, _fbconfig);
|
||||||
_visual = _visuals;
|
_visual = _visuals;
|
||||||
|
|
||||||
@ -761,6 +770,10 @@ choose_visual(const FrameBufferProperties &properties) {
|
|||||||
FrameBufferProperties best_props;
|
FrameBufferProperties best_props;
|
||||||
|
|
||||||
// Scan available visuals.
|
// Scan available visuals.
|
||||||
|
if (_visuals != (XVisualInfo *)NULL) {
|
||||||
|
XFree(_visuals);
|
||||||
|
_visuals = NULL;
|
||||||
|
}
|
||||||
int nvisuals = 0;
|
int nvisuals = 0;
|
||||||
_visuals = XGetVisualInfo(_display, 0, 0, &nvisuals);
|
_visuals = XGetVisualInfo(_display, 0, 0, &nvisuals);
|
||||||
if (_visuals != 0) {
|
if (_visuals != 0) {
|
||||||
@ -804,10 +817,19 @@ init_temp_context() {
|
|||||||
|
|
||||||
destroy_temp_xwindow();
|
destroy_temp_xwindow();
|
||||||
|
|
||||||
|
// Assume everyone uses TrueColor or DirectColor these days.
|
||||||
|
Visual *visual = _visual->visual;
|
||||||
|
nassertv(visual->c_class == DirectColor || visual->c_class == TrueColor);
|
||||||
|
_temp_colormap = XCreateColormap(_display, root_window,
|
||||||
|
visual, AllocNone);
|
||||||
|
XSetWindowAttributes wa;
|
||||||
|
wa.colormap = _temp_colormap;
|
||||||
|
unsigned long attrib_mask = CWColormap;
|
||||||
|
|
||||||
_temp_xwindow = XCreateWindow
|
_temp_xwindow = XCreateWindow
|
||||||
(_display, root_window, 0, 0, 1, 1,
|
(_display, root_window, 0, 0, 100, 100,
|
||||||
0, _visual->depth, InputOutput,
|
0, _visual->depth, InputOutput,
|
||||||
_visual->visual, 0, NULL);
|
visual, attrib_mask, &wa);
|
||||||
if (_temp_xwindow == (Window)NULL) {
|
if (_temp_xwindow == (Window)NULL) {
|
||||||
glxdisplay_cat.error()
|
glxdisplay_cat.error()
|
||||||
<< "Could not create temporary window for context\n";
|
<< "Could not create temporary window for context\n";
|
||||||
@ -830,4 +852,8 @@ destroy_temp_xwindow() {
|
|||||||
XDestroyWindow(_display, _temp_xwindow);
|
XDestroyWindow(_display, _temp_xwindow);
|
||||||
_temp_xwindow = (Window)NULL;
|
_temp_xwindow = (Window)NULL;
|
||||||
}
|
}
|
||||||
|
if (_temp_colormap != (Colormap)NULL) {
|
||||||
|
XFreeColormap(_display, _temp_colormap);
|
||||||
|
_temp_colormap = (Colormap)NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,7 @@ private:
|
|||||||
bool _checked_get_proc_address;
|
bool _checked_get_proc_address;
|
||||||
PFNGLXGETPROCADDRESSPROC _glXGetProcAddress;
|
PFNGLXGETPROCADDRESSPROC _glXGetProcAddress;
|
||||||
Window _temp_xwindow;
|
Window _temp_xwindow;
|
||||||
|
Colormap _temp_colormap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user