mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
support new interface from panda
This commit is contained in:
parent
9a2e560d20
commit
559366c37b
@ -66,10 +66,3 @@ bool gl_force_invalid = config_wgldisplay.GetBool("gl-force-invalid", false);
|
|||||||
// fullscreen windows, no matter what resolution of window was
|
// fullscreen windows, no matter what resolution of window was
|
||||||
// requested. It only affects fullscreen windows.
|
// requested. It only affects fullscreen windows.
|
||||||
bool gl_do_vidmemsize_check = config_wgldisplay.GetBool("gl-do-vidmemsize-check", true);
|
bool gl_do_vidmemsize_check = config_wgldisplay.GetBool("gl-do-vidmemsize-check", true);
|
||||||
|
|
||||||
// For now, we fake offscreen rendering without using the
|
|
||||||
// poorly-supported pbuffer extension; we simply render into an
|
|
||||||
// invisible window. Some drivers don't like that, so for these
|
|
||||||
// drivers set show-pbuffers to true to force the window to be visible
|
|
||||||
// so you can at least get some work done.
|
|
||||||
bool show_pbuffers = config_wgldisplay.GetBool("show-pbuffers", false);
|
|
||||||
|
@ -29,6 +29,5 @@ extern EXPCL_PANDAGL void init_libwgldisplay();
|
|||||||
extern int gl_force_pixfmt;
|
extern int gl_force_pixfmt;
|
||||||
extern bool gl_force_invalid;
|
extern bool gl_force_invalid;
|
||||||
extern bool gl_do_vidmemsize_check;
|
extern bool gl_do_vidmemsize_check;
|
||||||
extern bool show_pbuffers;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,6 +84,47 @@ begin_frame() {
|
|||||||
return GraphicsBuffer::begin_frame();
|
return GraphicsBuffer::begin_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: wglGraphicsBuffer::end_frame
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This function will be called within the draw thread
|
||||||
|
// after rendering is completed for a given frame. It
|
||||||
|
// should do whatever finalization is required.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void wglGraphicsBuffer::
|
||||||
|
end_frame() {
|
||||||
|
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||||
|
_gsg->end_frame();
|
||||||
|
|
||||||
|
if (_copy_texture) {
|
||||||
|
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 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.
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// For now, we copy the framebuffer to the texture every frame.
|
||||||
|
// Eventually we can take advantage of the render_texture
|
||||||
|
// 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: wglGraphicsBuffer::make_current
|
// Function: wglGraphicsBuffer::make_current
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
@ -137,37 +178,14 @@ release_gsg() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void wglGraphicsBuffer::
|
void wglGraphicsBuffer::
|
||||||
begin_flip() {
|
begin_flip() {
|
||||||
|
// In principle, we shouldn't need to flip the pbuffer. But it
|
||||||
|
// seems that if we don't, at least on my nVidia driver, it won't
|
||||||
|
// copy to texture properly somehow.
|
||||||
|
|
||||||
if (_gsg != (GraphicsStateGuardian *)NULL) {
|
if (_gsg != (GraphicsStateGuardian *)NULL) {
|
||||||
make_current();
|
make_current();
|
||||||
glFinish();
|
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
|
|
||||||
// OpenGL; there's no interface to make the offscreen buffer
|
|
||||||
// itself be a texture.
|
|
||||||
PT(DisplayRegion) dr = make_scratch_display_region(_x_size, _y_size);
|
|
||||||
get_texture()->copy(_gsg, dr, _gsg->get_render_buffer(RenderBuffer::T_back));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_pbuffer_dc) {
|
if (_pbuffer_dc) {
|
||||||
SwapBuffers(_pbuffer_dc);
|
SwapBuffers(_pbuffer_dc);
|
||||||
} else {
|
} else {
|
||||||
@ -323,10 +341,7 @@ make_window() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(_window, SW_SHOWNORMAL);
|
|
||||||
if (!show_pbuffers) {
|
|
||||||
ShowWindow(_window, SW_HIDE);
|
ShowWindow(_window, SW_HIDE);
|
||||||
}
|
|
||||||
|
|
||||||
_window_dc = GetDC(_window);
|
_window_dc = GetDC(_window);
|
||||||
|
|
||||||
|
@ -47,11 +47,13 @@ public:
|
|||||||
virtual ~wglGraphicsBuffer();
|
virtual ~wglGraphicsBuffer();
|
||||||
|
|
||||||
virtual bool begin_frame();
|
virtual bool begin_frame();
|
||||||
|
virtual void end_frame();
|
||||||
|
|
||||||
virtual void make_current();
|
virtual void make_current();
|
||||||
virtual void release_gsg();
|
virtual void release_gsg();
|
||||||
|
|
||||||
virtual void begin_flip();
|
virtual void begin_flip();
|
||||||
|
|
||||||
virtual void process_events();
|
virtual void process_events();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user