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
    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.

Similar Threads

  1. Texture Array from Variable Texture Sizes
    By Christoph in forum Vulkan
    Replies: 4
    Last Post: 07-08-2016, 08:32 AM
  2. vertex array and texture : no texture displayed
    By jean-luc in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-03-2010, 08:02 AM
  3. Corrupt compressed 2D texture array texture on NV
    By bertgp in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 11-25-2008, 04:10 PM
  4. Share texture array among multiple texture object
    By theVIPER in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-30-2006, 08:51 AM
  5. texture coordinate array enabled but texture mapping not?
    By drumminj in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 01-18-2001, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean