Skip to content

Commit

Permalink
glretrace,glws: Move profile check into glws module.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfonseca committed Jun 27, 2015
1 parent e58cc50 commit 276d225
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
23 changes: 1 addition & 22 deletions retrace/glretrace_main.cpp
Expand Up @@ -344,29 +344,8 @@ initContext() {
glretrace::Context *currentContext = glretrace::getCurrentContext();
assert(currentContext);

/* Ensure we got a matching profile.
*
* In particular on MacOSX, there is no way to specify specific versions, so this is all we can do.
*
* Also, see if OpenGL ES can be handled through ARB_ES*_compatibility.
*/
glprofile::Profile expectedProfile = currentContext->wsContext->profile;
glprofile::Profile currentProfile = glprofile::getCurrentContextProfile();
if (!currentProfile.matches(expectedProfile)) {
if (expectedProfile.api == glprofile::API_GLES &&
currentProfile.api == glprofile::API_GL &&
((expectedProfile.major == 2 && currentContext->hasExtension("GL_ARB_ES2_compatibility")) ||
(expectedProfile.major == 3 && currentContext->hasExtension("GL_ARB_ES3_compatibility")))) {
std::cerr << "warning: context mismatch:"
<< " expected " << expectedProfile << ","
<< " but got " << currentProfile << " with GL_ARB_ES" << expectedProfile.major << "_compatibility\n";
} else {
std::cerr << "error: context mismatch: expected " << expectedProfile << ", but got " << currentProfile << "\n";
exit(1);
}
}

/* Ensure we have adequate extension support */
glprofile::Profile currentProfile = currentContext->profile();
supportsTimestamp = currentProfile.versionGreaterOrEqual(glprofile::API_GL, 3, 3) ||
currentContext->hasExtension("GL_ARB_timer_query");
supportsElapsed = currentContext->hasExtension("GL_EXT_timer_query") || supportsTimestamp;
Expand Down
22 changes: 22 additions & 0 deletions retrace/glws.cpp
Expand Up @@ -80,6 +80,28 @@ Context::initialize(void)

extensions.getCurrentContextExtensions(profile);

/* Ensure we got a matching profile.
*
* In particular on MacOSX, there is no way to specify specific versions, so this is all we can do.
*
* Also, see if OpenGL ES can be handled through ARB_ES*_compatibility.
*/
glprofile::Profile expectedProfile = profile;
glprofile::Profile currentProfile = glprofile::getCurrentContextProfile();
if (!currentProfile.matches(expectedProfile)) {
if (expectedProfile.api == glprofile::API_GLES &&
currentProfile.api == glprofile::API_GL &&
((expectedProfile.major == 2 && extensions.has("GL_ARB_ES2_compatibility")) ||
(expectedProfile.major == 3 && extensions.has("GL_ARB_ES3_compatibility")))) {
std::cerr << "warning: context mismatch:"
<< " expected " << expectedProfile << ","
<< " but got " << currentProfile << " with GL_ARB_ES" << expectedProfile.major << "_compatibility\n";
} else {
std::cerr << "error: context mismatch: expected " << expectedProfile << ", but got " << currentProfile << "\n";
exit(1);
}
}

initialized = true;
}

Expand Down

0 comments on commit 276d225

Please sign in to comment.