mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
reformat renderer
This commit is contained in:
4573
renderer.cpp
4573
renderer.cpp
File diff suppressed because it is too large
Load Diff
595
renderer.h
595
renderer.h
@@ -31,385 +31,342 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
//#define EU07_USE_DEBUG_CAMERA
|
//#define EU07_USE_DEBUG_CAMERA
|
||||||
//#define EU07_USE_DEBUG_SOUNDEMITTERS
|
//#define EU07_USE_DEBUG_SOUNDEMITTERS
|
||||||
|
|
||||||
struct opengl_light : public basic_light {
|
struct opengl_light : public basic_light
|
||||||
|
{
|
||||||
|
|
||||||
GLuint id { (GLuint)-1 };
|
GLuint id{(GLuint)-1};
|
||||||
|
|
||||||
float factor;
|
float factor;
|
||||||
|
|
||||||
void
|
void apply_intensity(float const Factor = 1.0f);
|
||||||
apply_intensity( float const Factor = 1.0f );
|
void apply_angle();
|
||||||
void
|
|
||||||
apply_angle();
|
|
||||||
|
|
||||||
opengl_light &
|
opengl_light &operator=(basic_light const &Right)
|
||||||
operator=( basic_light const &Right ) {
|
{
|
||||||
basic_light::operator=( Right );
|
basic_light::operator=(Right);
|
||||||
return *this; }
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// encapsulates basic rendering setup.
|
// encapsulates basic rendering setup.
|
||||||
// for modern opengl this translates to a specific collection of glsl shaders,
|
// for modern opengl this translates to a specific collection of glsl shaders,
|
||||||
// for legacy opengl this is combination of blending modes, active texture units etc
|
// for legacy opengl this is combination of blending modes, active texture units etc
|
||||||
struct opengl_technique {
|
struct opengl_technique
|
||||||
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
// simple camera object. paired with 'virtual camera' in the scene
|
// simple camera object. paired with 'virtual camera' in the scene
|
||||||
class opengl_camera {
|
class opengl_camera
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// methods:
|
// methods:
|
||||||
inline
|
inline void update_frustum()
|
||||||
void
|
{
|
||||||
update_frustum() { update_frustum( m_projection, m_modelview ); }
|
update_frustum(m_projection, m_modelview);
|
||||||
void
|
}
|
||||||
update_frustum( glm::mat4 const &Projection, glm::mat4 const &Modelview );
|
void update_frustum(glm::mat4 const &Projection, glm::mat4 const &Modelview);
|
||||||
bool
|
bool visible(scene::bounding_area const &Area) const;
|
||||||
visible( scene::bounding_area const &Area ) const;
|
bool visible(TDynamicObject const *Dynamic) const;
|
||||||
bool
|
inline glm::dvec3 const &position() const
|
||||||
visible( TDynamicObject const *Dynamic ) const;
|
{
|
||||||
inline
|
return m_position;
|
||||||
glm::dvec3 const &
|
}
|
||||||
position() const { return m_position; }
|
inline glm::dvec3 &position()
|
||||||
inline
|
{
|
||||||
glm::dvec3 &
|
return m_position;
|
||||||
position() { return m_position; }
|
}
|
||||||
inline
|
inline glm::mat4 const &projection() const
|
||||||
glm::mat4 const &
|
{
|
||||||
projection() const { return m_projection; }
|
return m_projection;
|
||||||
inline
|
}
|
||||||
glm::mat4 &
|
inline glm::mat4 &projection()
|
||||||
projection() { return m_projection; }
|
{
|
||||||
inline
|
return m_projection;
|
||||||
glm::mat4 const &
|
}
|
||||||
modelview() const { return m_modelview; }
|
inline glm::mat4 const &modelview() const
|
||||||
inline
|
{
|
||||||
glm::mat4 &
|
return m_modelview;
|
||||||
modelview() { return m_modelview; }
|
}
|
||||||
inline
|
inline glm::mat4 &modelview()
|
||||||
std::vector<glm::vec4> &
|
{
|
||||||
frustum_points() { return m_frustumpoints; }
|
return m_modelview;
|
||||||
// transforms provided set of clip space points to world space
|
}
|
||||||
template <class Iterator_>
|
inline std::vector<glm::vec4> &frustum_points()
|
||||||
void
|
{
|
||||||
transform_to_world( Iterator_ First, Iterator_ Last ) const {
|
return m_frustumpoints;
|
||||||
std::for_each(
|
}
|
||||||
First, Last,
|
// transforms provided set of clip space points to world space
|
||||||
[this]( glm::vec4 &point ) {
|
template <class Iterator_> void transform_to_world(Iterator_ First, Iterator_ Last) const
|
||||||
// transform each point using the cached matrix...
|
{
|
||||||
point = this->m_inversetransformation * point;
|
std::for_each(First, Last, [this](glm::vec4 &point) {
|
||||||
// ...and scale by transformed w
|
// transform each point using the cached matrix...
|
||||||
point = glm::vec4{ glm::vec3{ point } / point.w, 1.f }; } ); }
|
point = this->m_inversetransformation * point;
|
||||||
// debug helper, draws shape of frustum in world space
|
// ...and scale by transformed w
|
||||||
void
|
point = glm::vec4{glm::vec3{point} / point.w, 1.f};
|
||||||
draw( glm::vec3 const &Offset ) const;
|
});
|
||||||
|
}
|
||||||
|
// debug helper, draws shape of frustum in world space
|
||||||
|
void draw(glm::vec3 const &Offset) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// members:
|
// members:
|
||||||
cFrustum m_frustum;
|
cFrustum m_frustum;
|
||||||
std::vector<glm::vec4> m_frustumpoints; // visualization helper; corners of defined frustum, in world space
|
std::vector<glm::vec4> m_frustumpoints; // visualization helper; corners of defined frustum, in world space
|
||||||
glm::dvec3 m_position;
|
glm::dvec3 m_position;
|
||||||
glm::mat4 m_projection;
|
glm::mat4 m_projection;
|
||||||
glm::mat4 m_modelview;
|
glm::mat4 m_modelview;
|
||||||
glm::mat4 m_inversetransformation; // cached transformation to world space
|
glm::mat4 m_inversetransformation; // cached transformation to world space
|
||||||
};
|
};
|
||||||
|
|
||||||
// bare-bones render controller, in lack of anything better yet
|
// bare-bones render controller, in lack of anything better yet
|
||||||
class opengl_renderer {
|
class opengl_renderer
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// types
|
// types
|
||||||
|
|
||||||
// destructor
|
// methods
|
||||||
~opengl_renderer() { gluDeleteQuadric( m_quadric ); }
|
bool Init(GLFWwindow *Window);
|
||||||
|
// main draw call. returns false on error
|
||||||
|
bool Render();
|
||||||
|
void SwapBuffers();
|
||||||
|
inline float Framerate()
|
||||||
|
{
|
||||||
|
return m_framerate;
|
||||||
|
}
|
||||||
|
// geometry methods
|
||||||
|
// NOTE: hands-on geometry management is exposed as a temporary measure; ultimately all visualization data should be generated/handled automatically by the renderer itself
|
||||||
|
// creates a new geometry bank. returns: handle to the bank or NULL
|
||||||
|
gfx::geometrybank_handle Create_Bank();
|
||||||
|
// creates a new geometry chunk of specified type from supplied vertex data, in specified bank. returns: handle to the chunk or NULL
|
||||||
|
gfx::geometry_handle Insert(gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type);
|
||||||
|
// replaces data of specified chunk with the supplied vertex data, starting from specified offset
|
||||||
|
bool Replace(gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type, std::size_t const Offset = 0);
|
||||||
|
// adds supplied vertex data at the end of specified chunk
|
||||||
|
bool Append(gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type);
|
||||||
|
// provides direct access to vertex data of specfied chunk
|
||||||
|
gfx::vertex_array const &Vertices(gfx::geometry_handle const &Geometry) const;
|
||||||
|
// material methods
|
||||||
|
material_handle Fetch_Material(std::string const &Filename, bool const Loadnow = true);
|
||||||
|
void Bind_Material(material_handle const Material);
|
||||||
|
|
||||||
// methods
|
// shader methods
|
||||||
bool
|
std::shared_ptr<gl::program> Fetch_Shader(std::string const &name);
|
||||||
Init( GLFWwindow *Window );
|
|
||||||
// main draw call. returns false on error
|
|
||||||
bool
|
|
||||||
Render();
|
|
||||||
void SwapBuffers();
|
|
||||||
inline
|
|
||||||
float
|
|
||||||
Framerate() { return m_framerate; }
|
|
||||||
// geometry methods
|
|
||||||
// NOTE: hands-on geometry management is exposed as a temporary measure; ultimately all visualization data should be generated/handled automatically by the renderer itself
|
|
||||||
// creates a new geometry bank. returns: handle to the bank or NULL
|
|
||||||
gfx::geometrybank_handle
|
|
||||||
Create_Bank();
|
|
||||||
// creates a new geometry chunk of specified type from supplied vertex data, in specified bank. returns: handle to the chunk or NULL
|
|
||||||
gfx::geometry_handle
|
|
||||||
Insert( gfx::vertex_array &Vertices, gfx::geometrybank_handle const &Geometry, int const Type );
|
|
||||||
// replaces data of specified chunk with the supplied vertex data, starting from specified offset
|
|
||||||
bool
|
|
||||||
Replace( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type, std::size_t const Offset = 0 );
|
|
||||||
// adds supplied vertex data at the end of specified chunk
|
|
||||||
bool
|
|
||||||
Append( gfx::vertex_array &Vertices, gfx::geometry_handle const &Geometry, int const Type );
|
|
||||||
// provides direct access to vertex data of specfied chunk
|
|
||||||
gfx::vertex_array const &
|
|
||||||
Vertices( gfx::geometry_handle const &Geometry ) const;
|
|
||||||
// material methods
|
|
||||||
material_handle
|
|
||||||
Fetch_Material( std::string const &Filename, bool const Loadnow = true );
|
|
||||||
void
|
|
||||||
Bind_Material( material_handle const Material );
|
|
||||||
|
|
||||||
// shader methods
|
opengl_material const &Material(material_handle const Material) const;
|
||||||
std::shared_ptr<gl::program> Fetch_Shader(std::string const &name);
|
// texture methods
|
||||||
|
texture_handle Fetch_Texture(std::string const &Filename, bool const Loadnow = true);
|
||||||
|
void Bind_Texture(size_t Unit, texture_handle const Texture);
|
||||||
|
opengl_texture &Texture(texture_handle const Texture) const;
|
||||||
|
// utility methods
|
||||||
|
TSubModel const *Pick_Control() const
|
||||||
|
{
|
||||||
|
return m_pickcontrolitem;
|
||||||
|
}
|
||||||
|
scene::basic_node const *Pick_Node() const
|
||||||
|
{
|
||||||
|
return m_picksceneryitem;
|
||||||
|
}
|
||||||
|
// maintenance methods
|
||||||
|
void Update(double const Deltatime);
|
||||||
|
TSubModel const *Update_Pick_Control();
|
||||||
|
scene::basic_node const *Update_Pick_Node();
|
||||||
|
// debug methods
|
||||||
|
std::string const &info_times() const;
|
||||||
|
std::string const &info_stats() const;
|
||||||
|
|
||||||
opengl_material const &
|
// members
|
||||||
Material( material_handle const Material ) const;
|
GLenum static const sunlight{GL_LIGHT0};
|
||||||
// texture methods
|
std::size_t m_drawcount{0};
|
||||||
texture_handle
|
|
||||||
Fetch_Texture( std::string const &Filename, bool const Loadnow = true );
|
|
||||||
void
|
|
||||||
Bind_Texture( size_t Unit, texture_handle const Texture );
|
|
||||||
opengl_texture &
|
|
||||||
Texture( texture_handle const Texture ) const;
|
|
||||||
// utility methods
|
|
||||||
TSubModel const *
|
|
||||||
Pick_Control() const { return m_pickcontrolitem; }
|
|
||||||
scene::basic_node const *
|
|
||||||
Pick_Node() const { return m_picksceneryitem; }
|
|
||||||
// maintenance methods
|
|
||||||
void
|
|
||||||
Update( double const Deltatime );
|
|
||||||
TSubModel const *
|
|
||||||
Update_Pick_Control();
|
|
||||||
scene::basic_node const *
|
|
||||||
Update_Pick_Node();
|
|
||||||
// debug methods
|
|
||||||
std::string const &
|
|
||||||
info_times() const;
|
|
||||||
std::string const &
|
|
||||||
info_stats() const;
|
|
||||||
|
|
||||||
// members
|
private:
|
||||||
GLenum static const sunlight { GL_LIGHT0 };
|
// types
|
||||||
std::size_t m_drawcount { 0 };
|
enum class rendermode
|
||||||
|
{
|
||||||
|
none,
|
||||||
|
color,
|
||||||
|
shadows,
|
||||||
|
cabshadows,
|
||||||
|
reflections,
|
||||||
|
pickcontrols,
|
||||||
|
pickscenery
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
struct debug_stats
|
||||||
// types
|
{
|
||||||
enum class rendermode {
|
int dynamics{0};
|
||||||
none,
|
int models{0};
|
||||||
color,
|
int submodels{0};
|
||||||
shadows,
|
int paths{0};
|
||||||
cabshadows,
|
int traction{0};
|
||||||
reflections,
|
int shapes{0};
|
||||||
pickcontrols,
|
int lines{0};
|
||||||
pickscenery
|
int drawcalls{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct debug_stats {
|
using section_sequence = std::vector<scene::basic_section *>;
|
||||||
int dynamics { 0 };
|
using distancecell_pair = std::pair<double, scene::basic_cell *>;
|
||||||
int models { 0 };
|
using cell_sequence = std::vector<distancecell_pair>;
|
||||||
int submodels { 0 };
|
|
||||||
int paths { 0 };
|
|
||||||
int traction { 0 };
|
|
||||||
int shapes { 0 };
|
|
||||||
int lines { 0 };
|
|
||||||
int drawcalls { 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
using section_sequence = std::vector<scene::basic_section *>;
|
struct renderpass_config
|
||||||
using distancecell_pair = std::pair<double, scene::basic_cell *>;
|
{
|
||||||
using cell_sequence = std::vector<distancecell_pair>;
|
|
||||||
|
|
||||||
struct renderpass_config {
|
opengl_camera camera;
|
||||||
|
rendermode draw_mode{rendermode::none};
|
||||||
|
float draw_range{0.0f};
|
||||||
|
};
|
||||||
|
|
||||||
opengl_camera camera;
|
typedef std::vector<opengl_light> opengllight_array;
|
||||||
rendermode draw_mode { rendermode::none };
|
|
||||||
float draw_range { 0.0f };
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<opengl_light> opengllight_array;
|
// methods
|
||||||
|
bool Init_caps();
|
||||||
|
void setup_pass(renderpass_config &Config, rendermode const Mode, float const Znear = 0.f, float const Zfar = 1.f, bool const Ignoredebug = false);
|
||||||
|
void setup_matrices();
|
||||||
|
void setup_drawing(bool const Alpha = false);
|
||||||
|
void setup_shadow_map(opengl_texture *tex);
|
||||||
|
void setup_environment_light(TEnvironmentType const Environment = e_flat);
|
||||||
|
// runs jobs needed to generate graphics for specified render pass
|
||||||
|
void Render_pass(rendermode const Mode);
|
||||||
|
// creates dynamic environment cubemap
|
||||||
|
bool Render_reflections();
|
||||||
|
bool Render(world_environment *Environment);
|
||||||
|
void Render(scene::basic_region *Region);
|
||||||
|
void Render(section_sequence::iterator First, section_sequence::iterator Last);
|
||||||
|
void Render(cell_sequence::iterator First, cell_sequence::iterator Last);
|
||||||
|
void Render(scene::shape_node const &Shape, bool const Ignorerange);
|
||||||
|
void Render(TAnimModel *Instance);
|
||||||
|
bool Render(TDynamicObject *Dynamic);
|
||||||
|
bool Render(TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, Math3D::vector3 const &Angle);
|
||||||
|
bool Render(TModel3d *Model, material_data const *Material, float const Squaredistance);
|
||||||
|
void Render(TSubModel *Submodel);
|
||||||
|
void Render(TTrack *Track);
|
||||||
|
void Render(scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last);
|
||||||
|
bool Render_cab(TDynamicObject const *Dynamic, bool const Alpha = false);
|
||||||
|
void Render(TMemCell *Memcell);
|
||||||
|
void Render_Alpha(scene::basic_region *Region);
|
||||||
|
void Render_Alpha(cell_sequence::reverse_iterator First, cell_sequence::reverse_iterator Last);
|
||||||
|
void Render_Alpha(TAnimModel *Instance);
|
||||||
|
void Render_Alpha(TTraction *Traction);
|
||||||
|
void Render_Alpha(scene::lines_node const &Lines);
|
||||||
|
bool Render_Alpha(TDynamicObject *Dynamic);
|
||||||
|
bool Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, Math3D::vector3 const &Angle);
|
||||||
|
bool Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance);
|
||||||
|
void Render_Alpha(TSubModel *Submodel);
|
||||||
|
void Update_Lights(light_array &Lights);
|
||||||
|
glm::vec3 pick_color(std::size_t const Index);
|
||||||
|
std::size_t pick_index(glm::ivec3 const &Color);
|
||||||
|
|
||||||
// methods
|
// members
|
||||||
bool
|
GLFWwindow *m_window{nullptr};
|
||||||
Init_caps();
|
gfx::geometrybank_manager m_geometry;
|
||||||
void
|
material_manager m_materials;
|
||||||
setup_pass( renderpass_config &Config, rendermode const Mode, float const Znear = 0.f, float const Zfar = 1.f, bool const Ignoredebug = false );
|
texture_manager m_textures;
|
||||||
void
|
opengl_light m_sunlight;
|
||||||
setup_matrices();
|
opengllight_array m_lights;
|
||||||
void
|
/*
|
||||||
setup_drawing( bool const Alpha = false );
|
float m_sunandviewangle; // cached dot product of sunlight and camera vectors
|
||||||
void
|
*/
|
||||||
setup_shadow_map(opengl_texture *tex);
|
gfx::geometry_handle m_billboardgeometry{0, 0};
|
||||||
void
|
texture_handle m_glaretexture{-1};
|
||||||
setup_environment_light( TEnvironmentType const Environment = e_flat );
|
texture_handle m_suntexture{-1};
|
||||||
// runs jobs needed to generate graphics for specified render pass
|
texture_handle m_moontexture{-1};
|
||||||
void
|
texture_handle m_reflectiontexture{-1};
|
||||||
Render_pass( rendermode const Mode );
|
// TODO: refactor framebuffer stuff into an object
|
||||||
// creates dynamic environment cubemap
|
bool m_framebuffersupport{false};
|
||||||
bool
|
|
||||||
Render_reflections();
|
|
||||||
bool
|
|
||||||
Render( world_environment *Environment );
|
|
||||||
void
|
|
||||||
Render( scene::basic_region *Region );
|
|
||||||
void
|
|
||||||
Render( section_sequence::iterator First, section_sequence::iterator Last );
|
|
||||||
void
|
|
||||||
Render( cell_sequence::iterator First, cell_sequence::iterator Last );
|
|
||||||
void
|
|
||||||
Render( scene::shape_node const &Shape, bool const Ignorerange );
|
|
||||||
void
|
|
||||||
Render( TAnimModel *Instance );
|
|
||||||
bool
|
|
||||||
Render( TDynamicObject *Dynamic );
|
|
||||||
bool
|
|
||||||
Render( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
|
||||||
bool
|
|
||||||
Render( TModel3d *Model, material_data const *Material, float const Squaredistance );
|
|
||||||
void
|
|
||||||
Render( TSubModel *Submodel );
|
|
||||||
void
|
|
||||||
Render( TTrack *Track );
|
|
||||||
void
|
|
||||||
Render( scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last );
|
|
||||||
bool
|
|
||||||
Render_cab( TDynamicObject const *Dynamic, bool const Alpha = false );
|
|
||||||
void
|
|
||||||
Render( TMemCell *Memcell );
|
|
||||||
void
|
|
||||||
Render_Alpha( scene::basic_region *Region );
|
|
||||||
void
|
|
||||||
Render_Alpha( cell_sequence::reverse_iterator First, cell_sequence::reverse_iterator Last );
|
|
||||||
void
|
|
||||||
Render_Alpha( TAnimModel *Instance );
|
|
||||||
void
|
|
||||||
Render_Alpha( TTraction *Traction );
|
|
||||||
void
|
|
||||||
Render_Alpha( scene::lines_node const &Lines );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TDynamicObject *Dynamic );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance );
|
|
||||||
void
|
|
||||||
Render_Alpha( TSubModel *Submodel );
|
|
||||||
void
|
|
||||||
Update_Lights( light_array &Lights );
|
|
||||||
glm::vec3
|
|
||||||
pick_color( std::size_t const Index );
|
|
||||||
std::size_t
|
|
||||||
pick_index( glm::ivec3 const &Color );
|
|
||||||
|
|
||||||
// members
|
|
||||||
GLFWwindow *m_window { nullptr };
|
|
||||||
gfx::geometrybank_manager m_geometry;
|
|
||||||
material_manager m_materials;
|
|
||||||
texture_manager m_textures;
|
|
||||||
opengl_light m_sunlight;
|
|
||||||
opengllight_array m_lights;
|
|
||||||
/*
|
|
||||||
float m_sunandviewangle; // cached dot product of sunlight and camera vectors
|
|
||||||
*/
|
|
||||||
gfx::geometry_handle m_billboardgeometry { 0, 0 };
|
|
||||||
texture_handle m_glaretexture { -1 };
|
|
||||||
texture_handle m_suntexture { -1 };
|
|
||||||
texture_handle m_moontexture { -1 };
|
|
||||||
texture_handle m_reflectiontexture { -1 };
|
|
||||||
GLUquadricObj *m_quadric { nullptr }; // helper object for drawing debug mode scene elements
|
|
||||||
// TODO: refactor framebuffer stuff into an object
|
|
||||||
bool m_framebuffersupport { false };
|
|
||||||
#ifdef EU07_USE_PICKING_FRAMEBUFFER
|
#ifdef EU07_USE_PICKING_FRAMEBUFFER
|
||||||
GLuint m_pickframebuffer { 0 };
|
GLuint m_pickframebuffer{0};
|
||||||
GLuint m_picktexture { 0 };
|
GLuint m_picktexture{0};
|
||||||
GLuint m_pickdepthbuffer { 0 };
|
GLuint m_pickdepthbuffer{0};
|
||||||
#endif
|
#endif
|
||||||
// main shadowmap resources
|
// main shadowmap resources
|
||||||
int m_shadowbuffersize { 2048 };
|
int m_shadowbuffersize{2048};
|
||||||
GLuint m_shadowframebuffer { 0 };
|
GLuint m_shadowframebuffer{0};
|
||||||
GLuint m_shadowtexture { 0 };
|
GLuint m_shadowtexture{0};
|
||||||
#ifdef EU07_USE_DEBUG_SHADOWMAP
|
#ifdef EU07_USE_DEBUG_SHADOWMAP
|
||||||
GLuint m_shadowdebugtexture{ 0 };
|
GLuint m_shadowdebugtexture{0};
|
||||||
#endif
|
#endif
|
||||||
#ifdef EU07_USE_DEBUG_CABSHADOWMAP
|
#ifdef EU07_USE_DEBUG_CABSHADOWMAP
|
||||||
GLuint m_cabshadowdebugtexture{ 0 };
|
GLuint m_cabshadowdebugtexture{0};
|
||||||
#endif
|
#endif
|
||||||
glm::mat4 m_shadowtexturematrix; // conversion from camera-centric world space to light-centric clip space
|
glm::mat4 m_shadowtexturematrix; // conversion from camera-centric world space to light-centric clip space
|
||||||
// cab shadowmap resources
|
// cab shadowmap resources
|
||||||
GLuint m_cabshadowframebuffer { 0 };
|
GLuint m_cabshadowframebuffer{0};
|
||||||
GLuint m_cabshadowtexture { 0 };
|
GLuint m_cabshadowtexture{0};
|
||||||
glm::mat4 m_cabshadowtexturematrix; // conversion from cab-centric world space to light-centric clip space
|
glm::mat4 m_cabshadowtexturematrix; // conversion from cab-centric world space to light-centric clip space
|
||||||
// environment map resources
|
// environment map resources
|
||||||
GLuint m_environmentframebuffer { 0 };
|
GLuint m_environmentframebuffer{0};
|
||||||
GLuint m_environmentcubetexture { 0 };
|
GLuint m_environmentcubetexture{0};
|
||||||
GLuint m_environmentdepthbuffer { 0 };
|
GLuint m_environmentdepthbuffer{0};
|
||||||
bool m_environmentcubetexturesupport { false }; // indicates whether we can use the dynamic environment cube map
|
bool m_environmentcubetexturesupport{false}; // indicates whether we can use the dynamic environment cube map
|
||||||
int m_environmentcubetextureface { 0 }; // helper, currently processed cube map face
|
int m_environmentcubetextureface{0}; // helper, currently processed cube map face
|
||||||
int m_environmentupdatetime { 0 }; // time of the most recent environment map update
|
int m_environmentupdatetime{0}; // time of the most recent environment map update
|
||||||
glm::dvec3 m_environmentupdatelocation; // coordinates of most recent environment map update
|
glm::dvec3 m_environmentupdatelocation; // coordinates of most recent environment map update
|
||||||
|
|
||||||
unsigned int m_framestamp; // id of currently rendered gfx frame
|
unsigned int m_framestamp; // id of currently rendered gfx frame
|
||||||
float m_framerate;
|
float m_framerate;
|
||||||
double m_updateaccumulator { 0.0 };
|
double m_updateaccumulator{0.0};
|
||||||
std::string m_debugtimestext;
|
std::string m_debugtimestext;
|
||||||
std::string m_pickdebuginfo;
|
std::string m_pickdebuginfo;
|
||||||
debug_stats m_debugstats;
|
debug_stats m_debugstats;
|
||||||
std::string m_debugstatstext;
|
std::string m_debugstatstext;
|
||||||
|
|
||||||
glm::vec4 m_baseambient { 0.0f, 0.0f, 0.0f, 1.0f };
|
glm::vec4 m_baseambient{0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
glm::vec4 m_shadowcolor { colors::shadow };
|
glm::vec4 m_shadowcolor{colors::shadow};
|
||||||
// TEnvironmentType m_environment { e_flat };
|
// TEnvironmentType m_environment { e_flat };
|
||||||
float m_specularopaquescalefactor { 1.f };
|
float m_specularopaquescalefactor{1.f};
|
||||||
float m_speculartranslucentscalefactor { 1.f };
|
float m_speculartranslucentscalefactor{1.f};
|
||||||
bool m_renderspecular{ false }; // controls whether to include specular component in the calculations
|
bool m_renderspecular{false}; // controls whether to include specular component in the calculations
|
||||||
|
|
||||||
renderpass_config m_renderpass; // parameters for current render pass
|
renderpass_config m_renderpass; // parameters for current render pass
|
||||||
section_sequence m_sectionqueue; // list of sections in current render pass
|
section_sequence m_sectionqueue; // list of sections in current render pass
|
||||||
cell_sequence m_cellqueue;
|
cell_sequence m_cellqueue;
|
||||||
renderpass_config m_shadowpass; // parametrs of most recent shadowmap pass
|
renderpass_config m_shadowpass; // parametrs of most recent shadowmap pass
|
||||||
renderpass_config m_cabshadowpass; // parameters of most recent cab shadowmap pass
|
renderpass_config m_cabshadowpass; // parameters of most recent cab shadowmap pass
|
||||||
std::vector<TSubModel const *> m_pickcontrolsitems;
|
std::vector<TSubModel const *> m_pickcontrolsitems;
|
||||||
TSubModel const *m_pickcontrolitem { nullptr };
|
TSubModel const *m_pickcontrolitem{nullptr};
|
||||||
std::vector<scene::basic_node const *> m_picksceneryitems;
|
std::vector<scene::basic_node const *> m_picksceneryitems;
|
||||||
scene::basic_node const *m_picksceneryitem { nullptr };
|
scene::basic_node const *m_picksceneryitem{nullptr};
|
||||||
#ifdef EU07_USE_DEBUG_CAMERA
|
#ifdef EU07_USE_DEBUG_CAMERA
|
||||||
renderpass_config m_worldcamera; // debug item
|
renderpass_config m_worldcamera; // debug item
|
||||||
#endif
|
#endif
|
||||||
GLuint m_gltimequery = 0;
|
GLuint m_gltimequery = 0;
|
||||||
GLuint64 m_gllasttime = 0;
|
GLuint64 m_gllasttime = 0;
|
||||||
|
|
||||||
std::unique_ptr<gl::shader> m_vertex_shader;
|
std::unique_ptr<gl::shader> m_vertex_shader;
|
||||||
|
|
||||||
std::unique_ptr<gl::ubo> scene_ubo;
|
std::unique_ptr<gl::ubo> scene_ubo;
|
||||||
std::unique_ptr<gl::ubo> model_ubo;
|
std::unique_ptr<gl::ubo> model_ubo;
|
||||||
std::unique_ptr<gl::ubo> light_ubo;
|
std::unique_ptr<gl::ubo> light_ubo;
|
||||||
gl::scene_ubs scene_ubs;
|
gl::scene_ubs scene_ubs;
|
||||||
gl::model_ubs model_ubs;
|
gl::model_ubs model_ubs;
|
||||||
gl::light_ubs light_ubs;
|
gl::light_ubs light_ubs;
|
||||||
|
|
||||||
std::unordered_map<std::string, std::shared_ptr<gl::program>> m_shaders;
|
std::unordered_map<std::string, std::shared_ptr<gl::program>> m_shaders;
|
||||||
|
|
||||||
std::unique_ptr<gl::program> m_line_shader;
|
std::unique_ptr<gl::program> m_line_shader;
|
||||||
std::unique_ptr<gl::program> m_freespot_shader;
|
std::unique_ptr<gl::program> m_freespot_shader;
|
||||||
|
|
||||||
std::unique_ptr<gl::framebuffer> m_msaa_fb;
|
std::unique_ptr<gl::framebuffer> m_msaa_fb;
|
||||||
std::unique_ptr<gl::renderbuffer> m_msaa_rbc;
|
std::unique_ptr<gl::renderbuffer> m_msaa_rbc;
|
||||||
std::unique_ptr<gl::renderbuffer> m_msaa_rbd;
|
std::unique_ptr<gl::renderbuffer> m_msaa_rbd;
|
||||||
|
|
||||||
std::unique_ptr<gl::framebuffer> m_main_fb;
|
std::unique_ptr<gl::framebuffer> m_main_fb;
|
||||||
std::unique_ptr<opengl_texture> m_main_tex;
|
std::unique_ptr<opengl_texture> m_main_tex;
|
||||||
std::unique_ptr<gl::postfx> m_pfx;
|
std::unique_ptr<gl::postfx> m_pfx;
|
||||||
|
|
||||||
std::unique_ptr<gl::framebuffer> m_shadow_fb;
|
std::unique_ptr<gl::framebuffer> m_shadow_fb;
|
||||||
std::unique_ptr<opengl_texture> m_shadow_tex;
|
std::unique_ptr<opengl_texture> m_shadow_tex;
|
||||||
std::unique_ptr<gl::program> m_shadow_shader;
|
std::unique_ptr<gl::program> m_shadow_shader;
|
||||||
|
|
||||||
std::unique_ptr<gl::framebuffer> m_pick_fb;
|
std::unique_ptr<gl::framebuffer> m_pick_fb;
|
||||||
std::unique_ptr<opengl_texture> m_pick_tex;
|
std::unique_ptr<opengl_texture> m_pick_tex;
|
||||||
std::unique_ptr<gl::renderbuffer> m_pick_rb;
|
std::unique_ptr<gl::renderbuffer> m_pick_rb;
|
||||||
std::unique_ptr<gl::program> m_pick_shader;
|
std::unique_ptr<gl::program> m_pick_shader;
|
||||||
|
|
||||||
material_handle m_invalid_material;
|
material_handle m_invalid_material;
|
||||||
|
|
||||||
bool m_widelines_supported;
|
bool m_widelines_supported;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern opengl_renderer GfxRenderer;
|
extern opengl_renderer GfxRenderer;
|
||||||
|
|||||||
Reference in New Issue
Block a user