17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-31 21:39:03 +01:00

Move modern OpenGL renderer to rendering/opengl46 and rename classes

This commit is contained in:
2026-10-15 01:12:05 +02:00
parent 0e10ce4d0b
commit 61bfc6eb1a
27 changed files with 220 additions and 219 deletions

View File

@@ -49,6 +49,7 @@ file(GLOB HEADERS "*.h"
"simulation/*.h" "simulation/*.h"
"scene/*.h" "scene/*.h"
"rendering/*.h" "rendering/*.h"
"rendering/opengl46/*.h"
"audio/*.h" "audio/*.h"
"environment/*.h" "environment/*.h"
"application/*.h" "application/*.h"
@@ -327,13 +328,13 @@ endif()
if (WITH_OPENGL_MODERN) if (WITH_OPENGL_MODERN)
set(SOURCES ${SOURCES} set(SOURCES ${SOURCES}
"rendering/opengl33geometrybank.cpp" "rendering/opengl46/opengl46geometrybank.cpp"
"rendering/opengl33light.cpp" "rendering/opengl46/opengl46light.cpp"
"rendering/opengl33skydome.cpp" "rendering/opengl46/opengl46skydome.cpp"
"rendering/opengl33precipitation.cpp" "rendering/opengl46/opengl46precipitation.cpp"
"rendering/opengl33particles.cpp" "rendering/opengl46/opengl46particles.cpp"
"rendering/opengl33terrain.cpp" "rendering/opengl46/opengl46terrain.cpp"
"rendering/opengl33renderer.cpp") "rendering/opengl46/opengl46renderer.cpp")
set(DEFINITIONS ${DEFINITIONS} "WITH_OPENGL_MODERN") set(DEFINITIONS ${DEFINITIONS} "WITH_OPENGL_MODERN")
endif() endif()

View File

@@ -14,7 +14,7 @@ http://mozilla.org/MPL/2.0/.
class TSky { class TSky {
friend opengl33_renderer; friend opengl46_renderer;
public: public:
TSky() = default; TSky() = default;

View File

@@ -8,7 +8,7 @@
class cStars { class cStars {
friend opengl33_renderer; friend opengl46_renderer;
public: public:
// types: // types:

View File

@@ -107,7 +107,7 @@ class TAnimContainer : public std::enable_shared_from_this<TAnimContainer>
// opakowanie modelu, określające stan egzemplarza // opakowanie modelu, określające stan egzemplarza
class TAnimModel : public scene::basic_node { class TAnimModel : public scene::basic_node {
friend opengl33_renderer; friend opengl46_renderer;
friend itemproperties_panel; friend itemproperties_panel;
public: public:

View File

@@ -56,7 +56,7 @@ class TSubModel
{ // klasa submodelu - pojedyncza siatka, punkt świetlny albo grupa punktów { // klasa submodelu - pojedyncza siatka, punkt świetlny albo grupa punktów
//m7todo: zrobić normalną serializację //m7todo: zrobić normalną serializację
friend opengl33_renderer; friend opengl46_renderer;
friend TModel3d; // temporary workaround. TODO: clean up class content/hierarchy friend TModel3d; // temporary workaround. TODO: clean up class content/hierarchy
friend TDynamicObject; // temporary etc friend TDynamicObject; // temporary etc
friend scene::shape_node; // temporary etc friend scene::shape_node; // temporary etc
@@ -267,7 +267,7 @@ public:
class TModel3d class TModel3d
{ {
friend opengl33_renderer; friend opengl46_renderer;
public: public:
// submodels which scenery instances of the model refer to by name // submodels which scenery instances of the model refer to by name

View File

@@ -8,7 +8,7 @@ http://mozilla.org/MPL/2.0/.
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "rendering/opengl33geometrybank.h" #include "rendering/opengl46/opengl46geometrybank.h"
#include "utilities/Logs.h" #include "utilities/Logs.h"
@@ -18,7 +18,7 @@ namespace gfx {
// create() subclass details // create() subclass details
void void
opengl33_vaogeometrybank::create_( gfx::geometry_handle const &Geometry ) { opengl46_vaogeometrybank::create_( gfx::geometry_handle const &Geometry ) {
// adding a chunk means we'll be (re)building the buffer, which will fill the chunk records, amongst other things. // adding a chunk means we'll be (re)building the buffer, which will fill the chunk records, amongst other things.
// thus we don't need to initialize the values here // thus we don't need to initialize the values here
m_chunkrecords.emplace_back( chunk_record() ); m_chunkrecords.emplace_back( chunk_record() );
@@ -28,7 +28,7 @@ opengl33_vaogeometrybank::create_( gfx::geometry_handle const &Geometry ) {
// replace() subclass details // replace() subclass details
void void
opengl33_vaogeometrybank::replace_( gfx::geometry_handle const &Geometry ) { opengl46_vaogeometrybank::replace_( gfx::geometry_handle const &Geometry ) {
auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ]; auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ];
chunkrecord.is_good = false; chunkrecord.is_good = false;
@@ -41,7 +41,7 @@ opengl33_vaogeometrybank::replace_( gfx::geometry_handle const &Geometry ) {
} }
} }
void opengl33_vaogeometrybank::setup_buffer() void opengl46_vaogeometrybank::setup_buffer()
{ {
if( m_vertexbuffer ) { return; } if( m_vertexbuffer ) { return; }
// if there's no buffer, we'll have to make one // if there's no buffer, we'll have to make one
@@ -106,7 +106,7 @@ void opengl33_vaogeometrybank::setup_buffer()
} }
void void
opengl33_vaogeometrybank::setup_attrib(size_t offset) opengl46_vaogeometrybank::setup_attrib(size_t offset)
{ {
m_vao->setup_attrib( *m_vertexbuffer, 0, 3, GL_FLOAT, sizeof( basic_vertex ), offsetof(basic_vertex, position) + offset * sizeof( basic_vertex ) ); m_vao->setup_attrib( *m_vertexbuffer, 0, 3, GL_FLOAT, sizeof( basic_vertex ), offsetof(basic_vertex, position) + offset * sizeof( basic_vertex ) );
// NOTE: normal and color streams share the data // NOTE: normal and color streams share the data
@@ -115,7 +115,7 @@ opengl33_vaogeometrybank::setup_attrib(size_t offset)
m_vao->setup_attrib( *m_vertexbuffer, 3, 4, GL_FLOAT, sizeof( basic_vertex ), offsetof(basic_vertex, tangent) + offset * sizeof( basic_vertex ) ); m_vao->setup_attrib( *m_vertexbuffer, 3, 4, GL_FLOAT, sizeof( basic_vertex ), offsetof(basic_vertex, tangent) + offset * sizeof( basic_vertex ) );
} }
void opengl33_vaogeometrybank::setup_userdata(size_t offset) { void opengl46_vaogeometrybank::setup_userdata(size_t offset) {
const size_t offset_evaluated = m_vertex_count * sizeof(basic_vertex) + offset * sizeof( vertex_userdata ); const size_t offset_evaluated = m_vertex_count * sizeof(basic_vertex) + offset * sizeof( vertex_userdata );
m_vao->setup_attrib( *m_vertexbuffer, 4, 4, GL_FLOAT, sizeof( vertex_userdata ), offsetof(vertex_userdata, data) + offset_evaluated );} m_vao->setup_attrib( *m_vertexbuffer, 4, 4, GL_FLOAT, sizeof( vertex_userdata ), offsetof(vertex_userdata, data) + offset_evaluated );}
@@ -123,7 +123,7 @@ void opengl33_vaogeometrybank::setup_userdata(size_t offset) {
// NOTE: units and stream parameters are unused, but they're part of (legacy) interface // NOTE: units and stream parameters are unused, but they're part of (legacy) interface
// TBD: specialized bank/manager pair without the cruft? // TBD: specialized bank/manager pair without the cruft?
std::size_t std::size_t
opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams ) opengl46_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, unsigned int const Streams )
{ {
setup_buffer(); setup_buffer();
@@ -183,7 +183,7 @@ opengl33_vaogeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stre
// draw_instanced() subclass details — single GL instanced draw for InstanceCount instances. // draw_instanced() subclass details — single GL instanced draw for InstanceCount instances.
// The vertex shader reads per-instance modelview from instance_ubo[gl_InstanceID]. // The vertex shader reads per-instance modelview from instance_ubo[gl_InstanceID].
std::size_t std::size_t
opengl33_vaogeometrybank::draw_instanced_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams ) opengl46_vaogeometrybank::draw_instanced_( gfx::geometry_handle const &Geometry, gfx::stream_units const &Units, std::size_t const InstanceCount, unsigned int const Streams )
{ {
setup_buffer(); setup_buffer();
@@ -246,7 +246,7 @@ opengl33_vaogeometrybank::draw_instanced_( gfx::geometry_handle const &Geometry,
// draw_batch() subclass details — neighbouring non-indexed chunks of the same type are sent with a single GL call. // draw_batch() subclass details — neighbouring non-indexed chunks of the same type are sent with a single GL call.
// The chunks are drawn in the supplied order, same as with a draw_() call for each of them. // The chunks are drawn in the supplied order, same as with a draw_() call for each of them.
std::size_t std::size_t
opengl33_vaogeometrybank::draw_batch_( gfx::geometry_handle const *First, gfx::geometry_handle const *Last, gfx::stream_units const &Units, unsigned int const Streams ) opengl46_vaogeometrybank::draw_batch_( gfx::geometry_handle const *First, gfx::geometry_handle const *Last, gfx::stream_units const &Units, unsigned int const Streams )
{ {
std::size_t count { 0 }; std::size_t count { 0 };
@@ -305,13 +305,13 @@ opengl33_vaogeometrybank::draw_batch_( gfx::geometry_handle const *First, gfx::g
// release () subclass details // release () subclass details
void void
opengl33_vaogeometrybank::release_() { opengl46_vaogeometrybank::release_() {
delete_buffer(); delete_buffer();
} }
void void
opengl33_vaogeometrybank::delete_buffer() { opengl46_vaogeometrybank::delete_buffer() {
m_vao.reset(); m_vao.reset();
m_vertexbuffer.reset(); m_vertexbuffer.reset();

View File

@@ -17,13 +17,13 @@ namespace gfx {
// opengl vao/vbo-based variant of the geometry bank // opengl vao/vbo-based variant of the geometry bank
class opengl33_vaogeometrybank : public geometry_bank { class opengl46_vaogeometrybank : public geometry_bank {
public: public:
// constructors: // constructors:
opengl33_vaogeometrybank() = default; opengl46_vaogeometrybank() = default;
// destructor // destructor
~opengl33_vaogeometrybank() { ~opengl46_vaogeometrybank() {
delete_buffer(); } delete_buffer(); }
// methods: // methods:
static static

View File

@@ -9,14 +9,14 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h" #include "stdafx.h"
#include "rendering/opengl33light.h" #include "rendering/opengl46/opengl46light.h"
void opengl33_light::apply_intensity(float const Factor) { void opengl46_light::apply_intensity(float const Factor) {
factor = Factor; factor = Factor;
} }
void opengl33_light::apply_angle() const { /* nothing to do */ } void opengl46_light::apply_angle() const { /* nothing to do */ }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/.
#include "rendering/light.h" #include "rendering/light.h"
struct opengl33_light : public basic_light { struct opengl46_light : public basic_light {
GLuint id{(GLuint)-1}; GLuint id{(GLuint)-1};
@@ -20,7 +20,7 @@ struct opengl33_light : public basic_light {
void apply_intensity(float const Factor = 1.0f); void apply_intensity(float const Factor = 1.0f);
void apply_angle() const; void apply_angle() const;
opengl33_light &operator=(basic_light const &Right) { opengl46_light &operator=(basic_light const &Right) {
basic_light::operator=(Right); basic_light::operator=(Right);
return *this; } return *this; }
}; };

View File

@@ -8,7 +8,7 @@ http://mozilla.org/MPL/2.0/.
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "rendering/opengl33particles.h" #include "rendering/opengl46/opengl46particles.h"
#include "rendering/particles.h" #include "rendering/particles.h"
#include "rendering/openglcamera.h" #include "rendering/openglcamera.h"
@@ -26,7 +26,7 @@ std::vector<std::pair<glm::vec3, glm::vec2>> const billboard_vertices {
}; };
void void
opengl33_particles::update( opengl_camera const &Camera ) { opengl46_particles::update( opengl_camera const &Camera ) {
if (!Global.Smoke) if (!Global.Smoke)
return; return;
@@ -100,7 +100,7 @@ opengl33_particles::update( opengl_camera const &Camera ) {
} }
std::size_t std::size_t
opengl33_particles::render() { opengl46_particles::render() {
if( false == Global.Smoke ) { return 0; } if( false == Global.Smoke ) { return 0; }
if( m_buffercapacity == 0 ) { return 0; } if( m_buffercapacity == 0 ) { return 0; }

View File

@@ -16,10 +16,10 @@ http://mozilla.org/MPL/2.0/.
class opengl_camera; class opengl_camera;
// particle data visualizer // particle data visualizer
class opengl33_particles { class opengl46_particles {
public: public:
// constructors // constructors
opengl33_particles() = default; opengl46_particles() = default;
// methods // methods
void void

View File

@@ -8,18 +8,18 @@ http://mozilla.org/MPL/2.0/.
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "rendering/opengl33precipitation.h" #include "rendering/opengl46/opengl46precipitation.h"
#include "utilities/Globals.h" #include "utilities/Globals.h"
#include "rendering/renderer.h" #include "rendering/renderer.h"
#include "simulation/simulationenvironment.h" #include "simulation/simulationenvironment.h"
opengl33_precipitation::~opengl33_precipitation() { opengl46_precipitation::~opengl46_precipitation() {
// TODO: release allocated resources // TODO: release allocated resources
} }
void void
opengl33_precipitation::create( int const Tesselation ) { opengl46_precipitation::create( int const Tesselation ) {
m_vertices.clear(); m_vertices.clear();
m_uvs.clear(); m_uvs.clear();
@@ -86,7 +86,7 @@ opengl33_precipitation::create( int const Tesselation ) {
} }
void void
opengl33_precipitation::update() { opengl46_precipitation::update() {
if (!m_shader) if (!m_shader)
{ {
@@ -143,7 +143,7 @@ opengl33_precipitation::update() {
} }
void void
opengl33_precipitation::render() { opengl46_precipitation::render() {
if( !m_shader ) { return; } if( !m_shader ) { return; }
if( !m_vao ) { return; } if( !m_vao ) { return; }

View File

@@ -13,13 +13,13 @@ http://mozilla.org/MPL/2.0/.
#include "gl/vao.h" #include "gl/vao.h"
#include "gl/shader.h" #include "gl/shader.h"
class opengl33_precipitation { class opengl46_precipitation {
public: public:
// constructors // constructors
opengl33_precipitation() = default; opengl46_precipitation() = default;
// destructor // destructor
~opengl33_precipitation(); ~opengl46_precipitation();
// methods // methods
void void
update(); update();

View File

@@ -8,7 +8,7 @@ http://mozilla.org/MPL/2.0/.
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "rendering/opengl33renderer.h" #include "rendering/opengl46/opengl46renderer.h"
#include "utilities/color.h" #include "utilities/color.h"
#include "utilities/Globals.h" #include "utilities/Globals.h"
#include "utilities/Timer.h" #include "utilities/Timer.h"
@@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/.
#include "simulation/simulationtime.h" #include "simulation/simulationtime.h"
#include "application/application.h" #include "application/application.h"
#include "model/AnimModel.h" #include "model/AnimModel.h"
#include "rendering/opengl33geometrybank.h" #include "rendering/opengl46/opengl46geometrybank.h"
#include "rendering/screenshot.h" #include "rendering/screenshot.h"
#include "rendering/editoroverlay.h" #include "rendering/editoroverlay.h"
#include <imgui/imgui_impl_opengl3.h> #include <imgui/imgui_impl_opengl3.h>
@@ -94,7 +94,7 @@ ErrorCallback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei l
+ message ); + message );
} }
bool opengl33_renderer::Init(GLFWwindow *Window) bool opengl46_renderer::Init(GLFWwindow *Window)
{ {
if (Global.gfx_gldebug && GLAD_GL_KHR_debug) { if (Global.gfx_gldebug && GLAD_GL_KHR_debug) {
glEnable( GL_DEBUG_OUTPUT ); glEnable( GL_DEBUG_OUTPUT );
@@ -125,12 +125,12 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
Global.DayLight.diffuse[1] = 0.9490196f; // 242 / 255 Global.DayLight.diffuse[1] = 0.9490196f; // 242 / 255
Global.DayLight.diffuse[2] = 0.9058824f; // 231 / 255 Global.DayLight.diffuse[2] = 0.9058824f; // 231 / 255
Global.DayLight.is_directional = true; Global.DayLight.is_directional = true;
m_sunlight.id = opengl33_renderer::sunlight; m_sunlight.id = opengl46_renderer::sunlight;
// create dynamic light pool // create dynamic light pool
for (int idx = 0; idx < Global.DynamicLightCount; ++idx) for (int idx = 0; idx < Global.DynamicLightCount; ++idx)
{ {
opengl33_light light; opengl46_light light;
light.id = 1 + idx; light.id = 1 + idx;
light.is_directional = false; light.is_directional = false;
@@ -380,12 +380,12 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
return true; return true;
} }
void opengl33_renderer::Shutdown() void opengl46_renderer::Shutdown()
{ {
vr.reset(); vr.reset();
} }
bool opengl33_renderer::AddViewport(const global_settings::extraviewport_config &conf) bool opengl46_renderer::AddViewport(const global_settings::extraviewport_config &conf)
{ {
viewport_config *vp; viewport_config *vp;
@@ -410,7 +410,7 @@ bool opengl33_renderer::AddViewport(const global_settings::extraviewport_config
return ret; return ret;
} }
bool opengl33_renderer::init_viewport(viewport_config &vp) bool opengl46_renderer::init_viewport(viewport_config &vp)
{ {
if (vp.initialized) if (vp.initialized)
return true; return true;
@@ -552,7 +552,7 @@ bool opengl33_renderer::init_viewport(viewport_config &vp)
return true; return true;
} }
std::unique_ptr<gl::program> opengl33_renderer::make_shader(std::string v, std::string f) std::unique_ptr<gl::program> opengl46_renderer::make_shader(std::string v, std::string f)
{ {
gl::shader vert(v); gl::shader vert(v);
gl::shader frag(f); gl::shader frag(f);
@@ -560,7 +560,7 @@ std::unique_ptr<gl::program> opengl33_renderer::make_shader(std::string v, std::
return std::unique_ptr<gl::program>(prog); return std::unique_ptr<gl::program>(prog);
} }
bool opengl33_renderer::Render() bool opengl46_renderer::Render()
{ {
Timer::subsystem.gfx_total.start(); Timer::subsystem.gfx_total.start();
@@ -620,12 +620,12 @@ bool opengl33_renderer::Render()
Timer::subsystem.gfx_total.stop(); Timer::subsystem.gfx_total.stop();
// swapbuffers() could unbind current buffers so we prepare for it on our end // swapbuffers() could unbind current buffers so we prepare for it on our end
gfx::opengl33_vaogeometrybank::reset(); gfx::opengl46_vaogeometrybank::reset();
return true; // for now always succeed return true; // for now always succeed
} }
void opengl33_renderer::SwapBuffers() void opengl46_renderer::SwapBuffers()
{ {
Timer::subsystem.gfx_swap.start(); Timer::subsystem.gfx_swap.start();
@@ -692,7 +692,7 @@ void opengl33_renderer::SwapBuffers()
+ "particles: " + to_string( m_colorpass.draw_stats.particles, 7 ); + "particles: " + to_string( m_colorpass.draw_stats.particles, 7 );
} }
void opengl33_renderer::draw_debug_ui() void opengl46_renderer::draw_debug_ui()
{ {
if (!debug_ui_active) if (!debug_ui_active)
return; return;
@@ -722,7 +722,7 @@ void opengl33_renderer::draw_debug_ui()
} }
// runs jobs needed to generate graphics for specified render pass // runs jobs needed to generate graphics for specified render pass
void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode) void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
{ {
setup_pass(vp, m_renderpass, Mode); setup_pass(vp, m_renderpass, Mode);
switch (m_renderpass.draw_mode) switch (m_renderpass.draw_mode)
@@ -1252,7 +1252,7 @@ if (!Global.gfx_skippipeline)
} }
bool opengl33_renderer::Render_interior( bool const Alpha ) { bool opengl46_renderer::Render_interior( bool const Alpha ) {
// TODO: early frustum based cull, camera might be pointing elsewhere // TODO: early frustum based cull, camera might be pointing elsewhere
std::vector< std::pair<float, TDynamicObject *> > dynamics; std::vector< std::pair<float, TDynamicObject *> > dynamics;
auto *dynamic { simulation::Train->Dynamic() }; auto *dynamic { simulation::Train->Dynamic() };
@@ -1286,7 +1286,7 @@ bool opengl33_renderer::Render_interior( bool const Alpha ) {
return true; return true;
} }
bool opengl33_renderer::Render_lowpoly( TDynamicObject *Dynamic, float const Squaredistance, bool const Setup, bool const Alpha ) { bool opengl46_renderer::Render_lowpoly( TDynamicObject *Dynamic, float const Squaredistance, bool const Setup, bool const Alpha ) {
if( Dynamic->mdLowPolyInt == nullptr ) { return false; } if( Dynamic->mdLowPolyInt == nullptr ) { return false; }
@@ -1362,7 +1362,7 @@ bool opengl33_renderer::Render_lowpoly( TDynamicObject *Dynamic, float const Squ
return true; return true;
} }
bool opengl33_renderer::Render_coupler_adapter( TDynamicObject *Dynamic, float const Squaredistance, int const End, bool const Alpha ) { bool opengl46_renderer::Render_coupler_adapter( TDynamicObject *Dynamic, float const Squaredistance, int const End, bool const Alpha ) {
if( Dynamic->m_coupleradapters[ End ] == nullptr ) { return false; } if( Dynamic->m_coupleradapters[ End ] == nullptr ) { return false; }
@@ -1387,7 +1387,7 @@ bool opengl33_renderer::Render_coupler_adapter( TDynamicObject *Dynamic, float c
} }
// creates dynamic environment cubemap // creates dynamic environment cubemap
bool opengl33_renderer::Render_reflections(viewport_config &vp) bool opengl46_renderer::Render_reflections(viewport_config &vp)
{ {
if( Global.reflectiontune.update_interval == 0 ) { return false; } if( Global.reflectiontune.update_interval == 0 ) { return false; }
@@ -1428,7 +1428,7 @@ bool opengl33_renderer::Render_reflections(viewport_config &vp)
// based on // based on
// https://csc.lsu.edu/~kooima/articles/genperspective/index.html // https://csc.lsu.edu/~kooima/articles/genperspective/index.html
glm::mat4 opengl33_renderer::perspective_projection(const viewport_proj_config &c, glm::mat4 opengl46_renderer::perspective_projection(const viewport_proj_config &c,
float n, float f, glm::mat4 &frustum) float n, float f, glm::mat4 &frustum)
{ {
glm::vec3 vr, vu, vn; glm::vec3 vr, vu, vn;
@@ -1483,7 +1483,7 @@ glm::mat4 opengl33_renderer::perspective_projection(const viewport_proj_config &
return glm::translate(R * M, -c.pe); return glm::translate(R * M, -c.pe);
} }
glm::mat4 opengl33_renderer::perspective_projection_raw(float fovy, float aspect, float znear, float zfar) glm::mat4 opengl46_renderer::perspective_projection_raw(float fovy, float aspect, float znear, float zfar)
{ {
if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control) if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control)
{ {
@@ -1509,7 +1509,7 @@ glm::mat4 opengl33_renderer::perspective_projection_raw(float fovy, float aspect
glm::perspective(fovy, aspect, znear, zfar); glm::perspective(fovy, aspect, znear, zfar);
} }
glm::mat4 opengl33_renderer::ortho_projection(float l, float r, float b, float t, float znear, float zfar) glm::mat4 opengl46_renderer::ortho_projection(float l, float r, float b, float t, float znear, float zfar)
{ {
glm::mat4 proj = glm::ortho(l, r, b, t, znear, zfar); glm::mat4 proj = glm::ortho(l, r, b, t, znear, zfar);
if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control) if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control)
@@ -1533,14 +1533,14 @@ glm::mat4 opengl33_renderer::ortho_projection(float l, float r, float b, float t
proj; proj;
} }
glm::mat4 opengl33_renderer::ortho_frustumtest_projection(float l, float r, float b, float t, float znear, float zfar) glm::mat4 opengl46_renderer::ortho_frustumtest_projection(float l, float r, float b, float t, float znear, float zfar)
{ {
// for frustum calculation, use standard opengl matrix // for frustum calculation, use standard opengl matrix
return glm::ortho(l, r, b, t, znear, zfar); return glm::ortho(l, r, b, t, znear, zfar);
} }
// the main viewport of the editor in the orthographic view replaces the perspective projection // the main viewport of the editor in the orthographic view replaces the perspective projection
void opengl33_renderer::editor_ortho_projection(viewport_config const &Viewport, float const Zfar, glm::mat4 &Projection, glm::mat4 &Frustum) void opengl46_renderer::editor_ortho_projection(viewport_config const &Viewport, float const Zfar, glm::mat4 &Projection, glm::mat4 &Frustum)
{ {
if (false == (EditorModeFlag && Global.EditorOrtho && Viewport.main)) if (false == (EditorModeFlag && Global.EditorOrtho && Viewport.main))
return; return;
@@ -1550,7 +1550,7 @@ void opengl33_renderer::editor_ortho_projection(viewport_config const &Viewport,
Frustum = ortho_frustumtest_projection(-width, width, -height, height, -Zfar, Zfar); Frustum = ortho_frustumtest_projection(-width, width, -height, height, -Zfar, Zfar);
} }
void opengl33_renderer::setup_pass(viewport_config &Viewport, renderpass_config &Config, rendermode const Mode, void opengl46_renderer::setup_pass(viewport_config &Viewport, renderpass_config &Config, rendermode const Mode,
float const Znear, float const Zfar, bool const Ignoredebug) float const Znear, float const Zfar, bool const Ignoredebug)
{ {
Config.draw_mode = Mode; Config.draw_mode = Mode;
@@ -1762,7 +1762,7 @@ void opengl33_renderer::setup_pass(viewport_config &Viewport, renderpass_config
camera.update_frustum(frustumtest_proj); camera.update_frustum(frustumtest_proj);
} }
void opengl33_renderer::setup_matrices() void opengl46_renderer::setup_matrices()
{ {
OpenGLMatrices.mode(GL_PROJECTION); OpenGLMatrices.mode(GL_PROJECTION);
OpenGLMatrices.load_matrix(m_renderpass.pass_camera.projection()); OpenGLMatrices.load_matrix(m_renderpass.pass_camera.projection());
@@ -1771,7 +1771,7 @@ void opengl33_renderer::setup_matrices()
OpenGLMatrices.load_matrix(glm::mat4{glm::mat3{m_renderpass.pass_camera.modelview()}}); OpenGLMatrices.load_matrix(glm::mat4{glm::mat3{m_renderpass.pass_camera.modelview()}});
} }
void opengl33_renderer::setup_drawing(bool const Alpha) void opengl46_renderer::setup_drawing(bool const Alpha)
{ {
if (Alpha) if (Alpha)
{ {
@@ -1812,13 +1812,13 @@ void opengl33_renderer::setup_drawing(bool const Alpha)
} }
} }
void opengl33_renderer::setup_shadow_unbind_map() void opengl46_renderer::setup_shadow_unbind_map()
{ {
opengl_texture::unbind( gl::SHADOW_TEX ); opengl_texture::unbind( gl::SHADOW_TEX );
} }
// binds shadow map and updates shadow map uniform data // binds shadow map and updates shadow map uniform data
void opengl33_renderer::setup_shadow_bind_map() void opengl46_renderer::setup_shadow_bind_map()
{ {
if( false == Global.gfx_shadowmap_enabled ) { return; } if( false == Global.gfx_shadowmap_enabled ) { return; }
@@ -1862,12 +1862,12 @@ void opengl33_renderer::setup_shadow_bind_map()
scene_ubo->update(scene_ubs); scene_ubo->update(scene_ubs);
} }
void opengl33_renderer::setup_shadow_color( glm::vec4 const &Shadowcolor ) { void opengl46_renderer::setup_shadow_color( glm::vec4 const &Shadowcolor ) {
model_ubs.shadow_tone = glm::pow( Shadowcolor.x, 2.2f ); model_ubs.shadow_tone = glm::pow( Shadowcolor.x, 2.2f );
} }
void opengl33_renderer::setup_env_map(gl::cubemap *tex) void opengl46_renderer::setup_env_map(gl::cubemap *tex)
{ {
if (tex) if (tex)
{ {
@@ -1883,7 +1883,7 @@ void opengl33_renderer::setup_env_map(gl::cubemap *tex)
opengl_texture::reset_unit_cache(); opengl_texture::reset_unit_cache();
} }
void opengl33_renderer::setup_environment_light(TEnvironmentType const Environment) void opengl46_renderer::setup_environment_light(TEnvironmentType const Environment)
{ {
switch (Environment) switch (Environment)
@@ -1913,7 +1913,7 @@ void opengl33_renderer::setup_environment_light(TEnvironmentType const Environme
} }
} }
void opengl33_renderer::setup_sunlight_intensity( float const Factor ) { void opengl46_renderer::setup_sunlight_intensity( float const Factor ) {
m_sunlight.apply_intensity( Factor ); m_sunlight.apply_intensity( Factor );
light_ubs.lights[ 0 ].intensity = m_sunlight.factor * (1.0f - Global.Overcast * 0.33f); light_ubs.lights[ 0 ].intensity = m_sunlight.factor * (1.0f - Global.Overcast * 0.33f);
@@ -1921,7 +1921,7 @@ void opengl33_renderer::setup_sunlight_intensity( float const Factor ) {
light_ubo->update( light_ubs ); light_ubo->update( light_ubs );
} }
bool opengl33_renderer::Render(world_environment *Environment) bool opengl46_renderer::Render(world_environment *Environment)
{ {
m_shadowcolor = colors::white; // prevent shadow from affecting sky m_shadowcolor = colors::white; // prevent shadow from affecting sky
setup_shadow_color( m_shadowcolor ); setup_shadow_color( m_shadowcolor );
@@ -1946,7 +1946,7 @@ bool opengl33_renderer::Render(world_environment *Environment)
m_skydomerenderer.update(); m_skydomerenderer.update();
m_skydomerenderer.render(); m_skydomerenderer.render();
// skydome uses a custom vbo which could potentially confuse the main geometry system. hardly elegant but, eh // skydome uses a custom vbo which could potentially confuse the main geometry system. hardly elegant but, eh
gfx::opengl33_vaogeometrybank::reset(); gfx::opengl46_vaogeometrybank::reset();
} }
glPopMatrix(); glPopMatrix();
@@ -2120,20 +2120,20 @@ bool opengl33_renderer::Render(world_environment *Environment)
// geometry methods // geometry methods
// creates a new geometry bank. returns: handle to the bank or NULL // creates a new geometry bank. returns: handle to the bank or NULL
gfx::geometrybank_handle opengl33_renderer::Create_Bank() gfx::geometrybank_handle opengl46_renderer::Create_Bank()
{ {
return m_geometry.register_bank(std::make_unique<gfx::opengl33_vaogeometrybank>()); return m_geometry.register_bank(std::make_unique<gfx::opengl46_vaogeometrybank>());
} }
// creates a new indexed geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL // creates a new indexed geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL
gfx::geometry_handle opengl33_renderer::Insert(gfx::index_array &Indices, gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, int const Type) gfx::geometry_handle opengl46_renderer::Insert(gfx::index_array &Indices, gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, int const Type)
{ {
// NOTE: we expect indexed geometry to come with calculated tangents // NOTE: we expect indexed geometry to come with calculated tangents
return m_geometry.create_chunk( Indices, Vertices, Userdata, Geometry, Type ); return m_geometry.create_chunk( Indices, Vertices, Userdata, Geometry, Type );
} }
// creates a new geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL // creates a new geometry chunk of specified type from supplied data, in specified bank. returns: handle to the chunk or NULL
gfx::geometry_handle opengl33_renderer::Insert(gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, int const Type) gfx::geometry_handle opengl46_renderer::Insert(gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometrybank_handle const &Geometry, int const Type)
{ {
gfx::calculate_tangents(Vertices, gfx::index_array(), Type); gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
@@ -2141,7 +2141,7 @@ gfx::geometry_handle opengl33_renderer::Insert(gfx::vertex_array &Vertices, gfx:
} }
// replaces data of specified chunk with the supplied vertex data, starting from specified offset // replaces data of specified chunk with the supplied vertex data, starting from specified offset
bool opengl33_renderer::Replace(gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry, int const Type, const std::size_t Offset) bool opengl46_renderer::Replace(gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry, int const Type, const std::size_t Offset)
{ {
gfx::calculate_tangents(Vertices, gfx::index_array(), Type); gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
@@ -2149,7 +2149,7 @@ bool opengl33_renderer::Replace(gfx::vertex_array &Vertices, gfx::userdata_array
} }
// adds supplied vertex data at the end of specified chunk // adds supplied vertex data at the end of specified chunk
bool opengl33_renderer::Append(gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry, int const Type) bool opengl46_renderer::Append(gfx::vertex_array &Vertices, gfx::userdata_array &Userdata, gfx::geometry_handle const &Geometry, int const Type)
{ {
gfx::calculate_tangents(Vertices, gfx::index_array(), Type); gfx::calculate_tangents(Vertices, gfx::index_array(), Type);
@@ -2157,30 +2157,30 @@ bool opengl33_renderer::Append(gfx::vertex_array &Vertices, gfx::userdata_array
} }
// provides direct access to index data of specfied chunk // provides direct access to index data of specfied chunk
gfx::index_array const & opengl33_renderer::Indices(gfx::geometry_handle const &Geometry) const gfx::index_array const & opengl46_renderer::Indices(gfx::geometry_handle const &Geometry) const
{ {
return m_geometry.indices(Geometry); return m_geometry.indices(Geometry);
} }
// provides direct access to vertex data of specfied chunk // provides direct access to vertex data of specfied chunk
gfx::vertex_array const &opengl33_renderer::Vertices(gfx::geometry_handle const &Geometry) const gfx::vertex_array const &opengl46_renderer::Vertices(gfx::geometry_handle const &Geometry) const
{ {
return m_geometry.vertices(Geometry); return m_geometry.vertices(Geometry);
} }
gfx::userdata_array const &opengl33_renderer::UserData(const gfx::geometry_handle &Geometry) const gfx::userdata_array const &opengl46_renderer::UserData(const gfx::geometry_handle &Geometry) const
{ {
return m_geometry.userdata(Geometry); return m_geometry.userdata(Geometry);
} }
// material methods // material methods
material_handle opengl33_renderer::Fetch_Material(std::string const &Filename, bool const Loadnow) material_handle opengl46_renderer::Fetch_Material(std::string const &Filename, bool const Loadnow)
{ {
return m_materials.create(Filename, Loadnow); return m_materials.create(Filename, Loadnow);
} }
std::shared_ptr<gl::program> opengl33_renderer::Fetch_Shader(const std::string &name) std::shared_ptr<gl::program> opengl46_renderer::Fetch_Shader(const std::string &name)
{ {
auto it = m_shaders.find(name); auto it = m_shaders.find(name);
if (it == m_shaders.end()) if (it == m_shaders.end())
@@ -2193,7 +2193,7 @@ std::shared_ptr<gl::program> opengl33_renderer::Fetch_Shader(const std::string &
return m_shaders[name]; return m_shaders[name];
} }
void opengl33_renderer::Bind_Material( material_handle const Material, TSubModel const *sm, lighting_data const *lighting ) void opengl46_renderer::Bind_Material( material_handle const Material, TSubModel const *sm, lighting_data const *lighting )
{ {
if (Material != null_handle) if (Material != null_handle)
{ {
@@ -2349,7 +2349,7 @@ void opengl33_renderer::Bind_Material( material_handle const Material, TSubModel
Bind_Material(m_invalid_material); Bind_Material(m_invalid_material);
} }
void opengl33_renderer::Bind_Material_Shadow(material_handle const Material) void opengl46_renderer::Bind_Material_Shadow(material_handle const Material)
{ {
if (Material != null_handle) if (Material != null_handle)
{ {
@@ -2369,12 +2369,12 @@ void opengl33_renderer::Bind_Material_Shadow(material_handle const Material)
} }
} }
IMaterial const *opengl33_renderer::Material(material_handle const Material) const IMaterial const *opengl46_renderer::Material(material_handle const Material) const
{ {
return &m_materials.material(Material); return &m_materials.material(Material);
} }
material_handle opengl33_renderer::Terrain_Material(material_handle const Reuse, std::vector<gfx::terrain_layer> const &Layers, int const Samples, std::uint8_t const *Weights, glm::vec3 const &Placement) material_handle opengl46_renderer::Terrain_Material(material_handle const Reuse, std::vector<gfx::terrain_layer> const &Layers, int const Samples, std::uint8_t const *Weights, glm::vec3 const &Placement)
{ {
auto const material{m_terrainmaterials.make(Reuse, Layers, Samples, Weights, Placement)}; auto const material{m_terrainmaterials.make(Reuse, Layers, Samples, Weights, Placement)};
if (material != null_handle) if (material != null_handle)
@@ -2383,54 +2383,54 @@ material_handle opengl33_renderer::Terrain_Material(material_handle const Reuse,
return gfx_renderer::Terrain_Material(Reuse, Layers, Samples, Weights, Placement); return gfx_renderer::Terrain_Material(Reuse, Layers, Samples, Weights, Placement);
} }
void opengl33_renderer::Terrain_Release(material_handle const Material) void opengl46_renderer::Terrain_Release(material_handle const Material)
{ {
m_terrainmaterials.release(Material); m_terrainmaterials.release(Material);
} }
opengl_material &opengl33_renderer::Material(material_handle const Material) opengl_material &opengl46_renderer::Material(material_handle const Material)
{ {
return m_materials.material(Material); return m_materials.material(Material);
} }
opengl_material const & opengl33_renderer::Material( TSubModel const * Submodel ) const { opengl_material const & opengl46_renderer::Material( TSubModel const * Submodel ) const {
return m_materials.material( submodel_material( Submodel ) ); return m_materials.material( submodel_material( Submodel ) );
} }
texture_handle opengl33_renderer::Fetch_Texture(std::string const &Filename, bool const Loadnow, GLint format_hint) texture_handle opengl46_renderer::Fetch_Texture(std::string const &Filename, bool const Loadnow, GLint format_hint)
{ {
return m_textures.create(Filename, Loadnow, format_hint); return m_textures.create(Filename, Loadnow, format_hint);
} }
void opengl33_renderer::Bind_Texture( texture_handle const Texture ) void opengl46_renderer::Bind_Texture( texture_handle const Texture )
{ {
return Bind_Texture( 0, Texture ); return Bind_Texture( 0, Texture );
} }
void opengl33_renderer::Bind_Texture(std::size_t const Unit, texture_handle const Texture) void opengl46_renderer::Bind_Texture(std::size_t const Unit, texture_handle const Texture)
{ {
m_textures.bind(Unit, Texture); m_textures.bind(Unit, Texture);
} }
ITexture &opengl33_renderer::Texture(texture_handle const Texture) ITexture &opengl46_renderer::Texture(texture_handle const Texture)
{ {
return m_textures.texture(Texture); return m_textures.texture(Texture);
} }
ITexture const &opengl33_renderer::Texture(texture_handle const Texture) const ITexture const &opengl46_renderer::Texture(texture_handle const Texture) const
{ {
return m_textures.texture(Texture); return m_textures.texture(Texture);
} }
void opengl33_renderer::Update_AnimModel(TAnimModel *model) void opengl46_renderer::Update_AnimModel(TAnimModel *model)
{ {
model->RaAnimate(m_framestamp); model->RaAnimate(m_framestamp);
} }
void opengl33_renderer::Render(scene::basic_region *Region) void opengl46_renderer::Render(scene::basic_region *Region)
{ {
m_sectionqueue.clear(); m_sectionqueue.clear();
@@ -2526,7 +2526,7 @@ void opengl33_renderer::Render(scene::basic_region *Region)
} }
} }
void opengl33_renderer::Render(section_sequence::iterator First, section_sequence::iterator Last) void opengl46_renderer::Render(section_sequence::iterator First, section_sequence::iterator Last)
{ {
switch (m_renderpass.draw_mode) switch (m_renderpass.draw_mode)
@@ -2637,7 +2637,7 @@ void opengl33_renderer::Render(section_sequence::iterator First, section_sequenc
} }
} }
void opengl33_renderer::Render(cell_sequence::iterator First, cell_sequence::iterator Last) void opengl46_renderer::Render(cell_sequence::iterator First, cell_sequence::iterator Last)
{ {
// cache initial iterator for the second sweep // cache initial iterator for the second sweep
@@ -2881,7 +2881,7 @@ void opengl33_renderer::Render(cell_sequence::iterator First, cell_sequence::ite
} }
} }
void opengl33_renderer::Draw_Geometry(std::vector<gfx::geometrybank_handle>::iterator begin, std::vector<gfx::geometrybank_handle>::iterator end) void opengl46_renderer::Draw_Geometry(std::vector<gfx::geometrybank_handle>::iterator begin, std::vector<gfx::geometrybank_handle>::iterator end)
{ {
if (begin == end) if (begin == end)
{ {
@@ -2892,12 +2892,12 @@ void opengl33_renderer::Draw_Geometry(std::vector<gfx::geometrybank_handle>::ite
m_geometry.draw_batch(first, first + std::distance(begin, end)); m_geometry.draw_batch(first, first + std::distance(begin, end));
} }
void opengl33_renderer::Draw_Geometry(const gfx::geometrybank_handle &handle) void opengl46_renderer::Draw_Geometry(const gfx::geometrybank_handle &handle)
{ {
m_geometry.draw(handle); m_geometry.draw(handle);
} }
void opengl33_renderer::draw(const gfx::geometry_handle &handle) void opengl46_renderer::draw(const gfx::geometry_handle &handle)
{ {
model_ubs.set_modelview(OpenGLMatrices.data(GL_MODELVIEW)); model_ubs.set_modelview(OpenGLMatrices.data(GL_MODELVIEW));
model_ubo->update(model_ubs); model_ubo->update(model_ubs);
@@ -2912,7 +2912,7 @@ void opengl33_renderer::draw(const gfx::geometry_handle &handle)
} }
} }
void opengl33_renderer::draw(std::vector<gfx::geometrybank_handle>::iterator it, std::vector<gfx::geometrybank_handle>::iterator end) void opengl46_renderer::draw(std::vector<gfx::geometrybank_handle>::iterator it, std::vector<gfx::geometrybank_handle>::iterator end)
{ {
model_ubs.set_modelview(OpenGLMatrices.data(GL_MODELVIEW)); model_ubs.set_modelview(OpenGLMatrices.data(GL_MODELVIEW));
model_ubo->update(model_ubs); model_ubo->update(model_ubs);
@@ -2920,7 +2920,7 @@ void opengl33_renderer::draw(std::vector<gfx::geometrybank_handle>::iterator it,
Draw_Geometry(it, end); Draw_Geometry(it, end);
} }
void opengl33_renderer::Render(scene::shape_node const &Shape, bool const Ignorerange) void opengl46_renderer::Render(scene::shape_node const &Shape, bool const Ignorerange)
{ {
auto const &data{Shape.data()}; auto const &data{Shape.data()};
@@ -2988,7 +2988,7 @@ void opengl33_renderer::Render(scene::shape_node const &Shape, bool const Ignore
++m_renderpass.draw_stats.drawcalls; ++m_renderpass.draw_stats.drawcalls;
} }
void opengl33_renderer::Render(TAnimModel *Instance) void opengl46_renderer::Render(TAnimModel *Instance)
{ {
if (false == Instance->m_visible) { return; } if (false == Instance->m_visible) { return; }
@@ -3091,7 +3091,7 @@ void opengl33_renderer::Render(TAnimModel *Instance)
// Render_Instanced() culls each instance it's given. the tests it makes are repeated here on the copies of instance // Render_Instanced() culls each instance it's given. the tests it makes are repeated here on the copies of instance
// bounds kept by the buckets, with some slack for the single precision of the copies, and the instances which fail are // bounds kept by the buckets, with some slack for the single precision of the copies, and the instances which fail are
// left out: the instances themselves are fetched only when there's a chance for them to be drawn // left out: the instances themselves are fetched only when there's a chance for them to be drawn
void opengl33_renderer::Queue_Instances( scene::basic_cell const *Cell ) void opengl46_renderer::Queue_Instances( scene::basic_cell const *Cell )
{ {
// the editor moves and resizes the instances in place, the copies can't be relied on while it's active // the editor moves and resizes the instances in place, the copies can't be relied on while it's active
auto const usebounds { false == EditorModeFlag }; auto const usebounds { false == EditorModeFlag };
@@ -3139,7 +3139,7 @@ void opengl33_renderer::Queue_Instances( scene::basic_cell const *Cell )
} }
// makes the copies of the bounds of the instances held by a bucket of a scene cell // makes the copies of the bounds of the instances held by a bucket of a scene cell
void opengl33_renderer::Update_Instance_Bounds( TModel3d const *Model, scene::basic_cell::instance_bucket const &Bucket ) void opengl46_renderer::Update_Instance_Bounds( TModel3d const *Model, scene::basic_cell::instance_bucket const &Bucket )
{ {
// a submodel is drawn only closer than its fSquareMaxDist, see Render( TSubModel * ). past the largest of these // a submodel is drawn only closer than its fSquareMaxDist, see Render( TSubModel * ). past the largest of these
// there's nothing of the model left to draw, which makes it another limit of the range of its instances // there's nothing of the model left to draw, which makes it another limit of the range of its instances
@@ -3178,7 +3178,7 @@ void opengl33_renderer::Update_Instance_Bounds( TModel3d const *Model, scene::ba
// (accumulated by the matrix stack starting from identity, NOT the camera/instance frame). // (accumulated by the matrix stack starting from identity, NOT the camera/instance frame).
// //
// Batch size is capped at MAX_INSTANCES_PER_BATCH (256). Larger groups are split. // Batch size is capped at MAX_INSTANCES_PER_BATCH (256). Larger groups are split.
void opengl33_renderer::Render_Instanced( TModel3d *Model, std::vector<TAnimModel *> const &Instances ) void opengl46_renderer::Render_Instanced( TModel3d *Model, std::vector<TAnimModel *> const &Instances )
{ {
if( Model == nullptr ) { return; } if( Model == nullptr ) { return; }
if( Instances.empty() ) { return; } if( Instances.empty() ) { return; }
@@ -3381,7 +3381,7 @@ void opengl33_renderer::Render_Instanced( TModel3d *Model, std::vector<TAnimMode
// - the track has no sleepermodel // - the track has no sleepermodel
// - the track is farther than Global.SleeperDistance meters from the camera // - the track is farther than Global.SleeperDistance meters from the camera
// releases gl textures used only by vehicles farther than gfx.textures.releasedistance times the draw range // releases gl textures used only by vehicles farther than gfx.textures.releasedistance times the draw range
void opengl33_renderer::Update_Texture_Release() void opengl46_renderer::Update_Texture_Release()
{ {
if (m_colorpass.draw_range <= 0.f) if (m_colorpass.draw_range <= 0.f)
{ {
@@ -3439,7 +3439,7 @@ void opengl33_renderer::Update_Texture_Release()
} }
// textures used by materials of the sub-models of specified model, replaceable skins excluded // textures used by materials of the sub-models of specified model, replaceable skins excluded
std::vector<texture_handle> const &opengl33_renderer::Model_Textures(TModel3d *Model) std::vector<texture_handle> const &opengl46_renderer::Model_Textures(TModel3d *Model)
{ {
auto const lookup{m_modeltextures.find(Model)}; auto const lookup{m_modeltextures.find(Model)};
if (lookup != m_modeltextures.end()) if (lookup != m_modeltextures.end())
@@ -3493,7 +3493,7 @@ std::vector<texture_handle> const &opengl33_renderer::Model_Textures(TModel3d *M
return textures; return textures;
} }
void opengl33_renderer::Render_Sleepers( TTrack *Track ) void opengl46_renderer::Render_Sleepers( TTrack *Track )
{ {
if( Track == nullptr ) { return; } if( Track == nullptr ) { return; }
if( false == Track->m_sleeper_enabled ) { return; } if( false == Track->m_sleeper_enabled ) { return; }
@@ -3677,7 +3677,7 @@ void opengl33_renderer::Render_Sleepers( TTrack *Track )
m_renderpass.draw_stats.models += static_cast<int>( total ); m_renderpass.draw_stats.models += static_cast<int>( total );
} }
bool opengl33_renderer::Render(TDynamicObject *Dynamic) bool opengl46_renderer::Render(TDynamicObject *Dynamic)
{ {
glDebug("Render TDynamicObject"); glDebug("Render TDynamicObject");
@@ -3853,7 +3853,7 @@ bool opengl33_renderer::Render(TDynamicObject *Dynamic)
} }
// rendering kabiny gdy jest oddzielnym modelem i ma byc wyswietlana // rendering kabiny gdy jest oddzielnym modelem i ma byc wyswietlana
bool opengl33_renderer::Render_cab(TDynamicObject const *Dynamic, float const Lightlevel, bool const Alpha) bool opengl46_renderer::Render_cab(TDynamicObject const *Dynamic, float const Lightlevel, bool const Alpha)
{ {
if (Dynamic == nullptr) if (Dynamic == nullptr)
@@ -3947,7 +3947,7 @@ bool opengl33_renderer::Render_cab(TDynamicObject const *Dynamic, float const Li
return true; return true;
} }
bool opengl33_renderer::Render(TModel3d *Model, material_data const *Material, float const Squaredistance) bool opengl46_renderer::Render(TModel3d *Model, material_data const *Material, float const Squaredistance)
{ {
auto alpha = (Material != nullptr ? Material->textures_alpha : 0x30300030); auto alpha = (Material != nullptr ? Material->textures_alpha : 0x30300030);
@@ -3973,7 +3973,7 @@ bool opengl33_renderer::Render(TModel3d *Model, material_data const *Material, f
return true; return true;
} }
bool opengl33_renderer::Render(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle) bool opengl46_renderer::Render(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle)
{ {
::glPushMatrix(); ::glPushMatrix();
::glTranslated(Position.x, Position.y, Position.z); ::glTranslated(Position.x, Position.y, Position.z);
@@ -3991,7 +3991,7 @@ bool opengl33_renderer::Render(TModel3d *Model, material_data const *Material, f
return result; return result;
} }
void opengl33_renderer::Render(TSubModel *Submodel) void opengl46_renderer::Render(TSubModel *Submodel)
{ {
glDebug("Render TSubModel"); glDebug("Render TSubModel");
@@ -4160,7 +4160,7 @@ void opengl33_renderer::Render(TSubModel *Submodel)
Render(Submodel->Next); // dalsze rekurencyjnie Render(Submodel->Next); // dalsze rekurencyjnie
} }
void opengl33_renderer::Render(TTrack *Track) void opengl46_renderer::Render(TTrack *Track)
{ {
if ((Track->m_material1 == 0) && (Track->m_material2 == 0) && (Track->eType != tt_Switch || Track->SwitchExtension->m_material3 == 0)) if ((Track->m_material1 == 0) && (Track->m_material2 == 0) && (Track->eType != tt_Switch || Track->SwitchExtension->m_material3 == 0))
{ {
@@ -4196,7 +4196,7 @@ void opengl33_renderer::Render(TTrack *Track)
} }
// experimental, does track rendering in two passes, to take advantage of reduced texture switching // experimental, does track rendering in two passes, to take advantage of reduced texture switching
void opengl33_renderer::Render(scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last) void opengl46_renderer::Render(scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last)
{ {
// setup // setup
@@ -4465,7 +4465,7 @@ void opengl33_renderer::Render(scene::basic_cell::path_sequence::const_iterator
} }
} }
void opengl33_renderer::Render(TMemCell *Memcell) void opengl46_renderer::Render(TMemCell *Memcell)
{ {
::glPushMatrix(); ::glPushMatrix();
@@ -4497,7 +4497,7 @@ void opengl33_renderer::Render(TMemCell *Memcell)
::glPopMatrix(); ::glPopMatrix();
} }
void opengl33_renderer::Render_particles() void opengl46_renderer::Render_particles()
{ {
model_ubs.set_modelview(OpenGLMatrices.data(GL_MODELVIEW)); model_ubs.set_modelview(OpenGLMatrices.data(GL_MODELVIEW));
model_ubo->update(model_ubs); model_ubo->update(model_ubs);
@@ -4507,7 +4507,7 @@ void opengl33_renderer::Render_particles()
m_renderpass.draw_stats.particles = m_particlerenderer.render(); m_renderpass.draw_stats.particles = m_particlerenderer.render();
} }
void opengl33_renderer::Render_vr_models() void opengl46_renderer::Render_vr_models()
{ {
if (!vr) if (!vr)
return; return;
@@ -4526,7 +4526,7 @@ void opengl33_renderer::Render_vr_models()
::glPopMatrix(); ::glPopMatrix();
} }
void opengl33_renderer::Render_precipitation() void opengl46_renderer::Render_precipitation()
{ {
if (Global.Overcast <= 1.f) if (Global.Overcast <= 1.f)
{ {
@@ -4580,7 +4580,7 @@ void opengl33_renderer::Render_precipitation()
::glPopMatrix(); ::glPopMatrix();
} }
void opengl33_renderer::Render_Alpha(scene::basic_region *Region) void opengl46_renderer::Render_Alpha(scene::basic_region *Region)
{ {
// sort the nodes based on their distance to viewer // sort the nodes based on their distance to viewer
@@ -4589,7 +4589,7 @@ void opengl33_renderer::Render_Alpha(scene::basic_region *Region)
Render_Alpha(std::rbegin(m_cellqueue), std::rend(m_cellqueue)); Render_Alpha(std::rbegin(m_cellqueue), std::rend(m_cellqueue));
} }
void opengl33_renderer::Render_Alpha(cell_sequence::reverse_iterator First, cell_sequence::reverse_iterator Last) void opengl46_renderer::Render_Alpha(cell_sequence::reverse_iterator First, cell_sequence::reverse_iterator Last)
{ {
// NOTE: this method is launched only during color pass therefore we don't bother with mode test here // NOTE: this method is launched only during color pass therefore we don't bother with mode test here
@@ -4679,7 +4679,7 @@ void opengl33_renderer::Render_Alpha(cell_sequence::reverse_iterator First, cell
} }
} }
void opengl33_renderer::Render_Alpha(TAnimModel *Instance) void opengl46_renderer::Render_Alpha(TAnimModel *Instance)
{ {
if (false == Instance->m_visible) { return; } if (false == Instance->m_visible) { return; }
@@ -4741,7 +4741,7 @@ void opengl33_renderer::Render_Alpha(TAnimModel *Instance)
} }
} }
void opengl33_renderer::Render_Alpha(TTraction *Traction) void opengl46_renderer::Render_Alpha(TTraction *Traction)
{ {
glDebug("Render_Alpha TTraction"); glDebug("Render_Alpha TTraction");
@@ -4786,7 +4786,7 @@ void opengl33_renderer::Render_Alpha(TTraction *Traction)
glLineWidth(1.0f); glLineWidth(1.0f);
} }
void opengl33_renderer::Render_editor_overlay() void opengl46_renderer::Render_editor_overlay()
{ {
if (false == EditorModeFlag || EditorOverlay.batches.empty()) if (false == EditorModeFlag || EditorOverlay.batches.empty())
return; return;
@@ -4835,7 +4835,7 @@ void opengl33_renderer::Render_editor_overlay()
::glPopMatrix(); ::glPopMatrix();
} }
void opengl33_renderer::Render_Alpha(scene::lines_node const &Lines) void opengl46_renderer::Render_Alpha(scene::lines_node const &Lines)
{ {
glDebug("Render_Alpha scene::lines_node"); glDebug("Render_Alpha scene::lines_node");
@@ -4868,7 +4868,7 @@ void opengl33_renderer::Render_Alpha(scene::lines_node const &Lines)
glLineWidth(1.0f); glLineWidth(1.0f);
} }
bool opengl33_renderer::Render_Alpha(TDynamicObject *Dynamic) bool opengl46_renderer::Render_Alpha(TDynamicObject *Dynamic)
{ {
if (!Global.render_cab && Global.pCamera.m_owner == Dynamic) if (!Global.render_cab && Global.pCamera.m_owner == Dynamic)
return false; return false;
@@ -4949,7 +4949,7 @@ bool opengl33_renderer::Render_Alpha(TDynamicObject *Dynamic)
return true; return true;
} }
bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance) bool opengl46_renderer::Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance)
{ {
auto alpha = (Material != nullptr ? Material->textures_alpha : 0x30300030); auto alpha = (Material != nullptr ? Material->textures_alpha : 0x30300030);
@@ -4975,7 +4975,7 @@ bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Mater
return true; return true;
} }
bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle) bool opengl46_renderer::Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle)
{ {
::glPushMatrix(); ::glPushMatrix();
::glTranslated(Position.x, Position.y, Position.z); ::glTranslated(Position.x, Position.y, Position.z);
@@ -4994,7 +4994,7 @@ bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Mater
} }
// characters of a text display, laid out in a row. the text can be encoded in utf-8 or in windows-1250 // characters of a text display, laid out in a row. the text can be encoded in utf-8 or in windows-1250
void opengl33_renderer::Render_Alpha_text(TSubModel *Submodel) void opengl46_renderer::Render_Alpha_text(TSubModel *Submodel)
{ {
if (TSubModel::pasText == nullptr) if (TSubModel::pasText == nullptr)
{ {
@@ -5008,7 +5008,7 @@ void opengl33_renderer::Render_Alpha_text(TSubModel *Submodel)
} }
} }
void opengl33_renderer::Render_Alpha(TSubModel *Submodel) void opengl46_renderer::Render_Alpha(TSubModel *Submodel)
{ {
// renderowanie przezroczystych przez DL // renderowanie przezroczystych przez DL
if ((Submodel->iVisible) && (TSubModel::fSquareDist >= Submodel->fSquareMinDist) && (TSubModel::fSquareDist < Submodel->fSquareMaxDist) && (false == m_previewing || Submodel->fVisible > 0.f)) if ((Submodel->iVisible) && (TSubModel::fSquareDist >= Submodel->fSquareMinDist) && (TSubModel::fSquareDist < Submodel->fSquareMaxDist) && (false == m_previewing || Submodel->fVisible > 0.f))
@@ -5250,7 +5250,7 @@ void opengl33_renderer::Render_Alpha(TSubModel *Submodel)
Render_Alpha(Submodel->Next); Render_Alpha(Submodel->Next);
}; };
bool opengl33_renderer::Debug_Ui_State(std::optional<bool> param) bool opengl46_renderer::Debug_Ui_State(std::optional<bool> param)
{ {
if (param) { if (param) {
debug_ui_active = *param; debug_ui_active = *param;
@@ -5260,7 +5260,7 @@ bool opengl33_renderer::Debug_Ui_State(std::optional<bool> param)
} }
// utility methods // utility methods
void opengl33_renderer::Update_Pick_Control() void opengl46_renderer::Update_Pick_Control()
{ {
if (!m_picking_pbo->is_busy()) if (!m_picking_pbo->is_busy())
{ {
@@ -5305,7 +5305,7 @@ void opengl33_renderer::Update_Pick_Control()
} }
} }
void opengl33_renderer::Update_Pick_Node() void opengl46_renderer::Update_Pick_Node()
{ {
if (!m_picking_node_pbo->is_busy()) if (!m_picking_node_pbo->is_busy())
{ {
@@ -5344,7 +5344,7 @@ void opengl33_renderer::Update_Pick_Node()
} }
} }
void opengl33_renderer::Pick_Control_Callback(std::function<void(TSubModel const *, const glm::vec2 pos)> callback) void opengl46_renderer::Pick_Control_Callback(std::function<void(TSubModel const *, const glm::vec2 pos)> callback)
{ {
if (!Global.render_cab) { if (!Global.render_cab) {
callback(nullptr, glm::vec2()); callback(nullptr, glm::vec2());
@@ -5353,12 +5353,12 @@ void opengl33_renderer::Pick_Control_Callback(std::function<void(TSubModel const
m_control_pick_requests.push_back(callback); m_control_pick_requests.push_back(callback);
} }
void opengl33_renderer::Pick_Node_Callback(std::function<void(scene::basic_node *)> callback) void opengl46_renderer::Pick_Node_Callback(std::function<void(scene::basic_node *)> callback)
{ {
m_node_pick_requests.push_back(callback); m_node_pick_requests.push_back(callback);
} }
glm::dvec3 opengl33_renderer::Update_Mouse_Position() glm::dvec3 opengl46_renderer::Update_Mouse_Position()
{ {
if (!m_depth_pointer_pbo->is_busy()) if (!m_depth_pointer_pbo->is_busy())
{ {
@@ -5411,7 +5411,7 @@ glm::dvec3 opengl33_renderer::Update_Mouse_Position()
return m_colorpass.pass_camera.position() + glm::dvec3{m_worldmousecoordinates}; return m_colorpass.pass_camera.position() + glm::dvec3{m_worldmousecoordinates};
} }
void opengl33_renderer::Update(double const Deltatime) void opengl46_renderer::Update(double const Deltatime)
{ {
Update_Pick_Control(); Update_Pick_Control();
Update_Pick_Node(); Update_Pick_Node();
@@ -5500,19 +5500,19 @@ void opengl33_renderer::Update(double const Deltatime)
} }
// debug performance string // debug performance string
std::string const &opengl33_renderer::info_times() const std::string const &opengl46_renderer::info_times() const
{ {
return m_debugtimestext; return m_debugtimestext;
} }
std::string const &opengl33_renderer::info_stats() const std::string const &opengl46_renderer::info_stats() const
{ {
return m_debugstatstext; return m_debugstatstext;
} }
void opengl33_renderer::MakeScreenshot() void opengl46_renderer::MakeScreenshot()
{ {
screenshot_manager::make_screenshot(); screenshot_manager::make_screenshot();
} }
@@ -5530,7 +5530,7 @@ float const preview_fieldofview{30.f};
float const preview_background{16.f}; float const preview_background{16.f};
} // namespace } // namespace
void opengl33_renderer::Preview_Bounds(TSubModel const *Submodel, glm::dmat4 const &Transform, glm::dvec3 &Min, glm::dvec3 &Max) const void opengl46_renderer::Preview_Bounds(TSubModel const *Submodel, glm::dmat4 const &Transform, glm::dvec3 &Min, glm::dvec3 &Max) const
{ {
// same walk as the one of Render(TSubModel *) bar the range checks, which leave out parts only for the bounds to be smaller // same walk as the one of Render(TSubModel *) bar the range checks, which leave out parts only for the bounds to be smaller
for (auto const *submodel{Submodel}; submodel != nullptr; submodel = submodel->Next) for (auto const *submodel{Submodel}; submodel != nullptr; submodel = submodel->Next)
@@ -5557,7 +5557,7 @@ void opengl33_renderer::Preview_Bounds(TSubModel const *Submodel, glm::dmat4 con
} }
} }
bool opengl33_renderer::Preview_Targets(int const Size) bool opengl46_renderer::Preview_Targets(int const Size)
{ {
if (m_preview.size == Size) if (m_preview.size == Size)
{ {
@@ -5597,7 +5597,7 @@ bool opengl33_renderer::Preview_Targets(int const Size)
return true; return true;
} }
void opengl33_renderer::Preview_Model(TAnimModel *Instance, float const Squaredistance, bool const Alpha) void opengl46_renderer::Preview_Model(TAnimModel *Instance, float const Squaredistance, bool const Alpha)
{ {
// the placement of Render(TAnimModel *), without its range and visibility tests // the placement of Render(TAnimModel *), without its range and visibility tests
::glPushMatrix(); ::glPushMatrix();
@@ -5619,7 +5619,7 @@ void opengl33_renderer::Preview_Model(TAnimModel *Instance, float const Squaredi
::glPopMatrix(); ::glPopMatrix();
} }
void opengl33_renderer::Preview_Color(TAnimModel *Instance, float const Squaredistance, int const Size, glm::dvec3 const &Eye, glm::mat4 const &View, glm::mat4 const &Projection, bool const Shadows) void opengl46_renderer::Preview_Color(TAnimModel *Instance, float const Squaredistance, int const Size, glm::dvec3 const &Eye, glm::mat4 const &View, glm::mat4 const &Projection, bool const Shadows)
{ {
m_renderpass.draw_mode = rendermode::color; m_renderpass.draw_mode = rendermode::color;
m_renderpass.pass_camera.position() = Eye; m_renderpass.pass_camera.position() = Eye;
@@ -5687,7 +5687,7 @@ void opengl33_renderer::Preview_Color(TAnimModel *Instance, float const Squaredi
setup_shadow_unbind_map(); setup_shadow_unbind_map();
} }
bool opengl33_renderer::Render_Preview(TAnimModel *Instance, int const Size, int const Margin, bool const Shadows, std::vector<std::uint8_t> &Image) bool opengl46_renderer::Render_Preview(TAnimModel *Instance, int const Size, int const Margin, bool const Shadows, std::vector<std::uint8_t> &Image)
{ {
if ((Instance == nullptr) || (Instance->pModel == nullptr) || (Size <= 0) || (Margin < 0) || (Margin * 2 >= Size)) if ((Instance == nullptr) || (Instance->pModel == nullptr) || (Size <= 0) || (Margin < 0) || (Margin * 2 >= Size))
{ {
@@ -5714,7 +5714,7 @@ bool opengl33_renderer::Render_Preview(TAnimModel *Instance, int const Size, int
glfwMakeContextCurrent(m_window); glfwMakeContextCurrent(m_window);
opengl_texture::reset_unit_cache(); opengl_texture::reset_unit_cache();
gfx::opengl33_vaogeometrybank::reset(); gfx::opengl46_vaogeometrybank::reset();
m_previewing = true; m_previewing = true;
// lights and visibility of the submodels, for this instance // lights and visibility of the submodels, for this instance
Instance->RaAnimate(m_framestamp); Instance->RaAnimate(m_framestamp);
@@ -5860,7 +5860,7 @@ bool opengl33_renderer::Render_Preview(TAnimModel *Instance, int const Size, int
glDisable(GL_FRAMEBUFFER_SRGB); glDisable(GL_FRAMEBUFFER_SRGB);
opengl_texture::reset_unit_cache(); opengl_texture::reset_unit_cache();
// the post processing binds its own vertex array, which the geometry banks don't know about // the post processing binds its own vertex array, which the geometry banks don't know about
gfx::opengl33_vaogeometrybank::reset(); gfx::opengl46_vaogeometrybank::reset();
auto const targetpixels{static_cast<std::size_t>(targetsize) * targetsize}; auto const targetpixels{static_cast<std::size_t>(targetsize) * targetsize};
std::vector<std::uint8_t> colors(targetpixels * 4); std::vector<std::uint8_t> colors(targetpixels * 4);
@@ -5924,7 +5924,7 @@ bool opengl33_renderer::Render_Preview(TAnimModel *Instance, int const Size, int
return true; return true;
} }
void opengl33_renderer::Update_Lights(light_array &Lights) void opengl46_renderer::Update_Lights(light_array &Lights)
{ {
glDebug("Update_Lights"); glDebug("Update_Lights");
@@ -6088,7 +6088,7 @@ void opengl33_renderer::Update_Lights(light_array &Lights)
light_ubo->update(light_ubs); light_ubo->update(light_ubs);
} }
bool opengl33_renderer::Init_caps() bool opengl46_renderer::Init_caps()
{ {
std::string gl_renderer((char *)glGetString(GL_RENDERER)); std::string gl_renderer((char *)glGetString(GL_RENDERER));
std::string gl_vendor((char *)glGetString(GL_VENDOR)); std::string gl_vendor((char *)glGetString(GL_VENDOR));
@@ -6185,46 +6185,46 @@ bool opengl33_renderer::Init_caps()
return true; return true;
} }
glm::vec3 opengl33_renderer::pick_color(std::size_t const Index) glm::vec3 opengl46_renderer::pick_color(std::size_t const Index)
{ {
return glm::vec3{((Index & 0xff0000) >> 16) / 255.0f, ((Index & 0x00ff00) >> 8) / 255.0f, (Index & 0x0000ff) / 255.0f}; return glm::vec3{((Index & 0xff0000) >> 16) / 255.0f, ((Index & 0x00ff00) >> 8) / 255.0f, (Index & 0x0000ff) / 255.0f};
} }
std::size_t opengl33_renderer::pick_index(glm::ivec3 const &Color) std::size_t opengl46_renderer::pick_index(glm::ivec3 const &Color)
{ {
return Color.b + (Color.g * 256) + (Color.r * 256 * 256); return Color.b + (Color.g * 256) + (Color.r * 256 * 256);
} }
std::unique_ptr<gfx_renderer> opengl33_renderer::create_func() std::unique_ptr<gfx_renderer> opengl46_renderer::create_func()
{ {
return std::unique_ptr<gfx_renderer>(new opengl33_renderer()); return std::unique_ptr<gfx_renderer>(new opengl46_renderer());
} }
bool opengl33_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("modern", opengl33_renderer::create_func); bool opengl46_renderer::renderer_register = gfx_renderer_factory::get_instance()->register_backend("modern", opengl46_renderer::create_func);
bool opengl33_renderer::opengl33_imgui_renderer::Init() bool opengl46_renderer::opengl46_imgui_renderer::Init()
{ {
crashreport_add_info("imgui_ver", "gl3"); crashreport_add_info("imgui_ver", "gl3");
return ImGui_ImplOpenGL3_Init("#version 330 core"); return ImGui_ImplOpenGL3_Init("#version 330 core");
} }
void opengl33_renderer::opengl33_imgui_renderer::Shutdown() void opengl46_renderer::opengl46_imgui_renderer::Shutdown()
{ {
ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplOpenGL3_Shutdown();
} }
void opengl33_renderer::opengl33_imgui_renderer::BeginFrame() void opengl46_renderer::opengl46_imgui_renderer::BeginFrame()
{ {
ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplOpenGL3_NewFrame();
} }
void opengl33_renderer::opengl33_imgui_renderer::Render() void opengl46_renderer::opengl46_imgui_renderer::Render()
{ {
gl::buffer::unbind(gl::buffer::ARRAY_BUFFER); gl::buffer::unbind(gl::buffer::ARRAY_BUFFER);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
} }
std::uint64_t opengl33_renderer::opengl33_imgui_renderer::Create_Image(std::uint8_t const *Rgba, int const Width, int const Height) std::uint64_t opengl46_renderer::opengl46_imgui_renderer::Create_Image(std::uint8_t const *Rgba, int const Width, int const Height)
{ {
// the ui colours are made linear in its shaders, the image is too, by sampling it as srgb. the bindings the renderer // the ui colours are made linear in its shaders, the image is too, by sampling it as srgb. the bindings the renderer
// keeps track of are put back as they were // keeps track of are put back as they were
@@ -6248,7 +6248,7 @@ std::uint64_t opengl33_renderer::opengl33_imgui_renderer::Create_Image(std::uint
return image; return image;
} }
void opengl33_renderer::opengl33_imgui_renderer::Release_Image(std::uint64_t const Image) void opengl46_renderer::opengl46_imgui_renderer::Release_Image(std::uint64_t const Image)
{ {
auto const image{static_cast<GLuint>(Image)}; auto const image{static_cast<GLuint>(Image)};
glDeleteTextures(1, &image); glDeleteTextures(1, &image);

View File

@@ -11,10 +11,10 @@ http://mozilla.org/MPL/2.0/.
#include "rendering/renderer.h" #include "rendering/renderer.h"
#include "rendering/openglcamera.h" #include "rendering/openglcamera.h"
#include "rendering/opengl33light.h" #include "rendering/opengl46/opengl46light.h"
#include "rendering/opengl33particles.h" #include "rendering/opengl46/opengl46particles.h"
#include "rendering/opengl33skydome.h" #include "rendering/opengl46/opengl46skydome.h"
#include "rendering/opengl33precipitation.h" #include "rendering/opengl46/opengl46precipitation.h"
#include "simulation/simulationenvironment.h" #include "simulation/simulationenvironment.h"
#include "scene/scene.h" #include "scene/scene.h"
#include "world/MemCell.h" #include "world/MemCell.h"
@@ -29,15 +29,15 @@ http://mozilla.org/MPL/2.0/.
#include "gl/glsl_common.h" #include "gl/glsl_common.h"
#include "gl/pbo.h" #include "gl/pbo.h"
#include "gl/query.h" #include "gl/query.h"
#include "rendering/opengl33terrain.h" #include "rendering/opengl46/opengl46terrain.h"
// bare-bones render controller, in lack of anything better yet // bare-bones render controller, in lack of anything better yet
class opengl33_renderer : public gfx_renderer { class opengl46_renderer : public gfx_renderer {
public: public:
// constructors // constructors
opengl33_renderer() = default; opengl46_renderer() = default;
// destructor // destructor
~opengl33_renderer() {} ~opengl46_renderer() {}
// methods // methods
bool bool
Init( GLFWwindow *Window ) override; Init( GLFWwindow *Window ) override;
@@ -260,7 +260,7 @@ class opengl33_renderer : public gfx_renderer {
viewport_config *m_current_viewport = nullptr; viewport_config *m_current_viewport = nullptr;
typedef std::vector<opengl33_light> opengllight_array; typedef std::vector<opengl46_light> opengllight_array;
// methods // methods
std::unique_ptr<gl::program> make_shader(std::string v, std::string f); std::unique_ptr<gl::program> make_shader(std::string v, std::string f);
@@ -355,8 +355,8 @@ class opengl33_renderer : public gfx_renderer {
gfx::geometrybank_manager m_geometry; gfx::geometrybank_manager m_geometry;
material_manager m_materials; material_manager m_materials;
texture_manager m_textures; texture_manager m_textures;
opengl33_terrain_materials m_terrainmaterials{m_materials, m_textures}; opengl46_terrain_materials m_terrainmaterials{m_materials, m_textures};
opengl33_light m_sunlight; opengl46_light m_sunlight;
opengllight_array m_lights; opengllight_array m_lights;
/* /*
float m_sunandviewangle; // cached dot product of sunlight and camera vectors float m_sunandviewangle; // cached dot product of sunlight and camera vectors
@@ -377,9 +377,9 @@ class opengl33_renderer : public gfx_renderer {
bool m_environmentready{false}; // the environment map was drawn whole at least once bool m_environmentready{false}; // the environment map was drawn whole at least once
double m_environmentupdatetime{0}; // time of the most recent environment map update double 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
opengl33_skydome m_skydomerenderer; opengl46_skydome m_skydomerenderer;
opengl33_precipitation m_precipitationrenderer; opengl46_precipitation m_precipitationrenderer;
opengl33_particles m_particlerenderer; // particle visualization subsystem opengl46_particles m_particlerenderer; // particle visualization subsystem
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;
@@ -576,7 +576,7 @@ class opengl33_renderer : public gfx_renderer {
static bool renderer_register; static bool renderer_register;
class opengl33_imgui_renderer : public imgui_renderer class opengl46_imgui_renderer : public imgui_renderer
{ {
virtual bool Init() override; virtual bool Init() override;
virtual void Shutdown() override; virtual void Shutdown() override;

View File

@@ -8,11 +8,11 @@ http://mozilla.org/MPL/2.0/.
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "rendering/opengl33skydome.h" #include "rendering/opengl46/opengl46skydome.h"
#include "simulation/simulationenvironment.h" #include "simulation/simulationenvironment.h"
void opengl33_skydome::update() { void opengl46_skydome::update() {
if (!m_shader) { if (!m_shader) {
@@ -55,7 +55,7 @@ void opengl33_skydome::update() {
} }
// render skydome to screen // render skydome to screen
void opengl33_skydome::render() { void opengl46_skydome::render() {
if( ( !m_shader) || ( !m_vao ) ) { return; } if( ( !m_shader) || ( !m_vao ) ) { return; }

View File

@@ -13,13 +13,13 @@ http://mozilla.org/MPL/2.0/.
#include "gl/shader.h" #include "gl/shader.h"
#include "gl/buffer.h" #include "gl/buffer.h"
class opengl33_skydome { class opengl46_skydome {
public: public:
// constructors // constructors
opengl33_skydome() = default; opengl46_skydome() = default;
// destructor // destructor
~opengl33_skydome() = default; ~opengl46_skydome() = default;
// methods // methods
// updates data stores on the opengl end. NOTE: unbinds buffers // updates data stores on the opengl end. NOTE: unbinds buffers
void update(); void update();

View File

@@ -8,9 +8,9 @@ http://mozilla.org/MPL/2.0/.
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "rendering/opengl33terrain.h" #include "rendering/opengl46/opengl46terrain.h"
#include "rendering/opengl33geometrybank.h" #include "rendering/opengl46/opengl46geometrybank.h"
#include "utilities/Globals.h" #include "utilities/Globals.h"
#include "utilities/Logs.h" #include "utilities/Logs.h"
@@ -39,7 +39,7 @@ void set_anisotropy(GLenum const Target)
} // namespace } // namespace
bool opengl33_terrain_materials::init() bool opengl46_terrain_materials::init()
{ {
if (m_state != 0) if (m_state != 0)
return m_state > 0; return m_state > 0;
@@ -91,7 +91,7 @@ bool opengl33_terrain_materials::init()
return true; return true;
} }
texture_handle opengl33_terrain_materials::make_texture(std::string const &Name, GLenum const Target) texture_handle opengl46_terrain_materials::make_texture(std::string const &Name, GLenum const Target)
{ {
auto const handle{m_textures.create(Name, false, GL_RGBA)}; auto const handle{m_textures.create(Name, false, GL_RGBA)};
auto &texture{m_textures.texture(handle)}; auto &texture{m_textures.texture(handle)};
@@ -107,7 +107,7 @@ texture_handle opengl33_terrain_materials::make_texture(std::string const &Name,
return handle; return handle;
} }
void opengl33_terrain_materials::make_storage(texture_array &Array, int const Layers) void opengl46_terrain_materials::make_storage(texture_array &Array, int const Layers)
{ {
auto &texture{m_textures.texture(Array.handle)}; auto &texture{m_textures.texture(Array.handle)};
bind_for_upload(texture); bind_for_upload(texture);
@@ -124,7 +124,7 @@ void opengl33_terrain_materials::make_storage(texture_array &Array, int const La
texture.data_components = GL_RGBA; texture.data_components = GL_RGBA;
} }
int opengl33_terrain_materials::layer_index(gfx::terrain_layer const &Layer) int opengl46_terrain_materials::layer_index(gfx::terrain_layer const &Layer)
{ {
for (auto const &existing : m_layers) for (auto const &existing : m_layers)
if (existing.material == Layer.material && existing.size == Layer.size) if (existing.material == Layer.material && existing.size == Layer.size)
@@ -167,7 +167,7 @@ int opengl33_terrain_materials::layer_index(gfx::terrain_layer const &Layer)
return entry.index; return entry.index;
} }
std::size_t opengl33_terrain_materials::acquire_slot(material_handle const Reuse) std::size_t opengl46_terrain_materials::acquire_slot(material_handle const Reuse)
{ {
if (Reuse != null_handle) if (Reuse != null_handle)
{ {
@@ -234,7 +234,7 @@ std::size_t opengl33_terrain_materials::acquire_slot(material_handle const Reuse
return index; return index;
} }
material_handle opengl33_terrain_materials::make(material_handle const Reuse, std::vector<gfx::terrain_layer> const &Layers, int const Samples, std::uint8_t const *Weights, glm::vec3 const &Placement) material_handle opengl46_terrain_materials::make(material_handle const Reuse, std::vector<gfx::terrain_layer> const &Layers, int const Samples, std::uint8_t const *Weights, glm::vec3 const &Placement)
{ {
if (Layers.empty() || false == init()) if (Layers.empty() || false == init())
return null_handle; return null_handle;
@@ -303,7 +303,7 @@ material_handle opengl33_terrain_materials::make(material_handle const Reuse, st
return entry.material; return entry.material;
} }
void opengl33_terrain_materials::release(material_handle const Material) void opengl46_terrain_materials::release(material_handle const Material)
{ {
auto const lookup{m_slotof.find(Material)}; auto const lookup{m_slotof.find(Material)};
if (lookup == m_slotof.end() || false == m_slots[lookup->second].used) if (lookup == m_slotof.end() || false == m_slots[lookup->second].used)
@@ -312,7 +312,7 @@ void opengl33_terrain_materials::release(material_handle const Material)
m_free.push_back(lookup->second); m_free.push_back(lookup->second);
} }
bool opengl33_terrain_materials::copy_layer(layer &Layer) bool opengl46_terrain_materials::copy_layer(layer &Layer)
{ {
auto const &material{m_materials.material(Layer.material)}; auto const &material{m_materials.material(Layer.material)};
auto const slot = [&](char const *Name, int const Fallback) { auto const slot = [&](char const *Name, int const Fallback) {
@@ -378,7 +378,7 @@ bool opengl33_terrain_materials::copy_layer(layer &Layer)
return true; return true;
} }
void opengl33_terrain_materials::update() void opengl46_terrain_materials::update()
{ {
if (false == m_pending || m_state <= 0) if (false == m_pending || m_state <= 0)
return; return;
@@ -430,5 +430,5 @@ void opengl33_terrain_materials::update()
::glDisable(GL_FRAMEBUFFER_SRGB); ::glDisable(GL_FRAMEBUFFER_SRGB);
::glDepthMask(GL_TRUE); ::glDepthMask(GL_TRUE);
opengl_texture::reset_unit_cache(); opengl_texture::reset_unit_cache();
gfx::opengl33_vaogeometrybank::reset(); gfx::opengl46_vaogeometrybank::reset();
} }

View File

@@ -23,10 +23,10 @@ http://mozilla.org/MPL/2.0/.
// materials of the heightmap terrain for the opengl 3.3 renderer (shader mat_terrain). // materials of the heightmap terrain for the opengl 3.3 renderer (shader mat_terrain).
// the textures of the layer materials are copied into texture arrays shared by all chunks; each chunk gets a material // the textures of the layer materials are copied into texture arrays shared by all chunks; each chunk gets a material
// of its own, with textures holding the weights of its layers and a table of what its layers are // of its own, with textures holding the weights of its layers and a table of what its layers are
class opengl33_terrain_materials class opengl46_terrain_materials
{ {
public: public:
opengl33_terrain_materials(material_manager &Materials, texture_manager &Textures) : m_materials(Materials), m_textures(Textures) {} opengl46_terrain_materials(material_manager &Materials, texture_manager &Textures) : m_materials(Materials), m_textures(Textures) {}
// see gfx_renderer::Terrain_Material. returns null_handle if the terrain shader can't be used // see gfx_renderer::Terrain_Material. returns null_handle if the terrain shader can't be used
material_handle make(material_handle const Reuse, std::vector<gfx::terrain_layer> const &Layers, int const Samples, std::uint8_t const *Weights, glm::vec3 const &Placement); material_handle make(material_handle const Reuse, std::vector<gfx::terrain_layer> const &Layers, int const Samples, std::uint8_t const *Weights, glm::vec3 const &Placement);

View File

@@ -26,7 +26,7 @@ http://mozilla.org/MPL/2.0/.
#include "input/command.h" #include "input/command.h"
#include "utilities/utilities.h" #include "utilities/utilities.h"
class opengl33_renderer; class opengl46_renderer;
namespace scene { namespace scene {
@@ -95,7 +95,7 @@ struct terrain_block {
// TBD, TODO: replace with quadtree scheme? // TBD, TODO: replace with quadtree scheme?
class basic_cell { class basic_cell {
friend opengl33_renderer; friend opengl46_renderer;
public: public:
// constructors // constructors
@@ -292,7 +292,7 @@ public:
// basic scene partitioning structure, holds terrain geometry and collection of cells // basic scene partitioning structure, holds terrain geometry and collection of cells
class basic_section { class basic_section {
friend opengl33_renderer; friend opengl46_renderer;
public: public:
// constructors // constructors
@@ -415,7 +415,7 @@ public:
// top-level of scene spatial structure, holds collection of sections // top-level of scene spatial structure, holds collection of sections
class basic_region { class basic_region {
friend opengl33_renderer; friend opengl46_renderer;
public: public:
// constructors // constructors

View File

@@ -17,12 +17,12 @@ http://mozilla.org/MPL/2.0/.
#include "rendering/precipitation.h" #include "rendering/precipitation.h"
#include "audio/sound.h" #include "audio/sound.h"
class opengl33_renderer; class opengl46_renderer;
// wrapper for environment elements -- sky, sun, stars, clouds etc // wrapper for environment elements -- sky, sun, stars, clouds etc
class world_environment { class world_environment {
friend opengl33_renderer; friend opengl46_renderer;
public: public:
// methods // methods

View File

@@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Ra: zestaw klas do robienia wskaźników, aby uporządkować nagłówki // Ra: zestaw klas do robienia wskaźników, aby uporządkować nagłówki
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class opengl33_renderer; class opengl46_renderer;
class TTrack; // odcinek trajektorii class TTrack; // odcinek trajektorii
class basic_event; class basic_event;
class TTrain; // pojazd sterowany class TTrain; // pojazd sterowany

View File

@@ -188,7 +188,7 @@ struct material_data {
class TDynamicObject { // klasa pojazdu class TDynamicObject { // klasa pojazdu
friend opengl33_renderer; friend opengl46_renderer;
public: public:
static bool bDynamicRemove; // moved from ground static bool bDynamicRemove; // moved from ground

View File

@@ -16,7 +16,7 @@ ui::map_panel::map_panel() : ui_panel(STR_C("Map"), false)
window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
#ifdef WITH_OPENGL_MODERN #ifdef WITH_OPENGL_MODERN
opengl33_renderer *gl33 = dynamic_cast<opengl33_renderer*>(GfxRenderer.get()); opengl46_renderer *gl33 = dynamic_cast<opengl46_renderer*>(GfxRenderer.get());
if (!gl33) { if (!gl33) {
ErrorLog("map not supported on old renderer"); ErrorLog("map not supported on old renderer");
return; return;
@@ -144,7 +144,7 @@ void ui::map_panel::render_map_texture(glm::mat4 transform, glm::vec2 surface_si
scene_ubo->bind_uniform(); scene_ubo->bind_uniform();
#ifdef WITH_OPENGL_MODERN #ifdef WITH_OPENGL_MODERN
opengl33_renderer *gl33 = dynamic_cast<opengl33_renderer*>(GfxRenderer.get()); opengl46_renderer *gl33 = dynamic_cast<opengl46_renderer*>(GfxRenderer.get());
gl33->Draw_Geometry(m_section_handles.begin(), m_section_handles.end()); gl33->Draw_Geometry(m_section_handles.begin(), m_section_handles.end());
@@ -421,7 +421,7 @@ void ui::handle_map_object_hover(std::shared_ptr<map::map_object> &obj)
for (int i = 0; i < iMaxNumLights; i++) for (int i = 0; i < iMaxNumLights; i++)
{ {
#ifdef WITH_OPENGL_MODERN #ifdef WITH_OPENGL_MODERN
dynamic_cast<opengl33_renderer*>(GfxRenderer.get())->Update_AnimModel(model); // update lamp opacities dynamic_cast<opengl46_renderer*>(GfxRenderer.get())->Update_AnimModel(model); // update lamp opacities
#endif #endif
auto state = model->LightGet(i); auto state = model->LightGet(i);
if (!state) if (!state)
@@ -477,7 +477,7 @@ void ui::semaphore_window::render_content()
for (int i = 0; i < iMaxNumLights; i++) for (int i = 0; i < iMaxNumLights; i++)
{ {
#ifdef WITH_OPENGL_MODERN #ifdef WITH_OPENGL_MODERN
dynamic_cast<opengl33_renderer*>(GfxRenderer.get())->Update_AnimModel(model); // update lamp opacities dynamic_cast<opengl46_renderer*>(GfxRenderer.get())->Update_AnimModel(model); // update lamp opacities
#endif #endif
auto state = model->LightGet(i); auto state = model->LightGet(i);
if (!state) if (!state)

View File

@@ -8,7 +8,7 @@
#include "gl/framebuffer.h" #include "gl/framebuffer.h"
#include "rendering/frustum.h" #include "rendering/frustum.h"
#ifdef WITH_OPENGL_MODERN #ifdef WITH_OPENGL_MODERN
#include "rendering/opengl33renderer.h" #include "rendering/opengl46/opengl46renderer.h"
#endif #endif
namespace ui namespace ui

View File

@@ -151,7 +151,7 @@ private:
// trajektoria ruchu - opakowanie // trajektoria ruchu - opakowanie
class TTrack : public scene::basic_node class TTrack : public scene::basic_node
{ {
friend opengl33_renderer; friend opengl46_renderer;
// NOTE: temporary arrangement // NOTE: temporary arrangement
friend itemproperties_panel; friend itemproperties_panel;
friend class editor_track; friend class editor_track;

View File

@@ -20,7 +20,7 @@ class TTractionPowerSource;
class TTraction : public scene::basic_node class TTraction : public scene::basic_node
{ {
friend opengl33_renderer; friend opengl46_renderer;
public: // na razie public: // na razie
TTractionPowerSource *psPower[ 2 ] { nullptr, nullptr }; // najbliższe zasilacze z obu kierunków TTractionPowerSource *psPower[ 2 ] { nullptr, nullptr }; // najbliższe zasilacze z obu kierunków