Sign in to follow this  

Problem on texture mapping quad drawing

Recommended Posts

rosicky2005    122
In the following code, w and h stand for width and height, the code specification said that this function aim to find the maximum value of an array of w*h by computing the local maximum of each 2x2 group of elements in one kernel. But I can't understand how this is done by the code below. Can anyone please help me?
void drawQuad(int w, int h) {

    glMultiTexCoord2f(GL_TEXTURE0, -0.5, -0.5);
    glMultiTexCoord2f(GL_TEXTURE1,  0.5, -0.5);
    glMultiTexCoord2f(GL_TEXTURE2, -0.5,  0.5);
    glMultiTexCoord2f(GL_TEXTURE3,  0.5,  0.5);
    glVertex2f(0.0, 0.0);

    glMultiTexCoord2f(GL_TEXTURE0, 2*w-0.5, -0.5);
    glMultiTexCoord2f(GL_TEXTURE1, 2*w+0.5, -0.5);
    glMultiTexCoord2f(GL_TEXTURE2, 2*w-0.5,  0.5);
    glMultiTexCoord2f(GL_TEXTURE3, 2*w+0.5,  0.5);
    glVertex2f(w, 0.0);

    glMultiTexCoord2f(GL_TEXTURE0, 2*w-0.5, 2*h-0.5);
    glMultiTexCoord2f(GL_TEXTURE1, 2*w+0.5, 2*h-0.5);
    glMultiTexCoord2f(GL_TEXTURE2, 2*w-0.5, 2*h+0.5);
    glMultiTexCoord2f(GL_TEXTURE3, 2*w+0.5, 2*h+0.5);
    glVertex2f(w, h);

    glMultiTexCoord2f(GL_TEXTURE0, -0.5, 2*h-0.5);
    glMultiTexCoord2f(GL_TEXTURE1,  0.5, 2*h-0.5);
    glMultiTexCoord2f(GL_TEXTURE2, -0.5, 2*h+0.5);
    glMultiTexCoord2f(GL_TEXTURE3,  0.5, 2*h+0.5);
    glVertex2f(0.0, h);
[Edited by - rosicky2005 on November 16, 2006 3:08:09 AM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this