mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 17:29:18 +02:00
back to RGB4, better logging
This commit is contained in:
8
Logs.cpp
8
Logs.cpp
@@ -119,6 +119,14 @@ void ErrorLog( const char *str, logtype const Type ) {
|
|||||||
errors.flush();
|
errors.flush();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void LogsFlush()
|
||||||
|
{
|
||||||
|
if (output.is_open())
|
||||||
|
output.flush();
|
||||||
|
if (errors.is_open())
|
||||||
|
errors.flush();
|
||||||
|
}
|
||||||
|
|
||||||
void Error(const std::string &asMessage, bool box)
|
void Error(const std::string &asMessage, bool box)
|
||||||
{
|
{
|
||||||
// if (box)
|
// if (box)
|
||||||
|
|||||||
1
Logs.h
1
Logs.h
@@ -27,3 +27,4 @@ void ErrorLog( const std::string &str, logtype const Type = logtype::generic );
|
|||||||
void WriteLog( const std::string &str, logtype const Type = logtype::generic );
|
void WriteLog( const std::string &str, logtype const Type = logtype::generic );
|
||||||
void CommLog( const char *str );
|
void CommLog( const char *str );
|
||||||
void CommLog( const std::string &str );
|
void CommLog( const std::string &str );
|
||||||
|
void LogsFlush();
|
||||||
|
|||||||
@@ -298,6 +298,8 @@ eu07_application::run()
|
|||||||
Timer::subsystem.mainloop_total.stop();
|
Timer::subsystem.mainloop_total.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogsFlush();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
21
map.cpp
21
map.cpp
@@ -6,15 +6,17 @@
|
|||||||
#include "Train.h"
|
#include "Train.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
|
|
||||||
void map::init()
|
bool map::init()
|
||||||
{
|
{
|
||||||
|
WriteLog("initializing map gfx...");
|
||||||
|
|
||||||
gl::shader vert("map.vert");
|
gl::shader vert("map.vert");
|
||||||
gl::shader frag("map.frag");
|
gl::shader frag("map.frag");
|
||||||
gl::program *prog = new gl::program({vert, frag});
|
gl::program *prog = new gl::program({vert, frag});
|
||||||
m_shader = std::unique_ptr<gl::program>(prog);
|
m_shader = std::unique_ptr<gl::program>(prog);
|
||||||
|
|
||||||
m_tex = std::make_unique<opengl_texture>();
|
m_tex = std::make_unique<opengl_texture>();
|
||||||
m_tex->alloc_rendertarget(GL_RGB8, GL_RGB, GL_FLOAT, fb_size, fb_size);
|
m_tex->alloc_rendertarget(GL_RGB4, GL_RGB, GL_FLOAT, fb_size, fb_size);
|
||||||
|
|
||||||
m_fb = std::make_unique<gl::framebuffer>();
|
m_fb = std::make_unique<gl::framebuffer>();
|
||||||
m_fb->attach(*m_tex, GL_COLOR_ATTACHMENT0);
|
m_fb->attach(*m_tex, GL_COLOR_ATTACHMENT0);
|
||||||
@@ -24,13 +26,13 @@ void map::init()
|
|||||||
if (!m_fb->is_complete())
|
if (!m_fb->is_complete())
|
||||||
{
|
{
|
||||||
ErrorLog("map framebuffer incomplete");
|
ErrorLog("map framebuffer incomplete");
|
||||||
throw std::runtime_error("map framebuffer incomplete");
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Global.iMultisampling)
|
if (Global.iMultisampling)
|
||||||
{
|
{
|
||||||
m_msaa_rb = std::make_unique<gl::renderbuffer>();
|
m_msaa_rb = std::make_unique<gl::renderbuffer>();
|
||||||
m_msaa_rb->alloc(GL_RGB8, fb_size, fb_size, 1 << Global.iMultisampling);
|
m_msaa_rb->alloc(GL_RGB4, fb_size, fb_size, 1 << Global.iMultisampling);
|
||||||
|
|
||||||
m_msaa_fb = std::make_unique<gl::framebuffer>();
|
m_msaa_fb = std::make_unique<gl::framebuffer>();
|
||||||
m_msaa_fb->attach(*m_msaa_rb, GL_COLOR_ATTACHMENT0);
|
m_msaa_fb->attach(*m_msaa_rb, GL_COLOR_ATTACHMENT0);
|
||||||
@@ -40,11 +42,15 @@ void map::init()
|
|||||||
if (!m_msaa_fb->is_complete())
|
if (!m_msaa_fb->is_complete())
|
||||||
{
|
{
|
||||||
ErrorLog("map multisampling framebuffer incomplete");
|
ErrorLog("map multisampling framebuffer incomplete");
|
||||||
throw std::runtime_error("map multisampling framebuffer incomplete");
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scene_ubo = std::make_unique<gl::ubo>(sizeof(gl::scene_ubs), 0);
|
scene_ubo = std::make_unique<gl::ubo>(sizeof(gl::scene_ubs), 0);
|
||||||
|
|
||||||
|
WriteLog("map init ok");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float map::get_vehicle_rotation()
|
float map::get_vehicle_rotation()
|
||||||
@@ -61,8 +67,9 @@ void map::render(scene::basic_region *Region)
|
|||||||
if (!map_opened)
|
if (!map_opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_shader)
|
if (!scene_ubo)
|
||||||
init();
|
if (!init())
|
||||||
|
return;
|
||||||
|
|
||||||
ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(fb_size, fb_size));
|
ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(fb_size, fb_size));
|
||||||
if (ImGui::Begin("Map", &map_opened, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse))
|
if (ImGui::Begin("Map", &map_opened, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse))
|
||||||
|
|||||||
Reference in New Issue
Block a user