Good day
I am trying to render one triangle with hard coded vertices in NDC coordinates:
const float vdata[] = {
-0.7f, -0.7f, 0.0f,
0.7f, -0.7f, 0.0f,
0.7f, 0.7f, 0.0f
};
unsigned short inds[] = {0,1,2};
with trivial shaders:
vert:
#version 330
layout (location = 0) in vec3 Position;
void main()
{
gl_Position = vec4(Position, 1.0);
}
frag:
#version 330
out vec4 ColorOut;
void main()
{
ColorOut = vec4(1.0, 1.0, 1.0, 1.0);
}
with red clear color,
as the result I get the triangle in correct place, but the color pattern is flickering with kind of “random” pattern (looks like memory corruption).
tried rendering just with glDrawArrays, and glDrawElements (thus the index buffer) with the same result…
Any ideas what’s gone wrong would be appreciated…
rendering function looks like follows:
glViewport(0, 0, mBufferWidth, mBufferHeight);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glBindBuffer(GL_ARRAY_BUFFER, mBufferId[buffer_type::VERTEX_BUFFER]);
glBufferData(GL_ARRAY_BUFFER, sizeof(vdata), vdata, GL_STATIC_DRAW);
glEnableVertexAttribArray(attr_type::POSITION);
glVertexAttribPointer(attr_type::POSITION, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_TRIANGLES, 0, 3);
SwapBuffers(mHDC);
Thank you!
Tatiana
P.S. did not manage to upload image file, so here is the link:
https://1drv.ms/i/s!AgiCIBNkQKeZxTO07fvI5lsZmJRR