mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
pbuffers shouldn't flip
This commit is contained in:
parent
0022871ce6
commit
4d416cce51
@ -392,8 +392,7 @@ get_screenshot(PNMImage &image) {
|
||||
PixelBuffer::F_rgb);
|
||||
|
||||
DisplayRegion dr(_x_size, _y_size);
|
||||
RenderBuffer rb = _gsg->get_render_buffer(RenderBuffer::T_front);
|
||||
if (!p.copy(_gsg, &dr, rb)) {
|
||||
if (!p.copy(_gsg, &dr, get_screenshot_buffer())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -630,6 +629,19 @@ declare_channel(int index, GraphicsChannel *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
|
||||
// Access: Private
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "displayRegion.h"
|
||||
#include "graphicsStateGuardian.h"
|
||||
#include "clearableRegion.h"
|
||||
#include "renderBuffer.h"
|
||||
|
||||
#include "typedWritableReferenceCount.h"
|
||||
#include "pStatCollector.h"
|
||||
@ -129,6 +130,7 @@ public:
|
||||
|
||||
protected:
|
||||
void declare_channel(int index, GraphicsChannel *chan);
|
||||
virtual RenderBuffer get_screenshot_buffer();
|
||||
|
||||
protected:
|
||||
PT(GraphicsStateGuardian) _gsg;
|
||||
|
@ -91,34 +91,21 @@ release_gsg() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: glxGraphicsBuffer::begin_flip
|
||||
// Function: glxGraphicsBuffer::end_frame
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// after end_frame() has been called on all windows, to
|
||||
// initiate the exchange of the front and back buffers.
|
||||
//
|
||||
// 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.
|
||||
// after rendering is completed for a given frame. It
|
||||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void glxGraphicsBuffer::
|
||||
begin_flip() {
|
||||
if (_gsg != (GraphicsStateGuardian *)NULL) {
|
||||
make_current();
|
||||
|
||||
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
|
||||
// OpenGL; there's no interface to make the offscreen buffer
|
||||
// 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);
|
||||
end_frame() {
|
||||
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
|
||||
// OpenGL; there's no interface to make the offscreen buffer
|
||||
// itself be a texture.
|
||||
DisplayRegion dr(_x_size, _y_size);
|
||||
get_texture()->copy(_gsg, &dr, _gsg->get_render_buffer(RenderBuffer::T_back));
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,3 +173,17 @@ open_buffer() {
|
||||
_is_valid = 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);
|
||||
}
|
||||
|
@ -39,12 +39,14 @@ public:
|
||||
virtual void make_current();
|
||||
virtual void release_gsg();
|
||||
|
||||
virtual void begin_flip();
|
||||
virtual void end_frame();
|
||||
|
||||
protected:
|
||||
virtual void close_buffer();
|
||||
virtual bool open_buffer();
|
||||
|
||||
virtual RenderBuffer get_screenshot_buffer();
|
||||
|
||||
private:
|
||||
Display *_display;
|
||||
GLXPbuffer _pbuffer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user