From 7b920e768a00345b1809c24e081ae1b30883ff82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 5 Mar 2024 23:09:31 +0100 Subject: [PATCH] GL: extend to size_t before casting to a pointer for glDrawElements(). Fixes the last MSVC C4312 occurence. --- src/Magnum/GL/Mesh.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index ecfb69acb..6c308ef8a 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -900,7 +900,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #else state.drawRangeElementsBaseVertexImplementation #endif - (GLenum(_primitive), indexStart, indexEnd, count, GLenum(_indexType), reinterpret_cast(indexByteOffset), baseVertex); + (GLenum(_primitive), indexStart, indexEnd, count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset)), baseVertex); /* Indexed mesh */ } else @@ -911,7 +911,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #else state.drawElementsBaseVertexImplementation #endif - (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexByteOffset), baseVertex); + (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset)), baseVertex); } #else CORRADE_ASSERT_UNREACHABLE("GL::AbstractShaderProgram::draw(): indexed mesh draw with base vertex specification possible only since WebGL 2.0", ); @@ -922,7 +922,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #ifndef MAGNUM_TARGET_GLES2 /* Indexed mesh with specified range */ if(indexEnd) { - glDrawRangeElements(GLenum(_primitive), indexStart, indexEnd, count, GLenum(_indexType), reinterpret_cast(indexByteOffset)); + glDrawRangeElements(GLenum(_primitive), indexStart, indexEnd, count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset))); /* Indexed mesh */ } else @@ -931,7 +931,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i static_cast(indexEnd); #endif { - glDrawElements(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexByteOffset)); + glDrawElements(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset))); } } @@ -971,7 +971,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #else state.drawElementsInstancedBaseVertexBaseInstanceImplementation #endif - (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexByteOffset), instanceCount, baseVertex, baseInstance); + (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset)), instanceCount, baseVertex, baseInstance); /* Indexed mesh with base vertex */ } else { @@ -980,7 +980,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #else state.drawElementsInstancedBaseVertexImplementation #endif - (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexByteOffset), instanceCount, baseVertex); + (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset)), instanceCount, baseVertex); } #else CORRADE_ASSERT_UNREACHABLE("GL::AbstractShaderProgram::draw(): instanced indexed mesh draw with base vertex specification possible only since OpenGL ES 3.0", ); @@ -996,7 +996,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #else state.drawElementsInstancedBaseInstanceImplementation #endif - (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexByteOffset), instanceCount, baseInstance); + (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset)), instanceCount, baseInstance); /* Instanced mesh */ } else @@ -1007,7 +1007,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i #else state.drawElementsInstancedImplementation #endif - (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexByteOffset), instanceCount); + (GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(std::size_t(indexByteOffset)), instanceCount); } } }