From: Chia-I Wu Date: Mon, 7 Nov 2011 23:12:29 +0000 (-0700) Subject: glws: Add support for profiles X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=d56c5318f7ba4855ee79b0deaf4549212f3e4780;p=apitrace glws: Add support for profiles 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. --- 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(visual)->pixelFormat; NSOpenGLContext *share_context = nil; NSOpenGLContext *context; + if (profile != PROFILE_COMPAT) { + return nil; + } + if (shareContext) { share_context = dynamic_cast(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(_visual); GLXContext share_context = NULL; GLXContext context; + if (profile != PROFILE_COMPAT) { + return NULL; + } + if (shareContext) { share_context = dynamic_cast(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(shareContext)); }