pbuffers shouldn't flip

This commit is contained in:
David Rose 2004-02-18 19:23:36 +00:00
parent 0022871ce6
commit 4d416cce51
4 changed files with 44 additions and 27 deletions

View File

@ -392,8 +392,7 @@ get_screenshot(PNMImage &image) {
PixelBuffer::F_rgb); PixelBuffer::F_rgb);
DisplayRegion dr(_x_size, _y_size); DisplayRegion dr(_x_size, _y_size);
RenderBuffer rb = _gsg->get_render_buffer(RenderBuffer::T_front); if (!p.copy(_gsg, &dr, get_screenshot_buffer())) {
if (!p.copy(_gsg, &dr, rb)) {
return false; return false;
} }
@ -630,6 +629,19 @@ declare_channel(int index, GraphicsChannel *chan) {
_channels[index] = chan; _channels[index] = chan;
} }
////////////////////////////////////////////////////////////////////
// Function: GraphicsOutput::get_screenshot_buffer
// Access: Protected, Virtual
// Description: Returns the RenderBuffer that should be used for
// capturing screenshots from this particular
// GraphicsOutput.
////////////////////////////////////////////////////////////////////
RenderBuffer GraphicsOutput::
get_screenshot_buffer() {
// By default, this is the front buffer.
return _gsg->get_render_buffer(RenderBuffer::T_front);
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: GraphicsOutput::do_determine_display_regions // Function: GraphicsOutput::do_determine_display_regions
// Access: Private // Access: Private

View File

@ -26,6 +26,7 @@
#include "displayRegion.h" #include "displayRegion.h"
#include "graphicsStateGuardian.h" #include "graphicsStateGuardian.h"
#include "clearableRegion.h" #include "clearableRegion.h"
#include "renderBuffer.h"
#include "typedWritableReferenceCount.h" #include "typedWritableReferenceCount.h"
#include "pStatCollector.h" #include "pStatCollector.h"
@ -129,6 +130,7 @@ public:
protected: protected:
void declare_channel(int index, GraphicsChannel *chan); void declare_channel(int index, GraphicsChannel *chan);
virtual RenderBuffer get_screenshot_buffer();
protected: protected:
PT(GraphicsStateGuardian) _gsg; PT(GraphicsStateGuardian) _gsg;

View File

@ -91,34 +91,21 @@ release_gsg() {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: glxGraphicsBuffer::begin_flip // Function: glxGraphicsBuffer::end_frame
// Access: Public, Virtual // Access: Public, Virtual
// Description: This function will be called within the draw thread // Description: This function will be called within the draw thread
// after end_frame() has been called on all windows, to // after rendering is completed for a given frame. It
// initiate the exchange of the front and back buffers. // should do whatever finalization is required.
//
// This should instruct the window to prepare for the
// flip at the next video sync, but it should not wait.
//
// We have the two separate functions, begin_flip() and
// end_flip(), to make it easier to flip all of the
// windows at the same time.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void glxGraphicsBuffer:: void glxGraphicsBuffer::
begin_flip() { end_frame() {
if (_gsg != (GraphicsStateGuardian *)NULL) { if (has_texture()) {
make_current(); // Use glCopyTexImage2D to copy the framebuffer to the texture.
// This appears to be the only way to "render to a texture" in
if (has_texture()) { // OpenGL; there's no interface to make the offscreen buffer
// Use glCopyTexImage2D to copy the framebuffer to the texture. // itself be a texture.
// This appears to be the only way to "render to a texture" in DisplayRegion dr(_x_size, _y_size);
// OpenGL; there's no interface to make the offscreen buffer get_texture()->copy(_gsg, &dr, _gsg->get_render_buffer(RenderBuffer::T_back));
// itself be a texture.
DisplayRegion dr(_x_size, _y_size);
get_texture()->copy(_gsg, &dr, _gsg->get_render_buffer(RenderBuffer::T_back));
}
glXSwapBuffers(_display, _pbuffer);
} }
} }
@ -186,3 +173,17 @@ open_buffer() {
_is_valid = true; _is_valid = true;
return true; return true;
} }
////////////////////////////////////////////////////////////////////
// Function: glxGraphicsBuffer::get_screenshot_buffer
// Access: Protected, Virtual
// Description: Returns the RenderBuffer that should be used for
// capturing screenshots from this particular
// GraphicsOutput.
////////////////////////////////////////////////////////////////////
RenderBuffer glxGraphicsBuffer::
get_screenshot_buffer() {
// Since the pbuffer never gets flipped, we get screenshots from the
// back buffer only.
return _gsg->get_render_buffer(RenderBuffer::T_back);
}

View File

@ -39,12 +39,14 @@ public:
virtual void make_current(); virtual void make_current();
virtual void release_gsg(); virtual void release_gsg();
virtual void begin_flip(); virtual void end_frame();
protected: protected:
virtual void close_buffer(); virtual void close_buffer();
virtual bool open_buffer(); virtual bool open_buffer();
virtual RenderBuffer get_screenshot_buffer();
private: private:
Display *_display; Display *_display;
GLXPbuffer _pbuffer; GLXPbuffer _pbuffer;