+#include <msp/gl/extensions/arb_shader_objects.h>
#include "misc.h"
namespace Msp {
return data;
}
+int get_shader_i(unsigned id, GLenum state)
+{
+ int data;
+ glGetShaderiv(id, state, &data);
+ return data;
+}
+
+int get_program_i(unsigned id, GLenum state)
+{
+ int data;
+ glGetProgramiv(id, state, &data);
+ return data;
+}
+
} // namespace GL
} // namespace Msp
#include <msp/strings/format.h>
#include "buffer.h"
#include "error.h"
+#include "misc.h"
#include "program.h"
#include "shader.h"
legacy_vars = false;
glLinkProgram(id);
- int value;
- glGetProgramiv(id, GL_LINK_STATUS, &value);
- if(!(linked = value))
+ linked = get_program_i(id, GL_LINK_STATUS);
+ if(!linked)
throw compile_error(get_info_log());
- int count;
- glGetProgramiv(id, GL_ACTIVE_UNIFORMS, &count);
+ unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS);
vector<UniformInfo *> uniforms_by_index(count);
- for(int i=0; i<count; ++i)
+ for(unsigned i=0; i<count; ++i)
{
char name[128];
int len = 0;
legacy_vars = true;
}
- glGetProgramiv(id, GL_ACTIVE_ATTRIBUTES, &count);
- for(int i=0; i<count; ++i)
+ count = get_program_i(id, GL_ACTIVE_ATTRIBUTES);
+ for(unsigned i=0; i<count; ++i)
{
char name[128];
int len = 0;
if(ARB_uniform_buffer_object)
{
- glGetProgramiv(id, GL_ACTIVE_UNIFORM_BLOCKS, &count);
- for(int i=0; i<count; ++i)
+ count = get_program_i(id, GL_ACTIVE_UNIFORM_BLOCKS);
+ for(unsigned i=0; i<count; ++i)
{
char name[128];
int len;
UniformBlockInfo &info = uniform_blocks[name];
info.name = name;
+ int value;
glGetActiveUniformBlockiv(id, i, GL_UNIFORM_BLOCK_DATA_SIZE, &value);
info.data_size = value;
string Program::get_info_log() const
{
- GLsizei len = 0;
- glGetProgramiv(id, GL_INFO_LOG_LENGTH, &len);
+ GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH);
char *buf = new char[len+1];
glGetProgramInfoLog(id, len+1, &len, buf);
string log(buf, len);
#include <msp/gl/extensions/arb_shader_objects.h>
#include <msp/gl/extensions/arb_vertex_shader.h>
#include "error.h"
+#include "misc.h"
#include "shader.h"
using namespace std;
void Shader::compile()
{
glCompileShader(id);
- int value = 0;
- glGetShaderiv(id, GL_COMPILE_STATUS, &value);
- if(!(compiled = value))
+ compiled = get_shader_i(id, GL_COMPILE_STATUS);
+ if(!compiled)
throw compile_error(get_info_log());
}
string Shader::get_info_log() const
{
- GLsizei len = 0;
- glGetShaderiv(id, GL_INFO_LOG_LENGTH, &len);
+ GLsizei len = get_shader_i(id, GL_INFO_LOG_LENGTH);
char *buf = new char[len+1];
glGetShaderInfoLog(id, len+1, &len, buf);
string log(buf, len);
#include <msp/gl/extensions/arb_multitexture.h>
#include <msp/gl/extensions/arb_vertex_shader.h>
#include "gl.h"
+#include "misc.h"
#include "texunit.h"
using namespace std;
if(count<0)
{
if(ARB_vertex_shader)
- glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &count);
+ count = get_i(GL_MAX_TEXTURE_IMAGE_UNITS);
else if(ARB_multitexture)
- glGetIntegerv(GL_MAX_TEXTURE_UNITS, &count);
+ count = get_i(GL_MAX_TEXTURE_UNITS);
else
count = 1;
}