charcoal/OpenGLEngine/MyObjectOrientedScene.cpp
elipzer 3485bcb2a0 Improved Batch Functionality
Now batches are actually batches.

Also added the MeshFactory class.

Drawing modes are now specified with DrawMode instead of the
GLenum. Renderables must be specified with a draw mode.
2018-09-06 23:22:40 -04:00

48 lines
956 B
C++

#include "MyObjectOrientedScene.h"
#include "DrawMode.h"
#include "MeshFactory.h"
MyObjectOrientedScene::MyObjectOrientedScene()
: m_shape(MeshFactory<MyShaderProgram::VertexType, MyShaderProgram::IndexType>::gen(
DrawMode::DRAW_TRIANGLES,
MyShaderProgram::VertexType(-0.5f, 0.4f, 0.0f),
MyShaderProgram::VertexType(0.5f, 0.4f, 0.0f),
MyShaderProgram::VertexType(-0.8f, -0.4f, 0.0f),
MyShaderProgram::VertexType(0.8f, -0.4f, 0.0f)
), DrawMode::DRAW_TRIANGLES), m_batch(&m_shape, 1, 1)
{
}
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)
{
}
void MyObjectOrientedScene::render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_shader_program.use();
m_batch.render();
}