如何在opengl中加载图像

时间:2012-05-25 10:39:25

标签: image opengl load

我需要将图片上传到我的背景中...... 有谁知道如何做到这一点? 我知道我必须执行以下步骤:

1) Load image data into system memory
2) Generate a texture name with glGenTextures
3) Bind the texture name with gBindTexture
4) Set wrapping and filtering mode with glTexParameter
5) call glTexImage2D with the right parameters depending on the image nature to load image data into video memory

但我不知道如何将它们放入opengl

1 个答案:

答案 0 :(得分:1)

OpenGL支持纹理和图像......但用户需要提供数据。因此,您必须使用sme库或其他代码来加载数据。

我建议使用非常简单的lib SOIL - http://www.lonesock.net/soil.html 或者您的SDK提供的一些库

一般来说:

load texture bytes into pBytes;
glTexImage2D(..., ..., ..., pBytes);