vs2015中glut的安装及初使用过程中的一些问题

网上好多地方都可以下载glut库文件,把glut.h  .lib .dll文件分别放入相应目录就好啦


安装后发现找不到win32控制台程序------


一开始visual c++下面只有windows这个选项,里面有个大概叫安装通用windows平台程序什么的,安装后就有了


新建项目选择win32控制台应用程序


下一步记得一定要选中 “空项目”




建立完成之后,在源文件处添加新建项



选择c++文件



放进一个正确的程序代码(Sierpinski triangle

#include <GL/glut.h>
#include<stdlib.h>

void myinit()
{
	// attributes
	glClearColor(1.0, 1.0, 1.0, 1.0);
	glColor3f(1.0, 0.0, 0.0);
	// set up viewing
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0, 50.0, 0.0, 50.0);
	glMatrixMode(GL_MODELVIEW);
}
void display()
{
	GLfloat vertices[3][3] = { { 0.0,0.0,0.0 },{ 25.0, 50.0,0.0 },{ 50.0,0.0,0.0 } };
	// an arbitrary triangle in the plane z = 0;
	GLfloat p[3] = { 7.5, 5.0, 0.0 };
	// or set any desired initial point which is inside the triangle;
	int  j, k;
	int  rand();
	glBegin(GL_POINTS);
	for (k = 0; k < 5000; k++)
	{
		/* pick a random vertex from 0, 1, 2*/
		j = rand() % 3;
		// compute new location;
		p[0] = (p[0] + vertices[j][0]) / 2;
		p[1] = (p[1] + vertices[j][1]) / 2;
		// display new point
		glVertex3fv(p);
	}
	glEnd();
	glFlush();
}

void  main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(500, 500);
	glutInitWindowPosition(0, 0);
	glutCreateWindow("Simple OpenGL Example");
	glutDisplayFunc(display);
	myinit();
	glutMainLoop();
}


F5调试


这就说明glut安装成功了


PS-----VS好难用。。csdn为什么不能直接粘贴图片。。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值