Skip to content

Commit

Permalink
Create a Visual for each Profile.
Browse files Browse the repository at this point in the history
Signed-off-by: José Fonseca <jose.r.fonseca@gmail.com>
  • Loading branch information
afrantzis authored and jrfonseca committed Dec 8, 2011
1 parent fefa663 commit c58efb0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion glretrace.hpp
Expand Up @@ -38,7 +38,7 @@ extern bool double_buffer;
extern bool insideGlBeginEnd; extern bool insideGlBeginEnd;
extern trace::Parser parser; extern trace::Parser parser;
extern glws::Profile defaultProfile; extern glws::Profile defaultProfile;
extern glws::Visual *visual; extern glws::Visual *visual[glws::PROFILE_MAX];
extern glws::Drawable *drawable; extern glws::Drawable *drawable;
extern glws::Context *context; extern glws::Context *context;


Expand Down
4 changes: 2 additions & 2 deletions glretrace_cgl.cpp
Expand Up @@ -53,7 +53,7 @@ getDrawable(unsigned long drawable_id) {
DrawableMap::const_iterator it; DrawableMap::const_iterator it;
it = drawable_map.find(drawable_id); it = drawable_map.find(drawable_id);
if (it == drawable_map.end()) { if (it == drawable_map.end()) {
return (drawable_map[drawable_id] = glws::createDrawable(visual)); return (drawable_map[drawable_id] = glws::createDrawable(visual[glretrace::defaultProfile]));
} }


return it->second; return it->second;
Expand All @@ -70,7 +70,7 @@ getContext(unsigned long long ctx) {
it = context_map.find(ctx); it = context_map.find(ctx);
if (it == context_map.end()) { if (it == context_map.end()) {
glws::Context *context; glws::Context *context;
context_map[ctx] = context = glws::createContext(visual, sharedContext, glretrace::defaultProfile); context_map[ctx] = context = glws::createContext(visual[glretrace::defaultProfile], sharedContext, glretrace::defaultProfile);
if (!sharedContext) { if (!sharedContext) {
sharedContext = context; sharedContext = context;
} }
Expand Down
4 changes: 2 additions & 2 deletions glretrace_egl.cpp
Expand Up @@ -78,7 +78,7 @@ getContext(unsigned long long context_ptr) {
static void retrace_eglCreateWindowSurface(trace::Call &call) { static void retrace_eglCreateWindowSurface(trace::Call &call) {
unsigned long long orig_surface = call.ret->toUIntPtr(); unsigned long long orig_surface = call.ret->toUIntPtr();


glws::Drawable *drawable = glws::createDrawable(glretrace::visual); glws::Drawable *drawable = glws::createDrawable(glretrace::visual[glws::PROFILE_COMPAT]);
drawable_map[orig_surface] = drawable; drawable_map[orig_surface] = drawable;
} }


Expand Down Expand Up @@ -126,7 +126,7 @@ static void retrace_eglCreateContext(trace::Call &call) {
} }




glws::Context *context = glws::createContext(glretrace::visual, share_context, profile); glws::Context *context = glws::createContext(glretrace::visual[glws::PROFILE_COMPAT], share_context, profile);
if (!context) { if (!context) {
const char *name; const char *name;
switch (profile) { switch (profile) {
Expand Down
10 changes: 5 additions & 5 deletions glretrace_glx.cpp
Expand Up @@ -47,7 +47,7 @@ getDrawable(unsigned long drawable_id) {
DrawableMap::const_iterator it; DrawableMap::const_iterator it;
it = drawable_map.find(drawable_id); it = drawable_map.find(drawable_id);
if (it == drawable_map.end()) { if (it == drawable_map.end()) {
return (drawable_map[drawable_id] = glws::createDrawable(visual)); return (drawable_map[drawable_id] = glws::createDrawable(visual[glretrace::defaultProfile]));
} }


return it->second; return it->second;
Expand All @@ -62,7 +62,7 @@ getContext(unsigned long long context_ptr) {
ContextMap::const_iterator it; ContextMap::const_iterator it;
it = context_map.find(context_ptr); it = context_map.find(context_ptr);
if (it == context_map.end()) { if (it == context_map.end()) {
return (context_map[context_ptr] = glws::createContext(visual, NULL, glretrace::defaultProfile)); return (context_map[context_ptr] = glws::createContext(visual[glretrace::defaultProfile], NULL, glretrace::defaultProfile));
} }


return it->second; return it->second;
Expand All @@ -72,15 +72,15 @@ static void retrace_glXCreateContext(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr(); unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *share_context = getContext(call.arg(2).toUIntPtr()); glws::Context *share_context = getContext(call.arg(2).toUIntPtr());


glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile); glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
context_map[orig_context] = context; context_map[orig_context] = context;
} }


static void retrace_glXCreateContextAttribsARB(trace::Call &call) { static void retrace_glXCreateContextAttribsARB(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr(); unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *share_context = getContext(call.arg(2).toUIntPtr()); glws::Context *share_context = getContext(call.arg(2).toUIntPtr());


glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile); glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
context_map[orig_context] = context; context_map[orig_context] = context;
} }


Expand Down Expand Up @@ -134,7 +134,7 @@ static void retrace_glXCreateNewContext(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr(); unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *share_context = getContext(call.arg(3).toUIntPtr()); glws::Context *share_context = getContext(call.arg(3).toUIntPtr());


glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile); glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
context_map[orig_context] = context; context_map[orig_context] = context;
} }


Expand Down
14 changes: 10 additions & 4 deletions glretrace_main.cpp
Expand Up @@ -40,7 +40,7 @@ bool double_buffer = true;
bool insideGlBeginEnd = false; bool insideGlBeginEnd = false;
trace::Parser parser; trace::Parser parser;
glws::Profile defaultProfile = glws::PROFILE_COMPAT; glws::Profile defaultProfile = glws::PROFILE_COMPAT;
glws::Visual *visual = NULL; glws::Visual *visual[glws::PROFILE_MAX];
glws::Drawable *drawable = NULL; glws::Drawable *drawable = NULL;
glws::Context *context = NULL; glws::Context *context = NULL;


Expand Down Expand Up @@ -330,7 +330,10 @@ int main(int argc, char **argv)
} }


glws::init(); glws::init();
visual = glws::createVisual(double_buffer, defaultProfile); visual[glws::PROFILE_COMPAT] = glws::createVisual(double_buffer, glws::PROFILE_COMPAT);
visual[glws::PROFILE_CORE] = glws::createVisual(double_buffer, glws::PROFILE_CORE);
visual[glws::PROFILE_ES1] = glws::createVisual(double_buffer, glws::PROFILE_ES1);
visual[glws::PROFILE_ES2] = glws::createVisual(double_buffer, glws::PROFILE_ES2);


for ( ; i < argc; ++i) { for ( ; i < argc; ++i) {
if (!parser.open(argv[i])) { if (!parser.open(argv[i])) {
Expand All @@ -342,8 +345,11 @@ int main(int argc, char **argv)


parser.close(); parser.close();
} }


delete visual; for (int n = 0; n < glws::PROFILE_MAX; n++) {
delete visual[n];
}

glws::cleanup(); glws::cleanup();


return 0; return 0;
Expand Down
8 changes: 4 additions & 4 deletions glretrace_wgl.cpp
Expand Up @@ -48,15 +48,15 @@ getDrawable(unsigned long long hdc) {
DrawableMap::const_iterator it; DrawableMap::const_iterator it;
it = drawable_map.find(hdc); it = drawable_map.find(hdc);
if (it == drawable_map.end()) { if (it == drawable_map.end()) {
return (drawable_map[hdc] = glws::createDrawable(visual)); return (drawable_map[hdc] = glws::createDrawable(visual[glretrace::defaultProfile]));
} }


return it->second; return it->second;
} }


static void retrace_wglCreateContext(trace::Call &call) { static void retrace_wglCreateContext(trace::Call &call) {
unsigned long long orig_context = call.ret->toUIntPtr(); unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *context = glws::createContext(glretrace::visual, NULL, glretrace::defaultProfile); glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], NULL, glretrace::defaultProfile);
context_map[orig_context] = context; context_map[orig_context] = context;
} }


Expand Down Expand Up @@ -181,7 +181,7 @@ static void retrace_wglCreatePbufferARB(trace::Call &call) {
int iHeight = call.arg(3).toUInt(); int iHeight = call.arg(3).toUInt();


unsigned long long orig_pbuffer = call.ret->toUIntPtr(); unsigned long long orig_pbuffer = call.ret->toUIntPtr();
glws::Drawable *drawable = glws::createDrawable(glretrace::visual); glws::Drawable *drawable = glws::createDrawable(glretrace::visual[glretrace::defaultProfile]);


drawable->resize(iWidth, iHeight); drawable->resize(iWidth, iHeight);
drawable->show(); drawable->show();
Expand Down Expand Up @@ -223,7 +223,7 @@ static void retrace_wglCreateContextAttribsARB(trace::Call &call) {
share_context = context_map[call.arg(1).toUIntPtr()]; share_context = context_map[call.arg(1).toUIntPtr()];
} }


glws::Context *context = glws::createContext(glretrace::visual, share_context, glretrace::defaultProfile); glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
context_map[orig_context] = context; context_map[orig_context] = context;
} }


Expand Down
1 change: 1 addition & 0 deletions glws.hpp
Expand Up @@ -42,6 +42,7 @@ enum Profile {
PROFILE_CORE, PROFILE_CORE,
PROFILE_ES1, PROFILE_ES1,
PROFILE_ES2, PROFILE_ES2,
PROFILE_MAX
}; };




Expand Down
2 changes: 2 additions & 0 deletions glws_egl_xlib.cpp
Expand Up @@ -384,6 +384,8 @@ createContext(const Visual *_visual, Context *shareContext, Profile profile)
eglBindAPI(EGL_OPENGL_ES_API); eglBindAPI(EGL_OPENGL_ES_API);
attribs.add(EGL_CONTEXT_CLIENT_VERSION, 2); attribs.add(EGL_CONTEXT_CLIENT_VERSION, 2);
break; break;
default:
return NULL;
} }


attribs.end(EGL_NONE); attribs.end(EGL_NONE);
Expand Down

0 comments on commit c58efb0

Please sign in to comment.