glVertexAttribPointer 的最后一个属性是 const GLvoid* 类型。但它真的是一个指针吗?它实际上是一个偏移量。如果我输入 0,则表示偏移量为 0,而不是指向偏移量的空指针。在我的引擎中,我使用这个功能:
void AbstractVertexData::vertexAttribPtr(int layout) const
{
glVertexAttribPointer(layout,
getShaderAttribs()[layout]->nbComponents,
static_cast<GLenum>(getShaderAttribs()[layout]->attribDataType),
getShaderAttribs()[layout]->shouldNormalize,
getVertexStride(layout),
reinterpret_cast<const void*>(getVertexAttribStart(layout)));
}
getVertexAttribStart 返回一个 intptr_t。当我运行 drmemory 时,它显示“未初始化读取”,我想删除该警告。此警告来自 reinterpret_cast。我不能 static_cast 到 const void* 因为我的值不是指针。我应该怎么做才能解决这个警告?