diff options
author | Brian <brian.paul@tungstengraphics.com> | 2008-04-09 22:28:23 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2008-04-09 22:30:42 -0600 |
commit | 2dca3373ae6207d2deb375148f4dce1817cfd5b7 (patch) | |
tree | cac9680283f396afaf16712d9355d40f0dd51e75 /progs/glsl/bitmap.c | |
parent | 90caba3d766406db32e51387f830ce55836f0709 (diff) |
Replace duplicated code with new shaderutil.c functions
Diffstat (limited to 'progs/glsl/bitmap.c')
-rw-r--r-- | progs/glsl/bitmap.c | 55 |
1 files changed, 5 insertions, 50 deletions
diff --git a/progs/glsl/bitmap.c b/progs/glsl/bitmap.c index 4b62686cbf..d488ec6cb9 100644 --- a/progs/glsl/bitmap.c +++ b/progs/glsl/bitmap.c @@ -13,6 +13,7 @@ #include <GL/glut.h> #include <GL/glext.h> #include "extfuncs.h" +#include "shaderutil.h" static GLuint FragShader; @@ -247,40 +248,6 @@ MakeBitmapTextures(void) static void -LoadAndCompileShader(GLuint shader, const char *text) -{ - GLint stat; - - glShaderSource_func(shader, 1, (const GLchar **) &text, NULL); - - glCompileShader_func(shader); - - glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetShaderInfoLog_func(shader, 1000, &len, log); - fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log); - exit(1); - } -} - - -static void -CheckLink(GLuint prog) -{ - GLint stat; - glGetProgramiv_func(prog, GL_LINK_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetProgramInfoLog_func(prog, 1000, &len, log); - fprintf(stderr, "Linker error:\n%s\n", log); - } -} - - -static void Init(void) { /* Fragment shader: modulate raster color by texture, discard fragments @@ -306,28 +273,16 @@ Init(void) " gl_TexCoord[0] = gl_MultiTexCoord0; \n" " gl_FrontColor = gl_Color; \n" "}\n"; - const char *version; - version = (const char *) glGetString(GL_VERSION); - if (version[0] != '2' || version[1] != '.') { - printf("This program requires OpenGL 2.x, found %s\n", version); + if (!ShadersSupported()) exit(1); - } - printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); GetExtensionFuncs(); - FragShader = glCreateShader_func(GL_FRAGMENT_SHADER); - LoadAndCompileShader(FragShader, fragShaderText); - - VertShader = glCreateShader_func(GL_VERTEX_SHADER); - LoadAndCompileShader(VertShader, vertShaderText); + VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText); + FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText); + Program = LinkShaders(VertShader, FragShader); - Program = glCreateProgram_func(); - glAttachShader_func(Program, FragShader); - glAttachShader_func(Program, VertShader); - glLinkProgram_func(Program); - CheckLink(Program); glUseProgram_func(Program); uScale = glGetUniformLocation_func(Program, "scale"); |