Ignore:
Timestamp:
Feb 17, 2011, 7:06:26 PM (11 years ago)
Author:
sam
Message:

Clean up stuff in the shader crap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scene.cpp

    r656 r657  
    3737
    3838#if SHADER_CRAP
    39 #   define ATTRIB_POSITION 42 /* arbitrary id */
    40     extern GLuint prog;
    41     extern GLint uni_mvp, uni_color;
     39extern GLuint prog;
    4240#endif
    4341
     
    163161    {  1.0,  0.0  } };
    164162
    165     GLuint id[4];
    166     glGenVertexArrays(1, &id[0]);
    167     glBindVertexArray(id[0]);
    168     glGenBuffers(3, &id[1]);
    169 
    170     glBindBuffer(GL_ARRAY_BUFFER, id[1]);
     163    GLuint vao, vbo[3];
     164    glGenVertexArrays(1, &vao);
     165    glBindVertexArray(vao);
     166    glGenBuffers(3, &vbo[0]);
     167
     168    glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
    171169    glBufferData(GL_ARRAY_BUFFER, 18 * sizeof(GLfloat), vertices, GL_STATIC_DRAW);
    172170    glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    173171    glEnableVertexAttribArray(0);
    174172
    175     glBindBuffer(GL_ARRAY_BUFFER, id[2]);
     173    glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
    176174    glBufferData(GL_ARRAY_BUFFER, 18 * sizeof(GLfloat), colors, GL_STATIC_DRAW);
    177175    glVertexAttribPointer((GLuint)1, 3, GL_FLOAT, GL_FALSE, 0, 0);
    178176    glEnableVertexAttribArray(1);
    179177
    180     glBindBuffer(GL_ARRAY_BUFFER, id[3]);
     178    glBindBuffer(GL_ARRAY_BUFFER, vbo[2]);
    181179    glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(GLfloat), tex, GL_STATIC_DRAW);
    182180    glVertexAttribPointer((GLuint)2, 2, GL_FLOAT, GL_FALSE, 0, 0);
     
    186184
    187185    glUseProgram(prog);
    188     glBindVertexArray(id[0]);
     186    glBindVertexArray(vao);
    189187    Tiler::Bind(1 << 16);
    190188    glDrawArrays(GL_TRIANGLES, 0, 6);
     
    233231        glEnableClientState(GL_VERTEX_ARRAY);
    234232        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    235 #if SHADER_CRAP
    236         glUseProgram(prog);
    237         //float4x4 mvp(1.0f);
    238         //mvp = mvp - mvp;
    239         //glUniformMatrix4fv(uni_mvp, 1, GL_FALSE, (GLfloat *)&mvp[0][0]);
    240         //glUniform4f(uni_color, 1.0f, 0.0f, 1.0f, 1.0f);
    241 #endif
    242233
    243234        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf]);
     
    245236                     vertex, GL_DYNAMIC_DRAW);
    246237        glVertexPointer(3, GL_FLOAT, 0, NULL);
    247 #if SHADER_CRAP
    248         glVertexAttribPointer(ATTRIB_POSITION, (n - i) * 6, GL_FLOAT, false, 0, vertex);
    249         glEnableVertexAttribArray(ATTRIB_POSITION);
    250 #endif
    251238
    252239        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf + 1]);
Note: See TracChangeset for help on using the changeset viewer.