纹理映射C ++ OpenGL [英] Texture Mapping C++ OpenGL

查看:198
本文介绍了纹理映射C ++ OpenGL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读过,包括Nehe和这里的解决方案,但我找不到具体的答案。

I have read around on this, including Nehe and here for solutions, but I cant find a specific answer.

我试图加载aa照片,称为stars .jpg。我想把这个场景的背景,通过映射它使用uv坐标,做它

I am trying to load a a photo, called stars.jpg. I want to make this my background of the scene, by mapping it using uv coordinates, doing it by

glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(0,0);

但是我只是很困惑的如何加载实际的纹理,所有的调用



However I am just very confused about how to load the actual textures in, all the calls for

glActiveTexture();
glEnable(GL_TEXTURE_2d);
glBindTexture(GL_TEXTURE);

他们所做的一切都是混淆我,这些意思/做什么,假设把这些放在,为了得到stars.jpg是我的背景?

All they do is confuse me, what do all these mean/do, and in what order am I suppose to put these in, in order to get the stars.jpg to be my background?

推荐答案

这里是一步一步教程加载纹理

http://www.nullterminator.net/gltexture.html

Here's a step by step tutorial on loading textures
http://www.nullterminator.net/gltexture.html

重要的是要记住OpenGL是一个状态机,所以你必须告诉它我要谈论纹理现在,那里的 glActiveTexture();

Its important to remember that OpenGL is a state machine, so you have to tell it "I'm going to talk about textures now" that's where the glActiveTexture(); comes in.

还要记住,你必须逐像素地加载颜色你的.jpg(压缩)到你的纹理数组,所以你需要找到一个库,它会给你的.jpg文件的位图值,或者你需要将它预转换为.ppm或.bmp使阅读的价值更容易。

Also keep in mind that you will have to load in pixel by pixel the colors from your .jpg (compressed) to your texture array, so either you will need to find a library that will give you bitmap values of your .jpg file or you will need to pre-convert it into a .ppm or a .bmp which will make reading in the values easier.

这篇关于纹理映射C ++ OpenGL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆