From 2ccef5448acf58e536a647780dd9c4c0a236d7d2 Mon Sep 17 00:00:00 2001 From: Alexandros Frantzis Date: Fri, 2 Dec 2011 14:35:44 +0200 Subject: [PATCH] Add 'profile' parameter to glws::createVisual(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: José Fonseca --- glretrace_main.cpp | 2 +- glws.hpp | 2 +- glws_cocoa.mm | 6 +++++- glws_egl_xlib.cpp | 2 +- glws_glx.cpp | 7 ++++++- glws_wgl.cpp | 6 +++++- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/glretrace_main.cpp b/glretrace_main.cpp index 3bf9de8..fdc52ab 100644 --- a/glretrace_main.cpp +++ b/glretrace_main.cpp @@ -330,7 +330,7 @@ int main(int argc, char **argv) } glws::init(); - visual = glws::createVisual(double_buffer); + visual = glws::createVisual(double_buffer, defaultProfile); for ( ; i < argc; ++i) { if (!parser.open(argv[i])) { diff --git a/glws.hpp b/glws.hpp index 8294f6b..fdc61c0 100644 --- a/glws.hpp +++ b/glws.hpp @@ -148,7 +148,7 @@ void cleanup(void); Visual * -createVisual(bool doubleBuffer = false); +createVisual(bool doubleBuffer = false, Profile profile = PROFILE_COMPAT); Drawable * createDrawable(const Visual *visual, int width = 32, int height = 32); diff --git a/glws_cocoa.mm b/glws_cocoa.mm index 2e9bbae..aa96d9c 100644 --- a/glws_cocoa.mm +++ b/glws_cocoa.mm @@ -171,7 +171,7 @@ cleanup(void) { Visual * -createVisual(bool doubleBuffer) { +createVisual(bool doubleBuffer, Profile profile) { NSOpenGLPixelFormatAttribute single_attribs[] = { NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)1, NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24, @@ -189,6 +189,10 @@ createVisual(bool doubleBuffer) { (NSOpenGLPixelFormatAttribute)0 }; + if (profile != PROFILE_COMPAT) { + return nil; + } + NSOpenGLPixelFormatAttribute *attribs = doubleBuffer ? double_attribs : single_attribs; NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] diff --git a/glws_egl_xlib.cpp b/glws_egl_xlib.cpp index e383a53..a9ffa52 100644 --- a/glws_egl_xlib.cpp +++ b/glws_egl_xlib.cpp @@ -270,7 +270,7 @@ cleanup(void) { } Visual * -createVisual(bool doubleBuffer) { +createVisual(bool doubleBuffer, Profile profile) { EglVisual *visual = new EglVisual(); // possible combinations const EGLint api_bits[7] = { diff --git a/glws_glx.cpp b/glws_glx.cpp index a7f0b0f..c151db1 100644 --- a/glws_glx.cpp +++ b/glws_glx.cpp @@ -240,7 +240,12 @@ cleanup(void) { } Visual * -createVisual(bool doubleBuffer) { +createVisual(bool doubleBuffer, Profile profile) { + if (profile != PROFILE_COMPAT && + profile != PROFILE_CORE) { + return NULL; + } + GlxVisual *visual = new GlxVisual; if (glxVersion >= 0x0103) { diff --git a/glws_wgl.cpp b/glws_wgl.cpp index 63ce5fe..ca100d9 100644 --- a/glws_wgl.cpp +++ b/glws_wgl.cpp @@ -199,7 +199,11 @@ cleanup(void) { } Visual * -createVisual(bool doubleBuffer) { +createVisual(bool doubleBuffer, Profile profile) { + if (profile != PROFILE_COMPAT) { + return NULL; + } + Visual *visual = new Visual(); visual->doubleBuffer = doubleBuffer; -- 2.7.4