read the GL uniform locations

This commit is contained in:
Josh Holtrop 2011-07-15 12:42:16 -04:00
parent eed74a64f3
commit 9a483990a2
2 changed files with 20 additions and 4 deletions

View File

@ -158,6 +158,7 @@ Engine::Engine(const string & path, AV & av)
registerLibraries();
{
const char *obj_v_src = (const char *) getFile("shaders/obj.vp", NULL);
const char *obj_f_src = (const char *) getFile("shaders/obj.fp", NULL);
const static guAttribBinding obj_bindings[] = {
@ -175,6 +176,17 @@ Engine::Engine(const string & path, AV & av)
m_programs[PROG_OBJ] = 0;
cerr << "Error: Could not obtain 'obj' shader sources" << endl;
}
guUniformLocation uniforms_obj[] = {
{&m_uniforms_obj[UNIFORM_OBJ_AMBIENT], "ambient"},
{&m_uniforms_obj[UNIFORM_OBJ_DIFFUSE], "diffuse"},
{&m_uniforms_obj[UNIFORM_OBJ_SPECULAR], "specular"},
{&m_uniforms_obj[UNIFORM_OBJ_SHININESS], "shininess"},
{NULL, NULL}
};
guGetUniformLocations(m_programs[PROG_OBJ], uniforms_obj);
}
{
const char *obj_tex_v_src =
(const char *) getFile("shaders/obj_tex.vp", NULL);
const char *obj_tex_f_src =
@ -195,6 +207,14 @@ Engine::Engine(const string & path, AV & av)
m_programs[PROG_OBJ_TEX] = 0;
cerr << "Error: Could not obtain 'obj_tex' shader sources" << endl;
}
guUniformLocation uniforms_obj_tex[] = {
{&m_uniforms_obj_tex[UNIFORM_OBJ_TEX_AMBIENT], "ambient"},
{&m_uniforms_obj_tex[UNIFORM_OBJ_TEX_SPECULAR], "specular"},
{&m_uniforms_obj_tex[UNIFORM_OBJ_TEX_SHININESS], "shininess"},
{NULL, NULL}
};
guGetUniformLocations(m_programs[PROG_OBJ_TEX], uniforms_obj_tex);
}
}
Engine::~Engine()

View File

@ -372,8 +372,6 @@ class Engine
enum { PROG_OBJ, PROG_OBJ_TEX, PROG_COUNT };
GLuint m_programs[PROG_COUNT];
enum {
UNIFORM_OBJ_PROJECTION,
UNIFORM_OBJ_MODELVIEW,
UNIFORM_OBJ_AMBIENT,
UNIFORM_OBJ_DIFFUSE,
UNIFORM_OBJ_SPECULAR,
@ -387,8 +385,6 @@ class Engine
};
GLint m_uniforms_obj[UNIFORM_OBJ_COUNT];
enum {
UNIFORM_OBJ_TEX_PROJECTION,
UNIFORM_OBJ_TEX_MODELVIEW,
UNIFORM_OBJ_TEX_AMBIENT,
UNIFORM_OBJ_TEX_SPECULAR,
UNIFORM_OBJ_TEX_SHININESS,