Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Texture Array

  1. #1
    Newbie Newbie
    Join Date
    May 2017

    Question Texture Array

    Hi, can someone explain how can I use it?
    I have 3 textures and I'm putting them into array. Is it proper way?

    Code :
            int width = 1024;
    	int height = 1024;
    	GLuint ID;
    	glGenTextures(1, &ID);
    	glBindTexture(GL_TEXTURE_2D_ARRAY, ID);
    	glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, width, height, 3)
    	glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE, data[0]);
    	glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 1, width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE, data[1]);
    	glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 2, width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE, data[2]);
    	glBindTexture(GL_TEXTURE_2D_ARRAY, 0);

    but I don't know how to set texture to render. I use immediate mode (I will change it to VBO later) but firstly I want to know how to use this array properly. Textures are 2D, I use GLUT and glext.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Looks pretty close if you don't want MIPmaps. However, you've got a few copy/paste bugs in your glTexParameter calls (the first arg for both calls, as well as the value you're setting for the MIN filter). Since you're not allocating MIPmaps, you don't want to use a MIN filter that expects them.

    As to how to render with this texarray, you're going to need to write shaders to be able to sample (read) from them when texturing your fragments.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts