简体   繁体   English

OpenGL翻译

[英]OpenGL translation

I'm having some problems translating an object I'm drawing. 翻译我正在绘制的对象时遇到一些问题。 This is the entirety of my display function. 这是我的整个显示功能。 I can't seem to find anything I'm doing wrong. 我似乎找不到任何我做错的事。

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, 720, 480, 0, -1.0, 1.0);
glTranslatef(-0.5f,0.0f,0.0f);

//drawing object here

glPopMatrix();
glutSwapBuffers();

You need to start modifying the modelview matrix stack after you've done glOrtho : 完成glOrtho后,需要开始修改glOrtho矩阵堆栈:

// ...
glOrtho(0, 720, 480, 0, -1.0, 1.0);

glMatrixMode(GL_MODELVIEW);
glTranslatef(-0.5f,0.0f,0.0f);
// ...

But now your glPushMatrix and glPopMatrix are modifying different stacks, so the glPopMatrix will result in an error. 但是现在你的glPushMatrixglPopMatrix正在修改不同的堆栈,因此glPopMatrix会导致错误。 You shouldn't need them for such a simple example anyway. 无论如何,你不应该为了这么简单的例子而需要它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM