2018-09-11 05:18:17 +00:00
|
|
|
#include "MyBasicScene.h"
|
2018-09-04 19:25:54 +00:00
|
|
|
|
2018-09-11 05:18:17 +00:00
|
|
|
MyBasicScene::MyBasicScene(Application& application)
|
2018-09-08 04:06:10 +00:00
|
|
|
: Scene(application)
|
2018-09-04 19:25:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-11 05:18:17 +00:00
|
|
|
MyBasicScene::~MyBasicScene()
|
2018-09-04 19:25:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-11 05:18:17 +00:00
|
|
|
void MyBasicScene::init()
|
2018-09-05 15:47:09 +00:00
|
|
|
{
|
2018-09-05 20:26:50 +00:00
|
|
|
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);
|
2018-09-05 23:10:38 +00:00
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
2018-09-05 20:26:50 +00:00
|
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
|
2018-09-05 15:47:09 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 05:18:17 +00:00
|
|
|
void MyBasicScene::use()
|
2018-09-04 19:25:54 +00:00
|
|
|
{
|
2018-09-05 23:10:38 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc(GL_LESS);
|
2018-09-04 19:25:54 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 05:18:17 +00:00
|
|
|
void MyBasicScene::unuse()
|
2018-09-04 19:25:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-11 05:18:17 +00:00
|
|
|
void MyBasicScene::update(float delta_time, clock_t clock)
|
2018-09-04 19:25:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-12 15:22:56 +00:00
|
|
|
void MyBasicScene::prerender()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-11 05:18:17 +00:00
|
|
|
void MyBasicScene::render()
|
2018-09-04 19:25:54 +00:00
|
|
|
{
|
2018-09-05 20:26:50 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
2018-09-05 06:49:02 +00:00
|
|
|
m_shader_program.use();
|
2018-09-05 20:26:50 +00:00
|
|
|
glBindVertexArray(m_vao);
|
2018-09-05 15:47:09 +00:00
|
|
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
2018-09-05 20:26:50 +00:00
|
|
|
|
2018-09-04 19:25:54 +00:00
|
|
|
}
|