OpenGL glRectf() 不显示
OpenGL glRectf() not displaying
glRectf() 没有显示在我的 window:
中
#include <GL/gl.h>
#include <GL/glut.h>
void renderScene(){
glClearColor(0.0f,1.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,0.0f,0.0f);
glRectf(225.0f,150.0f,150.0f,100.0f);
glFlush();
}
int main(int argc, char*argv[]){
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGBA);
glutInitWindowSize(450, 350);
glutCreateWindow("My first OpenGL Program...took forever");
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
(225.0f,150.0f) 离身份视锥体很远。
提供一些适当的变换矩阵,这样您的矩形就不会被裁剪:
#include <GL/glut.h>
void renderScene()
{
glClearColor(0.0f,1.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( -300, 300, -300, 300, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glColor3f(1.0f,0.0f,0.0f);
glRectf(225.0f,150.0f,150.0f,100.0f);
glFlush();
}
int main(int argc, char*argv[])
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGBA);
glutInitWindowSize(450, 350);
glutCreateWindow("My first OpenGL Program...took forever");
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
glRectf() 没有显示在我的 window:
中#include <GL/gl.h>
#include <GL/glut.h>
void renderScene(){
glClearColor(0.0f,1.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,0.0f,0.0f);
glRectf(225.0f,150.0f,150.0f,100.0f);
glFlush();
}
int main(int argc, char*argv[]){
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGBA);
glutInitWindowSize(450, 350);
glutCreateWindow("My first OpenGL Program...took forever");
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
(225.0f,150.0f) 离身份视锥体很远。
提供一些适当的变换矩阵,这样您的矩形就不会被裁剪:
#include <GL/glut.h>
void renderScene()
{
glClearColor(0.0f,1.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( -300, 300, -300, 300, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glColor3f(1.0f,0.0f,0.0f);
glRectf(225.0f,150.0f,150.0f,100.0f);
glFlush();
}
int main(int argc, char*argv[])
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGBA);
glutInitWindowSize(450, 350);
glutCreateWindow("My first OpenGL Program...took forever");
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}