mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
osxGraphicsBuffer
This commit is contained in:
parent
3cfc2b6427
commit
a7678cb3e4
@ -65,7 +65,7 @@ init_libosxdisplay() {
|
|||||||
}
|
}
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
osxGraphicsStateGuardian::init_type();
|
osxGraphicsBuffer::init_type();
|
||||||
osxGraphicsPipe::init_type();
|
osxGraphicsPipe::init_type();
|
||||||
osxGraphicsWindow::init_type();
|
osxGraphicsWindow::init_type();
|
||||||
osxGraphicsStateGuardian::init_type();
|
osxGraphicsStateGuardian::init_type();
|
||||||
|
@ -38,6 +38,10 @@ osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
osxGraphicsPipe *osx_pipe;
|
osxGraphicsPipe *osx_pipe;
|
||||||
DCAST_INTO_V(osx_pipe, _pipe);
|
DCAST_INTO_V(osx_pipe, _pipe);
|
||||||
|
|
||||||
|
_pbuffer = NULL;
|
||||||
|
|
||||||
|
// Since the pbuffer never gets flipped, we get screenshots from the
|
||||||
|
// same buffer we draw into.
|
||||||
_screenshot_buffer_type = _draw_buffer_type;
|
_screenshot_buffer_type = _draw_buffer_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +52,7 @@ osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
osxGraphicsBuffer::
|
osxGraphicsBuffer::
|
||||||
~osxGraphicsBuffer() {
|
~osxGraphicsBuffer() {
|
||||||
|
nassertv(_pbuffer == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -67,15 +72,23 @@ begin_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
nassertr(_pbuffer != NULL, false);
|
||||||
|
|
||||||
osxGraphicsStateGuardian *osxgsg;
|
osxGraphicsStateGuardian *osxgsg;
|
||||||
DCAST_INTO_R(osxgsg, _gsg, false);
|
DCAST_INTO_R(osxgsg, _gsg, false);
|
||||||
// osxMakeCurrent(_display, _pbuffer, osxgsg->_context);
|
if (!aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0)) {
|
||||||
|
aglReportError("aglSetPBuffer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aglSetCurrentContext(osxgsg->get_context())) {
|
||||||
|
aglReportError("aglSetCurrentContext");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
osxgsg->reset_if_new();
|
osxgsg->reset_if_new();
|
||||||
|
|
||||||
if (mode == FM_render)
|
if (mode == FM_render) {
|
||||||
{
|
|
||||||
for (int i=0; i<count_textures(); i++) {
|
for (int i=0; i<count_textures(); i++) {
|
||||||
if (get_rtm_mode(i) == RTM_bind_or_copy) {
|
if (get_rtm_mode(i) == RTM_bind_or_copy) {
|
||||||
_textures[i]._rtm_mode = RTM_copy_texture;
|
_textures[i]._rtm_mode = RTM_copy_texture;
|
||||||
@ -99,8 +112,7 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
end_frame_spam(mode);
|
end_frame_spam(mode);
|
||||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||||
|
|
||||||
if (mode == FM_render)
|
if (mode == FM_render) {
|
||||||
{
|
|
||||||
copy_to_textures();
|
copy_to_textures();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,10 +136,14 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
|||||||
void osxGraphicsBuffer::
|
void osxGraphicsBuffer::
|
||||||
close_buffer() {
|
close_buffer() {
|
||||||
if (_gsg != (GraphicsStateGuardian *)NULL) {
|
if (_gsg != (GraphicsStateGuardian *)NULL) {
|
||||||
//osxMakeCurrent(_display, None, NULL);
|
// aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0);
|
||||||
_gsg.clear();
|
_gsg.clear();
|
||||||
_active = false;
|
_active = false;
|
||||||
}
|
}
|
||||||
|
if (_pbuffer != NULL) {
|
||||||
|
aglDestroyPBuffer(_pbuffer);
|
||||||
|
_pbuffer = NULL;
|
||||||
|
}
|
||||||
_is_valid = false;
|
_is_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,11 +156,52 @@ close_buffer() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool osxGraphicsBuffer::
|
bool osxGraphicsBuffer::
|
||||||
open_buffer() {
|
open_buffer() {
|
||||||
|
|
||||||
if (_gsg == 0) {
|
if (_gsg == 0) {
|
||||||
_gsg = new osxGraphicsStateGuardian(_engine, _pipe, NULL);
|
_gsg = new osxGraphicsStateGuardian(_engine, _pipe, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pbuffer == NULL) {
|
||||||
|
if (!aglCreatePBuffer(_x_size, _y_size, GL_TEXTURE_2D, GL_RGBA, 0, &_pbuffer)) {
|
||||||
|
aglReportError("aglCreatePBuffer");
|
||||||
|
close_buffer();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
osxGraphicsStateGuardian *osxgsg;
|
||||||
|
DCAST_INTO_R(osxgsg, _gsg, false);
|
||||||
|
OSStatus stat = osxgsg->buildGL(false, true, _fb_properties);
|
||||||
|
if (stat != noErr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0)) {
|
||||||
|
aglReportError("aglSetPBuffer");
|
||||||
|
close_buffer();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aglSetCurrentContext(osxgsg->get_context())) {
|
||||||
|
aglReportError("aglSetCurrentContext");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
osxgsg->reset_if_new();
|
||||||
|
if (!osxgsg->is_valid()) {
|
||||||
|
close_buffer();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (!osxgsg->get_fb_properties().verify_hardware_software
|
||||||
|
(_fb_properties, osxgsg->get_gl_renderer())) {
|
||||||
|
close_buffer();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_fb_properties = osxgsg->get_fb_properties();
|
||||||
|
*/
|
||||||
|
|
||||||
|
_is_valid = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,11 @@
|
|||||||
#include "glgsg.h"
|
#include "glgsg.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : OSXGraphicsBuffer
|
// Class : osxGraphicsBuffer
|
||||||
// rhh mar-2006
|
// Description : An offscreen buffer in the OSX environment. This
|
||||||
// Sorry ... this is not functional at all... I have no need for it yet ?
|
// creates an AGLPbuffer.
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDAGL osxGraphicsBuffer : public GraphicsBuffer {
|
class osxGraphicsBuffer : public GraphicsBuffer {
|
||||||
public:
|
public:
|
||||||
osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
|
osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
|
||||||
const string &name,
|
const string &name,
|
||||||
@ -39,7 +38,6 @@ public:
|
|||||||
GraphicsOutput *host);
|
GraphicsOutput *host);
|
||||||
virtual ~osxGraphicsBuffer();
|
virtual ~osxGraphicsBuffer();
|
||||||
|
|
||||||
|
|
||||||
virtual bool begin_frame(FrameMode mode, Thread *current_thread);
|
virtual bool begin_frame(FrameMode mode, Thread *current_thread);
|
||||||
virtual void end_frame(FrameMode mode, Thread *current_thread);
|
virtual void end_frame(FrameMode mode, Thread *current_thread);
|
||||||
|
|
||||||
@ -47,6 +45,8 @@ protected:
|
|||||||
virtual void close_buffer();
|
virtual void close_buffer();
|
||||||
virtual bool open_buffer();
|
virtual bool open_buffer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
AGLPbuffer _pbuffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
}
|
}
|
||||||
static void init_type() {
|
static void init_type() {
|
||||||
GraphicsBuffer::init_type();
|
GraphicsBuffer::init_type();
|
||||||
register_type(_type_handle, "owsGraphicsBuffer",
|
register_type(_type_handle, "osxGraphicsBuffer",
|
||||||
GraphicsBuffer::get_class_type());
|
GraphicsBuffer::get_class_type());
|
||||||
}
|
}
|
||||||
virtual TypeHandle get_type() const {
|
virtual TypeHandle get_type() const {
|
||||||
|
@ -212,7 +212,6 @@ make_output(const string &name,
|
|||||||
GraphicsOutput *host,
|
GraphicsOutput *host,
|
||||||
int retry,
|
int retry,
|
||||||
bool &precertify) {
|
bool &precertify) {
|
||||||
|
|
||||||
if (!_is_valid) {
|
if (!_is_valid) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -269,7 +268,6 @@ make_output(const string &name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Third thing to try: an osxGraphicsBuffer
|
// Third thing to try: an osxGraphicsBuffer
|
||||||
/*
|
|
||||||
if (retry == 2) {
|
if (retry == 2) {
|
||||||
if ((!support_render_texture)||
|
if ((!support_render_texture)||
|
||||||
((flags&BF_require_parasite)!=0)||
|
((flags&BF_require_parasite)!=0)||
|
||||||
@ -282,7 +280,7 @@ make_output(const string &name,
|
|||||||
return new osxGraphicsBuffer(engine, this, name, fb_prop, win_prop,
|
return new osxGraphicsBuffer(engine, this, name, fb_prop, win_prop,
|
||||||
flags, gsg, host);
|
flags, gsg, host);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// Nothing else left to try.
|
// Nothing else left to try.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -184,8 +184,7 @@ draw_resize_box() {
|
|||||||
// Description: This function will build up a context for a gsg..
|
// Description: This function will build up a context for a gsg..
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
OSStatus osxGraphicsStateGuardian::
|
OSStatus osxGraphicsStateGuardian::
|
||||||
buildGL(osxGraphicsWindow &window, bool full_screen,
|
buildGL(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
|
||||||
FrameBufferProperties &fb_props) {
|
|
||||||
if (_aglcontext) {
|
if (_aglcontext) {
|
||||||
describe_pixel_format(fb_props);
|
describe_pixel_format(fb_props);
|
||||||
return noErr; // already built
|
return noErr; // already built
|
||||||
@ -230,16 +229,14 @@ buildGL(osxGraphicsWindow &window, bool full_screen,
|
|||||||
if (full_screen) {
|
if (full_screen) {
|
||||||
attrib.push_back(AGL_FULLSCREEN);
|
attrib.push_back(AGL_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
if (pbuffer) {
|
||||||
|
attrib.push_back(AGL_PBUFFER);
|
||||||
|
}
|
||||||
|
|
||||||
// These are renderer modes, not pixel modes. Not sure if they have
|
|
||||||
// any meaning here; maybe we should handle these flags differently.
|
|
||||||
if (fb_props.get_force_hardware()) {
|
if (fb_props.get_force_hardware()) {
|
||||||
attrib.push_back(AGL_ACCELERATED);
|
attrib.push_back(AGL_ACCELERATED);
|
||||||
attrib.push_back(AGL_NO_RECOVERY);
|
attrib.push_back(AGL_NO_RECOVERY);
|
||||||
}
|
}
|
||||||
if (fb_props.get_force_software()) {
|
|
||||||
attrib.push_back(AGL_PBUFFER);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow the system to choose the largest buffers requested that
|
// Allow the system to choose the largest buffers requested that
|
||||||
// meets all our selections.
|
// meets all our selections.
|
||||||
|
@ -50,8 +50,7 @@ protected:
|
|||||||
virtual void *get_extension_func(const char *prefix, const char *name);
|
virtual void *get_extension_func(const char *prefix, const char *name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSStatus buildGL(osxGraphicsWindow &window, bool full_screen,
|
OSStatus buildGL(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props);
|
||||||
FrameBufferProperties &fb_props);
|
|
||||||
AGLContext get_context(void) { return _aglcontext; };
|
AGLContext get_context(void) { return _aglcontext; };
|
||||||
|
|
||||||
const AGLPixelFormat getAGlPixelFormat() const { return _aglPixFmt; };
|
const AGLPixelFormat getAGlPixelFormat() const { return _aglPixFmt; };
|
||||||
|
@ -692,7 +692,7 @@ buildGL(bool full_screen) {
|
|||||||
// make sure the ggs is up and runnig..
|
// make sure the ggs is up and runnig..
|
||||||
osxGraphicsStateGuardian *osxgsg = NULL;
|
osxGraphicsStateGuardian *osxgsg = NULL;
|
||||||
osxgsg = DCAST(osxGraphicsStateGuardian, _gsg);
|
osxgsg = DCAST(osxGraphicsStateGuardian, _gsg);
|
||||||
OSStatus stat = osxgsg->buildGL(*this, full_screen, _fb_properties);
|
OSStatus stat = osxgsg->buildGL(full_screen, false, _fb_properties);
|
||||||
|
|
||||||
if(stat != noErr) {
|
if(stat != noErr) {
|
||||||
return stat;
|
return stat;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user