2016-09-28 09:50:35 +00:00
|
|
|
#include "renderer_polygon_3d.hpp"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2016-09-28 11:00:40 +00:00
|
|
|
#include "polygon_model.hpp"
|
|
|
|
|
2016-09-28 09:50:35 +00:00
|
|
|
namespace endofthejedi {
|
|
|
|
void RendererPolygon3d::setup()
|
|
|
|
{
|
|
|
|
std::cout<<"setup 3d" << std::endl;
|
2016-09-28 11:00:40 +00:00
|
|
|
|
2016-09-28 11:36:22 +00:00
|
|
|
//m_atomicBomb = new PolygonModel("../data/mesh/small_atomic_bomb.stl");
|
|
|
|
m_atomicBomb = new PolygonModel("../data/mesh/quad_screen_coords.stl");
|
|
|
|
m_atomicBomb->import();
|
|
|
|
m_atomicBomb->uploadToOpenGl();
|
2016-09-28 11:16:11 +00:00
|
|
|
|
|
|
|
m_models.push_back(m_atomicBomb);
|
2016-09-28 11:36:22 +00:00
|
|
|
|
|
|
|
std::string vss =
|
|
|
|
"varying vec3 vertex;\n"
|
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
|
|
|
" gl_Position = gl_Vertex;\n"
|
|
|
|
" vertex = gl_Vertex.xyz;\n"
|
|
|
|
"}\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
std::string fss =
|
|
|
|
"varying vec3 vertex;\n"
|
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
|
|
|
//" gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
|
|
|
|
" gl_FragColor = vec4(0.5+0.5*vertex.xyz, 1.0);\n"
|
|
|
|
"}\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
m_shader.init();
|
|
|
|
m_shader.load(vss.c_str(), GL_VERTEX_SHADER);
|
|
|
|
m_shader.load(fss.c_str(), GL_FRAGMENT_SHADER);
|
2016-09-28 09:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RendererPolygon3d::render(const game::State *state)
|
|
|
|
{
|
2016-09-28 11:36:22 +00:00
|
|
|
m_shader.bind();
|
|
|
|
|
2016-09-28 09:50:35 +00:00
|
|
|
(void) state;
|
|
|
|
|
2016-09-28 11:36:22 +00:00
|
|
|
//m_atomicBomb->bind();
|
|
|
|
//m_atomicBomb->render();
|
|
|
|
|
|
|
|
glColor3f(1.0, 0.0, 0.0);
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
glVertex2f(-1.0f, -1.0f);
|
|
|
|
glVertex2f(1.0f, -1.0f);
|
|
|
|
glVertex2f(1.0f, 1.0f);
|
|
|
|
glVertex2f(-1.0f, 1.0f);
|
|
|
|
glEnd();
|
2016-09-28 11:16:11 +00:00
|
|
|
|
|
|
|
//std::cout<<"render 3d" << std::endl;
|
2016-09-28 09:50:35 +00:00
|
|
|
}
|
|
|
|
}
|