Just announcing theese functions
VBO
VAOCode:GLuint create() { glGenBuffers(1, &vboId); return vboId; }; GLvoid bind(int __type__) { glBindBuffer(__type__, vboId); }; GLvoid unbind() { glBindBuffer(0, 0); }
Here is my init codeCode:GLuint create() { glGenVertexArrays(1, &vaoId); return vaoId; }; GLvoid bind() { glBindVertexArray(vaoId); }; GLvoid unbind() { glBindVertexArray(0); };
Code:float verts[4 * 3]; verts[0] = 0.0f; verts[1] = 5.0f; verts[2] = 0.0f; verts[3] = 1.0f; verts[4] = 5.0f; verts[5] = 0.0f; verts[6] = 1.0f; verts[7] = 5.0f; verts[8] = 1.0f; verts[9] = 0.0f; verts[10] = 5.0f; verts[11] = 1.0f; vao.create(); vao.bind(); { vbo.create(); vbo.bind(GL_ARRAY_BUFFER); { glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(GLfloat), &verts[0], GL_STATIC_DRAW); glVertexAttribPointer((GLuint)0, 4, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); } vbo.unbind(); } vao.unbind();
And my draw code
Code:vao.bind(); { glDrawArrays(GL_QUADS, 0, 4); } vao.unbind();
For some reason my output is this
And the red circle indicates a point that is always on the center of the screen, even if I rotate the camera.
So, is there any obvious faults in my code?
I guess the code is sloppy, due to me beeing a java programmer.
C++ seems kinda odd![]()



LinkBack URL
About LinkBacks



