发个没什么技术含量的文,最近准备通过opengl的学习来好好c++,于是找了网上的教程来搭建opengl的编写环境,建了个空项目,又找了个案例稍微改了改运行了下,还成,ok了~喜不自禁~
贴个图:
代码如下:
#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glutSwapBuffers();
}
void main(int argc,char*argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Hello OpenGL");
glutDisplayFunc(renderScene);
glutMainLoop();//enters the GLUT event processing loop.
}
时间: 2024-10-11 12:30:46