16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 00:09:18 +02:00
This commit is contained in:
milek7
2018-07-14 17:00:54 +02:00
parent a81499f7e5
commit 4566375faa
14 changed files with 157 additions and 75 deletions

View File

@@ -106,6 +106,17 @@ void gl::program::init()
}
glUniform1i(glGetUniformLocation(*this, "shadowmap"), 10); //m7t: do something better
GLuint index;
if ((index = glGetUniformBlockIndex(*this, "scene_ubo")) != GL_INVALID_INDEX)
glUniformBlockBinding(*this, 0, index);
if ((index = glGetUniformBlockIndex(*this, "model_ubo")) != GL_INVALID_INDEX)
glUniformBlockBinding(*this, 1, index);
if ((index = glGetUniformBlockIndex(*this, "light_ubo")) != GL_INVALID_INDEX)
glUniformBlockBinding(*this, 2, index);
}
gl::program::program()

View File

@@ -33,6 +33,7 @@ namespace gl
void attach(const shader &);
void link();
virtual void init();
private:
void init();
};
}

View File

@@ -1,16 +0,0 @@
#include "stdafx.h"
#include "shader_mvp.h"
void gl::program_mvp::init()
{
GLuint index;
if ((index = glGetUniformBlockIndex(*this, "scene_ubo")) != GL_INVALID_INDEX)
glUniformBlockBinding(*this, 0, index);
if ((index = glGetUniformBlockIndex(*this, "model_ubo")) != GL_INVALID_INDEX)
glUniformBlockBinding(*this, 1, index);
if ((index = glGetUniformBlockIndex(*this, "light_ubo")) != GL_INVALID_INDEX)
glUniformBlockBinding(*this, 2, index);
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include "shader.h"
namespace gl
{
class program_mvp : public program
{
public:
using program::program;
virtual void init() override;
};
}

View File

@@ -5,7 +5,7 @@ gl::ubo::ubo(int size, int index)
{
glGenBuffers(1, *this);
bind();
glBufferData(GL_UNIFORM_BUFFER, size, nullptr, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, size, nullptr, GL_STREAM_DRAW);
glBindBufferBase(GL_UNIFORM_BUFFER, index, *this);
}

View File

@@ -87,7 +87,7 @@ namespace gl
static_assert(sizeof(light_element_ubs) == 64, "bad size of ubs");
const size_t MAX_LIGHTS = 16;
const size_t MAX_LIGHTS = 4;
struct light_ubs
{