diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index a5734f77f0..deac9a9bd8 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -102,9 +102,8 @@ end_frame() { // If we've lost the pbuffer image (due to a mode-switch, for // instance), don't attempt to copy it to the texture, since the - // frame is invalid. For excruciating correctness, we should - // force the frame to be re-rendered, but we'll just discard the - // frame instead. + // frame is invalid. In fact, now we need to recreate the + // pbuffer. if (_pbuffer_dc) { int flag = 0; wglgsg->_wglQueryPbufferARB(_pbuffer, WGL_PBUFFER_LOST_ARB, &flag); @@ -120,8 +119,10 @@ end_frame() { // extension, if it is available, to render directly into a // texture in the first place (but I don't have a card that // supports that right now). - PT(DisplayRegion) dr = make_scratch_display_region(_x_size, _y_size); - get_texture()->copy(_gsg, dr, _gsg->get_render_buffer(RenderBuffer::T_back)); + nassertv(has_texture()); + DisplayRegion dr(this, _x_size, _y_size); + RenderBuffer buffer = _gsg->get_render_buffer(get_draw_buffer_type()); + get_texture()->copy(_gsg, &dr, buffer); } } diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index 96cb2f7135..15cee4c4d3 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -248,9 +248,18 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc, continue; } - DWORD dwReqFlags = (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW); - if ((frame_buffer_mode & FrameBufferProperties::FM_double_buffer) != 0) { - dwReqFlags|= PFD_DOUBLEBUFFER; + DWORD want_flags = (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW); + DWORD dont_want_flags = 0; + + switch (frame_buffer_mode & FrameBufferProperties::FM_buffer) { + case FrameBufferProperties::FM_single_buffer: + dont_want_flags |= PFD_DOUBLEBUFFER; + break; + + case FrameBufferProperties::FM_double_buffer: + case FrameBufferProperties::FM_triple_buffer: + want_flags |= PFD_DOUBLEBUFFER; + break; } if (wgldisplay_cat.is_debug()) { @@ -278,7 +287,8 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc, } wgldisplay_cat.debug() << "flags = " << format_pfd_flags(pfd.dwFlags) << " (missing " - << format_pfd_flags((~pfd.dwFlags) & dwReqFlags) << ")\n"; + << format_pfd_flags((~pfd.dwFlags) & want_flags) << ", extra " + << format_pfd_flags(pfd.dwFlags & dont_want_flags) << ")\n"; } if ((frame_buffer_mode & FrameBufferProperties::FM_alpha) != 0 && @@ -300,7 +310,8 @@ find_pixfmtnum(FrameBufferProperties &properties, HDC hdc, continue; } - if ((pfd.dwFlags & dwReqFlags) != dwReqFlags) { + if ((pfd.dwFlags & want_flags) != want_flags || + (pfd.dwFlags & dont_want_flags) != 0) { wgldisplay_cat.debug() << " rejecting.\n"; continue;