Changeset 654


Ignore:
Timestamp:
Feb 17, 2011, 1:05:58 AM (9 years ago)
Author:
sam
Message:

More shader crap. We can now display a coloured quad. Still disabled.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scene.cpp

    r653 r654  
    137137    qsort(data->tiles, data->ntiles, sizeof(Tile), SceneData::Compare);
    138138
     139#if SHADER_CRAP
     140    float *vertices = new float[18];
     141    vertices[0] = -0.5f; vertices[1] = -0.5f; vertices[2] = 0.0f;
     142    vertices[3] = -0.5f; vertices[4] = 0.5f; vertices[5] = 0.0f;
     143    vertices[6] = 0.5f; vertices[7] = 0.5f; vertices[8] = 0.0f;
     144
     145    vertices[9] = 0.5f; vertices[10] = -0.5f; vertices[11] = 0.0f;
     146    vertices[12] = -0.5f; vertices[13] = -0.5f; vertices[14] = 0.0f;
     147    vertices[15] = 0.5f; vertices[16] = 0.5f; vertices[17] = 0.0f;
     148
     149    const GLfloat colors[6][3] = {
     150    {  1.0,  0.0,  0.0  },
     151    {  0.0,  1.0,  0.0  },
     152    {  0.0,  0.0,  1.0  },
     153    {  1.0,  0.0,  0.0  },
     154    {  0.0,  1.0,  0.0  },
     155    {  1.0,  1.0,  0.0  } };
     156
     157    GLuint id[3];
     158    glGenVertexArrays(1, &id[0]);
     159    glBindVertexArray(id[0]);
     160    glGenBuffers(2, &id[1]);
     161
     162    glBindBuffer(GL_ARRAY_BUFFER, id[1]);
     163    glBufferData(GL_ARRAY_BUFFER, 18 * sizeof(GLfloat), vertices, GL_STATIC_DRAW);
     164    glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0);
     165    glEnableVertexAttribArray(0);
     166
     167    glBindBuffer(GL_ARRAY_BUFFER, id[2]);
     168    glBufferData(GL_ARRAY_BUFFER, 18 * sizeof(GLfloat), colors, GL_STATIC_DRAW);
     169    glVertexAttribPointer((GLuint)1, 3, GL_FLOAT, GL_FALSE, 0, 0);
     170    glEnableVertexAttribArray(1);
     171
     172    delete[] vertices;
     173
     174    glUseProgram(prog);
     175    glBindVertexArray(id[0]);
     176    glDrawArrays(GL_TRIANGLES, 0, 6);
     177    glBindVertexArray(0);
     178
     179#else
    139180    // XXX: debug stuff
    140181    glPushMatrix();
     
    211252
    212253    glPopMatrix();
     254#endif
    213255
    214256    free(data->tiles);
  • trunk/src/video.cpp

    r653 r654  
    4444    "in vec3 in_Color;\n"
    4545    "out vec3 pass_Color;\n"
    46     "//attribute vec4 position;\n"
    4746    "uniform mat4 projection_matrix;\n"
    4847    "uniform mat4 view_matrix;\n"
     
    5150    "void main()\n"
    5251    "{\n"
    53     "    gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n"
     52    "    //gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n"
     53    "    gl_Position = vec4(in_Position, 1.0f);\n"
    5454    "    pass_Color = in_Color;\n"
    5555    "}\n";
     
    6363    "void main()\n"
    6464    "{\n"
    65     "    gl_FragColor = pass_Color;\n"
     65    "    gl_FragColor = vec4(pass_Color, 1.0);\n"
    6666    "}\n";
    6767#endif
Note: See TracChangeset for help on using the changeset viewer.