From 5d1351fc66b669cbde2afdddf6180151adbba0f1 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 11 Jun 2015 20:06:17 -0400 Subject: [PATCH] create a buffer, draw a quad --- test/test.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test.cpp b/test/test.cpp index e54c1ba..b08ec7b 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -11,6 +11,7 @@ using namespace std; shared_ptr vs; shared_ptr fs; shared_ptr program; +shared_ptr buffer; bool init(void) { @@ -20,9 +21,18 @@ bool init(void) vs = make_shared(); fs = make_shared(); program = make_shared(); + buffer = make_shared(); + vs->create_from_file(GL_VERTEX_SHADER, "test/vert.glsl"); fs->create_from_file(GL_FRAGMENT_SHADER, "test/frag.glsl"); program->create(vs, fs); + GLfloat coords[] = { + -0.5, -0.5, + 0.5, -0.5, + 0.5, 0.5, + -0.5, 0.5 + }; + buffer->create(GL_ARRAY_BUFFER, GL_STATIC_DRAW, &coords, sizeof(coords)); } catch (glcxx::Error & e) { @@ -35,6 +45,10 @@ bool init(void) void display(SDL_Window * window) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), NULL); + program->use(); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); SDL_GL_SwapWindow(window); }