diff options
author | Max Horn | 2010-07-20 07:10:25 +0000 |
---|---|---|
committer | Max Horn | 2010-07-20 07:10:25 +0000 |
commit | 5b626533cdbc2b9a8cb0b478d8e93ece852de1b9 (patch) | |
tree | 3bd0cbca8487e521683fc6f34749f03cdd265b6a /backends | |
parent | 302400a701187eba6d0dee2daa253da87b29d83f (diff) | |
download | scummvm-rg350-5b626533cdbc2b9a8cb0b478d8e93ece852de1b9.tar.gz scummvm-rg350-5b626533cdbc2b9a8cb0b478d8e93ece852de1b9.tar.bz2 scummvm-rg350-5b626533cdbc2b9a8cb0b478d8e93ece852de1b9.zip |
Change CHECK_GL_ERROR to not take a 'call statement' as parameter
Passing a 'call statement' to CHECK_GL_ERROR has various issues.
For once, it confuses code parsers in many editors and other
tools that work with C++ source directly.
Moreover, this can lead to subtle bugs if a mistake is
made with the definition of CHECK_GL_ERROR.
It also causes incorrect warnings if CHECK_GL_ERROR is
used with an "empty" call statement.
svn-id: r51050
Diffstat (limited to 'backends')
-rw-r--r-- | backends/graphics/opengl/glerrorcheck.h | 6 | ||||
-rw-r--r-- | backends/graphics/opengl/gltexture.cpp | 46 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 38 |
3 files changed, 45 insertions, 45 deletions
diff --git a/backends/graphics/opengl/glerrorcheck.h b/backends/graphics/opengl/glerrorcheck.h index c5cbf5726b..a94699ce1d 100644 --- a/backends/graphics/opengl/glerrorcheck.h +++ b/backends/graphics/opengl/glerrorcheck.h @@ -25,13 +25,13 @@ #if !defined(DEBUG) -// If not in debug, just do the GL call -#define CHECK_GL_ERROR(call) (call) +// If not in debug, do nothing +#define CHECK_GL_ERROR() do {} while (false) #else // If in debug, check for an error after a GL call -#define CHECK_GL_ERROR(call) ((call), checkGlError(__FILE__, __LINE__)) +#define CHECK_GL_ERROR() checkGlError(__FILE__, __LINE__) void checkGlError(const char *file, int line); diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp index e3760ee2d8..bd2d67edf5 100644 --- a/backends/graphics/opengl/gltexture.cpp +++ b/backends/graphics/opengl/gltexture.cpp @@ -61,7 +61,7 @@ void GLTexture::initGLExtensions() { const char* ext_string = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); - CHECK_GL_ERROR(0); + CHECK_GL_ERROR(); Common::StringTokenizer tokenizer(ext_string, " "); while (!tokenizer.empty()) { Common::String token = tokenizer.nextToken(); @@ -83,7 +83,7 @@ GLTexture::GLTexture(byte bpp, GLenum format, GLenum type) _refresh(false) { // Generates the texture ID for GL - CHECK_GL_ERROR( glGenTextures(1, &_textureName) ); + glGenTextures(1, &_textureName); CHECK_GL_ERROR(); // This all gets reset later in allocBuffer: _surface.w = 0; @@ -94,12 +94,12 @@ GLTexture::GLTexture(byte bpp, GLenum format, GLenum type) } GLTexture::~GLTexture() { - CHECK_GL_ERROR( glDeleteTextures(1, &_textureName) ); + glDeleteTextures(1, &_textureName); CHECK_GL_ERROR(); } void GLTexture::refresh() { // Generates the texture ID for GL - CHECK_GL_ERROR( glGenTextures(1, &_textureName) ); + glGenTextures(1, &_textureName); CHECK_GL_ERROR(); _refresh = true; } @@ -121,13 +121,13 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) { // Allocate room for the texture now, but pixel data gets uploaded // later (perhaps with multiple TexSubImage2D operations). - CHECK_GL_ERROR( glBindTexture(GL_TEXTURE_2D, _textureName) ); - CHECK_GL_ERROR( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) ); - CHECK_GL_ERROR( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) ); - CHECK_GL_ERROR( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) ); - CHECK_GL_ERROR( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) ); - CHECK_GL_ERROR( glTexImage2D(GL_TEXTURE_2D, 0, _glFormat, - _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL) ); + glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL_ERROR(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); CHECK_GL_ERROR(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); CHECK_GL_ERROR(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); CHECK_GL_ERROR(); + glTexImage2D(GL_TEXTURE_2D, 0, _glFormat, + _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL); CHECK_GL_ERROR(); if (_surface.w != _textureWidth || _surface.h != _textureHeight) _surface.create(_textureWidth, _textureHeight, _bytesPerPixel); @@ -136,17 +136,17 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) { } void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLuint w, GLuint h) { - CHECK_GL_ERROR( glBindTexture(GL_TEXTURE_2D, _textureName) ); + glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR(); if (static_cast<int>(w) * _bytesPerPixel == pitch) { - CHECK_GL_ERROR( glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, - _glFormat, _glType, buf) ); + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, + _glFormat, _glType, buf); CHECK_GL_ERROR(); memcpy(_surface.getBasePtr(x, y), buf, h * pitch); } else { const byte* src = static_cast<const byte*>(buf); do { - CHECK_GL_ERROR( glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, - w, 1, _glFormat, _glType, src) ); + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, + w, 1, _glFormat, _glType, src); CHECK_GL_ERROR(); memcpy(_surface.getBasePtr(x, y), src, w * _bytesPerPixel); ++y; src += pitch; @@ -156,13 +156,13 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu void GLTexture::fillBuffer(byte x) { memset(_surface.pixels, x, _surface.h * _surface.pitch); - CHECK_GL_ERROR( glBindTexture(GL_TEXTURE_2D, _textureName) ); - CHECK_GL_ERROR( glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _surface.w, _surface.h, - _glFormat, _glType, _surface.pixels) ); + glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR(); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _surface.w, _surface.h, + _glFormat, _glType, _surface.pixels); CHECK_GL_ERROR(); } void GLTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) { - CHECK_GL_ERROR( glBindTexture(GL_TEXTURE_2D, _textureName) ); + glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR(); const GLfloat texWidth = (GLfloat)_realWidth / _textureWidth;//xdiv(_surface.w, _textureWidth); const GLfloat texHeight = (GLfloat)_realHeight / _textureHeight;//xdiv(_surface.h, _textureHeight); @@ -172,7 +172,7 @@ void GLTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) { 0, texHeight, texWidth, texHeight, }; - CHECK_GL_ERROR( glTexCoordPointer(2, GL_FLOAT, 0, texcoords) ); + glTexCoordPointer(2, GL_FLOAT, 0, texcoords); CHECK_GL_ERROR(); const GLshort vertices[] = { x, y, @@ -180,9 +180,9 @@ void GLTexture::drawTexture(GLshort x, GLshort y, GLshort w, GLshort h) { x, y + h, x + w, y + h, }; - CHECK_GL_ERROR( glVertexPointer(2, GL_SHORT, 0, vertices) ); + glVertexPointer(2, GL_SHORT, 0, vertices); CHECK_GL_ERROR(); - CHECK_GL_ERROR( glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) ); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); CHECK_GL_ERROR(); } #endif diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 540e1ada0e..4b0591e420 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -527,7 +527,7 @@ void OpenGLGraphicsManager::getGLPixelFormat(Graphics::PixelFormat pixelFormat, void OpenGLGraphicsManager::internUpdateScreen() { // Clear the screen - CHECK_GL_ERROR( glClear(GL_COLOR_BUFFER_BIT) ); + glClear(GL_COLOR_BUFFER_BIT); CHECK_GL_ERROR(); // Draw the game screen _gameTexture->drawTexture(0, 0, _videoMode.hardwareWidth, _videoMode.hardwareHeight); @@ -550,33 +550,33 @@ void OpenGLGraphicsManager::initGL() { GLTexture::initGLExtensions(); // Disable 3D properties - CHECK_GL_ERROR( glDisable(GL_CULL_FACE) ); - CHECK_GL_ERROR( glDisable(GL_DEPTH_TEST) ); - CHECK_GL_ERROR( glDisable(GL_LIGHTING) ); - CHECK_GL_ERROR( glDisable(GL_FOG) ); - CHECK_GL_ERROR( glDisable(GL_DITHER) ); - CHECK_GL_ERROR( glShadeModel(GL_FLAT) ); - CHECK_GL_ERROR( glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST) ); + glDisable(GL_CULL_FACE); CHECK_GL_ERROR(); + glDisable(GL_DEPTH_TEST); CHECK_GL_ERROR(); + glDisable(GL_LIGHTING); CHECK_GL_ERROR(); + glDisable(GL_FOG); CHECK_GL_ERROR(); + glDisable(GL_DITHER); CHECK_GL_ERROR(); + glShadeModel(GL_FLAT); CHECK_GL_ERROR(); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); CHECK_GL_ERROR(); // Setup alpha blend (For overlay and cursor) - CHECK_GL_ERROR( glEnable(GL_BLEND) ); - CHECK_GL_ERROR( glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ); + glEnable(GL_BLEND); CHECK_GL_ERROR(); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); CHECK_GL_ERROR(); // Enable rendering with vertex and coord arrays - CHECK_GL_ERROR( glEnableClientState(GL_VERTEX_ARRAY) ); - CHECK_GL_ERROR( glEnableClientState(GL_TEXTURE_COORD_ARRAY) ); + glEnableClientState(GL_VERTEX_ARRAY); CHECK_GL_ERROR(); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); CHECK_GL_ERROR(); - CHECK_GL_ERROR( glEnable(GL_TEXTURE_2D) ); + glEnable(GL_TEXTURE_2D); CHECK_GL_ERROR(); // Setup the GL viewport - CHECK_GL_ERROR( glViewport(0, 0, _videoMode.hardwareWidth, _videoMode.hardwareHeight) ); + glViewport(0, 0, _videoMode.hardwareWidth, _videoMode.hardwareHeight); CHECK_GL_ERROR(); // Setup coordinates system - CHECK_GL_ERROR( glMatrixMode(GL_PROJECTION) ); - CHECK_GL_ERROR( glLoadIdentity() ); - CHECK_GL_ERROR( glOrtho(0, _videoMode.hardwareWidth, _videoMode.hardwareHeight, 0, -1, 1) ); - CHECK_GL_ERROR( glMatrixMode(GL_MODELVIEW) ); - CHECK_GL_ERROR( glLoadIdentity() ); + glMatrixMode(GL_PROJECTION); CHECK_GL_ERROR(); + glLoadIdentity(); CHECK_GL_ERROR(); + glOrtho(0, _videoMode.hardwareWidth, _videoMode.hardwareHeight, 0, -1, 1); CHECK_GL_ERROR(); + glMatrixMode(GL_MODELVIEW); CHECK_GL_ERROR(); + glLoadIdentity(); CHECK_GL_ERROR(); } bool OpenGLGraphicsManager::loadGFXMode() { |