Changeset 806


Ignore:
Timestamp:
Aug 8, 2011, 12:26:52 PM (9 years ago)
Author:
sam
Message:

debug: add a slightly more complex vertex buffer test quad.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/debug/quad.cpp

    r803 r806  
    335335
    336336    /*
    337      * Test #7: vertex buffer
     337     * Test #7: vertex buffer + per-vertex coloring
    338338     * Renders a multicolored square with varying colors.
    339339     */
     
    354354    glDisableClientState(GL_VERTEX_ARRAY);
    355355    glDisableClientState(GL_COLOR_ARRAY);
    356     glUseProgram(0);
    357 
    358     Advance();
    359 
    360     /*
    361      * Test #8: vertex buffer + texture & color in 1.10 fragment shader
     356
     357    Advance();
     358
     359    /*
     360     * Test #8: vertex buffer + per-vertex coloring + texture
     361     * Renders a multicolored square with varying colors multiplied with an
     362     * animated distorted checkerboard.
     363     */
     364    GLfloat const vertices2[] = { data->aa.x, data->bb.y, 0.0f,
     365                                  data->bb.x, data->bb.y, 0.0f,
     366                                  data->bb.x, data->aa.y, 0.0f,
     367                                  data->bb.x, data->aa.y, 0.0f,
     368                                  data->aa.x, data->aa.y, 0.0f,
     369                                  data->aa.x, data->bb.y, 0.0f };
     370
     371    glEnable(GL_TEXTURE_2D);
     372    glBindTexture(GL_TEXTURE_2D, data->texture[0]);
     373    glEnableClientState(GL_COLOR_ARRAY);
     374    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     375    glEnableClientState(GL_VERTEX_ARRAY);
     376
     377    glColorPointer(3, GL_FLOAT, 0, colors);
     378    glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
     379    glVertexPointer(3, GL_FLOAT, 0, vertices2);
     380    glDrawArrays(GL_TRIANGLES, 0, 6);
     381
     382    glDisableClientState(GL_VERTEX_ARRAY);
     383    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     384    glDisableClientState(GL_COLOR_ARRAY);
     385    glDisable(GL_TEXTURE_2D);
     386
     387    Advance();
     388
     389    /*
     390     * Test #9: vertex buffer + texture & color in 1.10 fragment shader
    362391     * Renders a multicolored square with varying colors xored with an
    363392     * animated distorted checkerboard.
     
    384413
    385414    data->shader[3]->Bind();
    386     GLfloat const vertices2[] = { data->aa.x, data->bb.y, 0.0f,
     415    GLfloat const vertices3[] = { data->aa.x, data->bb.y, 0.0f,
    387416                                  data->bb.x, data->bb.y, 0.0f,
    388417                                  data->bb.x, data->aa.y, 0.0f,
     
    395424    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    396425
    397     glVertexPointer(3, GL_FLOAT, 0, vertices2);
     426    glVertexPointer(3, GL_FLOAT, 0, vertices3);
    398427    glColorPointer(3, GL_FLOAT, 0, colors);
    399428    glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
     
    408437
    409438    /*
    410      * Test #8: vertex buffer + texture & color in 1.20 fragment shader
     439     * Test #10: vertex buffer + texture & color in 1.20 fragment shader
    411440     * Renders a multicolored square with varying colors xored with an
    412441     * animated distorted checkerboard.
     
    440469    }
    441470    data->shader[4]->Bind();
    442     GLfloat const vertices3[] = { data->aa.x, data->bb.y, 0.0f,
     471    GLfloat const vertices4[] = { data->aa.x, data->bb.y, 0.0f,
    443472                                  data->bb.x, data->bb.y, 0.0f,
    444473                                  data->bb.x, data->aa.y, 0.0f,
     
    450479
    451480    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[0]);
    452     glBufferData(GL_ARRAY_BUFFER, sizeof(vertices3), vertices3,
     481    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices4), vertices4,
    453482                 GL_DYNAMIC_DRAW);
    454483    glVertexAttribPointer(data->attr[0], 3, GL_FLOAT, GL_FALSE, 0, 0);
     
    478507
    479508    /*
    480      * Test #8: vertex buffer + texture & color in 1.30 fragment shader
     509     * Test #11: vertex buffer + texture & color in 1.30 fragment shader
    481510     * Renders a multicolored square with varying colors xored with an
    482511     * animated distorted checkerboard.
     
    510539    }
    511540    data->shader[5]->Bind();
    512     GLfloat const vertices4[] = { data->aa.x, data->bb.y, 0.0f,
     541    GLfloat const vertices5[] = { data->aa.x, data->bb.y, 0.0f,
    513542                                  data->bb.x, data->bb.y, 0.0f,
    514543                                  data->bb.x, data->aa.y, 0.0f,
     
    520549
    521550    glBindBuffer(GL_ARRAY_BUFFER, data->buffer[3]);
    522     glBufferData(GL_ARRAY_BUFFER, sizeof(vertices4), vertices4,
     551    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices5), vertices5,
    523552                 GL_DYNAMIC_DRAW);
    524553    glVertexAttribPointer(data->attr[3], 3, GL_FLOAT, GL_FALSE, 0, 0);
Note: See TracChangeset for help on using the changeset viewer.