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:
30
gl/shader_mvp.cpp
Normal file
30
gl/shader_mvp.cpp
Normal 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));
|
||||
}
|
||||
Reference in New Issue
Block a user