我在不同的计算机上遇到了 OpenGL 渲染的问题:
作品:Intel HD3000 / Sandy 桥接器:ATI 6950 ATI 6970m ATI 5670m Quadro FX 2000
不工作:Nvidia 移动 9600 gt Quadro FX 1800
当调用代码行“renderLines()”时,屏幕上不会出现“不起作用”的显卡。没有“renderLines()”,在我测试过的所有显卡上,一切都按预期工作。
"renderSprites()" 与 renderLines() 非常相似,唯一的区别是它将四边形渲染到屏幕而不是线条。
void GraphicsEngineOGL3::update()
{
this->renderSprites();
this->renderLines(); // this is the offending line of code
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
checkError();
}
void GraphicsEngineOGL3::renderLines()
{
if(lineBuffer_.empty()) // note: lineBuffer is a std::Vector<Vertex>
return;
glEnableClientState(GL_VERTEX_ARRAY); // DEPRECATED in OGL 3.1
glEnableClientState(GL_COLOR_ARRAY);
// Note: glVertexPointer is deprecated, change to glVertexAttribPointer
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &(lineBuffer_[0].x)); // DEPRECATED in OGL 3.1
glColorPointer(4, GL_BYTE, sizeof(Vertex), &(lineBuffer_[0].r));
glBindBuffer( GL_ARRAY_BUFFER, VBOs_[activeVBO_]);
glBufferData( GL_ARRAY_BUFFER, lineBuffer_.size() * sizeof(Vertex), &(lineBuffer_[0]), GL_STREAM_DRAW);
glDrawArrays( GL_LINES, 0, lineBuffer_.size()); // where 4 is the number of vertices in the quad
glBindBuffer( GL_ARRAY_BUFFER, 0); // Binding the buffer object with 0 switchs off VBO operation.
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
lineBuffer_.clear();
checkError();
}