Skip to content

Commit

Permalink
progs/util: remove extfuncs.h (we use GLEW instead)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpaul committed Jul 17, 2009
1 parent ee0b1bc commit cd10996
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions progs/util/shaderutil.c
Expand Up @@ -11,7 +11,6 @@
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glut.h>
#include "extfuncs.h"
#include "shaderutil.h"


Expand All @@ -20,7 +19,6 @@ Init(void)
{
static GLboolean firstCall = GL_TRUE;
if (firstCall) {
GetExtensionFuncs();
firstCall = GL_FALSE;
}
}
Expand Down Expand Up @@ -51,14 +49,14 @@ CompileShaderText(GLenum shaderType, const char *text)

Init();

shader = glCreateShader_func(shaderType);
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
glCompileShader_func(shader);
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
shader = glCreateShader(shaderType);
glShaderSource(shader, 1, (const GLchar **) &text, NULL);
glCompileShader(shader);
glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
glGetShaderInfoLog_func(shader, 1000, &len, log);
glGetShaderInfoLog(shader, 1000, &len, log);
fprintf(stderr, "Error: problem compiling shader: %s\n", log);
exit(1);
}
Expand Down Expand Up @@ -110,24 +108,24 @@ CompileShaderFile(GLenum shaderType, const char *filename)
GLuint
LinkShaders(GLuint vertShader, GLuint fragShader)
{
GLuint program = glCreateProgram_func();
GLuint program = glCreateProgram();

assert(vertShader || fragShader);

if (fragShader)
glAttachShader_func(program, fragShader);
glAttachShader(program, fragShader);
if (vertShader)
glAttachShader_func(program, vertShader);
glLinkProgram_func(program);
glAttachShader(program, vertShader);
glLinkProgram(program);

/* check link */
{
GLint stat;
glGetProgramiv_func(program, GL_LINK_STATUS, &stat);
glGetProgramiv(program, GL_LINK_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
glGetProgramInfoLog_func(program, 1000, &len, log);
glGetProgramInfoLog(program, 1000, &len, log);
fprintf(stderr, "Shader link error:\n%s\n", log);
return 0;
}
Expand All @@ -144,27 +142,27 @@ InitUniforms(GLuint program, struct uniform_info uniforms[])

for (i = 0; uniforms[i].name; i++) {
uniforms[i].location
= glGetUniformLocation_func(program, uniforms[i].name);
= glGetUniformLocation(program, uniforms[i].name);

printf("Uniform %s location: %d\n", uniforms[i].name,
uniforms[i].location);

switch (uniforms[i].size) {
case 1:
if (uniforms[i].type == GL_INT)
glUniform1i_func(uniforms[i].location,
glUniform1i(uniforms[i].location,
(GLint) uniforms[i].value[0]);
else
glUniform1fv_func(uniforms[i].location, 1, uniforms[i].value);
glUniform1fv(uniforms[i].location, 1, uniforms[i].value);
break;
case 2:
glUniform2fv_func(uniforms[i].location, 1, uniforms[i].value);
glUniform2fv(uniforms[i].location, 1, uniforms[i].value);
break;
case 3:
glUniform3fv_func(uniforms[i].location, 1, uniforms[i].value);
glUniform3fv(uniforms[i].location, 1, uniforms[i].value);
break;
case 4:
glUniform4fv_func(uniforms[i].location, 1, uniforms[i].value);
glUniform4fv(uniforms[i].location, 1, uniforms[i].value);
break;
default:
abort();
Expand Down

0 comments on commit cd10996

Please sign in to comment.