Skip to content

Commit

Permalink
gl: check error when testing texture parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Aug 3, 2016
1 parent 2d7ad78 commit 5c541bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/opengl/OpenGLHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,26 @@ bool test_gl_param(const gl_param_t& gp, bool* has_16 = 0)
qWarning("%s: current context is null", __FUNCTION__);
return false;
}
if (!gl().GetTexLevelParameteriv) {
qDebug("Do not support glGetTexLevelParameteriv. test_gl_param returns false");
return false;
}
GLuint tex;
DYGL(glGenTextures(1, &tex));
DYGL(glBindTexture(GL_TEXTURE_2D, tex));
while (DYGL(glGetError()) != GL_NO_ERROR) {}
DYGL(glTexImage2D(GL_TEXTURE_2D, 0, gp.internal_format, 64, 64, 0, gp.format, gp.type, NULL));
if (DYGL(glGetError()) != GL_NO_ERROR) {
DYGL(glDeleteTextures(1, &tex));
return false;
}
if (!gl().GetTexLevelParameteriv) {
qDebug("Do not support glGetTexLevelParameteriv. test_gl_param returns false");
DYGL(glDeleteTextures(1, &tex));
return false;
}
GLint param = 0;
//GL_PROXY_TEXTURE_2D and no glGenTextures?
#ifndef GL_TEXTURE_INTERNAL_FORMAT //only in desktop
#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
#endif
gl().GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &param);
// TODO: check glGetError()?
if (param != gp.internal_format) {
qDebug("Do not support texture internal format: %#x (result %#x)", gp.internal_format, param);
DYGL(glDeleteTextures(1, &tex));
Expand Down
4 changes: 2 additions & 2 deletions src/opengl/gl_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void* GetProcAddressWithExt(GetProcAddress_t get, const char *name)
return fp;
}
}
return nullptr;
return NULL;
}

static void* GetProcAddressDefault(const char *name)
Expand Down Expand Up @@ -101,7 +101,7 @@ static void* GetProcAddressDefault(const char *name)
#endif //QT_OPENGL_DYNAMIC


#define GL_RESOLVE_NONE(name) do { name = nullptr;}while(0)
#define GL_RESOLVE_NONE(name) do { name = NULL;}while(0)
#define GL_RESOLVE_EXT(name) do {\
void** fp = (void**)(&name); \
*fp = GetProcAddressDefault("gl" # name); \
Expand Down

0 comments on commit 5c541bd

Please sign in to comment.