Home > database >  openGL triange isnt showing
openGL triange isnt showing

Time:10-21

empty window

Help find my error

How can i debug such an issue in future?

CodePudding user response:

Points of your geometry don't define a triangle, but a line:

float vertexCoords[] = {
        -0.5f, -0.5f,
        -0.0f, -0.5f,
        0.5f, -0.5f
};

all have the same y-coord. Change the last point coords to: 0.5f, 0.5f.


Also you missed to define VAO:

GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

uint32_t buffer;
glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexCoords), vertexCoords, GL_STATIC_DRAW);
  • Related