a8c4b05d2f
This commit gets creates the ObjectOriented scene and gets it working. The current test program swaps a triangle from small to large with the 1 and 2 keys on the keyboard. (1 for small and 2 for large). The small triangle is rendered by the simple scene and the large one is rendered by the object oriented one.
53 lines
905 B
C++
53 lines
905 B
C++
#include "MySimpleScene.h"
|
|
|
|
MySimpleScene::MySimpleScene()
|
|
{
|
|
}
|
|
|
|
|
|
MySimpleScene::~MySimpleScene()
|
|
{
|
|
}
|
|
|
|
void MySimpleScene::init()
|
|
{
|
|
float points[] = {
|
|
0.0f, 0.5f, 0.0f,
|
|
0.5f, -0.5f, 0.0f,
|
|
-0.5f, -0.5f, 0.0f
|
|
};
|
|
|
|
glGenBuffers(1, &m_vbo);
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
|
glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(float), points, GL_STATIC_DRAW);
|
|
|
|
glGenVertexArrays(1, &m_vao);
|
|
glBindVertexArray(m_vao);
|
|
glEnableVertexAttribArray(0);
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
|
|
}
|
|
|
|
void MySimpleScene::use()
|
|
{
|
|
glEnable(GL_DEPTH_TEST);
|
|
glDepthFunc(GL_LESS);
|
|
}
|
|
|
|
void MySimpleScene::unuse()
|
|
{
|
|
}
|
|
|
|
void MySimpleScene::update(float delta_time, clock_t clock)
|
|
{
|
|
}
|
|
|
|
void MySimpleScene::render()
|
|
{
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
m_shader_program.use();
|
|
glBindVertexArray(m_vao);
|
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
|
|
|
}
|