简体   繁体   English

opengl纹理映射

[英]opengl texture mapping

i have got a single texture working in my opengl project the problem is it only lets me use one texture i was wondering how i can change this so i can use multiple textures maybe an array? 我有一个单一的纹理在我的opengl项目中工作问题是它只让我使用一个纹理我想知道我怎么能改变这个所以我可以使用多个纹理可能是一个数组? when i load in more than one bitmap image i can't seem to get it to work 当我加载多个位图图像时,我似乎无法让它工作

this is the code i am using to create the texture 这是我用来创建纹理的代码

glEnable (GL_TEXTURE_2D);
    Bitmap image;

    image.loadBMP ("TEXTURE1.bmp");
    glGenTextures(1, &m_TextureID);
    glBindTexture ( GL_TEXTURE_2D, m_TextureID);

    glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_MODULATE);
    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);

    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    gluBuild2DMipmaps ( GL_TEXTURE_2D, 3, image.width, image.height, GL_RGB, GL_UNSIGNED_BYTE, image.data);
    glDisable (GL_TEXTURE_2D)

can anybody point me in the right direction thanks 任何人都可以指出我正确的方向谢谢

Besides calling glGenTextures n times, you can do this : 除了调用glGenTextures n次之外,你可以这样做:

const GLsizei n = 5;
GLuint textureIDs = new GLuint[ n ];
glGenTextures( n, textureIDs );

Try this if your stuck 如果卡住了就试试这个

GLuint num_textures = 5;
GLuint textures[num_textures];

glGenTextures(num_textures, textures);

:) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM