query for pbuffer getting lost

This commit is contained in:
David Rose 2004-02-18 01:24:22 +00:00
parent e5ee695b0c
commit 31cc2f4d8f
2 changed files with 53 additions and 0 deletions

View File

@ -53,6 +53,37 @@ wglGraphicsBuffer::
~wglGraphicsBuffer() {
}
////////////////////////////////////////////////////////////////////
// Function: wglGraphicsBuffer::begin_frame
// Access: Public, Virtual
// Description: This function will be called within the draw thread
// before beginning rendering for a given frame. It
// should do whatever setup is required, and return true
// if the frame should be rendered, or false if it
// should be skipped.
////////////////////////////////////////////////////////////////////
bool wglGraphicsBuffer::
begin_frame() {
if (_gsg == (GraphicsStateGuardian *)NULL) {
return false;
}
wglGraphicsStateGuardian *wglgsg;
DCAST_INTO_R(wglgsg, _gsg, false);
if (_pbuffer_dc) {
int flag = 0;
wglgsg->_wglQueryPbufferARB(_pbuffer, WGL_PBUFFER_LOST_ARB, &flag);
if (flag != 0) {
wgldisplay_cat.info()
<< "Pbuffer contents lost.\n";
return false;
}
}
return GraphicsBuffer::begin_frame();
}
////////////////////////////////////////////////////////////////////
// Function: wglGraphicsBuffer::make_current
// Access: Public, Virtual
@ -108,6 +139,24 @@ begin_flip() {
make_current();
glFinish();
wglGraphicsStateGuardian *wglgsg;
DCAST_INTO_V(wglgsg, _gsg);
// If we've lost the pbuffer image (due to a mode-switch, for
// instance), don't attempt to flip the buffers, 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.
if (_pbuffer_dc) {
int flag = 0;
wglgsg->_wglQueryPbufferARB(_pbuffer, WGL_PBUFFER_LOST_ARB, &flag);
if (flag != 0) {
wgldisplay_cat.info()
<< "Pbuffer contents lost.\n";
return;
}
}
if (has_texture()) {
// Use glCopyTexImage2D to copy the framebuffer to the texture.
// This appears to be the only way to "render to a texture" in
@ -332,6 +381,8 @@ make_pbuffer() {
// request (and subsequently use) must be "pbuffer capable".
iattrib_list[ni++] = WGL_DRAW_TO_PBUFFER_ARB;
iattrib_list[ni++] = true;
iattrib_list[ni++] = WGL_SUPPORT_OPENGL_ARB;
iattrib_list[ni++] = true;
// Match up the framebuffer bits.
iattrib_list[ni++] = WGL_RED_BITS_ARB;

View File

@ -45,6 +45,8 @@ public:
int x_size, int y_size, bool want_texture);
virtual ~wglGraphicsBuffer();
virtual bool begin_frame();
virtual void make_current();
virtual void release_gsg();