2013-11-05 10:45:26 +00:00
|
|
|
#include "OpenGLRenderer.h"
|
2013-04-16 14:57:14 +00:00
|
|
|
|
2013-11-05 10:45:26 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
|
|
|
#include "Scenery.h"
|
2013-11-12 20:34:35 +00:00
|
|
|
#include "SoftwareRenderer.h"
|
2013-11-05 10:45:26 +00:00
|
|
|
#include "renderer.h"
|
2013-11-14 17:47:03 +00:00
|
|
|
#include "CameraDefinition.h"
|
2013-04-16 14:57:14 +00:00
|
|
|
|
2013-11-05 10:45:26 +00:00
|
|
|
OpenGLRenderer::OpenGLRenderer(Scenery* scenery):
|
|
|
|
scenery(scenery)
|
|
|
|
{
|
2013-11-12 20:34:35 +00:00
|
|
|
renderer = new SoftwareRenderer(scenery);
|
|
|
|
renderer->prepare();
|
2013-11-05 10:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OpenGLRenderer::~OpenGLRenderer()
|
|
|
|
{
|
|
|
|
rendererDelete(renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLRenderer::initialize()
|
2013-04-16 14:57:14 +00:00
|
|
|
{
|
|
|
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
|
|
|
glFrontFace(GL_CCW);
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
glDepthFunc(GL_LESS);
|
|
|
|
glDepthMask(1);
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
glLineWidth(1.0);
|
|
|
|
|
|
|
|
glDisable(GL_FOG);
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
|
2013-11-05 10:45:26 +00:00
|
|
|
void OpenGLRenderer::resize(int width, int height)
|
2013-04-16 14:57:14 +00:00
|
|
|
{
|
2013-04-27 19:41:57 +00:00
|
|
|
CameraPerspective perspective;
|
|
|
|
|
2013-04-16 14:57:14 +00:00
|
|
|
glViewport(0, 0, width, height);
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
2013-11-14 17:47:03 +00:00
|
|
|
perspective = renderer->render_camera->getPerspective();
|
2013-04-27 19:41:57 +00:00
|
|
|
gluPerspective(perspective.yfov * 180.0 / M_PI, perspective.xratio, perspective.znear, perspective.zfar);
|
2013-04-16 14:57:14 +00:00
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
|
2013-11-05 10:45:26 +00:00
|
|
|
void OpenGLRenderer::paint()
|
2013-04-16 14:57:14 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|