opengl 例子学习笔记
2012-05-04 15:20
295 查看
今天花了大半天的时间做QT opengl 关于贴图的例子http://www.qiliang.net/old/nehe_qt/lesson06.html
这个例子的框架是对的,但有些错误,改错的过程也是学习的过程
发现以前C语言关于指针,数组的知识都忘光了
这是stack overflow 上的一篇回答 (http://stackoverflow.com/questions/5027672/glgentextures-gluint-or-array)
glGenTextures()函数的第二个参数是一个GLuint型的指针,这个参数可以用GLuint 型变量的地址(&), 数组名,或者一个GLuint类型的指针来充当
第二点,发现贴图貌似对格式要求很高,长宽比必须是2的整数倍,128×128, 256×256,,, 还必须是bmp格式的
第三点, 想要让六面体在窗口中转起来的话,要加一个QTimer
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(50);
加在构造函数里就行了
这个例子的框架是对的,但有些错误,改错的过程也是学习的过程
发现以前C语言关于指针,数组的知识都忘光了
GLuint myTexture; glGenTextures(1, &myTexture); // generate just one texture GLuint myTextures[32]; glGenTextures(32, myTextures); // generate 32 textures GLuint myOtherTexture; GLuint* myTexturePointer = &myOtherTexture; glGenTextures(1, myTexturePointer); // generate 1 texture using a pointer GLuint* moreTextures = new GLuint[16]; // generate only 8 textures in the latter half of the array glGenTextures(8, moreTextures + 8);
这是stack overflow 上的一篇回答 (http://stackoverflow.com/questions/5027672/glgentextures-gluint-or-array)
glGenTextures()函数的第二个参数是一个GLuint型的指针,这个参数可以用GLuint 型变量的地址(&), 数组名,或者一个GLuint类型的指针来充当
第二点,发现贴图貌似对格式要求很高,长宽比必须是2的整数倍,128×128, 256×256,,, 还必须是bmp格式的
第三点, 想要让六面体在窗口中转起来的话,要加一个QTimer
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(50);
加在构造函数里就行了
相关文章推荐
- OpenGL学习笔记 (1) —— 在VS2008下的两个简单例子
- OpenMesh学习笔记5 OpenMesh+OpenGL的一个例子
- OpenGL学习笔记(七):创建第一个Qt5.9.3 OpenGL工程模版(与平台无关)
- OpenGL_Qt学习笔记之_05(纹理映射)
- Opengl学习笔记:(一).Ply文件文件格式和文件读取
- OPENGL 变换_视图模型变换与部分透视变换_学习笔记
- JasperReport学习笔记2-创建简单的报表例子
- OpenGL学习笔记(九)
- OpenGL学习笔记(一)
- OpenGL学习笔记2:绘制和混合
- openGL学习笔记3(三维场景变换简介)
- openGL学习笔记4(动画)
- openGL学习笔记之一--视图
- 基础学习笔记之opencv(1):opencv中facedetect例子浅析
- 【C#学习笔记】各种定义方法的例子
- OpenGL_Qt学习笔记之_06(纹理滤波、光照和色彩融合)
- 【深度学习】笔记4_caffe第二个比较经典的[小图片]识别例子CIFAR_10的运行,网络模型的详解
- Android OpenGL 学习笔记
- 《OpenGL游戏程序设计》学习笔记---第七章图像、位图与OpenGL
- Spring学习笔记1--简介及入门例子