Generate texture from polygon (openGL)

Posted by user146780 on Stack Overflow See other posts from Stack Overflow or by user146780
Published on 2010-05-02T00:09:35Z Indexed on 2010/05/02 0:17 UTC
Read the original article Hit count: 181

Filed under:
|

I have a quad and I would like to use the gradient it produces as a texture for another polygon.

glPushMatrix();
glTranslatef(250,250,0);
    glBegin(GL_POLYGON);


    glColor3f(255,0,0);
glVertex2f(10,0);
glVertex2f(100,0);
glVertex2f(100,100);
glVertex2f(50,50);
glVertex2f(0,100);

    glEnd(); //End quadrilateral coordinates

    glPopMatrix();
    glBegin(GL_QUADS); //Begin quadrilateral coordinates

    glVertex2f(0,0);
glColor3f(0,255,0);
    glVertex2f(150,0);
    glVertex2f(150,150);
    glColor3f(255,0,0);
    glVertex2f(0,150);


    glEnd(); //End quadrilateral coordinates

My goal is to make the 5 vertex polygon have the gradient of the quad (maybe a texture is not the best bet) Thanks

© Stack Overflow or respective owner

Related posts about opengl

Related posts about graphics