计算机图形学C语言画图问题
//Drawawhitesquareagainstablackbackground#include<stdio.h>#include<GL/glut.h>voiddraw...
// Draw a white square against a black background
#include <stdio.h>
#include <GL/glut.h>
void draw(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, -0.5f, 0.0f);
glVertex3f( 0.0f, 0.5f, 0.0f);
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400,300);
glutInitWindowPosition(200,100);
glutCreateWindow("sample");
glClearColor(1.0,1.0,1.0,0.0);
gluOrtho2D(0.0,400.0,0.0,300.0);
glutDisplayFunc(draw);
glutMainLoop();
}
画个三角形,为什么这代码运行出来是个大白框,求助!! 展开
#include <stdio.h>
#include <GL/glut.h>
void draw(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, -0.5f, 0.0f);
glVertex3f( 0.0f, 0.5f, 0.0f);
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400,300);
glutInitWindowPosition(200,100);
glutCreateWindow("sample");
glClearColor(1.0,1.0,1.0,0.0);
gluOrtho2D(0.0,400.0,0.0,300.0);
glutDisplayFunc(draw);
glutMainLoop();
}
画个三角形,为什么这代码运行出来是个大白框,求助!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询