#include <msp/strings/format.h>
#include "buffer.h"
#include "error.h"
-#include "misc.h"
#include "program.h"
#include "resources.h"
#include "glsl/compiler.h"
void Program::compile_glsl_stage(unsigned stage_id)
{
glCompileShader(stage_id);
- bool compiled = get_shader_i(stage_id, GL_COMPILE_STATUS);
+ int status = 0;
+ glGetShaderiv(stage_id, GL_COMPILE_STATUS, &status);
- GLsizei info_log_len = get_shader_i(stage_id, GL_INFO_LOG_LENGTH);
+ int info_log_len = 0;
+ glGetShaderiv(stage_id, GL_INFO_LOG_LENGTH, &info_log_len);
string info_log(info_log_len+1, 0);
glGetShaderInfoLog(stage_id, info_log_len+1, &info_log_len, &info_log[0]);
info_log.erase(info_log_len);
if(module && module->get_format()==Module::GLSL)
info_log = static_cast<const GlslModule *>(module)->get_source_map().translate_errors(info_log);
- if(!compiled)
+ if(!status)
throw compile_error(info_log);
#ifdef DEBUG
if(!info_log.empty())
attributes.clear();
glLinkProgram(id);
- linked = get_program_i(id, GL_LINK_STATUS);
+ int status = 0;
+ glGetProgramiv(id, GL_LINK_STATUS, &status);
+ linked = status;
- GLsizei info_log_len = get_program_i(id, GL_INFO_LOG_LENGTH);
+ int info_log_len = 0;
+ glGetProgramiv(id, GL_INFO_LOG_LENGTH, &info_log_len);
string info_log(info_log_len+1, 0);
glGetProgramInfoLog(id, info_log_len+1, &info_log_len, &info_log[0]);
info_log.erase(info_log_len);
void Program::query_uniforms()
{
- unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS);
+ unsigned count = 0;
+ glGetProgramiv(id, GL_ACTIVE_UNIFORMS, reinterpret_cast<int *>(&count));
uniforms.reserve(count);
vector<string> uniform_names(count);
for(unsigned i=0; i<count; ++i)
void Program::query_uniform_blocks(const vector<UniformInfo *> &uniforms_by_index)
{
- unsigned count = get_program_i(id, GL_ACTIVE_UNIFORM_BLOCKS);
+ unsigned count = 0;
+ glGetProgramiv(id, GL_ACTIVE_UNIFORM_BLOCKS, reinterpret_cast<int *>(&count));
// Reserve an extra index for the default block
uniform_blocks.reserve(count+1);
for(unsigned i=0; i<count; ++i)
void Program::query_attributes()
{
- unsigned count = get_program_i(id, GL_ACTIVE_ATTRIBUTES);
+ unsigned count = 0;
+ glGetProgramiv(id, GL_ACTIVE_ATTRIBUTES, reinterpret_cast<int *>(&count));
attributes.reserve(count);
for(unsigned i=0; i<count; ++i)
{