3205680062
Also added a required prerender function to scene and application. This function is intended to be used as a way to prepare the scene to be rendered in its current state. For that reason, the delta time and the current clock tick are not passed to it.
58 lines
977 B
C++
58 lines
977 B
C++
#include "MyBasicScene.h"
|
|
|
|
MyBasicScene::MyBasicScene(Application& application)
|
|
: Scene(application)
|
|
{
|
|
}
|
|
|
|
|
|
MyBasicScene::~MyBasicScene()
|
|
{
|
|
}
|
|
|
|
void MyBasicScene::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 MyBasicScene::use()
|
|
{
|
|
glEnable(GL_DEPTH_TEST);
|
|
glDepthFunc(GL_LESS);
|
|
}
|
|
|
|
void MyBasicScene::unuse()
|
|
{
|
|
}
|
|
|
|
void MyBasicScene::update(float delta_time, clock_t clock)
|
|
{
|
|
}
|
|
|
|
void MyBasicScene::prerender()
|
|
{
|
|
}
|
|
|
|
void MyBasicScene::render()
|
|
{
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
m_shader_program.use();
|
|
glBindVertexArray(m_vao);
|
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
|
|
|
}
|