summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-12-05 09:44:52 +0000
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-12-05 09:44:52 +0000
commit8842c2353d673b45d34c163e444d6ecd068d255c (patch)
tree5a5fd9b734435c1de4d9ba6c016e491ddb0d3241
parente147b61b3e822cf6b2d81f8a62ae7d0ddec81815 (diff)
Add option to request an Opengl 3.2 core profile context.
-rw-r--r--glretrace.hpp1
-rw-r--r--glretrace_cgl.cpp2
-rw-r--r--glretrace_glx.cpp8
-rw-r--r--glretrace_main.cpp4
-rw-r--r--glretrace_wgl.cpp6
-rw-r--r--glws.hpp3
-rw-r--r--glws_egl_xlib.cpp3
-rw-r--r--glws_glx.cpp37
8 files changed, 47 insertions, 17 deletions
diff --git a/glretrace.hpp b/glretrace.hpp
index 81b5d1ec..15035b21 100644
--- a/glretrace.hpp
+++ b/glretrace.hpp
@@ -37,6 +37,7 @@ namespace glretrace {
extern bool double_buffer;
extern bool insideGlBeginEnd;
extern trace::Parser parser;
+extern glws::Profile defaultProfile;
extern glws::Visual *visual;
extern glws::Drawable *drawable;
extern glws::Context *context;
diff --git a/glretrace_cgl.cpp b/glretrace_cgl.cpp
index 2feebc33..0c5aa735 100644
--- a/glretrace_cgl.cpp
+++ b/glretrace_cgl.cpp
@@ -70,7 +70,7 @@ getContext(unsigned long long ctx) {
it = context_map.find(ctx);
if (it == context_map.end()) {
glws::Context *context;
- context_map[ctx] = context = glws::createContext(visual, sharedContext);
+ context_map[ctx] = context = glws::createContext(visual, sharedContext, glretrace::defaultProfile);
if (!sharedContext) {
sharedContext = context;
}
diff --git a/glretrace_glx.cpp b/glretrace_glx.cpp
index d04bca6d..749907ac 100644
--- a/glretrace_glx.cpp
+++ b/glretrace_glx.cpp
@@ -62,7 +62,7 @@ getContext(unsigned long long context_ptr) {
ContextMap::const_iterator it;
it = context_map.find(context_ptr);
if (it == context_map.end()) {
- return (context_map[context_ptr] = glws::createContext(visual, NULL));
+ return (context_map[context_ptr] = glws::createContext(visual, NULL, glretrace::defaultProfile));
}
return it->second;
@@ -72,7 +72,7 @@ static void retrace_glXCreateContext(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
- glws::Context *context = glws::createContext(glretrace::visual, share_context);
+ glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
context_map[orig_context] = context;
}
@@ -80,7 +80,7 @@ static void retrace_glXCreateContextAttribsARB(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
- glws::Context *context = glws::createContext(glretrace::visual, share_context);
+ glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
context_map[orig_context] = context;
}
@@ -134,7 +134,7 @@ static void retrace_glXCreateNewContext(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *share_context = getContext(call.arg(3).toUIntPtr());
- glws::Context *context = glws::createContext(glretrace::visual, share_context);
+ glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
context_map[orig_context] = context;
}
diff --git a/glretrace_main.cpp b/glretrace_main.cpp
index 3c010d28..3bf9de89 100644
--- a/glretrace_main.cpp
+++ b/glretrace_main.cpp
@@ -39,6 +39,7 @@ namespace glretrace {
bool double_buffer = true;
bool insideGlBeginEnd = false;
trace::Parser parser;
+glws::Profile defaultProfile = glws::PROFILE_COMPAT;
glws::Visual *visual = NULL;
glws::Drawable *drawable = NULL;
glws::Context *context = NULL;
@@ -248,6 +249,7 @@ static void usage(void) {
"\n"
" -b benchmark mode (no error checking or warning messages)\n"
" -c PREFIX compare against snapshots\n"
+ " -core use core profile\n"
" -db use a double buffer visual (default)\n"
" -sb use a single buffer visual\n"
" -s PREFIX take snapshots; `-` for PNM stdout output\n"
@@ -283,6 +285,8 @@ int main(int argc, char **argv)
} else if (!strcmp(arg, "-D")) {
dump_state = atoi(argv[++i]);
retrace::verbosity = -2;
+ } else if (!strcmp(arg, "-core")) {
+ defaultProfile = glws::PROFILE_CORE;
} else if (!strcmp(arg, "-db")) {
double_buffer = true;
} else if (!strcmp(arg, "-sb")) {
diff --git a/glretrace_wgl.cpp b/glretrace_wgl.cpp
index 9cef80af..243dfe0e 100644
--- a/glretrace_wgl.cpp
+++ b/glretrace_wgl.cpp
@@ -56,7 +56,7 @@ getDrawable(unsigned long long hdc) {
static void retrace_wglCreateContext(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr();
- glws::Context *context = glws::createContext(glretrace::visual);
+ glws::Context *context = glws::createContext(glretrace::visual, NULL, glretrace::defaultProfile);
context_map[orig_context] = context;
}
@@ -114,7 +114,7 @@ static void retrace_wglShareLists(trace::Call &call) {
glws::Context *old_context = context_map[hglrc2];
glws::Context *new_context =
- glws::createContext(old_context->visual, share_context);
+ glws::createContext(old_context->visual, share_context, glretrace::defaultProfile);
if (new_context) {
if (context == old_context) {
glws::makeCurrent(drawable, new_context);
@@ -223,7 +223,7 @@ static void retrace_wglCreateContextAttribsARB(trace::Call &call) {
share_context = context_map[call.arg(1).toUIntPtr()];
}
- glws::Context *context = glws::createContext(glretrace::visual, share_context);
+ glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile);
context_map[orig_context] = context;
}
diff --git a/glws.hpp b/glws.hpp
index 8d72a833..8294f6b3 100644
--- a/glws.hpp
+++ b/glws.hpp
@@ -38,7 +38,8 @@ namespace glws {
enum Profile {
- PROFILE_COMPAT,
+ PROFILE_COMPAT = 0,
+ PROFILE_CORE,
PROFILE_ES1,
PROFILE_ES2,
};
diff --git a/glws_egl_xlib.cpp b/glws_egl_xlib.cpp
index d1277058..e383a532 100644
--- a/glws_egl_xlib.cpp
+++ b/glws_egl_xlib.cpp
@@ -339,6 +339,9 @@ createContext(const Visual *_visual, Context *shareContext, Profile profile)
load("libGL.so.1");
eglBindAPI(EGL_OPENGL_API);
break;
+ case PROFILE_CORE:
+ assert(0);
+ return NULL;
case PROFILE_ES1:
load("libGLESv1_CM.so.1");
eglBindAPI(EGL_OPENGL_ES_API);
diff --git a/glws_glx.cpp b/glws_glx.cpp
index db24b7f5..a7f0b0fc 100644
--- a/glws_glx.cpp
+++ b/glws_glx.cpp
@@ -297,28 +297,49 @@ createContext(const Visual *_visual, Context *shareContext, Profile profile)
GLXContext share_context = NULL;
GLXContext context;
- if (profile != PROFILE_COMPAT) {
- return NULL;
- }
-
if (shareContext) {
share_context = static_cast<GlxContext*>(shareContext)->context;
}
if (glxVersion >= 0x0104 && has_GLX_ARB_create_context) {
Attributes<int> attribs;
+
attribs.add(GLX_RENDER_TYPE, GLX_RGBA_TYPE);
if (debug) {
attribs.add(GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB);
}
+
+ switch (profile) {
+ case PROFILE_COMPAT:
+ break;
+ case PROFILE_CORE:
+ // XXX: This will invariable return a 3.2 context, when supported.
+ // We probably should have a PROFILE_CORE_XX per version.
+ attribs.add(GLX_CONTEXT_MAJOR_VERSION_ARB, 3);
+ attribs.add(GLX_CONTEXT_MINOR_VERSION_ARB, 2);
+ attribs.add(GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB);
+ break;
+ default:
+ return NULL;
+ }
+
attribs.end();
context = glXCreateContextAttribsARB(display, visual->fbconfig, share_context, True, attribs);
- } else
- if (glxVersion >= 0x103) {
- context = glXCreateNewContext(display, visual->fbconfig, GLX_RGBA_TYPE, share_context, True);
} else {
- context = glXCreateContext(display, visual->visinfo, share_context, True);
+ if (profile != PROFILE_COMPAT) {
+ return NULL;
+ }
+
+ if (glxVersion >= 0x103) {
+ context = glXCreateNewContext(display, visual->fbconfig, GLX_RGBA_TYPE, share_context, True);
+ } else {
+ context = glXCreateContext(display, visual->visinfo, share_context, True);
+ }
+ }
+
+ if (!context) {
+ return NULL;
}
return new GlxContext(visual, profile, context);