Changeset 657


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

Clean up stuff in the shader crap.

Location:
trunk/src
Files:
2 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]);
  • trunk/src/video.cpp

    r656 r657  
    3030
    3131#if SHADER_CRAP
    32 #   define ATTRIB_POSITION 42 /* arbitrary id */
    3332    GLuint prog, sh1, sh2;
    3433    GLint uni_m1, uni_m2, uni_m3;
     
    5150    "void main()\n"
    5251    "{\n"
    53     "    //gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n"
    54     "    gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n"
     52    "    gl_Position = projection_matrix * view_matrix *"
     53    "                  model_matrix * vec4(in_Position, 1.0f);\n"
    5554    "    gl_TexCoord[0] = vec4(in_TexCoord, 0.0, 0.0);\n"
    5655    "    pass_Color = in_Color;\n"
     
    108107    glAttachShader(prog, sh2);
    109108
    110     //glBindAttribLocation(prog, ATTRIB_POSITION, "position");
    111109    glBindAttribLocation(prog, 0, "in_Position");
    112110    glBindAttribLocation(prog, 1, "in_Color");
Note: See TracChangeset for help on using the changeset viewer.