diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2018-10-25 11:17:21 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 16:12:46 -0400 |
commit | 30fa24966463a2c10c620b782ac5c8d1b8303ceb (patch) | |
tree | f089a8a934859109f67a66501b74239e35090708 | |
parent | c80c5fa512185d1c24c5c13f03a04326f9d0cc50 (diff) |
DRTVWR-476: Fix glVertexAttrib{IPointer,PointerARB}() OpenGL calls.
VS 2017 complains about the same thing that clang does: casting S32 to GLvoid*
can't possibly produce a valid pointer value because S32 can't fit a whole
64-bit pointer. To appease it, not only must we use reinterpret_cast, but we
must first cast S32 to intptr_t and then reinterpret_cast THAT.
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 1312f6afda..f89522ea57 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1471,7 +1471,12 @@ void LLVertexBuffer::setupVertexArray() //glVertexattribIPointer requires GLSL 1.30 or later if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30) { - glVertexAttribIPointer(i, attrib_size[i], attrib_type[i], sTypeSize[i], (const GLvoid*) mOffsets[i]); + // nat 2018-10-24: VS 2017 also notices the issue + // described below, and warns even with reinterpret_cast. + // Cast via intptr_t to make it painfully obvious to the + // compiler that we're doing this intentionally. + glVertexAttribIPointer(i, attrib_size[i], attrib_type[i], sTypeSize[i], + reinterpret_cast<const GLvoid*>(intptr_t(mOffsets[i]))); } #endif } @@ -1486,7 +1491,7 @@ void LLVertexBuffer::setupVertexArray() // rather than as an actual pointer, so it's okay. glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], attrib_normalized[i], sTypeSize[i], - reinterpret_cast<GLvoid*>(mOffsets[i])); + reinterpret_cast<GLvoid*>(intptr_t(mOffsets[i]))); } } else |