diff --git a/src/main.zig b/src/main.zig index 6f7e550..6d1d81c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -86,7 +86,9 @@ pub fn main() void { var r_vert_buffer: c_uint = undefined; gl.glad_glGenBuffers.?(1, &r_vert_buffer); gl.glad_glBindBuffer.?(gl.GL_ARRAY_BUFFER, r_vert_buffer); - gl.glBufferData(gl.GL_ARRAY_BUFFER, 2 * 3 * @sizeOf(f32), @ptrCast(&rect_verts), gl.GL_STATIC_DRAW); + gl.glBufferData(gl.GL_ARRAY_BUFFER, 4 * 3 * @sizeOf(f32), @ptrCast(&rect_verts), gl.GL_STATIC_DRAW); + gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, gl.GL_FALSE, 3 * @sizeOf(f32), @ptrCast(&0)); + gl.glEnableVertexAttribArray(0); // gl.glad_glBindBuffer.?(0); var element_buffer: c_uint = undefined; @@ -142,10 +144,9 @@ pub fn main() void { gl.glClear(gl.GL_COLOR_BUFFER_BIT); // color buffer, depth buffer, and stencil buffer gl.glUseProgram(shaderProgram); - gl.glad_glBindVertexArray.?(vao); - gl.glad_glBindBuffer.?(gl.GL_ARRAY_BUFFER, vbo); // offset into vertexes, and count - // gl.glDrawArrays(gl.GL_TRIANGLES, 0, 3); + gl.glad_glBindVertexArray.?(vao); + gl.glDrawArrays(gl.GL_TRIANGLES, 0, 3); gl_err = gl.glGetError(); @@ -155,8 +156,6 @@ pub fn main() void { } gl.glad_glBindVertexArray.?(rect_vao); - gl.glad_glBindBuffer.?(gl.GL_ARRAY_BUFFER, r_vert_buffer); - gl.glad_glBindBuffer.?(gl.GL_ELEMENT_ARRAY_BUFFER, element_buffer); gl.glDrawElements(gl.GL_TRIANGLES, 6, gl.GL_UNSIGNED_INT, null); gl_err = gl.glGetError();