16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00

back to RGB4, better logging

This commit is contained in:
milek7
2018-08-02 22:27:28 +02:00
parent 97cf5cbb60
commit d7c7305906
5 changed files with 26 additions and 8 deletions

View File

@@ -119,6 +119,14 @@ void ErrorLog( const char *str, logtype const Type ) {
errors.flush();
};
void LogsFlush()
{
if (output.is_open())
output.flush();
if (errors.is_open())
errors.flush();
}
void Error(const std::string &asMessage, bool box)
{
// if (box)

1
Logs.h
View File

@@ -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 CommLog( const char *str );
void CommLog( const std::string &str );
void LogsFlush();

View File

@@ -298,6 +298,8 @@ eu07_application::run()
Timer::subsystem.mainloop_total.stop();
}
LogsFlush();
return 0;
}

21
map.cpp
View File

@@ -6,15 +6,17 @@
#include "Train.h"
#include "Camera.h"
void map::init()
bool map::init()
{
WriteLog("initializing map gfx...");
gl::shader vert("map.vert");
gl::shader frag("map.frag");
gl::program *prog = new gl::program({vert, frag});
m_shader = std::unique_ptr<gl::program>(prog);
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->attach(*m_tex, GL_COLOR_ATTACHMENT0);
@@ -24,13 +26,13 @@ void map::init()
if (!m_fb->is_complete())
{
ErrorLog("map framebuffer incomplete");
throw std::runtime_error("map framebuffer incomplete");
return false;
}
if (Global.iMultisampling)
{
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->attach(*m_msaa_rb, GL_COLOR_ATTACHMENT0);
@@ -40,11 +42,15 @@ void map::init()
if (!m_msaa_fb->is_complete())
{
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);
WriteLog("map init ok");
return true;
}
float map::get_vehicle_rotation()
@@ -61,8 +67,9 @@ void map::render(scene::basic_region *Region)
if (!map_opened)
return;
if (!m_shader)
init();
if (!scene_ubo)
if (!init())
return;
ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(fb_size, fb_size));
if (ImGui::Begin("Map", &map_opened, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse))

2
map.h
View File

@@ -24,7 +24,7 @@ class map
float zoom = 1.0f / 1000.0f;
float get_vehicle_rotation();
void init();
bool init();
cFrustum frustum;
public: