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

further pruning of legacy render code, now runs on opengl 3.3 core

profile
This commit is contained in:
milek7
2018-06-24 20:21:07 +02:00
parent c42afa2401
commit 0c5f990528
30 changed files with 400 additions and 1241 deletions

30
gl/shader_mvp.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "stdafx.h"
#include "shader_mvp.h"
void gl::program_mvp::init()
{
mv_uniform = glGetUniformLocation(*this, "modelview");
mvn_uniform = glGetUniformLocation(*this, "modelviewnormal");
p_uniform = glGetUniformLocation(*this, "projection");
}
void gl::program_mvp::set_mv(const glm::mat4 &m)
{
if (mvn_uniform != -1)
{
glm::mat3 mvn = glm::mat3(glm::transpose(glm::inverse(m)));
glUniformMatrix3fv(mvn_uniform, 1, GL_FALSE, glm::value_ptr(mvn));
}
glUniformMatrix4fv(mv_uniform, 1, GL_FALSE, glm::value_ptr(m));
}
void gl::program_mvp::set_p(const glm::mat4 &m)
{
glUniformMatrix4fv(p_uniform, 1, GL_FALSE, glm::value_ptr(m));
}
void gl::program_mvp::copy_gl_mvp()
{
set_mv(OpenGLMatrices.data(GL_MODELVIEW));
set_p(OpenGLMatrices.data(GL_PROJECTION));
}