From cd87aeae00e17e49e258d4d0db6524d808ba7d3f Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 20 May 2008 18:49:40 -0400 Subject: add a simple but nice example of convolution filters in glsl shows basics of image processing with glsl --- progs/glsl/convolutions.c | 441 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 441 insertions(+) create mode 100644 progs/glsl/convolutions.c (limited to 'progs/glsl/convolutions.c') diff --git a/progs/glsl/convolutions.c b/progs/glsl/convolutions.c new file mode 100644 index 0000000000..be887714c4 --- /dev/null +++ b/progs/glsl/convolutions.c @@ -0,0 +1,441 @@ +#define GL_GLEXT_PROTOTYPES +#include "readtex.h" + +#include +#include +#include +#include +#include + +enum Filter { + GAUSSIAN_BLUR, + SHARPEN, + MEAN_REMOVAL, + EMBOSS, + NO_FILTER, + LAST +}; +#define QUIT LAST + +struct BoundingBox { + float minx, miny, minz; + float maxx, maxy, maxz; +}; +struct Texture { + GLuint id; + GLfloat x; + GLfloat y; + GLint width; + GLint height; + GLenum format; +}; + +static const char *textureLocation = "../images/girl2.rgb"; + +static GLfloat viewRotx = 0.0, viewRoty = 0.0, viewRotz = 0.0; +static struct BoundingBox box; +static struct Texture texture; +static GLuint program; +static GLint menuId; +static enum Filter filter = GAUSSIAN_BLUR; + + +static void checkError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error %s (0x%x) at line %d\n", + gluErrorString(err), (int) err, line); + } +} + +static void loadAndCompileShader(GLuint shader, const char *text) +{ + GLint stat; + + glShaderSource(shader, 1, (const GLchar **) &text, NULL); + + glCompileShader(shader); + + glGetShaderiv(shader, GL_COMPILE_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetShaderInfoLog(shader, 1000, &len, log); + fprintf(stderr, "Problem compiling shader: %s\n", log); + exit(1); + } + else { + printf("Shader compiled OK\n"); + } +} + +static void readShader(GLuint shader, const char *filename) +{ + const int max = 100*1000; + int n; + char *buffer = (char*) malloc(max); + FILE *f = fopen(filename, "r"); + if (!f) { + fprintf(stderr, "Unable to open shader file %s\n", filename); + exit(1); + } + + n = fread(buffer, 1, max, f); + printf("Read %d bytes from shader file %s\n", n, filename); + if (n > 0) { + buffer[n] = 0; + loadAndCompileShader(shader, buffer); + } + + fclose(f); + free(buffer); +} + + +static void +checkLink(GLuint prog) +{ + GLint stat; + glGetProgramiv(prog, GL_LINK_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetProgramInfoLog(prog, 1000, &len, log); + fprintf(stderr, "Linker error:\n%s\n", log); + } + else { + fprintf(stderr, "Link success!\n"); + } +} + +static void fillConvolution(GLint *k, + GLfloat *scale, + GLfloat *color) +{ + switch(filter) { + case GAUSSIAN_BLUR: + k[0] = 1; k[1] = 2; k[2] = 1; + k[3] = 2; k[4] = 4; k[5] = 2; + k[6] = 1; k[7] = 2; k[8] = 1; + + *scale = 1./16.; + break; + case SHARPEN: + k[0] = 0; k[1] = -2; k[2] = 0; + k[3] = -2; k[4] = 11; k[5] = -2; + k[6] = 0; k[7] = -2; k[8] = 0; + + *scale = 1./3.; + break; + case MEAN_REMOVAL: + k[0] = -1; k[1] = -1; k[2] = -1; + k[3] = -1; k[4] = 9; k[5] = -1; + k[6] = -1; k[7] = -1; k[8] = -1; + + *scale = 1./1.; + break; + case EMBOSS: + k[0] = -1; k[1] = 0; k[2] = -1; + k[3] = 0; k[4] = 4; k[5] = 0; + k[6] = -1; k[7] = 0; k[8] = -1; + + *scale = 1./1.; + color[0] = 0.5; + color[1] = 0.5; + color[2] = 0.5; + color[3] = 0.5; + break; + case NO_FILTER: + k[0] = 0; k[1] = 0; k[2] = 0; + k[3] = 0; k[4] = 1; k[5] = 0; + k[6] = 0; k[7] = 0; k[8] = 0; + + *scale = 1.; + break; + default: + assert(!"Unhandled switch value"); + } +} + +static void setupConvolution() +{ + GLint *kernel = (GLint*)malloc(sizeof(GLint) * 9); + GLfloat scale; + GLfloat *vecKer = (GLfloat*)malloc(sizeof(GLfloat) * 9 * 4); + GLuint loc; + GLuint i; + GLfloat baseColor[4]; + baseColor[0] = 0; + baseColor[1] = 0; + baseColor[2] = 0; + baseColor[3] = 0; + + fillConvolution(kernel, &scale, baseColor); + /*vector of 4*/ + for (i = 0; i < 9; ++i) { + vecKer[i*4 + 0] = kernel[i]; + vecKer[i*4 + 1] = kernel[i]; + vecKer[i*4 + 2] = kernel[i]; + vecKer[i*4 + 3] = kernel[i]; + } + + loc = glGetUniformLocationARB(program, "KernelValue"); + glUniform4fv(loc, 9, vecKer); + loc = glGetUniformLocationARB(program, "ScaleFactor"); + glUniform4f(loc, scale, scale, scale, scale); + loc = glGetUniformLocationARB(program, "BaseColor"); + glUniform4f(loc, baseColor[0], baseColor[1], + baseColor[2], baseColor[3]); + + free(vecKer); + free(kernel); +} + +static void createProgram(const char *vertProgFile, + const char *fragProgFile) +{ + GLuint fragShader = 0, vertShader = 0; + + program = glCreateProgram(); + if (vertProgFile) { + vertShader = glCreateShader(GL_VERTEX_SHADER); + readShader(vertShader, vertProgFile); + glAttachShader(program, vertShader); + } + + if (fragProgFile) { + fragShader = glCreateShader(GL_FRAGMENT_SHADER); + readShader(fragShader, fragProgFile); + glAttachShader(program, fragShader); + } + + glLinkProgram(program); + checkLink(program); + + glUseProgram(program); + + assert(glIsProgram(program)); + assert(glIsShader(fragShader)); + assert(glIsShader(vertShader)); + + checkError(__LINE__); + {/*texture*/ + GLuint texLoc = glGetUniformLocationARB(program, "srcTex"); + glUniform1iARB(texLoc, 0); + } + {/*setup offsets */ + float offsets[] = { 1.0 / texture.width, 1.0 / texture.height, + 0.0 , 1.0 / texture.height, + -1.0 / texture.width, 1.0 / texture.height, + 1.0 / texture.width, 0.0, + 0.0 , 0.0, + -1.0 / texture.width, 0.0, + 1.0 / texture.width, -1.0 / texture.height, + 0.0 , -1.0 / texture.height, + -1.0 / texture.width, -1.0 / texture.height }; + GLuint offsetLoc = glGetUniformLocationARB(program, "Offset"); + glUniform2fv(offsetLoc, 9, offsets); + } + setupConvolution(); + + checkError(__LINE__); +} + + +static void readTexture(const char *filename) +{ + GLubyte *data; + + texture.x = 0; + texture.y = 0; + + glGenTextures(1, &texture.id); + glBindTexture(GL_TEXTURE_2D, texture.id); + glTexParameteri(GL_TEXTURE_2D, + GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, + GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + data = LoadRGBImage(filename, &texture.width, &texture.height, + &texture.format); + if (!data) { + printf("Error: couldn't load texture image '%s'\n", filename); + exit(1); + } + printf("Texture %s (%d x %d)\n", + filename, texture.width, texture.height); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, + texture.width, texture.height, 0, texture.format, + GL_UNSIGNED_BYTE, data); +} + +static void menuSelected(int entry) +{ + switch (entry) { + case QUIT: + exit(0); + break; + default: + filter = (enum Filter)entry; + } + setupConvolution(); + + glutPostRedisplay(); +} + +static void menuInit() +{ + menuId = glutCreateMenu(menuSelected); + + glutAddMenuEntry("Gaussian blur", GAUSSIAN_BLUR); + glutAddMenuEntry("Sharpen", SHARPEN); + glutAddMenuEntry("Mean removal", MEAN_REMOVAL); + glutAddMenuEntry("Emboss", EMBOSS); + glutAddMenuEntry("None", NO_FILTER); + + glutAddMenuEntry("Quit", QUIT); + + glutAttachMenu(GLUT_RIGHT_BUTTON); +} + +static void init() +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + menuInit(); + readTexture(textureLocation); + createProgram("convolution.vert", "convolution.frag"); + + glEnable(GL_TEXTURE_2D); + glClearColor(1.0, 1.0, 1.0, 1.0); + /*glShadeModel(GL_SMOOTH);*/ + glShadeModel(GL_FLAT); +} + +static void reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + box.minx = 0; + box.maxx = width; + box.miny = 0; + box.maxy = height; + box.minz = 0; + box.maxz = 1; + glOrtho(box.minx, box.maxx, box.miny, box.maxy, -999999, 999999); + glMatrixMode(GL_MODELVIEW); +} + +static void keyPress(unsigned char key, int x, int y) +{ + switch(key) { + case 27: + exit(0); + default: + return; + } + glutPostRedisplay(); +} + +static void +special(int k, int x, int y) +{ + switch (k) { + case GLUT_KEY_UP: + viewRotx += 2.0; + break; + case GLUT_KEY_DOWN: + viewRotx -= 2.0; + break; + case GLUT_KEY_LEFT: + viewRoty += 2.0; + break; + case GLUT_KEY_RIGHT: + viewRoty -= 2.0; + break; + default: + return; + } + glutPostRedisplay(); +} + + +static void draw() +{ + GLfloat center[2]; + GLfloat anchor[2]; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glLoadIdentity(); + glPushMatrix(); + + center[0] = box.maxx/2; + center[1] = box.maxy/2; + anchor[0] = center[0] - texture.width/2; + anchor[1] = center[1] - texture.height/2; + + glTranslatef(center[0], center[1], 0); + glRotatef(viewRotx, 1.0, 0.0, 0.0); + glRotatef(viewRoty, 0.0, 1.0, 0.0); + glRotatef(viewRotz, 0.0, 0.0, 1.0); + glTranslatef(-center[0], -center[1], 0); + + glTranslatef(anchor[0], anchor[1], 0); + glBegin(GL_TRIANGLE_STRIP); + { + glColor3f(1., 0., 0.); + glTexCoord2f(0, 0); + glVertex3f(0, 0, 0); + + glColor3f(0., 1., 0.); + glTexCoord2f(0, 1.0); + glVertex3f(0, texture.height, 0); + + glColor3f(1., 0., 0.); + glTexCoord2f(1.0, 0); + glVertex3f(texture.width, 0, 0); + + glColor3f(0., 1., 0.); + glTexCoord2f(1, 1); + glVertex3f(texture.width, texture.height, 0); + } + glEnd(); + + glPopMatrix(); + + glFlush(); + + glutSwapBuffers(); +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); + glutInitWindowSize(400, 400); + glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE); + + if (!glutCreateWindow("Image Convolutions")) { + fprintf(stderr, "Couldn't create window!\n"); + exit(1); + } + + init(); + + glutReshapeFunc(reshape); + glutKeyboardFunc(keyPress); + glutSpecialFunc(special); + glutDisplayFunc(draw); + + + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 4d38d86b2c5e572b1ea5ff4a5a84acb7ab5b87fc Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 16 Jun 2008 13:19:41 -0400 Subject: add edge detection to that example --- progs/glsl/convolutions.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'progs/glsl/convolutions.c') diff --git a/progs/glsl/convolutions.c b/progs/glsl/convolutions.c index be887714c4..9b9ee53245 100644 --- a/progs/glsl/convolutions.c +++ b/progs/glsl/convolutions.c @@ -12,6 +12,7 @@ enum Filter { SHARPEN, MEAN_REMOVAL, EMBOSS, + EDGE_DETECT, NO_FILTER, LAST }; @@ -146,6 +147,17 @@ static void fillConvolution(GLint *k, color[2] = 0.5; color[3] = 0.5; break; + case EDGE_DETECT: + k[0] = 1; k[1] = 1; k[2] = 1; + k[3] = 0; k[4] = 0; k[5] = 0; + k[6] = -1; k[7] = -1; k[8] = -1; + + *scale = 1.; + color[0] = 0.5; + color[1] = 0.5; + color[2] = 0.5; + color[3] = 0.5; + break; case NO_FILTER: k[0] = 0; k[1] = 0; k[2] = 0; k[3] = 0; k[4] = 1; k[5] = 0; @@ -294,6 +306,7 @@ static void menuInit() glutAddMenuEntry("Sharpen", SHARPEN); glutAddMenuEntry("Mean removal", MEAN_REMOVAL); glutAddMenuEntry("Emboss", EMBOSS); + glutAddMenuEntry("Edge detect", EDGE_DETECT); glutAddMenuEntry("None", NO_FILTER); glutAddMenuEntry("Quit", QUIT); -- cgit v1.2.3 From b799af91d5ffbee1481161fec29eb4c92b161272 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 29 Jun 2009 14:13:58 +0100 Subject: progs/glsl: compile with scons and glew Get most of these working with scons. --- progs/SConscript | 1 + progs/glsl/SConscript | 55 ++++++++++++++++++++++++++++++++++++++++++ progs/glsl/array.c | 3 ++- progs/glsl/bitmap.c | 2 ++ progs/glsl/brick.c | 2 ++ progs/glsl/bump.c | 1 + progs/glsl/convolutions.c | 3 +++ progs/glsl/deriv.c | 2 ++ progs/glsl/fragcoord.c | 2 ++ progs/glsl/identity.c | 2 ++ progs/glsl/linktest.c | 2 ++ progs/glsl/mandelbrot.c | 2 ++ progs/glsl/multinoise.c | 2 ++ progs/glsl/multitex.c | 2 ++ progs/glsl/noise.c | 2 ++ progs/glsl/pointcoord.c | 2 ++ progs/glsl/points.c | 2 ++ progs/glsl/samplers.c | 2 ++ progs/glsl/shadow_sampler.c | 2 ++ progs/glsl/skinning.c | 2 ++ progs/glsl/texaaline.c | 2 ++ progs/glsl/texdemo1.c | 2 ++ progs/glsl/toyball.c | 2 ++ progs/glsl/trirast.c | 2 ++ progs/glsl/twoside.c | 2 ++ progs/glsl/vert-or-frag-only.c | 2 ++ progs/glsl/vert-tex.c | 2 ++ 27 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 progs/glsl/SConscript (limited to 'progs/glsl/convolutions.c') diff --git a/progs/SConscript b/progs/SConscript index 71ebe5e0f3..620dd30e69 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -1,6 +1,7 @@ SConscript([ 'util/SConscript', 'demos/SConscript', + 'glsl/SConscript', 'redbook/SConscript', 'samples/SConscript', 'tests/SConscript', diff --git a/progs/glsl/SConscript b/progs/glsl/SConscript new file mode 100644 index 0000000000..7a4549cd70 --- /dev/null +++ b/progs/glsl/SConscript @@ -0,0 +1,55 @@ +Import('*') + +if not env['GLUT']: + Return() + +env = env.Clone() + +env.Prepend(CPPPATH = [ + '../util', +]) + +env.Prepend(LIBS = [ + util, + '$GLUT_LIB' +]) + +if env['platform'] == 'windows': + env.Append(CPPDEFINES = ['NOMINMAX']) + env.Prepend(LIBS = ['winmm']) + +progs = [ + 'array', + 'bitmap', + 'brick', + 'bump', + 'convolutions', + 'deriv', + 'fragcoord', + 'identity', + 'linktest', + 'mandelbrot', + 'multinoise', + 'multitex', + 'noise', + 'noise2', + 'pointcoord', + 'points', + 'samplers', + 'shadow_sampler', + 'skinning', + 'texaaline', + 'texdemo1', + 'toyball', + 'trirast', + 'twoside', + 'vert-or-frag-only', + 'vert-tex', +] + +for prog in progs: + env.Program( + target = prog, + source = prog + '.c', + ) + diff --git a/progs/glsl/array.c b/progs/glsl/array.c index 46ef8043bc..6da15b2fcc 100644 --- a/progs/glsl/array.c +++ b/progs/glsl/array.c @@ -9,9 +9,9 @@ #include #include #include +#include #include #include -#include #include "extfuncs.h" #include "shaderutil.h" @@ -248,6 +248,7 @@ main(int argc, char *argv[]) glutInitWindowSize(500, 500); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/bitmap.c b/progs/glsl/bitmap.c index d488ec6cb9..08fac15c89 100644 --- a/progs/glsl/bitmap.c +++ b/progs/glsl/bitmap.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -309,6 +310,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/brick.c b/progs/glsl/brick.c index 526ef0e2e3..607acd0597 100644 --- a/progs/glsl/brick.c +++ b/progs/glsl/brick.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c index 0ea1f8331f..c401e590f7 100644 --- a/progs/glsl/bump.c +++ b/progs/glsl/bump.c @@ -288,6 +288,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/convolutions.c b/progs/glsl/convolutions.c index ac71c68235..22ce7edcdc 100644 --- a/progs/glsl/convolutions.c +++ b/progs/glsl/convolutions.c @@ -5,6 +5,8 @@ * Author: Zack Rusin */ +#include + #define GL_GLEXT_PROTOTYPES #include "readtex.h" @@ -455,6 +457,7 @@ int main(int argc, char **argv) exit(1); } + glewInit(); init(); glutReshapeFunc(reshape); diff --git a/progs/glsl/deriv.c b/progs/glsl/deriv.c index e69f0b82c4..3fd674c331 100644 --- a/progs/glsl/deriv.c +++ b/progs/glsl/deriv.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -228,6 +229,7 @@ main(int argc, char *argv[]) glutInitWindowSize(200, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/fragcoord.c b/progs/glsl/fragcoord.c index 0b7561f3e4..509ad47e7f 100644 --- a/progs/glsl/fragcoord.c +++ b/progs/glsl/fragcoord.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -174,6 +175,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/identity.c b/progs/glsl/identity.c index 37579eb346..5ba7468cc4 100644 --- a/progs/glsl/identity.c +++ b/progs/glsl/identity.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -195,6 +196,7 @@ main(int argc, char *argv[]) glutInitWindowSize(200, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/linktest.c b/progs/glsl/linktest.c index 988d082341..fe5d1564e0 100644 --- a/progs/glsl/linktest.c +++ b/progs/glsl/linktest.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -245,6 +246,7 @@ main(int argc, char *argv[]) glutInitWindowSize(300, 300); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/mandelbrot.c b/progs/glsl/mandelbrot.c index 24e1992665..eeea4eb52a 100644 --- a/progs/glsl/mandelbrot.c +++ b/progs/glsl/mandelbrot.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -206,6 +207,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/multinoise.c b/progs/glsl/multinoise.c index 2351863aff..400511508e 100644 --- a/progs/glsl/multinoise.c +++ b/progs/glsl/multinoise.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -270,6 +271,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/multitex.c b/progs/glsl/multitex.c index bbf58af055..724f15e1a3 100644 --- a/progs/glsl/multitex.c +++ b/progs/glsl/multitex.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "GL/glut.h" #include "readtex.h" #include "extfuncs.h" @@ -334,6 +335,7 @@ main(int argc, char *argv[]) glutInitWindowSize(500, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow(Demo); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(key); glutSpecialFunc(specialkey); diff --git a/progs/glsl/noise.c b/progs/glsl/noise.c index bd8f50036b..83e4696fc9 100644 --- a/progs/glsl/noise.c +++ b/progs/glsl/noise.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -207,6 +208,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/pointcoord.c b/progs/glsl/pointcoord.c index b240077c25..aa01e2166d 100644 --- a/progs/glsl/pointcoord.c +++ b/progs/glsl/pointcoord.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -195,6 +196,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/points.c b/progs/glsl/points.c index 392dc4db85..1b346228aa 100644 --- a/progs/glsl/points.c +++ b/progs/glsl/points.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -248,6 +249,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/samplers.c b/progs/glsl/samplers.c index 3fb8577d5e..cbb264dad1 100644 --- a/progs/glsl/samplers.c +++ b/progs/glsl/samplers.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "GL/glut.h" #include "readtex.h" #include "extfuncs.h" @@ -357,6 +358,7 @@ main(int argc, char *argv[]) glutInitWindowSize(500, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow(Demo); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(key); glutSpecialFunc(specialkey); diff --git a/progs/glsl/shadow_sampler.c b/progs/glsl/shadow_sampler.c index 2902b53552..673ad465ad 100644 --- a/progs/glsl/shadow_sampler.c +++ b/progs/glsl/shadow_sampler.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -329,6 +330,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 300); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/skinning.c b/progs/glsl/skinning.c index 8a65d0667c..d7b968fed0 100644 --- a/progs/glsl/skinning.c +++ b/progs/glsl/skinning.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -266,6 +267,7 @@ main(int argc, char *argv[]) glutInitWindowSize(500, 500); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/texaaline.c b/progs/glsl/texaaline.c index 0b3cc84958..6720941a6e 100644 --- a/progs/glsl/texaaline.c +++ b/progs/glsl/texaaline.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -359,6 +360,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/texdemo1.c b/progs/glsl/texdemo1.c index 96ddca1f32..08a87a5152 100644 --- a/progs/glsl/texdemo1.c +++ b/progs/glsl/texdemo1.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "GL/glut.h" #include "readtex.h" #include "extfuncs.h" @@ -426,6 +427,7 @@ main(int argc, char *argv[]) glutInitWindowSize(500, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); win = glutCreateWindow(Demo); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(key); glutSpecialFunc(specialkey); diff --git a/progs/glsl/toyball.c b/progs/glsl/toyball.c index 37ad6bf291..2b644acb6d 100644 --- a/progs/glsl/toyball.c +++ b/progs/glsl/toyball.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -212,6 +213,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/glsl/trirast.c b/progs/glsl/trirast.c index 89df64fc71..3d4decaa2f 100644 --- a/progs/glsl/trirast.c +++ b/progs/glsl/trirast.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -247,6 +248,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/twoside.c b/progs/glsl/twoside.c index 06488bd175..9ebc4ec360 100644 --- a/progs/glsl/twoside.c +++ b/progs/glsl/twoside.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -293,6 +294,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/vert-or-frag-only.c b/progs/glsl/vert-or-frag-only.c index f6eedd8327..8e1612aca4 100644 --- a/progs/glsl/vert-or-frag-only.c +++ b/progs/glsl/vert-or-frag-only.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -181,6 +182,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Redisplay); diff --git a/progs/glsl/vert-tex.c b/progs/glsl/vert-tex.c index 9d00a61054..b74bf50679 100644 --- a/progs/glsl/vert-tex.c +++ b/progs/glsl/vert-tex.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -266,6 +267,7 @@ main(int argc, char *argv[]) glutInitWindowSize(500, 500); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); -- cgit v1.2.3 From 680df529a323714013006aae9b3ad5298913a7b3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 17 Aug 2009 12:57:37 -0600 Subject: demos/glsl: remove glutInitWindowPosition() calls --- progs/glsl/brick.c | 1 - progs/glsl/bump.c | 1 - progs/glsl/convolutions.c | 1 - progs/glsl/deriv.c | 1 - progs/glsl/fragcoord.c | 1 - progs/glsl/identity.c | 1 - progs/glsl/mandelbrot.c | 1 - progs/glsl/multinoise.c | 1 - progs/glsl/noise.c | 1 - progs/glsl/noise2.c | 1 - progs/glsl/pointcoord.c | 1 - progs/glsl/shadow_sampler.c | 1 - progs/glsl/shtest.c | 1 - progs/glsl/texaaline.c | 1 - progs/glsl/toyball.c | 1 - progs/glsl/trirast.c | 1 - progs/glsl/twoside.c | 1 - progs/glsl/vert-or-frag-only.c | 1 - 18 files changed, 18 deletions(-) (limited to 'progs/glsl/convolutions.c') diff --git a/progs/glsl/brick.c b/progs/glsl/brick.c index 0653c592e5..20417aa462 100644 --- a/progs/glsl/brick.c +++ b/progs/glsl/brick.c @@ -184,7 +184,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c index c0d39c049d..87669aec73 100644 --- a/progs/glsl/bump.c +++ b/progs/glsl/bump.c @@ -281,7 +281,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/convolutions.c b/progs/glsl/convolutions.c index 22ce7edcdc..c2fb76e1aa 100644 --- a/progs/glsl/convolutions.c +++ b/progs/glsl/convolutions.c @@ -448,7 +448,6 @@ int main(int argc, char **argv) { glutInit(&argc, argv); - glutInitWindowPosition(0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE); diff --git a/progs/glsl/deriv.c b/progs/glsl/deriv.c index 9cf1e40e3e..265a515715 100644 --- a/progs/glsl/deriv.c +++ b/progs/glsl/deriv.c @@ -220,7 +220,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(200, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/fragcoord.c b/progs/glsl/fragcoord.c index 9f56a038c9..3dfcec87a5 100644 --- a/progs/glsl/fragcoord.c +++ b/progs/glsl/fragcoord.c @@ -166,7 +166,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/identity.c b/progs/glsl/identity.c index a772ccd716..526e9b82c1 100644 --- a/progs/glsl/identity.c +++ b/progs/glsl/identity.c @@ -187,7 +187,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(200, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/mandelbrot.c b/progs/glsl/mandelbrot.c index 729a6f125a..b05ef37fae 100644 --- a/progs/glsl/mandelbrot.c +++ b/progs/glsl/mandelbrot.c @@ -199,7 +199,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/multinoise.c b/progs/glsl/multinoise.c index 0afe230801..0d4026e29c 100644 --- a/progs/glsl/multinoise.c +++ b/progs/glsl/multinoise.c @@ -262,7 +262,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/noise.c b/progs/glsl/noise.c index 8c36e1c59b..fdab263ea6 100644 --- a/progs/glsl/noise.c +++ b/progs/glsl/noise.c @@ -200,7 +200,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/noise2.c b/progs/glsl/noise2.c index e972b62673..7a28f09947 100644 --- a/progs/glsl/noise2.c +++ b/progs/glsl/noise2.c @@ -186,7 +186,6 @@ static void Init (void) int main (int argc, char *argv[]) { glutInit (&argc, argv); - glutInitWindowPosition ( 0, 0); glutInitWindowSize (200, 200); glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow (argv[0]); diff --git a/progs/glsl/pointcoord.c b/progs/glsl/pointcoord.c index 27b73a05de..5dced6fac3 100644 --- a/progs/glsl/pointcoord.c +++ b/progs/glsl/pointcoord.c @@ -187,7 +187,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/shadow_sampler.c b/progs/glsl/shadow_sampler.c index 0a4d04dd8c..0adc9d88ba 100644 --- a/progs/glsl/shadow_sampler.c +++ b/progs/glsl/shadow_sampler.c @@ -321,7 +321,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 300); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/shtest.c b/progs/glsl/shtest.c index 97f6f9f8a4..2622af1313 100644 --- a/progs/glsl/shtest.c +++ b/progs/glsl/shtest.c @@ -612,7 +612,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/texaaline.c b/progs/glsl/texaaline.c index 1f566c86a6..2481c0f36e 100644 --- a/progs/glsl/texaaline.c +++ b/progs/glsl/texaaline.c @@ -351,7 +351,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/toyball.c b/progs/glsl/toyball.c index 89733d6175..c502f24077 100644 --- a/progs/glsl/toyball.c +++ b/progs/glsl/toyball.c @@ -205,7 +205,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/trirast.c b/progs/glsl/trirast.c index f7546f25a2..53bd91ef97 100644 --- a/progs/glsl/trirast.c +++ b/progs/glsl/trirast.c @@ -239,7 +239,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/twoside.c b/progs/glsl/twoside.c index b6c1b477dd..a57484f96c 100644 --- a/progs/glsl/twoside.c +++ b/progs/glsl/twoside.c @@ -285,7 +285,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); win = glutCreateWindow(argv[0]); diff --git a/progs/glsl/vert-or-frag-only.c b/progs/glsl/vert-or-frag-only.c index 81fcab8c5b..148991ca83 100644 --- a/progs/glsl/vert-or-frag-only.c +++ b/progs/glsl/vert-or-frag-only.c @@ -173,7 +173,6 @@ int main(int argc, char *argv[]) { glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(400, 200); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); -- cgit v1.2.3