charcoal/OpenGLEngine/GLUtil.cpp
elipzer 1eea92a3af LitScene Phong Lighting Complete
Now, LitScene allows for simple lighting. (Shadows still to come).
Ambient, specular, and diffuse lighting available and each mesh's
vertex can define a material that defines its reflectivity. An
example scene was added to the MyApplication as the scene for the
6 button.
2018-09-15 03:46:42 -04:00

55 lines
1.3 KiB
C++

#include "GLUtil.h"
#include "stdafx.h"
namespace charcoal
{
namespace builtin
{
namespace glutil
{
void clear_screen()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void uniform_int(int uniform_index, int value)
{
glUniform1i(uniform_index, value);
}
void uniform_uint(int uniform_index, unsigned int value)
{
glUniform1ui(uniform_index, value);
}
void uniform_float(int uniform_index, float value)
{
glUniform1f(uniform_index, value);
}
void uniform_vec3(int uniform_index, const vec3& value)
{
glUniform3fv(uniform_index, 1, &value[0]);
}
void uniform_matrix(int uniform_index, const mat4& matrix, bool transpose)
{
glUniformMatrix4fv(uniform_index, 1, transpose ? GL_TRUE : GL_FALSE, &matrix[0][0]);
}
void uniform_lights(int uniform_index, const std::vector<Light>& lights)
{
for (std::vector<Light>::size_type i = 0; i < lights.size(); ++i)
{
glUniform3fv(uniform_index++, 1, &lights[i].position[0]);
glUniform3fv(uniform_index++, 1, &lights[i].power[0]);
glUniform3fv(uniform_index++, 1, &lights[i].ambient[0]);
glUniform3fv(uniform_index++, 1, &lights[i].diffuse[0]);
glUniform3fv(uniform_index++, 1, &lights[i].specular[0]);
glUniform3fv(uniform_index++, 1, &lights[i].fade[0]);
}
}
}
}
}