[PATCH 2/6] glws: Add support for profiles

Chia-I Wu olvaffe at gmail.com
Tue Nov 8 15:48:39 PST 2011


The valid profiles are PROFILE_COMPAT, PROFILE_ES1, and PROFILE_ES2.  They
stand for desktop GL with compatibility profile, GLESv1, and GLESv2
respectively.  Update createContext to take profile as the last parameter.
---
 glws.hpp      |    9 ++++++++-
 glws_cocoa.mm |    6 +++++-
 glws_glx.cpp  |    6 +++++-
 glws_wgl.cpp  |    6 +++++-
 4 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/glws.hpp b/glws.hpp
index d6c2003..adabe14 100644
--- a/glws.hpp
+++ b/glws.hpp
@@ -37,6 +37,13 @@
 namespace glws {
 
 
+enum Profile {
+    PROFILE_COMPAT,
+    PROFILE_ES1,
+    PROFILE_ES2,
+};
+
+
 extern bool debug;
 
 
@@ -144,7 +151,7 @@ Drawable *
 createDrawable(const Visual *visual, int width = 32, int height = 32);
 
 Context *
-createContext(const Visual *visual, Context *shareContext = 0);
+createContext(const Visual *visual, Context *shareContext = 0, Profile profile = PROFILE_COMPAT);
 
 bool
 makeCurrent(Drawable *drawable, Context *context);
diff --git a/glws_cocoa.mm b/glws_cocoa.mm
index 493cb4a..315c6bc 100644
--- a/glws_cocoa.mm
+++ b/glws_cocoa.mm
@@ -204,12 +204,16 @@ createDrawable(const Visual *visual, int width, int height)
 }
 
 Context *
-createContext(const Visual *visual, Context *shareContext)
+createContext(const Visual *visual, Context *shareContext, Profile profile)
 {
     NSOpenGLPixelFormat *pixelFormat = dynamic_cast<const CocoaVisual *>(visual)->pixelFormat;
     NSOpenGLContext *share_context = nil;
     NSOpenGLContext *context;
 
+    if (profile != PROFILE_COMPAT) {
+        return nil;
+    }
+
     if (shareContext) {
         share_context = dynamic_cast<CocoaContext*>(shareContext)->context;
     }
diff --git a/glws_glx.cpp b/glws_glx.cpp
index 3c49de8..d771093 100644
--- a/glws_glx.cpp
+++ b/glws_glx.cpp
@@ -293,12 +293,16 @@ createDrawable(const Visual *visual, int width, int height)
 }
 
 Context *
-createContext(const Visual *_visual, Context *shareContext)
+createContext(const Visual *_visual, Context *shareContext, Profile profile)
 {
     const GlxVisual *visual = dynamic_cast<const GlxVisual *>(_visual);
     GLXContext share_context = NULL;
     GLXContext context;
 
+    if (profile != PROFILE_COMPAT) {
+        return NULL;
+    }
+
     if (shareContext) {
         share_context = dynamic_cast<GlxContext*>(shareContext)->context;
     }
diff --git a/glws_wgl.cpp b/glws_wgl.cpp
index 1958b5f..4b5870e 100644
--- a/glws_wgl.cpp
+++ b/glws_wgl.cpp
@@ -210,8 +210,12 @@ createDrawable(const Visual *visual, int width, int height)
 }
 
 Context *
-createContext(const Visual *visual, Context *shareContext)
+createContext(const Visual *visual, Context *shareContext, Profile profile)
 {
+    if (profile != PROFILE_COMPAT) {
+        return NULL;
+    }
+
     return new WglContext(visual, dynamic_cast<WglContext *>(shareContext));
 }
 
-- 
1.7.6.3



More information about the apitrace mailing list