[英]LIne not displaying with glFrustum()?
I was trying to draw a line on the window but it is not displaying with glFrustum()
. 我试图在窗口上画一条线,但没有用
glFrustum()
显示。 I have used the same code with glOrtho()
it does display the line. 我在
glOrtho()
使用了相同的代码,但它确实显示了该行。 Is there anything else I need to set up for my line to show up on set window? 我还需要设置其他内容以使行显示在设置窗口中吗?
void init() {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum( -2.0,2.0,-2.0,2.0, 1.0, 20.0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void display() {
glBegin(GL_LINES);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(0.0f, 0.0f, 2.0f);
glVertex3f(1.0f, 1.0f, 5.0f);
glEnd();
}
In OpenGL the camera looks along the negative Z axis. 在OpenGL中,相机沿负Z轴看。 Therefore, your line is behind the camera, and thus it's getting clipped.
因此,您的线在相机后面,因此被剪断。
Instead draw it at the front: 而是将其绘制在前面:
glVertex3f(0.0f, 0.0f, -2.0f);
glVertex3f(1.0f, 1.0f, -5.0f);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.