2DFluidSimulation icon indicating copy to clipboard operation
2DFluidSimulation copied to clipboard

Debug message (1): GL_INVALID_OPERATION in glDrawElements

Open shajder opened this issue 1 year ago • 0 comments

GLuint vbo=0;
GLuint vao=0;

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

glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

GLint loc_pos = glGetAttribLocation(shader_program, "position");
if(loc_pos!=-1) {
	  glVertexAttribPointer(loc_pos, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*) 0);
	  glEnableVertexAttribArray(loc_pos);
}

GLint loc_tc = glGetAttribLocation(shader_program, "tCoords");
if(loc_tc!=-1) {
	  glVertexAttribPointer(loc_tc, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float)));
	  glEnableVertexAttribArray(loc_tc);
}

glGenBuffers(1, &ebo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

shajder avatar Nov 13 '24 16:11 shajder