multi viewports (temporaily disable VAO)

This commit is contained in:
milek7
2019-03-12 00:53:34 +01:00
parent 3693c1660e
commit e85d588851
14 changed files with 314 additions and 173 deletions

View File

@@ -833,6 +833,17 @@ global_settings::ConfigParse(cParser &Parser) {
Parser >> network_client->first; Parser >> network_client->first;
Parser >> network_client->second; Parser >> network_client->second;
} }
else if (token == "extraviewport")
{
Parser.getTokens(3 + 16, false);
extraviewport_config conf;
Parser >> conf.monitor >> conf.width >> conf.height;
for (size_t i = 0; i < 16; i++)
Parser >> conf.transform[i / 4][i % 4];
extra_viewports.push_back(conf);
}
} while ((token != "") && (token != "endconfig")); //(!Parser->EndOfFile) } while ((token != "") && (token != "endconfig")); //(!Parser->EndOfFile)
// na koniec trochę zależności // na koniec trochę zależności
if (!bLoadTraction) // wczytywanie drutów i słupów if (!bLoadTraction) // wczytywanie drutów i słupów

View File

@@ -202,6 +202,15 @@ struct global_settings {
bool gfx_shadergamma = false; bool gfx_shadergamma = false;
bool gfx_usegles = false; bool gfx_usegles = false;
struct extraviewport_config {
std::string monitor;
int width;
int height;
glm::mat4 transform;
};
std::vector<extraviewport_config> extra_viewports;
std::vector<std::pair<std::string, std::string>> network_servers; std::vector<std::pair<std::string, std::string>> network_servers;
std::optional<std::pair<std::string, std::string>> network_client; std::optional<std::pair<std::string, std::string>> network_client;

View File

@@ -470,7 +470,7 @@ void eu07_application::on_focus_change(bool focus) {
} }
GLFWwindow * GLFWwindow *
eu07_application::window( int const Windowindex ) { eu07_application::window( int const Windowindex, bool visible, int width, int height, GLFWmonitor *monitor ) {
if( Windowindex >= 0 ) { if( Windowindex >= 0 ) {
return ( return (
@@ -479,14 +479,36 @@ eu07_application::window( int const Windowindex ) {
nullptr ); nullptr );
} }
// for index -1 create a new child window // for index -1 create a new child window
glfwWindowHint( GLFW_VISIBLE, GL_FALSE );
auto *childwindow = glfwCreateWindow( 1, 1, "eu07helper", nullptr, m_windows.front() ); glfwWindowHint( GLFW_VISIBLE, visible );
auto *childwindow = glfwCreateWindow( width, height, "eu07helper", monitor, m_windows.front() );
if( childwindow != nullptr ) { if( childwindow != nullptr ) {
m_windows.emplace_back( childwindow ); m_windows.emplace_back( childwindow );
} }
return childwindow; return childwindow;
} }
GLFWmonitor* eu07_application::find_monitor(const std::string &str) {
int monitor_count;
GLFWmonitor **monitors = glfwGetMonitors(&monitor_count);
for (size_t i = 0; i < monitor_count; i++) {
std::string name(glfwGetMonitorName(monitors[i]));
std::replace(std::begin(name), std::end(name), ' ', '_');
int x, y;
glfwGetMonitorPos(monitors[i], &x, &y);
std::string desc = name + ":" + std::to_string(x) + "," + std::to_string(y);
if (desc == str)
return monitors[i];
}
return nullptr;
}
// private: // private:
void void

View File

@@ -78,7 +78,9 @@ public:
on_focus_change(bool focus); on_focus_change(bool focus);
// gives access to specified window, creates a new window if index == -1 // gives access to specified window, creates a new window if index == -1
GLFWwindow * GLFWwindow *
window( int const Windowindex = 0 ); window(int const Windowindex = 0 , bool visible = false, int width = 1, int height = 1, GLFWmonitor *monitor = nullptr);
GLFWmonitor *
find_monitor(const std::string &str);
// generate network sync verification number // generate network sync verification number
double double
generate_sync(); generate_sync();

View File

@@ -6,7 +6,7 @@ namespace gl
class bindable class bindable
{ {
protected: protected:
static bindable<T>* active; thread_local static bindable<T>* active;
public: public:
void bind() void bind()
@@ -23,5 +23,5 @@ namespace gl
} }
}; };
template <typename T> bindable<T>* bindable<T>::active; template <typename T> thread_local bindable<T>* bindable<T>::active;
} }

View File

@@ -79,4 +79,4 @@ void gl::buffer::download(targets target, void *data, int offset, int size)
} }
} }
GLuint gl::buffer::binding_points[13]; thread_local GLuint gl::buffer::binding_points[13];

View File

@@ -7,7 +7,7 @@ namespace gl
{ {
class buffer : public object class buffer : public object
{ {
static GLuint binding_points[13]; thread_local static GLuint binding_points[13];
public: public:
enum targets enum targets

View File

@@ -1,24 +1,72 @@
#include "stdafx.h" #include "stdafx.h"
#include "vao.h" #include "vao.h"
/*
gl::vao::vao() gl::vao::vao()
{ {
glGenVertexArrays(1, *this); glGenVertexArrays(1, *this);
} }
gl::vao::~vao() gl::vao::~vao()
{ {
glDeleteVertexArrays(1, *this); glDeleteVertexArrays(1, *this);
} }
void gl::vao::setup_attrib(int attrib, int size, int type, int stride, int offset) void gl::vao::setup_attrib(gl::buffer &buffer, int attrib, int size, int type, int stride, int offset)
{ {
bind(); bind();
glVertexAttribPointer(attrib, size, type, GL_FALSE, stride, reinterpret_cast<void*>(offset)); buffer.bind(gl::buffer::ARRAY_BUFFER);
glEnableVertexAttribArray(attrib); glVertexAttribPointer(attrib, size, type, GL_FALSE, stride, reinterpret_cast<void*>(offset));
glEnableVertexAttribArray(attrib);
}
void gl::vao::setup_ebo(buffer &ebo)
{
bind();
ebo.bind(gl::buffer::ELEMENT_ARRAY_BUFFER);
} }
void gl::vao::bind(GLuint i) void gl::vao::bind(GLuint i)
{ {
glBindVertexArray(i); glBindVertexArray(i);
}
*/
void gl::vao::setup_attrib(gl::buffer &buffer, int attrib, int size, int type, int stride, int offset)
{
params.push_back({buffer, attrib, size, type, stride, offset});
active = nullptr;
}
void gl::vao::setup_ebo(buffer &e)
{
ebo = &e;
active = nullptr;
}
void gl::vao::bind()
{
if (active == this)
return;
active = this;
for (attrib_params &param : params) {
param.buffer.bind(gl::buffer::ARRAY_BUFFER);
glVertexAttribPointer(param.attrib, param.size, param.type, GL_FALSE, param.stride, reinterpret_cast<void*>(param.offset));
glEnableVertexAttribArray(param.attrib);
}
for (size_t i = params.size(); i < 4; i++)
glDisableVertexAttribArray(i);
if (ebo)
ebo->bind(gl::buffer::ELEMENT_ARRAY_BUFFER);
else
gl::buffer::unbind(gl::buffer::ELEMENT_ARRAY_BUFFER);
}
void gl::vao::unbind()
{
active = nullptr;
} }

View File

@@ -2,18 +2,36 @@
#include "object.h" #include "object.h"
#include "bindable.h" #include "bindable.h"
#include "buffer.h"
namespace gl namespace gl
{ {
class vao : public object, public bindable<vao> class vao : public bindable<vao>
{ {
struct attrib_params {
// TBD: should be shared_ptr? (when buffer is destroyed by owner VAO could still potentially exist)
gl::buffer &buffer;
int attrib;
int size;
int type;
int stride;
int offset;
};
buffer *ebo = nullptr;
std::vector<attrib_params> params;
public: public:
vao(); //vao();
~vao(); //~vao();
void setup_attrib(int attrib, int size, int type, int stride, int offset); void setup_attrib(buffer &buffer, int attrib, int size, int type, int stride, int offset);
void setup_ebo(buffer &ebo);
using bindable::bind; //using bindable::bind;
static void bind(GLuint i); void bind();
static void unbind();
//static void bind(GLuint i);
}; };
} }

View File

@@ -280,13 +280,12 @@ void opengl_vbogeometrybank::setup_buffer()
if (!m_vao) if (!m_vao)
{ {
m_vao.emplace(); m_vao.emplace();
m_buffer->bind(gl::buffer::ARRAY_BUFFER);
m_vao->setup_attrib(0, 3, GL_FLOAT, sizeof(basic_vertex), 0 * sizeof(GL_FLOAT)); m_vao->setup_attrib(*m_buffer, 0, 3, GL_FLOAT, sizeof(basic_vertex), 0 * sizeof(GL_FLOAT));
// NOTE: normal and color streams share the data // NOTE: normal and color streams share the data
m_vao->setup_attrib(1, 3, GL_FLOAT, sizeof(basic_vertex), 3 * sizeof(GL_FLOAT)); m_vao->setup_attrib(*m_buffer, 1, 3, GL_FLOAT, sizeof(basic_vertex), 3 * sizeof(GL_FLOAT));
m_vao->setup_attrib(2, 2, GL_FLOAT, sizeof(basic_vertex), 6 * sizeof(GL_FLOAT)); m_vao->setup_attrib(*m_buffer, 2, 2, GL_FLOAT, sizeof(basic_vertex), 6 * sizeof(GL_FLOAT));
m_vao->setup_attrib(3, 4, GL_FLOAT, sizeof(basic_vertex), 8 * sizeof(GL_FLOAT)); m_vao->setup_attrib(*m_buffer, 3, 4, GL_FLOAT, sizeof(basic_vertex), 8 * sizeof(GL_FLOAT));
m_buffer->unbind(gl::buffer::ARRAY_BUFFER); m_buffer->unbind(gl::buffer::ARRAY_BUFFER);
m_vao->unbind(); m_vao->unbind();

View File

@@ -186,20 +186,18 @@ basic_precipitation::render() {
m_vertexbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_vertices.size() * sizeof( glm::vec3 ), GL_STATIC_DRAW); m_vertexbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_vertices.size() * sizeof( glm::vec3 ), GL_STATIC_DRAW);
m_vertexbuffer->upload(gl::buffer::ARRAY_BUFFER, m_vertices.data(), 0, m_vertices.size() * sizeof( glm::vec3 )); m_vertexbuffer->upload(gl::buffer::ARRAY_BUFFER, m_vertices.data(), 0, m_vertices.size() * sizeof( glm::vec3 ));
m_vertexbuffer->bind(gl::buffer::ARRAY_BUFFER); m_vao->setup_attrib(*m_vertexbuffer, 0, 3, GL_FLOAT, sizeof(glm::vec3), 0);
m_vao->setup_attrib(0, 3, GL_FLOAT, sizeof(glm::vec3), 0);
m_uvbuffer.emplace(); m_uvbuffer.emplace();
m_uvbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_uvs.size() * sizeof( glm::vec2 ), GL_STATIC_DRAW); m_uvbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_uvs.size() * sizeof( glm::vec2 ), GL_STATIC_DRAW);
m_uvbuffer->upload(gl::buffer::ARRAY_BUFFER, m_uvs.data(), 0, m_uvs.size() * sizeof( glm::vec2 )); m_uvbuffer->upload(gl::buffer::ARRAY_BUFFER, m_uvs.data(), 0, m_uvs.size() * sizeof( glm::vec2 ));
m_uvbuffer->bind(gl::buffer::ARRAY_BUFFER); m_vao->setup_attrib(*m_uvbuffer, 1, 2, GL_FLOAT, sizeof(glm::vec2), 0);
m_vao->setup_attrib(1, 2, GL_FLOAT, sizeof(glm::vec2), 0);
m_indexbuffer.emplace(); m_indexbuffer.emplace();
m_indexbuffer->allocate(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), GL_STATIC_DRAW); m_indexbuffer->allocate(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), GL_STATIC_DRAW);
m_indexbuffer->upload(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.data(), 0, m_indices.size() * sizeof( unsigned short )); m_indexbuffer->upload(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.data(), 0, m_indices.size() * sizeof( unsigned short ));
m_indexbuffer->bind(gl::buffer::ELEMENT_ARRAY_BUFFER); m_vao->setup_ebo(*m_indexbuffer);
m_vao->unbind(); m_vao->unbind();
// NOTE: vertex and index source data is superfluous past this point, but, eh // NOTE: vertex and index source data is superfluous past this point, but, eh

View File

@@ -64,13 +64,6 @@ bool opengl_camera::visible(TDynamicObject const *Dynamic) const
void opengl_camera::draw(glm::vec3 const &Offset) const void opengl_camera::draw(glm::vec3 const &Offset) const
{ {
// m7t port to core gl // m7t port to core gl
/*
::glBegin( GL_LINES );
for( auto const pointindex : frustumshapepoinstorder ) {
::glVertex3fv( glm::value_ptr( glm::vec3{ m_frustumpoints[ pointindex ] } - Offset ) );
}
::glEnd();
*/
} }
bool opengl_renderer::Init(GLFWwindow *Window) bool opengl_renderer::Init(GLFWwindow *Window)
@@ -82,33 +75,6 @@ bool opengl_renderer::Init(GLFWwindow *Window)
m_window = Window; m_window = Window;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glClearColor(51.0f / 255.0f, 102.0f / 255.0f, 85.0f / 255.0f, 1.0f); // initial background Color
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
if (!Global.gfx_usegles)
glClearDepth(0.0f);
else
glClearDepthf(0.0f);
glDepthFunc(GL_GEQUAL);
if (GLAD_GL_ARB_clip_control)
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
else if (GLAD_GL_EXT_clip_control)
glClipControlEXT(GL_LOWER_LEFT_EXT, GL_ZERO_TO_ONE_EXT);
if (!Global.gfx_usegles)
glEnable(GL_PROGRAM_POINT_SIZE);
gl::glsl_common_setup(); gl::glsl_common_setup();
if (true == Global.ScaleSpecularValues) if (true == Global.ScaleSpecularValues)
@@ -127,7 +93,6 @@ bool opengl_renderer::Init(GLFWwindow *Window)
// create dynamic light pool // create dynamic light pool
for (int idx = 0; idx < Global.DynamicLightCount; ++idx) for (int idx = 0; idx < Global.DynamicLightCount; ++idx)
{ {
opengl_light light; opengl_light light;
light.id = 1 + idx; light.id = 1 + idx;
@@ -199,23 +164,71 @@ bool opengl_renderer::Init(GLFWwindow *Window)
viewport_config &default_viewport = *m_viewports.front().get(); viewport_config &default_viewport = *m_viewports.front().get();
default_viewport.width = Global.gfx_framebuffer_width; default_viewport.width = Global.gfx_framebuffer_width;
default_viewport.height = Global.gfx_framebuffer_height; default_viewport.height = Global.gfx_framebuffer_height;
default_viewport.main = true;
default_viewport.window = m_window;
/* for (const global_settings::extraviewport_config &conf : Global.extra_viewports) {
default_viewport.camera_transform = glm::rotate(glm::mat4(), 0.5f, glm::vec3(1.0f, 0.0f, 0.f)); m_viewports.push_back(std::make_unique<viewport_config>());
viewport_config &vp = *m_viewports.back().get();
m_viewports.push_back(std::make_unique<viewport_config>()); vp.width = conf.width;
viewport_config &vp2 = *m_viewports.back().get(); vp.height = conf.height;
vp2.width = Global.gfx_framebuffer_width; vp.window = Application.window(-1, true, vp.width, vp.height, Application.find_monitor(conf.monitor));
vp2.height = Global.gfx_framebuffer_height; vp.camera_transform = conf.transform;
std::cout << "ZXZ " << glm::to_string(vp.camera_transform) << std::endl;
vp2.camera_transform = glm::rotate(glm::mat4(), -0.5f, glm::vec3(1.0f, 0.0f, 0.f)); }
*/
for (auto &viewport : m_viewports) { for (auto &viewport : m_viewports) {
if (!init_viewport(*viewport.get())) if (!init_viewport(*viewport.get()))
return false; return false;
} }
glfwMakeContextCurrent(m_window);
if (Global.gfx_shadowmap_enabled)
{
m_shadow_fb = std::make_unique<gl::framebuffer>();
m_shadow_tex = std::make_unique<opengl_texture>();
m_shadow_tex->alloc_rendertarget(Global.gfx_format_depth, GL_DEPTH_COMPONENT, m_shadowbuffersize, m_shadowbuffersize);
m_shadow_fb->attach(*m_shadow_tex, GL_DEPTH_ATTACHMENT);
if (!m_shadow_fb->is_complete())
return false;
WriteLog("shadows enabled");
m_cabshadows_fb = std::make_unique<gl::framebuffer>();
m_cabshadows_tex = std::make_unique<opengl_texture>();
m_cabshadows_tex->alloc_rendertarget(Global.gfx_format_depth, GL_DEPTH_COMPONENT, m_shadowbuffersize, m_shadowbuffersize);
m_cabshadows_fb->attach(*m_cabshadows_tex, GL_DEPTH_ATTACHMENT);
if (!m_cabshadows_fb->is_complete())
return false;
WriteLog("cabshadows enabled");
}
if (Global.gfx_envmap_enabled)
{
m_env_rb = std::make_unique<gl::renderbuffer>();
m_env_rb->alloc(Global.gfx_format_depth, gl::ENVMAP_SIZE, gl::ENVMAP_SIZE);
m_env_tex = std::make_unique<gl::cubemap>();
m_env_tex->alloc(Global.gfx_format_color, gl::ENVMAP_SIZE, gl::ENVMAP_SIZE, GL_RGB, GL_FLOAT);
m_env_fb = std::make_unique<gl::framebuffer>();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
for (int i = 0; i < 6; i++)
{
m_env_fb->attach(*m_empty_cubemap, i, GL_COLOR_ATTACHMENT0);
m_env_fb->clear(GL_COLOR_BUFFER_BIT);
}
m_env_fb->detach(GL_COLOR_ATTACHMENT0);
m_env_fb->attach(*m_env_rb, GL_DEPTH_ATTACHMENT);
WriteLog("envmap enabled");
}
m_pick_tex = std::make_unique<opengl_texture>(); m_pick_tex = std::make_unique<opengl_texture>();
m_pick_tex->alloc_rendertarget(GL_RGB8, GL_RGB, EU07_PICKBUFFERSIZE, EU07_PICKBUFFERSIZE); m_pick_tex->alloc_rendertarget(GL_RGB8, GL_RGB, EU07_PICKBUFFERSIZE, EU07_PICKBUFFERSIZE);
m_pick_rb = std::make_unique<gl::renderbuffer>(); m_pick_rb = std::make_unique<gl::renderbuffer>();
@@ -290,8 +303,49 @@ bool opengl_renderer::Init(GLFWwindow *Window)
bool opengl_renderer::init_viewport(viewport_config &vp) bool opengl_renderer::init_viewport(viewport_config &vp)
{ {
glfwMakeContextCurrent(vp.window);
WriteLog("init viewport: " + std::to_string(vp.width) + ", " + std::to_string(vp.height));
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glClearColor(51.0f / 255.0f, 102.0f / 255.0f, 85.0f / 255.0f, 1.0f); // initial background Color
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
if (!Global.gfx_usegles)
glClearDepth(0.0f);
else
glClearDepthf(0.0f);
glDepthFunc(GL_GEQUAL);
if (GLAD_GL_ARB_clip_control)
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
else if (GLAD_GL_EXT_clip_control)
glClipControlEXT(GL_LOWER_LEFT_EXT, GL_ZERO_TO_ONE_EXT);
if (!Global.gfx_usegles)
glEnable(GL_PROGRAM_POINT_SIZE);
{
GLuint v;
glGenVertexArrays(1, &v);
glBindVertexArray(v);
}
int samples = 1 << Global.iMultisampling; int samples = 1 << Global.iMultisampling;
model_ubo->bind_uniform();
scene_ubo->bind_uniform();
light_ubo->bind_uniform();
if (!Global.gfx_skippipeline) if (!Global.gfx_skippipeline)
{ {
vp.msaa_rbc = std::make_unique<gl::renderbuffer>(); vp.msaa_rbc = std::make_unique<gl::renderbuffer>();
@@ -339,49 +393,6 @@ bool opengl_renderer::init_viewport(viewport_config &vp)
return false; return false;
} }
if (Global.gfx_shadowmap_enabled)
{
vp.shadow_fb = std::make_unique<gl::framebuffer>();
vp.shadow_tex = std::make_unique<opengl_texture>();
vp.shadow_tex->alloc_rendertarget(Global.gfx_format_depth, GL_DEPTH_COMPONENT, m_shadowbuffersize, m_shadowbuffersize);
vp.shadow_fb->attach(*vp.shadow_tex, GL_DEPTH_ATTACHMENT);
if (!vp.shadow_fb->is_complete())
return false;
vp.cabshadows_fb = std::make_unique<gl::framebuffer>();
vp.cabshadows_tex = std::make_unique<opengl_texture>();
vp.cabshadows_tex->alloc_rendertarget(Global.gfx_format_depth, GL_DEPTH_COMPONENT, m_shadowbuffersize, m_shadowbuffersize);
vp.cabshadows_fb->attach(*vp.cabshadows_tex, GL_DEPTH_ATTACHMENT);
if (!vp.cabshadows_fb->is_complete())
return false;
WriteLog("shadows enabled");
}
if (Global.gfx_envmap_enabled)
{
vp.env_rb = std::make_unique<gl::renderbuffer>();
vp.env_rb->alloc(Global.gfx_format_depth, gl::ENVMAP_SIZE, gl::ENVMAP_SIZE);
vp.env_tex = std::make_unique<gl::cubemap>();
vp.env_tex->alloc(Global.gfx_format_color, gl::ENVMAP_SIZE, gl::ENVMAP_SIZE, GL_RGB, GL_FLOAT);
vp.env_fb = std::make_unique<gl::framebuffer>();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
for (int i = 0; i < 6; i++)
{
vp.env_fb->attach(*m_empty_cubemap, i, GL_COLOR_ATTACHMENT0);
vp.env_fb->clear(GL_COLOR_BUFFER_BIT);
}
vp.env_fb->detach(GL_COLOR_ATTACHMENT0);
vp.env_fb->attach(*vp.env_rb, GL_DEPTH_ATTACHMENT);
WriteLog("envmap enabled");
}
return true; return true;
} }
@@ -432,7 +443,9 @@ bool opengl_renderer::Render()
for (auto &viewport : m_viewports) { for (auto &viewport : m_viewports) {
Render_pass(*viewport.get(), rendermode::color); Render_pass(*viewport.get(), rendermode::color);
} }
//Render_pass(*m_viewports.front().get(), rendermode::color);
glfwMakeContextCurrent(m_window);
m_current_viewport = &(*m_viewports.front());
m_drawcount = m_cellqueue.size(); m_drawcount = m_cellqueue.size();
m_debugtimestext.clear(); m_debugtimestext.clear();
@@ -466,7 +479,12 @@ bool opengl_renderer::Render()
void opengl_renderer::SwapBuffers() void opengl_renderer::SwapBuffers()
{ {
Timer::subsystem.gfx_swap.start(); Timer::subsystem.gfx_swap.start();
glfwSwapBuffers(m_window);
for (auto &viewport : m_viewports) {
if (viewport->window)
glfwSwapBuffers(viewport->window);
}
// 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::opengl_vbogeometrybank::reset(); gfx::opengl_vbogeometrybank::reset();
Timer::subsystem.gfx_swap.stop(); Timer::subsystem.gfx_swap.stop();
@@ -505,8 +523,15 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
{ {
glDebug("rendermode::color"); glDebug("rendermode::color");
glDebug("context switch");
glfwMakeContextCurrent(vp.window);
m_current_viewport = &vp;
if (!simulation::is_ready) if (!simulation::is_ready)
{ {
if (!vp.main)
break;
gl::framebuffer::unbind(); gl::framebuffer::unbind();
glClearColor(0.0f, 0.5f, 0.0f, 1.0f); glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -532,7 +557,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
setup_shadow_map(nullptr, m_renderpass); setup_shadow_map(nullptr, m_renderpass);
setup_env_map(nullptr); setup_env_map(nullptr);
if (Global.gfx_shadowmap_enabled) if (Global.gfx_shadowmap_enabled && vp.main)
{ {
glDebug("render shadowmap start"); glDebug("render shadowmap start");
Timer::subsystem.gfx_shadows.start(); Timer::subsystem.gfx_shadows.start();
@@ -546,12 +571,12 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glDebug("render shadowmap end"); glDebug("render shadowmap end");
} }
if (Global.gfx_envmap_enabled) if (Global.gfx_envmap_enabled && vp.main)
{ {
// potentially update environmental cube map // potentially update environmental cube map
if (Render_reflections(vp)) if (Render_reflections(vp))
setup_pass(vp, m_renderpass, Mode); // restore color pass settings setup_pass(vp, m_renderpass, Mode); // restore color pass settings
setup_env_map(vp.env_tex.get()); setup_env_map(m_env_tex.get());
} }
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -566,7 +591,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
else else
vp.msaa_fb->setup_drawing(1); vp.msaa_fb->setup_drawing(1);
glViewport(0, 0, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height); glViewport(0, 0, vp.width, vp.height);
vp.msaa_fb->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); vp.msaa_fb->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
} }
@@ -575,7 +600,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
if (!Global.gfx_usegles && !Global.gfx_shadergamma) if (!Global.gfx_usegles && !Global.gfx_shadergamma)
glEnable(GL_FRAMEBUFFER_SRGB); glEnable(GL_FRAMEBUFFER_SRGB);
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, Global.iWindowWidth, Global.iWindowHeight); glViewport(0, 0, vp.width, vp.height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
} }
@@ -610,7 +635,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
{ {
glDebug("render cab opaque"); glDebug("render cab opaque");
if (Global.gfx_shadowmap_enabled) if (Global.gfx_shadowmap_enabled)
setup_shadow_map(vp.cabshadows_tex.get(), m_cabshadowpass); setup_shadow_map(m_cabshadows_tex.get(), m_cabshadowpass);
auto const *vehicle = simulation::Train->Dynamic(); auto const *vehicle = simulation::Train->Dynamic();
Render_cab(vehicle, vehicle->InteriorLightLevel, false); Render_cab(vehicle, vehicle->InteriorLightLevel, false);
@@ -621,7 +646,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
model_ubs.future = future; model_ubs.future = future;
if (Global.gfx_shadowmap_enabled) if (Global.gfx_shadowmap_enabled)
setup_shadow_map(vp.shadow_tex.get(), m_shadowpass); setup_shadow_map(m_shadow_tex.get(), m_shadowpass);
Render(simulation::Region); Render(simulation::Region);
@@ -639,7 +664,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glDebug("render translucent cab"); glDebug("render translucent cab");
model_ubs.future = glm::mat4(); model_ubs.future = glm::mat4();
if (Global.gfx_shadowmap_enabled) if (Global.gfx_shadowmap_enabled)
setup_shadow_map(vp.cabshadows_tex.get(), m_cabshadowpass); setup_shadow_map(m_cabshadows_tex.get(), m_cabshadowpass);
// cache shadow colour in case we need to account for cab light // cache shadow colour in case we need to account for cab light
auto const *vehicle{simulation::Train->Dynamic()}; auto const *vehicle{simulation::Train->Dynamic()};
if (Global.Overcast > 1.0f) if (Global.Overcast > 1.0f)
@@ -665,8 +690,8 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
if (Global.gfx_postfx_motionblur_enabled) if (Global.gfx_postfx_motionblur_enabled)
{ {
vp.main_fb->clear(GL_COLOR_BUFFER_BIT); vp.main_fb->clear(GL_COLOR_BUFFER_BIT);
vp.msaa_fb->blit_to(vp.main_fb.get(), Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT0); vp.msaa_fb->blit_to(vp.main_fb.get(), vp.width, vp.height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT0);
vp.msaa_fb->blit_to(vp.main_fb.get(), Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT1); vp.msaa_fb->blit_to(vp.main_fb.get(), vp.width, vp.height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT1);
model_ubs.param[0].x = m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter); model_ubs.param[0].x = m_framerate / (1.0 / Global.gfx_postfx_motionblur_shutter);
model_ubo->update(model_ubs); model_ubo->update(model_ubs);
@@ -675,12 +700,12 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
else else
{ {
vp.main2_fb->clear(GL_COLOR_BUFFER_BIT); vp.main2_fb->clear(GL_COLOR_BUFFER_BIT);
vp.msaa_fb->blit_to(vp.main2_fb.get(), Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT0); vp.msaa_fb->blit_to(vp.main2_fb.get(), vp.width, vp.height, GL_COLOR_BUFFER_BIT, GL_COLOR_ATTACHMENT0);
} }
if (!Global.gfx_usegles && !Global.gfx_shadergamma) if (!Global.gfx_usegles && !Global.gfx_shadergamma)
glEnable(GL_FRAMEBUFFER_SRGB); glEnable(GL_FRAMEBUFFER_SRGB);
glViewport(0, 0, Global.iWindowWidth, Global.iWindowHeight); glViewport(0, 0, vp.width, vp.height);
m_pfx_tonemapping->apply(*vp.main2_tex, nullptr); m_pfx_tonemapping->apply(*vp.main2_tex, nullptr);
opengl_texture::reset_unit_cache(); opengl_texture::reset_unit_cache();
} }
@@ -691,8 +716,10 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glDebug("uilayer render"); glDebug("uilayer render");
Timer::subsystem.gfx_gui.start(); Timer::subsystem.gfx_gui.start();
draw_debug_ui(); if (vp.main) {
Application.render_ui(); draw_debug_ui();
Application.render_ui();
}
Timer::subsystem.gfx_gui.stop(); Timer::subsystem.gfx_gui.stop();
@@ -716,8 +743,8 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glViewport(0, 0, m_shadowbuffersize, m_shadowbuffersize); glViewport(0, 0, m_shadowbuffersize, m_shadowbuffersize);
vp.shadow_fb->bind(); m_shadow_fb->bind();
vp.shadow_fb->clear(GL_DEPTH_BUFFER_BIT); m_shadow_fb->clear(GL_DEPTH_BUFFER_BIT);
setup_matrices(); setup_matrices();
setup_drawing(false); setup_drawing(false);
@@ -734,7 +761,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
vp.shadow_fb->unbind(); m_shadow_fb->unbind();
glDebug("rendermodeshadows ::end"); glDebug("rendermodeshadows ::end");
@@ -751,8 +778,8 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glViewport(0, 0, m_shadowbuffersize, m_shadowbuffersize); glViewport(0, 0, m_shadowbuffersize, m_shadowbuffersize);
vp.cabshadows_fb->bind(); m_cabshadows_fb->bind();
vp.cabshadows_fb->clear(GL_DEPTH_BUFFER_BIT); m_cabshadows_fb->clear(GL_DEPTH_BUFFER_BIT);
setup_matrices(); setup_matrices();
setup_drawing(false); setup_drawing(false);
@@ -766,7 +793,7 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
vp.cabshadows_fb->unbind(); m_cabshadows_fb->unbind();
glDebug("rendermode::cabshadows end"); glDebug("rendermode::cabshadows end");
@@ -783,8 +810,8 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
// NOTE: buffer attachment and viewport setup in this mode is handled by the wrapper method // NOTE: buffer attachment and viewport setup in this mode is handled by the wrapper method
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
vp.env_fb->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_env_fb->clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
vp.env_fb->bind(); m_env_fb->bind();
setup_env_map(m_empty_cubemap.get()); setup_env_map(m_empty_cubemap.get());
@@ -800,13 +827,13 @@ void opengl_renderer::Render_pass(viewport_config &vp, rendermode const Mode)
// opaque parts... // opaque parts...
setup_drawing(false); setup_drawing(false);
setup_shadow_map(vp.shadow_tex.get(), m_shadowpass); setup_shadow_map(m_shadow_tex.get(), m_shadowpass);
scene_ubs.projection = OpenGLMatrices.data(GL_PROJECTION); scene_ubs.projection = OpenGLMatrices.data(GL_PROJECTION);
scene_ubo->update(scene_ubs); scene_ubo->update(scene_ubs);
Render(simulation::Region); Render(simulation::Region);
vp.env_fb->unbind(); m_env_fb->unbind();
glDebug("rendermode::reflections end"); glDebug("rendermode::reflections end");
@@ -891,12 +918,12 @@ bool opengl_renderer::Render_reflections(viewport_config &vp)
glViewport(0, 0, gl::ENVMAP_SIZE, gl::ENVMAP_SIZE); glViewport(0, 0, gl::ENVMAP_SIZE, gl::ENVMAP_SIZE);
for (m_environmentcubetextureface = 0; m_environmentcubetextureface < 6; ++m_environmentcubetextureface) for (m_environmentcubetextureface = 0; m_environmentcubetextureface < 6; ++m_environmentcubetextureface)
{ {
vp.env_fb->attach(*vp.env_tex, m_environmentcubetextureface, GL_COLOR_ATTACHMENT0); m_env_fb->attach(*m_env_tex, m_environmentcubetextureface, GL_COLOR_ATTACHMENT0);
if (vp.env_fb->is_complete()) if (m_env_fb->is_complete())
Render_pass(vp, rendermode::reflections); Render_pass(vp, rendermode::reflections);
} }
vp.env_tex->generate_mipmaps(); m_env_tex->generate_mipmaps();
vp.env_fb->detach(GL_COLOR_ATTACHMENT0); m_env_fb->detach(GL_COLOR_ATTACHMENT0);
return true; return true;
} }
@@ -1720,7 +1747,7 @@ void opengl_renderer::Render(scene::basic_region *Region)
Render(std::begin(m_sectionqueue), std::end(m_sectionqueue)); Render(std::begin(m_sectionqueue), std::end(m_sectionqueue));
// draw queue is filled while rendering sections // draw queue is filled while rendering sections
if (EditorModeFlag) if (EditorModeFlag && m_current_viewport->main)
{ {
// when editor mode is active calculate world position of the cursor // when editor mode is active calculate world position of the cursor
// at this stage the z-buffer is filled with only ground geometry // at this stage the z-buffer is filled with only ground geometry
@@ -3430,6 +3457,11 @@ void opengl_renderer::Render_Alpha(TSubModel *Submodel)
// utility methods // utility methods
void opengl_renderer::Update_Pick_Control() void opengl_renderer::Update_Pick_Control()
{ {
// context-switch workaround
gl::buffer::unbind(gl::buffer::PIXEL_PACK_BUFFER);
gl::buffer::unbind(gl::buffer::PIXEL_UNPACK_BUFFER);
gl::buffer::unbind(gl::buffer::ARRAY_BUFFER);
if (!m_picking_pbo->is_busy()) if (!m_picking_pbo->is_busy())
{ {
unsigned char pickreadout[4]; unsigned char pickreadout[4];
@@ -3548,11 +3580,11 @@ glm::dvec3 opengl_renderer::get_mouse_depth()
} }
else else
{ {
gl::framebuffer::blit(m_current_viewport->msaa_fb.get(), m_depth_pointer_fb.get(), bufferpos.x, bufferpos.y, 1, 1, GL_DEPTH_BUFFER_BIT, 0); gl::framebuffer::blit(m_viewports.front()->msaa_fb.get(), m_depth_pointer_fb.get(), bufferpos.x, bufferpos.y, 1, 1, GL_DEPTH_BUFFER_BIT, 0);
m_depth_pointer_fb->bind(); m_depth_pointer_fb->bind();
m_depth_pointer_pbo->request_read(0, 0, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT); m_depth_pointer_pbo->request_read(0, 0, 1, 1, 4, GL_DEPTH_COMPONENT, GL_FLOAT);
m_current_viewport->msaa_fb->bind(); m_viewports.front()->msaa_fb->bind();
} }
} }
else else
@@ -3577,7 +3609,7 @@ glm::dvec3 opengl_renderer::get_mouse_depth()
} }
else else
{ {
gl::framebuffer::blit(m_current_viewport->msaa_fb.get(), m_depth_pointer_fb.get(), 0, 0, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_DEPTH_BUFFER_BIT, 0); gl::framebuffer::blit(m_viewports.front()->msaa_fb.get(), m_depth_pointer_fb.get(), 0, 0, Global.gfx_framebuffer_width, Global.gfx_framebuffer_height, GL_DEPTH_BUFFER_BIT, 0);
m_empty_vao->bind(); m_empty_vao->bind();
m_depth_pointer_tex->bind(0); m_depth_pointer_tex->bind(0);
@@ -3587,7 +3619,7 @@ glm::dvec3 opengl_renderer::get_mouse_depth()
m_depth_pointer_pbo->request_read(bufferpos.x, bufferpos.y, 1, 1, 16, GL_RGBA_INTEGER, GL_UNSIGNED_INT); m_depth_pointer_pbo->request_read(bufferpos.x, bufferpos.y, 1, 1, 16, GL_RGBA_INTEGER, GL_UNSIGNED_INT);
m_depth_pointer_shader->unbind(); m_depth_pointer_shader->unbind();
m_empty_vao->unbind(); m_empty_vao->unbind();
m_current_viewport->msaa_fb->bind(); m_viewports.front()->msaa_fb->bind();
} }
} }
@@ -3893,7 +3925,7 @@ bool opengl_renderer::Init_caps()
if (Global.gfx_framebuffer_height == -1) if (Global.gfx_framebuffer_height == -1)
Global.gfx_framebuffer_height = Global.iWindowHeight; Global.gfx_framebuffer_height = Global.iWindowHeight;
WriteLog("rendering at " + std::to_string(Global.gfx_framebuffer_width) + "x" + std::to_string(Global.gfx_framebuffer_height)); WriteLog("main window size: " + std::to_string(Global.gfx_framebuffer_width) + "x" + std::to_string(Global.gfx_framebuffer_height));
return true; return true;
} }

View File

@@ -239,6 +239,9 @@ class opengl_renderer
int width; int width;
int height; int height;
bool main = false;
GLFWwindow *window = nullptr;
glm::mat4 camera_transform; glm::mat4 camera_transform;
std::unique_ptr<gl::framebuffer> msaa_fb; std::unique_ptr<gl::framebuffer> msaa_fb;
@@ -252,18 +255,10 @@ class opengl_renderer
std::unique_ptr<gl::framebuffer> main2_fb; std::unique_ptr<gl::framebuffer> main2_fb;
std::unique_ptr<opengl_texture> main2_tex; std::unique_ptr<opengl_texture> main2_tex;
std::unique_ptr<gl::framebuffer> shadow_fb;
std::unique_ptr<opengl_texture> shadow_tex;
std::unique_ptr<gl::framebuffer> cabshadows_fb;
std::unique_ptr<opengl_texture> cabshadows_tex;
std::unique_ptr<gl::framebuffer> env_fb;
std::unique_ptr<gl::renderbuffer> env_rb;
std::unique_ptr<gl::cubemap> env_tex;
}; };
viewport_config *m_current_viewport = nullptr;
typedef std::vector<opengl_light> opengllight_array; typedef std::vector<opengl_light> opengllight_array;
// methods // methods
@@ -315,7 +310,7 @@ class opengl_renderer
void draw_debug_ui(); void draw_debug_ui();
// members // members
GLFWwindow *m_window{nullptr}; GLFWwindow *m_window{nullptr}; // main window
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;
@@ -355,7 +350,6 @@ class opengl_renderer
float m_fogrange = 2000.0f; float m_fogrange = 2000.0f;
renderpass_config m_renderpass; // parameters for current render pass renderpass_config m_renderpass; // parameters for current render pass
viewport_config *m_current_viewport; // active viewport
section_sequence m_sectionqueue; // list of sections in current render pass section_sequence m_sectionqueue; // list of sections in current render pass
cell_sequence m_cellqueue; cell_sequence m_cellqueue;
renderpass_config m_colorpass; // parametrs of most recent color pass renderpass_config m_colorpass; // parametrs of most recent color pass
@@ -415,6 +409,16 @@ class opengl_renderer
std::unique_ptr<gl::cubemap> m_empty_cubemap; std::unique_ptr<gl::cubemap> m_empty_cubemap;
std::unique_ptr<gl::framebuffer> m_cabshadows_fb;
std::unique_ptr<opengl_texture> m_cabshadows_tex;
std::unique_ptr<gl::framebuffer> m_env_fb;
std::unique_ptr<gl::renderbuffer> m_env_rb;
std::unique_ptr<gl::cubemap> m_env_tex;
std::unique_ptr<gl::framebuffer> m_shadow_fb;
std::unique_ptr<opengl_texture> m_shadow_tex;
std::unique_ptr<gl::pbo> m_picking_pbo; std::unique_ptr<gl::pbo> m_picking_pbo;
std::unique_ptr<gl::pbo> m_picking_node_pbo; std::unique_ptr<gl::pbo> m_picking_node_pbo;

View File

@@ -132,22 +132,20 @@ void CSkyDome::Render() {
m_vertexbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_vertices.size() * sizeof( glm::vec3 ), GL_STATIC_DRAW); m_vertexbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_vertices.size() * sizeof( glm::vec3 ), GL_STATIC_DRAW);
m_vertexbuffer->upload(gl::buffer::ARRAY_BUFFER, m_vertices.data(), 0, m_vertices.size() * sizeof( glm::vec3 )); m_vertexbuffer->upload(gl::buffer::ARRAY_BUFFER, m_vertices.data(), 0, m_vertices.size() * sizeof( glm::vec3 ));
m_vertexbuffer->bind(gl::buffer::ARRAY_BUFFER); m_vao->setup_attrib(*m_vertexbuffer, 0, 3, GL_FLOAT, sizeof(glm::vec3), 0);
m_vao->setup_attrib(0, 3, GL_FLOAT, sizeof(glm::vec3), 0);
m_coloursbuffer.emplace(); m_coloursbuffer.emplace();
m_coloursbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_colours.size() * sizeof( glm::vec3 ), GL_STATIC_DRAW); m_coloursbuffer->allocate(gl::buffer::ARRAY_BUFFER, m_colours.size() * sizeof( glm::vec3 ), GL_STATIC_DRAW);
m_coloursbuffer->upload(gl::buffer::ARRAY_BUFFER, m_colours.data(), 0, m_colours.size() * sizeof( glm::vec3 )); m_coloursbuffer->upload(gl::buffer::ARRAY_BUFFER, m_colours.data(), 0, m_colours.size() * sizeof( glm::vec3 ));
m_coloursbuffer->bind(gl::buffer::ARRAY_BUFFER); m_vao->setup_attrib(*m_coloursbuffer, 1, 3, GL_FLOAT, sizeof(glm::vec3), 0);
m_vao->setup_attrib(1, 3, GL_FLOAT, sizeof(glm::vec3), 0);
m_indexbuffer.emplace(); m_indexbuffer.emplace();
m_indexbuffer->allocate(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), GL_STATIC_DRAW); m_indexbuffer->allocate(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), GL_STATIC_DRAW);
m_indexbuffer->upload(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.data(), 0, m_indices.size() * sizeof( unsigned short )); m_indexbuffer->upload(gl::buffer::ELEMENT_ARRAY_BUFFER, m_indices.data(), 0, m_indices.size() * sizeof( unsigned short ));
m_indexbuffer->bind(gl::buffer::ELEMENT_ARRAY_BUFFER); m_vao->setup_ebo(*m_indexbuffer);
m_vao->unbind(); m_vao->unbind();
} }
m_shader->bind(); m_shader->bind();