mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 12:43:44 -04:00
temp_context
This commit is contained in:
parent
24c91f85f3
commit
2475878a70
@ -236,7 +236,15 @@ open_buffer() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int error_count = x11GraphicsPipe::disable_x_error_messages();
|
||||||
glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
|
glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
|
||||||
|
if (x11GraphicsPipe::enable_x_error_messages() != error_count) {
|
||||||
|
// An error was generated during the glXMakeCurrent() call.
|
||||||
|
// Assume the worst.
|
||||||
|
close_buffer();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
glxgsg->reset_if_new();
|
glxgsg->reset_if_new();
|
||||||
if (!glxgsg->is_valid()) {
|
if (!glxgsg->is_valid()) {
|
||||||
close_buffer();
|
close_buffer();
|
||||||
|
@ -56,6 +56,7 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
_libgl_handle = NULL;
|
_libgl_handle = NULL;
|
||||||
_checked_get_proc_address = false;
|
_checked_get_proc_address = false;
|
||||||
_glXGetProcAddress = NULL;
|
_glXGetProcAddress = NULL;
|
||||||
|
_temp_context = (GLXContext)NULL;
|
||||||
_temp_xwindow = (Window)NULL;
|
_temp_xwindow = (Window)NULL;
|
||||||
_temp_colormap = (Colormap)NULL;
|
_temp_colormap = (Colormap)NULL;
|
||||||
}
|
}
|
||||||
@ -249,8 +250,9 @@ choose_pixel_format(const FrameBufferProperties &properties,
|
|||||||
// We need this before we can query the FBConfig interface, because
|
// We need this before we can query the FBConfig interface, because
|
||||||
// we need an OpenGL context to get the required extension function
|
// we need an OpenGL context to get the required extension function
|
||||||
// pointers.
|
// pointers.
|
||||||
choose_visual(properties);
|
destroy_temp_xwindow();
|
||||||
if (_context == NULL) {
|
choose_temp_visual(properties);
|
||||||
|
if (_temp_context == NULL) {
|
||||||
// No good.
|
// No good.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -271,6 +273,9 @@ choose_pixel_format(const FrameBufferProperties &properties,
|
|||||||
glxdisplay_cat.debug()
|
glxdisplay_cat.debug()
|
||||||
<< _fbprops << "\n";
|
<< _fbprops << "\n";
|
||||||
|
|
||||||
|
_context = _temp_context;
|
||||||
|
_temp_context = (GLXContext)NULL;
|
||||||
|
|
||||||
// By convention, every indirect XVisual that can render to a
|
// By convention, every indirect XVisual that can render to a
|
||||||
// window can also render to a GLXPixmap. Direct visuals we're
|
// window can also render to a GLXPixmap. Direct visuals we're
|
||||||
// not as sure about.
|
// not as sure about.
|
||||||
@ -305,12 +310,6 @@ choose_pixel_format(const FrameBufferProperties &properties,
|
|||||||
int num_configs = 0;
|
int num_configs = 0;
|
||||||
GLXFBConfig *configs =
|
GLXFBConfig *configs =
|
||||||
_glXChooseFBConfig(_display, _screen, attrib_list, &num_configs);
|
_glXChooseFBConfig(_display, _screen, attrib_list, &num_configs);
|
||||||
|
|
||||||
// Now that we're done querying the first context, we don't need it
|
|
||||||
// anymore. Clear it so we can create our actual OpenGL context.
|
|
||||||
glXDestroyContext(_display, _context);
|
|
||||||
_context = (GLXContext)NULL;
|
|
||||||
destroy_temp_xwindow();
|
|
||||||
|
|
||||||
if (configs != 0) {
|
if (configs != 0) {
|
||||||
bool context_has_pbuffer, context_has_pixmap, slow;
|
bool context_has_pbuffer, context_has_pixmap, slow;
|
||||||
@ -326,7 +325,7 @@ choose_pixel_format(const FrameBufferProperties &properties,
|
|||||||
const char *pixmaptext = context_has_pixmap ? " (pixmap)" : "";
|
const char *pixmaptext = context_has_pixmap ? " (pixmap)" : "";
|
||||||
const char *slowtext = slow ? " (slow)" : "";
|
const char *slowtext = slow ? " (slow)" : "";
|
||||||
glxdisplay_cat.debug()
|
glxdisplay_cat.debug()
|
||||||
<< i << ": " << fbprops << "quality=" << quality << pbuffertext << pixmaptext << slowtext << "\n";
|
<< i << ": " << fbprops << " quality=" << quality << pbuffertext << pixmaptext << slowtext << "\n";
|
||||||
}
|
}
|
||||||
if (need_pbuffer && !context_has_pbuffer) {
|
if (need_pbuffer && !context_has_pbuffer) {
|
||||||
continue;
|
continue;
|
||||||
@ -360,9 +359,6 @@ choose_pixel_format(const FrameBufferProperties &properties,
|
|||||||
get_properties_advanced(_fbprops, _context_has_pbuffer, _context_has_pixmap,
|
get_properties_advanced(_fbprops, _context_has_pbuffer, _context_has_pixmap,
|
||||||
_slow, _fbconfig);
|
_slow, _fbconfig);
|
||||||
|
|
||||||
// hack?
|
|
||||||
//init_temp_context();
|
|
||||||
|
|
||||||
if (glxdisplay_cat.is_debug()) {
|
if (glxdisplay_cat.is_debug()) {
|
||||||
glxdisplay_cat.debug()
|
glxdisplay_cat.debug()
|
||||||
<< "Selected context " << best_result << "\n";
|
<< "Selected context " << best_result << "\n";
|
||||||
@ -756,16 +752,18 @@ show_glx_server_string(const string &name, int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: glxGraphicsStateGuardian::choose_visual
|
// Function: glxGraphicsStateGuardian::choose_temp_visual
|
||||||
// Access: Private
|
// Access: Private
|
||||||
// Description: Selects a visual for this gsg. This may be called
|
// Description: Selects an XVisual for an initial OpenGL context.
|
||||||
// initially, to create the first context needed in
|
// This may be called initially, to create the first
|
||||||
// order to create the fbconfig. On successful return,
|
// context needed in order to create the fbconfig. On
|
||||||
// _visual and _context will be filled in with a
|
// successful return, _visual and _temp_context will be
|
||||||
// non-NULL value.
|
// filled in with a non-NULL value.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void glxGraphicsStateGuardian::
|
void glxGraphicsStateGuardian::
|
||||||
choose_visual(const FrameBufferProperties &properties) {
|
choose_temp_visual(const FrameBufferProperties &properties) {
|
||||||
|
nassertv(_temp_context == (GLXContext)NULL);
|
||||||
|
|
||||||
int best_quality = 0;
|
int best_quality = 0;
|
||||||
int best_result = 0;
|
int best_result = 0;
|
||||||
FrameBufferProperties best_props;
|
FrameBufferProperties best_props;
|
||||||
@ -792,8 +790,8 @@ choose_visual(const FrameBufferProperties &properties) {
|
|||||||
|
|
||||||
if (best_quality > 0) {
|
if (best_quality > 0) {
|
||||||
_visual = _visuals + best_result;
|
_visual = _visuals + best_result;
|
||||||
_context = glXCreateContext(_display, _visual, None, GL_TRUE);
|
_temp_context = glXCreateContext(_display, _visual, None, GL_TRUE);
|
||||||
if (_context) {
|
if (_temp_context) {
|
||||||
_fbprops = best_props;
|
_fbprops = best_props;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -806,9 +804,9 @@ choose_visual(const FrameBufferProperties &properties) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: glxGraphicsStateGuardian::init_temp_context
|
// Function: glxGraphicsStateGuardian::init_temp_context
|
||||||
// Access: Private
|
// Access: Private
|
||||||
// Description: Initializes the context created in choose_visual() by
|
// Description: Initializes the context created in
|
||||||
// creating a temporary window and binding the context
|
// choose_temp_visual() by creating a temporary window
|
||||||
// to that window.
|
// and binding the context to that window.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void glxGraphicsStateGuardian::
|
void glxGraphicsStateGuardian::
|
||||||
init_temp_context() {
|
init_temp_context() {
|
||||||
@ -816,8 +814,6 @@ init_temp_context() {
|
|||||||
DCAST_INTO_V(x11_pipe, get_pipe());
|
DCAST_INTO_V(x11_pipe, get_pipe());
|
||||||
Window root_window = x11_pipe->get_root();
|
Window root_window = x11_pipe->get_root();
|
||||||
|
|
||||||
destroy_temp_xwindow();
|
|
||||||
|
|
||||||
// Assume everyone uses TrueColor or DirectColor these days.
|
// Assume everyone uses TrueColor or DirectColor these days.
|
||||||
Visual *visual = _visual->visual;
|
Visual *visual = _visual->visual;
|
||||||
nassertv(visual->c_class == DirectColor || visual->c_class == TrueColor);
|
nassertv(visual->c_class == DirectColor || visual->c_class == TrueColor);
|
||||||
@ -837,7 +833,7 @@ init_temp_context() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glXMakeCurrent(_display, _temp_xwindow, _context);
|
glXMakeCurrent(_display, _temp_xwindow, _temp_context);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,12 +845,19 @@ init_temp_context() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void glxGraphicsStateGuardian::
|
void glxGraphicsStateGuardian::
|
||||||
destroy_temp_xwindow() {
|
destroy_temp_xwindow() {
|
||||||
if (_temp_xwindow != (Window)NULL) {
|
glXMakeCurrent(_display, None, NULL);
|
||||||
XDestroyWindow(_display, _temp_xwindow);
|
|
||||||
_temp_xwindow = (Window)NULL;
|
|
||||||
}
|
|
||||||
if (_temp_colormap != (Colormap)NULL) {
|
if (_temp_colormap != (Colormap)NULL) {
|
||||||
XFreeColormap(_display, _temp_colormap);
|
XFreeColormap(_display, _temp_colormap);
|
||||||
_temp_colormap = (Colormap)NULL;
|
_temp_colormap = (Colormap)NULL;
|
||||||
}
|
}
|
||||||
|
if (_temp_xwindow != (Window)NULL) {
|
||||||
|
XDestroyWindow(_display, _temp_xwindow);
|
||||||
|
_temp_xwindow = (Window)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_temp_context != (GLXContext)NULL){
|
||||||
|
glXDestroyContext(_display, _temp_context);
|
||||||
|
_temp_context = (GLXContext)NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ private:
|
|||||||
void *get_system_func(const char *name);
|
void *get_system_func(const char *name);
|
||||||
void show_glx_client_string(const string &name, int id);
|
void show_glx_client_string(const string &name, int id);
|
||||||
void show_glx_server_string(const string &name, int id);
|
void show_glx_server_string(const string &name, int id);
|
||||||
void choose_visual(const FrameBufferProperties &properties);
|
void choose_temp_visual(const FrameBufferProperties &properties);
|
||||||
void init_temp_context();
|
void init_temp_context();
|
||||||
void destroy_temp_xwindow();
|
void destroy_temp_xwindow();
|
||||||
|
|
||||||
@ -142,6 +142,8 @@ private:
|
|||||||
void *_libgl_handle;
|
void *_libgl_handle;
|
||||||
bool _checked_get_proc_address;
|
bool _checked_get_proc_address;
|
||||||
PFNGLXGETPROCADDRESSPROC _glXGetProcAddress;
|
PFNGLXGETPROCADDRESSPROC _glXGetProcAddress;
|
||||||
|
|
||||||
|
GLXContext _temp_context;
|
||||||
Window _temp_xwindow;
|
Window _temp_xwindow;
|
||||||
Colormap _temp_colormap;
|
Colormap _temp_colormap;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user