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:: No Line Numbers


A Paste by godecho
1
 
// Set up the view for render to texture
glViewport(0, 0, ShapesTexSize, ShapesTexSize);
glMatrixMode(GL_PROJECTION); 
glLoadIdentity();
gluPerspective(fov, (GLfloat)ShapesTexSize/(GLfloat)ShapesTexSize, nearclip, farclip);

DRAWWHATEVERYOUWANTINYOURTEXTURE();

glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, ShapesTexID);

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

//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, ShapesTexSize, ShapesTexSize, 0);
    
//glClearColor(0.0f, 0.0f, 0.0f, 0.0);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
// Reset the view
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); 
glLoadIdentity ();
gluPerspective(fov, (GLfloat)width/(GLfloat)height, nearclip, farclip);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glDisable(GL_TEXTURE_2D);