mirror of
https://github.com/MichaelFisher1997/opengl-cpp.git
synced 2025-04-27 14:13:10 +00:00
Added a vertex buffer
This commit is contained in:
parent
64bedd56c7
commit
0b32500d6f
12
src/sdl.cpp
12
src/sdl.cpp
@ -53,6 +53,17 @@ SdlWindow::SdlWindow(const char* title, int width, int height)
|
||||
|
||||
// 6. Mark as running
|
||||
m_isRunning = true;
|
||||
|
||||
float positions[6] = {
|
||||
-0.5f, -0.5f,
|
||||
0.0f, 0.5f,
|
||||
0.5f, -0.5f
|
||||
};
|
||||
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
|
||||
//
|
||||
}
|
||||
|
||||
SdlWindow::~SdlWindow() {
|
||||
@ -141,6 +152,7 @@ void SdlWindow::render() {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// TODO: Draw with OpenGL here (shaders, triangles, etc.)
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
// Swap buffers
|
||||
SDL_GL_SwapWindow(m_window);
|
||||
|
Loading…
x
Reference in New Issue
Block a user