From 3cab7282dc5afa2146f4f4d3068cd0fc93d4c1fc Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 5 Jan 2025 14:12:28 +0000 Subject: [PATCH] Added a vertex attributes and glEnable --- src/sdl.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sdl.cpp b/src/sdl.cpp index 0f497aa..fb1e3d8 100644 --- a/src/sdl.cpp +++ b/src/sdl.cpp @@ -54,16 +54,22 @@ SdlWindow::SdlWindow(const char* title, int width, int height) // 6. Mark as running m_isRunning = true; - float positions[6] = { + float positions[6] = { // vertex for a triangle + //x,y -0.5f, -0.5f, 0.0f, 0.5f, 0.5f, -0.5f }; + //vertex buffer unsigned int buffer; glGenBuffers(1, &buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer); //select buffer called 'buffer' glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), positions, GL_STATIC_DRAW); // assigne buffer size, static as we use many times, but does not change - // + //vertext attributes / layout + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0); + + } SdlWindow::~SdlWindow() {