Thank you for helping guys. I attempted to use VBOs, but something doesn't work. I was attempting to (for now) draw a red triangle in orthographic mode on the screen. Here's the buffer creating code:
int xValues[3] = {100, 40, 140};
int yValues[3] = {50, 70, 70};
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
GLuint vbo[2];
glGenBuffers(2, vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
glBufferData(GL_ARRAY_BUFFER, 3 * sizeof(int), xValues, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)0, 1, GL_INT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
glBufferData(GL_ARRAY_BUFFER, 3 * sizeof(int), yValues, GL_STATIC_DRAW);
glVertexAttribPointer((GLuint)1, 1, GL_INT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindVertexArray(0);
Then I draw as follows:
glBindVertexArray(vao);
glDrawArrays(GL_TRIANGLES, 0, 1);
glBindVertexArray(0);
My vertex shader:
// gui.vert
// The GUI vertex shader.
// This software, including the source code, is release under the terms of
// the License.
#version 150
// vertex input
in int in_x;
in int in_y;
void main()
{
float x = (float(in_x) / 320) - 1;
float y = (float(in_y) / 240) - 1;
gl_Position = vec4(x, y, 0.0, 1.0);
};
My fragment shader:
// gui.frag
// The GUI fragment shader.
// This software, including the source code, is release under the terms of
// the License.
#version 150
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
};
But the only thing I get is a black screen. Does anyone know what I'm doing wrong here?