opengl 例子学习笔记

今天花了大半天的时间做QT opengl 关于贴图的例子http://www.qiliang.net/old/nehe_qt/lesson06.html

这个例子的框架是对的,但有些错误,改错的过程也是学习的过程

发现以前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);

加在构造函数里就行了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值