16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 21:49:19 +02:00
This commit is contained in:
VB
2017-03-20 22:37:49 +01:00
46 changed files with 3170 additions and 2508 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
@@ -9,10 +9,13 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include "GL/glew.h"
#include <GL/glew.h>
#include "texture.h"
#include "lightarray.h"
#include "dumb3d.h"
#include "frustum.h"
#include "ground.h"
#include "shader.h"
// encapsulates basic rendering setup.
// for modern opengl this translates to a specific collection of glsl shaders,
@@ -28,6 +31,24 @@ struct opengl_material {
};
// simple camera object. paired with 'virtual camera' in the scene
class opengl_camera {
public:
// methods:
inline
void
update_frustum(glm::mat4 &Projection, glm::mat4 &Modelview) { m_frustum.calculate(Projection, Modelview); }
bool
visible( bounding_area const &Area ) const;
bool
visible( TDynamicObject const *Dynamic ) const;
private:
// members:
cFrustum m_frustum;
};
// bare-bones render controller, in lack of anything better yet
class opengl_renderer {
@@ -35,14 +56,40 @@ public:
// types
// methods
bool
Init( GLFWwindow *Window );
// main draw call. returns false on error
bool
Render();
#ifndef EU07_USE_OLD_RENDERCODE
bool
Render( TGround *Ground );
bool
Render( TDynamicObject *Dynamic );
bool
Render( TModel3d *Model, material_data const *Material, double const Squaredistance );
bool
Render( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
bool
Render_Alpha( TDynamicObject *Dynamic );
bool
Render_Alpha( TModel3d *Model, material_data const *Material, double const Squaredistance );
bool
Render_Alpha( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
#endif
// maintenance jobs
void
Init();
Update( double const Deltatime);
void
Update_Lights( light_array const &Lights );
void
Disable_Lights();
inline
bool
Visible( TDynamicObject const *Dynamic ) const { return m_camera.visible( Dynamic ); }
// debug performance string
std::string const &
Info() const;
texture_manager::size_type
GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true ) {
@@ -70,10 +117,19 @@ private:
enum class rendermode {
color
};
// methods
bool Init_caps();
// members
rendermode renderpass{ rendermode::color };
texture_manager m_textures;
opengl_camera m_camera;
float m_drawrange{ 2500.0f }; // current drawing range
float m_drawtime{ 1000.0f / 30.0f * 20.0f }; // start with presumed 'neutral' average of 30 fps
double m_updateaccumulator{ 0.0 };
std::string m_debuginfo;
GLFWwindow *m_window{ nullptr };
};
extern opengl_renderer GfxRenderer;