计算机图形学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();
}
画个三角形,为什么这代码运行出来是个大白框,求助!! 展开
--
2022-12-05 广告
2022-12-05 广告
图形化编程简单理解为用积木块形式编程,scratch和python也是其中的一种,属于入门级编程,以其简单生动的画面获得无数学生的喜爱,深圳市创客火科技有限公司是一家做教育无人机的公司,旗下有编程无人机,积木无人机及室内外编队,每款飞机含有...
点击进入详情页
本回答由--提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询