计算机图形学-课堂笔记1
2016-10-18 10:37
225 查看
一、【实践】配置OpenGL环境+测试
1.配置环境
下载glut工具包(下载链接-->http://download.csdn.net/detail/jinlin_23/9656597)
文件放置位置如下图所示:
2.新建项目
点击VS菜单上的【文件】-->【新建】-->【项目】;
选择【Visual C++】 中的 【Win32控制台应用程序】 ;
填写项目名称和项目存放位置后,点击【确定】;
【下一步】-->勾选【空项目】-->【完成】;
此时名为 ConsoleApplication2 的项目就创建好了。
对项目点右键-->【添加】-->【新建项】;
选择【Visual C++】-->【C++ 文件】;
编辑此文件名称后,点击【添加】;
即可添加名为【源.cpp】的文件。
3.运行测试
在【源.cpp】的文件中添加以下代码进行测试
运行结果为:
1.配置环境
下载glut工具包(下载链接-->http://download.csdn.net/detail/jinlin_23/9656597)
文件放置位置如下图所示:
2.新建项目
点击VS菜单上的【文件】-->【新建】-->【项目】;
选择【Visual C++】 中的 【Win32控制台应用程序】 ;
填写项目名称和项目存放位置后,点击【确定】;
【下一步】-->勾选【空项目】-->【完成】;
此时名为 ConsoleApplication2 的项目就创建好了。
对项目点右键-->【添加】-->【新建项】;
选择【Visual C++】-->【C++ 文件】;
编辑此文件名称后,点击【添加】;
即可添加名为【源.cpp】的文件。
3.运行测试
在【源.cpp】的文件中添加以下代码进行测试
// Simple OpenGl program which draws a red sphere in a white window of 500x500 size. #include void my_display (void) { glClearColor(1, 1, 1, 0); // Specify the background color used when the color buffers are cleared. Default: all 0s glClear(GL_COLOR_BUFFER_BIT); // Clear buffers to preset values glColor3f(1.0, 0.0, 0.0); // Specify the color used to draw objects glutSolidSphere(0.5, 50, 40); // Draw a sphere centerred at the origin, where the 3 parameters are: radius, slices, & stacks glFlush(); //若运行不成功可尝试注释掉glFlush();并添加glutSwapBuffers(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//若运行不成功可尝试将其中GLUT_SINGLE改为GLUT_DOUBLE glutInitWindowSize(500, 500); glutInitWindowPosition(100, 100); glutCreateWindow("A red sphere in a white window"); glutDisplayFunc(my_display); glutMainLoop(); return 0; }
运行结果为:
相关文章推荐
- 计算机图形学---学习笔记
- 计算机图形学笔记(一),色彩讲义
- 2017/5/15--计算机系统基础课堂笔记
- 计算机图形学 学习笔记(七):二维图形变换:平移,比例,旋转,坐标变换等
- 计算机图形学 学习笔记(六):消隐算法:Z-buffer,区间扫描线,Warnock,光栅图形学小结
- 计算机图形学入门Gossip学习笔记
- 计算机图形学 学习笔记(十一):曲线曲面(三):B样条 曲线与曲面
- 课堂笔记_图形学基础课程_简单认知00
- 计算机网络原理与应用3.29课堂笔记
- 计算机图形学 学习笔记(九):曲线曲面(一):参数曲线、参数几何代数形式
- 计算机图形学 复习笔记
- 计算机图形学 学习笔记(二):多边形扫描转换:X扫描线算法 和 改进的X扫描线算法
- [3D计算机图形学]学习笔记 第一章 计算机图形学中的数学基础
- 课堂笔记_图形学网格概述
- 计算机网络原理与应用3.15课堂笔记
- 3D计算机图形学,数学基础学习笔记(常用的坐标系解析)
- 课堂笔记(计算机存储)
- 计算机网络课堂笔记
- 计算机图形学 学习笔记(四):直线裁剪算法:Cohen-Suther land,中点分割法,Liang-Barsky
- 计算机图形学 学习笔记(十):曲线曲面(二):Bezier 曲线与曲面