Results 1 to 2 of 2

Thread: Multiple textures for objects

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    2

    Multiple textures for objects

    Hi,

    I have an object loaded into memory and the object has more than one texture for it. So some polygons have texture1 assign to it, and some polygons have texture2 assigned to it.

    I have wrote up the code that draws the model and determines what polygon needs which texture but im having a problem.

    At first, between my glBegin and glEnd, i looped through every polygon and drew it on screen, but it turns out i cant use glBindTexture between glBegin and glEnd to change the texture for the polygon.

    The only way ive managed to get this working, is to put glBegin and glEnd just before and after a single polygon to be drawn, instead of the whole lot. Then i can glBindTexture to change the active texture to draw with.

    Is that an effient way at doing that?
    Is there any ther way i can do this?

    Also, is it possible to put the object into a display list? with texture information for each polygon?

    Thanks

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    245

    Re: Multiple textures for objects

    Just sort the polygons by texture. Then do this:

    Bind the first texture.
    glBegin
    Draw all polygons that need that texture.
    glEnd
    Bind the second texture.
    glBegin
    Draw the rest of the polygons.
    glEnd

    Sorting geometry by GL state is a pretty common technique.

Similar Threads

  1. Replies: 9
    Last Post: 11-02-2018, 08:16 AM
  2. Replies: 2
    Last Post: 10-22-2017, 06:11 PM
  3. Multiple objects: single or multiple shaders?
    By sam_thedancer in forum OpenGL: Basic Coding
    Replies: 14
    Last Post: 04-29-2013, 03:29 AM
  4. Multiple objects in a VBO or Multiple VBOs?
    By Kreed in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 09-04-2012, 12:42 PM
  5. Multiple textures in objects using the same shader
    By th3w1zard in forum OpenGL: GLSL
    Replies: 7
    Last Post: 04-22-2009, 06:43 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