GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


GL Multitexturing by MrDutchy
terrain::draw()
{
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);


    glBindTexture(GL_TEXTURE_2D, terrtex1->id); 
    glEnable(GL_TEXTURE_2D);
    
    glClientActiveTextureARB(GL_TEXTURE0_ARB);
    glTexCoordPointer(2,GL_FLOAT,0,&texcoords1[0]);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY); 

    glBindTexture(GL_TEXTURE_2D, terrtex2->id);
    glEnable(GL_TEXTURE_2D); 

    glClientActiveTextureARB(GL_TEXTURE1_ARB);
    glTexCoordPointer(2,GL_FLOAT,0,&texcoords2[0]);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY); 

    glVertexPointer(3,GL_FLOAT,0,&vertdat[0]);
    
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP);

    glTexGeni(GL_S,GL_OBJECT_PLANE,GL_OBJECT_LINEAR);
    glTexGeni(GL_T,GL_OBJECT_PLANE,GL_OBJECT_LINEAR);
        
    /*glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);*/

    glDrawArrays(GL_TRIANGLES,0,vertcount);

    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}