2018-09-05 23:10:38 +00:00
|
|
|
#include "MyObjectOrientedScene.h"
|
|
|
|
|
2018-09-07 03:22:40 +00:00
|
|
|
#include "DrawMode.h"
|
|
|
|
#include "MeshFactory.h"
|
|
|
|
|
2018-09-05 23:10:38 +00:00
|
|
|
MyObjectOrientedScene::MyObjectOrientedScene()
|
2018-09-07 15:45:32 +00:00
|
|
|
: m_shape(MeshFactory<MyBatchTestShaderProgram::Vertex, MyBatchTestShaderProgram::Index>::gen(
|
2018-09-07 03:22:40 +00:00
|
|
|
DrawMode::DRAW_TRIANGLES,
|
2018-09-07 15:45:32 +00:00
|
|
|
MyBatchTestShaderProgram::Vertex(-0.1f, 0.1f, 0.0f),
|
|
|
|
MyBatchTestShaderProgram::Vertex(0.1f, 0.1f, 0.0f),
|
|
|
|
MyBatchTestShaderProgram::Vertex(-0.15f, -0.1f, 0.0f),
|
|
|
|
MyBatchTestShaderProgram::Vertex(0.15f, -0.1f, 0.0f)
|
2018-09-07 03:22:40 +00:00
|
|
|
), DrawMode::DRAW_TRIANGLES), m_batch(&m_shape, 1, 1)
|
2018-09-05 23:10:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MyObjectOrientedScene::~MyObjectOrientedScene()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyObjectOrientedScene::init()
|
|
|
|
{
|
|
|
|
m_batch.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyObjectOrientedScene::use()
|
|
|
|
{
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc(GL_LESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyObjectOrientedScene::unuse()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyObjectOrientedScene::update(float delta_time, clock_t clock)
|
|
|
|
{
|
2018-09-07 04:41:34 +00:00
|
|
|
float n;
|
2018-09-07 15:45:32 +00:00
|
|
|
clock_t c;
|
|
|
|
c = (clock / 10) % 512;
|
2018-09-07 04:41:34 +00:00
|
|
|
if (c < 256)
|
|
|
|
{
|
|
|
|
n = (float)c / 256;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = (float)(512 - c) / 256;
|
|
|
|
}
|
2018-09-05 23:10:38 +00:00
|
|
|
|
2018-09-07 15:45:32 +00:00
|
|
|
// TODO: Movement Test
|
|
|
|
|
|
|
|
MyBatchTestShaderProgram::Color& color = m_batch.get_color(0);
|
|
|
|
color.r = n;
|
|
|
|
color.g = n;
|
|
|
|
color.b = n;
|
|
|
|
color.a = 1.0f;
|
2018-09-07 04:41:34 +00:00
|
|
|
|
|
|
|
// TODO: Make a prerender function or move this to render
|
|
|
|
m_batch.prerender();
|
2018-09-05 23:10:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyObjectOrientedScene::render()
|
|
|
|
{
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
m_shader_program.use();
|
|
|
|
m_batch.render();
|
|
|
|
}
|