2018-09-13 04:51:47 +00:00
|
|
|
#include "GLUtil.h"
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
namespace charcoal
|
|
|
|
{
|
|
|
|
namespace builtin
|
|
|
|
{
|
|
|
|
namespace glutil
|
|
|
|
{
|
|
|
|
void clear_screen()
|
|
|
|
{
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
|
2018-09-14 22:09:43 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-09-13 04:51:47 +00:00
|
|
|
void uniform_matrix(int uniform_index, const mat4& matrix, bool transpose)
|
|
|
|
{
|
|
|
|
glUniformMatrix4fv(uniform_index, 1, transpose ? GL_TRUE : GL_FALSE, &matrix[0][0]);
|
|
|
|
}
|
2018-09-14 22:09:43 +00:00
|
|
|
|
|
|
|
void uniform_lights(int uniform_index, const std::vector<Light>& lights)
|
|
|
|
{
|
|
|
|
const int ambient_size = 1;
|
|
|
|
int current_location = uniform_index;
|
|
|
|
for (std::vector<Light>::size_type i = 0; i < lights.size(); ++i)
|
|
|
|
{
|
|
|
|
glUniform3fv(current_location, 1, &lights[i].ambient[0]);
|
|
|
|
current_location += ambient_size;
|
|
|
|
}
|
|
|
|
}
|
2018-09-13 04:51:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|