Results 1 to 2 of 2

Thread: Rendering multiple textures in one glDrawArrays call

  1. #1
    Newbie Newbie
    Join Date
    Mar 2014

    Question Rendering multiple textures in one glDrawArrays call

    I have a number of quads being drawn on screen using VBO's with the
    Code :
    call and I was wondering if it is possible to draw different textures onto each of these quads because they are in the same draw call and in the same vbo?

    The problem is, if I were to bind a number of textures (like in the code below) then ALL the quads would have the last bound texture.
    Code :
    glBindTexture(GL_TEXTURE_2D, image.image);
    glBindTexture(GL_TEXTURE_2D, image.image);

    So can I use the two bound textures above on two different quads rendered in the same glDrawArrays call and if so how is this possible?


  2. #2
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    A few different ways of doing this.

    If your textures don't need mipmaps and don't repeat you could pack them all into a texture atlas and adjust your texcoords for sub-rectangles within that atlas.

    If they're all square, all the same size, and you have no more than 6, you could put them on different faces of a cubemap.

    The above two methods will work on really old hardware. A slightly more modern approach would be to use a texture array; this retains the restriction that all of your textures should be the same size, but otherwise you'd add an additional vertex attrib to your vertex layout specifying which array slice to use. That would be my own preferred approach.

Similar Threads

  1. Rendering multiple 2D textures
    By blackwolf12333 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-25-2015, 07:13 AM
  2. glDrawArrays - Multiple Textures
    By EuadeLuxe in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-17-2013, 12:41 AM
  3. Multiple Textures on GL_QUADS Call
    By g0bl1n in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-20-2011, 03:54 AM
  4. textures with multiple rendering contexts
    By drumminj in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 12-29-2000, 08:39 PM
  5. Using multiple textures for terrain rendering
    By elroy in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 07-04-2000, 03:12 PM

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