mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
motion blur fixes
This commit is contained in:
18
Texture.cpp
18
Texture.cpp
@@ -880,14 +880,12 @@ opengl_texture::create() {
|
||||
::glBindTexture( target, id );
|
||||
|
||||
// analyze specified texture traits
|
||||
bool wraps{ true };
|
||||
bool wrapt{ true };
|
||||
for( auto const &trait : traits ) {
|
||||
|
||||
switch( trait ) {
|
||||
|
||||
case 's': { wraps = false; break; }
|
||||
case 't': { wrapt = false; break; }
|
||||
case 's': { wrap_mode_s = GL_CLAMP_TO_EDGE; break; }
|
||||
case 't': { wrap_mode_t = GL_CLAMP_TO_EDGE; break; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -900,8 +898,8 @@ opengl_texture::create() {
|
||||
{
|
||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_S, wrap_mode_s);
|
||||
glTexParameteri(target, GL_TEXTURE_WRAP_T, wrap_mode_t);
|
||||
if (data_components == GL_DEPTH_COMPONENT)
|
||||
{
|
||||
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
@@ -926,8 +924,8 @@ opengl_texture::create() {
|
||||
}
|
||||
else
|
||||
{
|
||||
::glTexParameteri(target, GL_TEXTURE_WRAP_S, (wraps == true ? GL_REPEAT : GL_CLAMP_TO_EDGE));
|
||||
::glTexParameteri(target, GL_TEXTURE_WRAP_T, (wrapt == true ? GL_REPEAT : GL_CLAMP_TO_EDGE));
|
||||
::glTexParameteri(target, GL_TEXTURE_WRAP_S, wrap_mode_s);
|
||||
::glTexParameteri(target, GL_TEXTURE_WRAP_T, wrap_mode_t);
|
||||
set_filtering();
|
||||
|
||||
// data_format and data_type specifies how image is laid out in memory
|
||||
@@ -1061,7 +1059,7 @@ opengl_texture::release() {
|
||||
return;
|
||||
}
|
||||
|
||||
void opengl_texture::alloc_rendertarget(GLint format, GLint components, int width, int height, int s)
|
||||
void opengl_texture::alloc_rendertarget(GLint format, GLint components, int width, int height, int s, GLint wrap)
|
||||
{
|
||||
data_width = width;
|
||||
data_height = height;
|
||||
@@ -1069,6 +1067,8 @@ void opengl_texture::alloc_rendertarget(GLint format, GLint components, int widt
|
||||
data_components = components;
|
||||
data_mapcount = 1;
|
||||
is_rendertarget = true;
|
||||
wrap_mode_s = wrap;
|
||||
wrap_mode_t = wrap;
|
||||
samples = s;
|
||||
if (samples > 1)
|
||||
target = GL_TEXTURE_2D_MULTISAMPLE;
|
||||
|
||||
@@ -43,7 +43,7 @@ struct opengl_texture {
|
||||
height() const {
|
||||
return data_height; }
|
||||
|
||||
void alloc_rendertarget(GLint format, GLint components, int width, int height, int samples = 1);
|
||||
void alloc_rendertarget(GLint format, GLint components, int width, int height, int samples = 1, GLint wrap = GL_CLAMP_TO_BORDER);
|
||||
void set_components_hint(GLint hint);
|
||||
static void reset_unit_cache();
|
||||
|
||||
@@ -87,6 +87,8 @@ private:
|
||||
data_components{ 0 };
|
||||
|
||||
GLint data_type = GL_UNSIGNED_BYTE;
|
||||
GLint wrap_mode_s = GL_REPEAT;
|
||||
GLint wrap_mode_t = GL_REPEAT;
|
||||
/*
|
||||
std::atomic<bool> is_loaded{ false }; // indicates the texture data was loaded and can be processed
|
||||
std::atomic<bool> is_good{ false }; // indicates the texture data was retrieved without errors
|
||||
|
||||
@@ -208,7 +208,7 @@ bool opengl_renderer::Init(GLFWwindow *Window)
|
||||
m_msaa_fb->attach(*m_msaa_rbv, GL_COLOR_ATTACHMENT1);
|
||||
|
||||
m_main_tex = std::make_unique<opengl_texture>();
|
||||
m_main_tex->alloc_rendertarget(Global.gfx_format_color, GL_RGB, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height);
|
||||
m_main_tex->alloc_rendertarget(Global.gfx_format_color, GL_RGB, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, 1, GL_CLAMP_TO_EDGE);
|
||||
|
||||
m_main_fb = std::make_unique<gl::framebuffer>();
|
||||
m_main_fb->attach(*m_main_tex, GL_COLOR_ATTACHMENT0);
|
||||
@@ -555,9 +555,9 @@ void opengl_renderer::Render_pass(rendermode const Mode)
|
||||
setup_drawing(true);
|
||||
|
||||
glm::mat4 future;
|
||||
if (!FreeFlyModeFlag)
|
||||
if (Global.pCamera.m_owner != nullptr)
|
||||
{
|
||||
auto const *vehicle = simulation::Train->Dynamic();
|
||||
auto const *vehicle = Global.pCamera.m_owner;
|
||||
glm::mat4 mv = OpenGLMatrices.data(GL_MODELVIEW);
|
||||
future = glm::translate(mv, -glm::vec3(vehicle->get_future_movement())) * glm::inverse(mv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user