From 64a8ebfb02df6630fde425aa183c8d0ae17bb73b Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 11 Mar 2009 23:26:47 +0000 Subject: [PATCH] support multisamples properly --- .../osxdisplay/osxGraphicsStateGuardian.cxx | 26 +++++++++---------- .../src/osxdisplay/osxGraphicsStateGuardian.h | 14 +++++----- panda/src/osxdisplay/osxGraphicsWindow.mm | 18 ++++++------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index 1894e675b6..fecaaee703 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -47,11 +47,6 @@ get_extension_func(const char *prefix, const char *name) { symbol = NSLookupAndBindSymbol (fullname.c_str()); } - if (osxdisplay_cat.is_debug()) { - osxdisplay_cat.debug() - << "Looking up symbol " << fullname << "\n" ; - } - return symbol ? NSAddressOfSymbol(symbol) : NULL; } @@ -68,7 +63,7 @@ osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _aglPixFmt(NULL), _aglcontext(NULL) { - SharedBuffer = 1011; + _shared_buffer = 1011; get_gamma_table(); } @@ -215,8 +210,13 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { attrib.push_back(fb_props.get_depth_bits()); attrib.push_back(AGL_STENCIL_SIZE); attrib.push_back(fb_props.get_stencil_bits()); - attrib.push_back(AGL_SAMPLES_ARB); - attrib.push_back(fb_props.get_multisamples()); + if (fb_props.get_multisamples() != 0) { + attrib.push_back(AGL_MULTISAMPLE); + attrib.push_back(AGL_SAMPLE_BUFFERS_ARB); + attrib.push_back(1); + attrib.push_back(AGL_SAMPLES_ARB); + attrib.push_back(fb_props.get_multisamples()); + } if (fb_props.is_stereo()) { attrib.push_back(AGL_STEREO); @@ -247,29 +247,29 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { // build context _aglcontext = NULL; _aglPixFmt = aglChoosePixelFormat(&display, 1, &attrib[0]); - err = report_agl_error ("aglChoosePixelFormat"); + err = report_agl_error("aglChoosePixelFormat"); if (_aglPixFmt) { if(_share_with == NULL) { _aglcontext = aglCreateContext(_aglPixFmt, NULL); } else { _aglcontext = aglCreateContext(_aglPixFmt, ((osxGraphicsStateGuardian *)_share_with)->_aglcontext); } - err = report_agl_error ("aglCreateContext"); + err = report_agl_error("aglCreateContext"); if (_aglcontext == NULL) { osxdisplay_cat.error() - << "osxGraphicsStateGuardian::buildG Error Getting Gl Context \n" ; + << "osxGraphicsStateGuardian::build_gl Error Getting GL Context \n" ; if(err == noErr) { err = -1; } } else { - aglSetInteger (_aglcontext, AGL_BUFFER_NAME, &SharedBuffer); + aglSetInteger(_aglcontext, AGL_BUFFER_NAME, &_shared_buffer); err = report_agl_error("aglSetInteger AGL_BUFFER_NAME"); } } else { osxdisplay_cat.error() - << "osxGraphicsStateGuardian::buildG Error Getting Pixel Format\n" ; + << "osxGraphicsStateGuardian::build_gl Error Getting Pixel Format\n" ; osxdisplay_cat.error() << fb_props << "\n"; if(err == noErr) { diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.h b/panda/src/osxdisplay/osxGraphicsStateGuardian.h index 1e4d9c0796..eb6da60b9a 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.h +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.h @@ -18,7 +18,7 @@ #include #include #include - + #include "pandabase.h" #include "glgsg.h" @@ -45,15 +45,15 @@ public: bool set_gamma(float gamma); void atexit_function(); void restore_gamma(); - + protected: virtual void *get_extension_func(const char *prefix, const char *name); public: OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props); - AGLContext get_context(void) { return _aglcontext; }; + AGLContext get_context() { return _aglcontext; }; - const AGLPixelFormat get_agl_pixel_format() const { return _aglPixFmt; }; + const AGLPixelFormat get_agl_pixel_format() const { return _aglPixFmt; }; private: void describe_pixel_format(FrameBufferProperties &fb_props); @@ -62,8 +62,8 @@ private: // context with, since we don't create our own context in the // constructor. PT(osxGraphicsStateGuardian) _share_with; - AGLPixelFormat _aglPixFmt; - AGLContext _aglcontext; + AGLPixelFormat _aglPixFmt; + AGLContext _aglcontext; CGGammaValue _gOriginalRedTable[ 256 ]; CGGammaValue _gOriginalGreenTable[ 256 ]; CGGammaValue _gOriginalBlueTable[ 256 ]; @@ -71,7 +71,7 @@ private: CGDisplayErr _cgErr; public: - GLint SharedBuffer; + GLint _shared_buffer; public: static TypeHandle get_class_type() { diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index e1e671c3ef..3606b8a926 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -568,14 +568,14 @@ release_system_resources() { } if (_osx_window != NULL) { - SetWRefCon (_osx_window, (long int) NULL); - HideWindow (_osx_window); + SetWRefCon(_osx_window, (long int) NULL); + HideWindow(_osx_window); DisposeWindow(_osx_window); _osx_window = NULL; } if (_holder_aglcontext) { - aglDestroyContext (_holder_aglcontext); + aglDestroyContext(_holder_aglcontext); _holder_aglcontext = NULL; } @@ -714,7 +714,7 @@ build_gl(bool full_screen) { OSStatus err = noErr; if (osxgsg->get_agl_pixel_format()) { - _holder_aglcontext = aglCreateContext(osxgsg->get_agl_pixel_format(),NULL); + _holder_aglcontext = aglCreateContext(osxgsg->get_agl_pixel_format(), NULL); err = report_agl_error("aglCreateContext"); if (_holder_aglcontext == NULL) { @@ -724,7 +724,7 @@ build_gl(bool full_screen) { err = -1; } } else { - aglSetInteger(_holder_aglcontext, AGL_BUFFER_NAME, &osxgsg->SharedBuffer); + aglSetInteger(_holder_aglcontext, AGL_BUFFER_NAME, &osxgsg->_shared_buffer); err = report_agl_error ("aglSetInteger AGL_BUFFER_NAME"); } } else { @@ -1216,8 +1216,8 @@ os_open_window(WindowProperties &req_properties) { osxdisplay_cat.error() << "Error in build_gl\n"; - HideWindow (_osx_window); - SetWRefCon (_osx_window, (long int) NULL); + HideWindow(_osx_window); + SetWRefCon(_osx_window, (long int) NULL); DisposeWindow(_osx_window); _osx_window = NULL; return false; @@ -1227,10 +1227,10 @@ os_open_window(WindowProperties &req_properties) { << "build_gl complete, set properties\n"; // - // atach the holder context to the window.. + // attach the holder context to the window.. // - if (!aglSetDrawable(_holder_aglcontext, GetWindowPort (_osx_window))) { + if (!aglSetDrawable(_holder_aglcontext, GetWindowPort(_osx_window))) { err = report_agl_error("aglSetDrawable"); }