From df6f911bddde722401a9df7de75fa38a20177996 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <Timur.Pocheptsov@cern.ch> Date: Wed, 16 May 2012 11:46:52 +0000 Subject: [PATCH] TGLWidget and TGLContext classes were designed to isolate gl-context/gl-window specific code inside gl module. Unfortunately, this isolation is bad as soon as we have to work with Obj-C, OpenGL, classes from Cocoa module. TGLFormat can not go to core/base (because of multi-sampling part of code), I have to convert format into something, I can pass to gVirtualX - array of pairs (enumerator-value). git-svn-id: http://root.cern.ch/svn/root/trunk@44263 27541ba8-7e3a-0410-8455-c3a389f83636 --- graf3d/gl/src/TGLWidget.cxx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/graf3d/gl/src/TGLWidget.cxx b/graf3d/gl/src/TGLWidget.cxx index c8c168f773f..c0ffcc99893 100644 --- a/graf3d/gl/src/TGLWidget.cxx +++ b/graf3d/gl/src/TGLWidget.cxx @@ -384,15 +384,33 @@ void TGLWidget::SetFormat() //============================================================================== //______________________________________________________________________________ -Window_t TGLWidget::CreateWindow(const TGWindow* /*parent*/, const TGLFormat &/*format*/, +Window_t TGLWidget::CreateWindow(const TGWindow* /*parent*/, const TGLFormat &format, UInt_t /*width*/, UInt_t /*height*/, - std::pair<void *, void *>& /*innerData*/) + std::pair<void *, void *>& /*internalData*/) { // CreateWidget - MacOSX/Cocoa version. // Static function called prior to construction. - // Can throw std::bad_alloc and std::runtime_error. - // This version is bad - I do not check the results of - // X11 calls. + + typedef std::pair<UInt_t, Int_t> component_type; + + std::vector<component_type>formatComponents; + + if (format.HasDepth()) + formatComponents.push_back(component_type(TGLFormat::kDepth, format.GetDepthSize())); + if (format.HasStencil()) + formatComponents.push_back(component_type(TGLFormat::kStencil, format.GetStencilSize())); + if (format.HasAccumBuffer()) + formatComponents.push_back(component_type(TGLFormat::kAccum, format.GetAccumSize())); + if (format.IsDoubleBuffered()) + formatComponents.push_back(component_type(TGLFormat::kDoubleBuffer, 0)); + if (format.IsStereo()) + formatComponents.push_back(component_type(TGLFormat::kStereo, 0)); + if (format.HasMultiSampling()) + formatComponents.push_back(component_type(TGLFormat::kMultiSample, format.GetSamples())); + + //return gVirtualX->CreateOpenGLWindow(parent->GetId(), width, height, formatComponents); + + return Window_t(); } -- GitLab