Browse Source

Return 1 as implicit alignment value.

Previously 0 was returned, which would fail at runtime for
division-by-zero in the following sanity check:

    CORRADE_INTERNAL_ASSERT(!(offset % BufferTexture::offsetAlignment()));
pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
dfd7de8df1
  1. 4
      src/Magnum/Buffer.cpp
  2. 4
      src/Magnum/Buffer.h
  3. 2
      src/Magnum/BufferTexture.cpp
  4. 2
      src/Magnum/BufferTexture.h

4
src/Magnum/Buffer.cpp

@ -39,7 +39,7 @@ namespace Magnum {
#ifndef MAGNUM_TARGET_GLES
Int Buffer::minMapAlignment() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::map_buffer_alignment>())
return 0;
return 1;
GLint& value = Context::current()->state().buffer->minMapAlignment;
@ -89,7 +89,7 @@ Int Buffer::shaderStorageOffsetAlignment() {
#else
if(!Context::current()->isVersionSupported(Version::GLES310))
#endif
return 0;
return 1;
GLint& value = Context::current()->state().buffer->shaderStorageOffsetAlignment;

4
src/Magnum/Buffer.h

@ -441,7 +441,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If extension @extension{ARB,map_buffer_alignment}
* (part of OpenGL 4.2) is not available, returns `0`.
* (part of OpenGL 4.2) is not available, returns `1`.
* @see @ref map(), @fn_gl{Get} with @def_gl{MIN_MAP_BUFFER_ALIGNMENT}
* @requires_gl No minimal value is specified for OpenGL ES.
*/
@ -476,7 +476,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object}
* (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `0`.
* (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `1`.
* @see @fn_gl{Get} with @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT}
* @requires_gles30 Not defined in OpenGL ES 2.0
*/

2
src/Magnum/BufferTexture.cpp

@ -49,7 +49,7 @@ Int BufferTexture::maxSize() {
Int BufferTexture::offsetAlignment() {
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::texture_buffer_range>())
return 0;
return 1;
GLint& value = Context::current()->state().texture->bufferOffsetAlignment;

2
src/Magnum/BufferTexture.h

@ -217,7 +217,7 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture {
*
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If extension @extension{ARB,texture_buffer_range}
* (part of OpenGL 4.3) is not available, returns `0`.
* (part of OpenGL 4.3) is not available, returns `1`.
* @see @fn_gl{Get} with @def_gl{TEXTURE_BUFFER_OFFSET_ALIGNMENT}
*/
static Int offsetAlignment();

Loading…
Cancel
Save