summaryrefslogtreecommitdiffstats
path: root/progs/fpglsl
diff options
context:
space:
mode:
Diffstat (limited to 'progs/fpglsl')
-rw-r--r--progs/fpglsl/.gitignore1
-rw-r--r--progs/fpglsl/Makefile52
-rw-r--r--progs/fpglsl/SConscript13
-rw-r--r--progs/fpglsl/dowhile.glsl8
-rw-r--r--progs/fpglsl/dowhile2.glsl10
-rw-r--r--progs/fpglsl/for.glsl11
-rw-r--r--progs/fpglsl/forbreak.glsl13
-rw-r--r--progs/fpglsl/fp-tri.c420
-rw-r--r--progs/fpglsl/mov-imm.glsl3
-rw-r--r--progs/fpglsl/mov.glsl3
-rw-r--r--progs/fpglsl/simpleif.glsl6
-rw-r--r--progs/fpglsl/tex-multi.glsl15
-rw-r--r--progs/fpglsl/tex.glsl6
-rw-r--r--progs/fpglsl/while.glsl7
-rw-r--r--progs/fpglsl/while2.glsl9
15 files changed, 0 insertions, 577 deletions
diff --git a/progs/fpglsl/.gitignore b/progs/fpglsl/.gitignore
deleted file mode 100644
index 9fe73ab0678..00000000000
--- a/progs/fpglsl/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-fp-tri
diff --git a/progs/fpglsl/Makefile b/progs/fpglsl/Makefile
deleted file mode 100644
index 3bf14b4b709..00000000000
--- a/progs/fpglsl/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-# progs/tests/Makefile
-
-
-# These programs aren't intended to be included with the normal distro.
-# They're not too interesting but they're good for testing.
-
-TOP = ../..
-include $(TOP)/configs/current
-
-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-
-SOURCES = \
- fp-tri.c
-
-
-
-PROGS = $(SOURCES:%.c=%)
-
-INCLUDES = -I. -I$(TOP)/include -I../samples
-
-
-##### RULES #####
-
-.SUFFIXES:
-.SUFFIXES: .c
-
-.c:
- $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: $(PROGS)
-
-clean:
- rm -f $(PROGS)
- rm -f *.o
- rm -f getproclist.h
-
-
-
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
diff --git a/progs/fpglsl/SConscript b/progs/fpglsl/SConscript
deleted file mode 100644
index e31fa320238..00000000000
--- a/progs/fpglsl/SConscript
+++ /dev/null
@@ -1,13 +0,0 @@
-Import('env')
-
-if not env['GLUT']:
- Return()
-
-env = env.Clone()
-
-env.Prepend(LIBS = ['$GLUT_LIB'])
-
-env.Program(
- target = 'fp-tri',
- source = ['fp-tri.c'],
- )
diff --git a/progs/fpglsl/dowhile.glsl b/progs/fpglsl/dowhile.glsl
deleted file mode 100644
index ed9d7296753..00000000000
--- a/progs/fpglsl/dowhile.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-void main() {
- float sum = 0.0;
- do {
- sum += 0.1;
- break;
- } while (true);
- gl_FragColor = vec4(sum);
-}
diff --git a/progs/fpglsl/dowhile2.glsl b/progs/fpglsl/dowhile2.glsl
deleted file mode 100644
index f3e00b8e865..00000000000
--- a/progs/fpglsl/dowhile2.glsl
+++ /dev/null
@@ -1,10 +0,0 @@
-void main() {
- float sum = 0.0;
- do {
- sum += 0.1;
- if (sum < 0.499999)
- continue;
- break;
- } while (true);
- gl_FragColor = vec4(sum);
-}
diff --git a/progs/fpglsl/for.glsl b/progs/fpglsl/for.glsl
deleted file mode 100644
index 862ca8bd6cc..00000000000
--- a/progs/fpglsl/for.glsl
+++ /dev/null
@@ -1,11 +0,0 @@
-uniform int KernelSizeInt;
-
-void main() {
- int i;
- vec4 sum = vec4(0.0);
- for (i = 0; i < KernelSizeInt; ++i) {
- sum.g += 0.25;
- }
- sum.a = 1.0;
- gl_FragColor = sum;
-}
diff --git a/progs/fpglsl/forbreak.glsl b/progs/fpglsl/forbreak.glsl
deleted file mode 100644
index 0b8d957cb04..00000000000
--- a/progs/fpglsl/forbreak.glsl
+++ /dev/null
@@ -1,13 +0,0 @@
-uniform int KernelSizeInt;
-
-void main() {
- int i;
- vec4 sum = vec4(0.0);
- for (i = 0; i < KernelSizeInt; ++i) {
- sum.g += 0.25;
- if (i > 0)
- break;
- }
- sum.a = 1.0;
- gl_FragColor = sum;
-}
diff --git a/progs/fpglsl/fp-tri.c b/progs/fpglsl/fp-tri.c
deleted file mode 100644
index 8af09845dd8..00000000000
--- a/progs/fpglsl/fp-tri.c
+++ /dev/null
@@ -1,420 +0,0 @@
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef WIN32
-#include <unistd.h>
-#include <signal.h>
-#endif
-
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-#include "readtex.c"
-
-
-#define TEXTURE_FILE "../images/bw.rgb"
-
-unsigned show_fps = 0;
-unsigned int frame_cnt = 0;
-void alarmhandler(int);
-static const char *filename = NULL;
-
-static GLuint fragShader;
-static GLuint vertShader;
-static GLuint program;
-
-
-static void usage(char *name)
-{
- fprintf(stderr, "usage: %s [ options ] shader_filename\n", name);
-#ifndef WIN32
- fprintf(stderr, "\n" );
- fprintf(stderr, "options:\n");
- fprintf(stderr, " -fps show frames per second\n");
-#endif
-}
-
-#ifndef WIN32
-void alarmhandler (int sig)
-{
- if (sig == SIGALRM) {
- printf("%d frames in 5.0 seconds = %.3f FPS\n", frame_cnt,
- frame_cnt / 5.0);
-
- frame_cnt = 0;
- }
- signal(SIGALRM, alarmhandler);
- alarm(5);
-}
-#endif
-
-
-
-
-static void load_and_compile_shader(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, "fp-tri: problem compiling shader:\n%s\n", log);
- exit(1);
- }
-}
-
-static void read_shader(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, "fp-tri: Unable to open shader file %s\n", filename);
- exit(1);
- }
-
- n = fread(buffer, 1, max, f);
- printf("fp-tri: read %d bytes from shader file %s\n", n, filename);
- if (n > 0) {
- buffer[n] = 0;
- load_and_compile_shader(shader, buffer);
- }
-
- fclose(f);
- free(buffer);
-}
-
-static void check_link(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);
- }
-}
-
-static void setup_uniforms()
-{
- {
- GLint loc1f = glGetUniformLocationARB(program, "Offset1f");
- GLint loc2f = glGetUniformLocationARB(program, "Offset2f");
- GLint loc4f = glGetUniformLocationARB(program, "Offset4f");
- GLfloat vecKer[] =
- { 1.0, 0.0, 0.0, 1.0,
- 0.0, 1.0, 0.0, 1.0,
- 1.0, 0.0, 0.0, 1.0,
- 0.0, 0.0, 0.0, 1.0
- };
- if (loc1f >= 0)
- glUniform1fv(loc1f, 16, vecKer);
-
- if (loc2f >= 0)
- glUniform2fv(loc2f, 8, vecKer);
-
- if (loc4f >= 0)
- glUniform4fv(loc4f, 4, vecKer);
-
- }
-
- {
- GLint loci = glGetUniformLocationARB(program, "KernelSizeInt");
- if (loci >= 0)
- glUniform1i(loci, 4);
- }
- {
- GLint loc1f = glGetUniformLocationARB(program, "KernelValue1f");
- GLint loc2f = glGetUniformLocationARB(program, "KernelValue2f");
- GLint loc4f = glGetUniformLocationARB(program, "KernelValue4f");
- GLfloat vecKer[] =
- { 1.0, 0.0, 0.0, 0.25,
- 0.0, 1.0, 0.0, 0.25,
- 0.0, 0.0, 1.0, 0.25,
- 0.0, 0.0, 0.0, 0.25,
- 0.5, 0.0, 0.0, 0.35,
- 0.0, 0.5, 0.0, 0.35,
- 0.0, 0.0, 0.5, 0.35,
- 0.0, 0.0, 0.0, 0.35
- };
- if (loc1f >= 0)
- glUniform1fv(loc1f, 16, vecKer);
-
- if (loc2f >= 0)
- glUniform2fv(loc2f, 8, vecKer);
-
- if (loc4f >= 0)
- glUniform4fv(loc4f, 4, vecKer);
- }
-}
-
-static void prepare_shaders()
-{
- static const char *fragShaderText =
- "void main() {\n"
- " gl_FragColor = gl_Color;\n"
- "}\n";
- static const char *vertShaderText =
- "void main() {\n"
- " gl_FrontColor = gl_Color;\n"
- " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
- "}\n";
- fragShader = glCreateShader(GL_FRAGMENT_SHADER);
- if (filename)
- read_shader(fragShader, filename);
- else
- load_and_compile_shader(fragShader, fragShaderText);
-
-
- vertShader = glCreateShader(GL_VERTEX_SHADER);
- load_and_compile_shader(vertShader, vertShaderText);
-
- program = glCreateProgram();
- glAttachShader(program, fragShader);
- glAttachShader(program, vertShader);
- glLinkProgram(program);
- check_link(program);
- glUseProgram(program);
-
- setup_uniforms();
-}
-
-#define LEVELS 8
-#define SIZE (1<<LEVELS)
-static int TexWidth = SIZE, TexHeight = SIZE;
-
-
-static void
-ResetTextureLevel( int i )
-{
- GLubyte tex2d[SIZE*SIZE][4];
-
- {
- GLint Width = TexWidth / (1 << i);
- GLint Height = TexHeight / (1 << i);
- GLint s, t;
-
- for (s = 0; s < Width; s++) {
- for (t = 0; t < Height; t++) {
- tex2d[t*Width+s][0] = ((s / 16) % 2) ? 0 : 255;
- tex2d[t*Width+s][1] = ((t / 16) % 2) ? 0 : 255;
- tex2d[t*Width+s][2] = 128;
- tex2d[t*Width+s][3] = 255;
- }
- }
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- glTexImage2D(GL_TEXTURE_2D, i, GL_RGB, Width, Height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, tex2d);
- }
-}
-
-
-static void
-ResetTexture( void )
-{
- int i;
-
- for (i = 0; i <= LEVELS; i++)
- {
- ResetTextureLevel(i);
- }
-}
-
-static void Init( void )
-{
- GLuint Texture;
-
- /* Load texture */
- glGenTextures(1, &Texture);
- glBindTexture(GL_TEXTURE_2D, Texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
- printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE);
- exit(1);
- }
-
-
- glGenTextures(1, &Texture);
- glActiveTextureARB(GL_TEXTURE0_ARB + 1);
- glBindTexture(GL_TEXTURE_2D, Texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- {
- GLubyte data[32][32];
- int width = 32;
- int height = 32;
- int i;
- int j;
-
- for (i = 0; i < 32; i++)
- for (j = 0; j < 32; j++)
- {
- /**
- ** +-----------+
- ** | W |
- ** | +-----+ |
- ** | | | |
- ** | | B | |
- ** | | | |
- ** | +-----+ |
- ** | |
- ** +-----------+
- **/
- int i2 = i - height / 2;
- int j2 = j - width / 2;
- int h8 = height / 8;
- int w8 = width / 8;
- if ( -h8 <= i2 && i2 <= h8 && -w8 <= j2 && j2 <= w8 ) {
- data[i][j] = 0x00;
- } else if ( -2 * h8 <= i2 && i2 <= 2 * h8 && -2 * w8 <= j2 && j2 <= 2 * w8 ) {
- data[i][j] = 0x55;
- } else if ( -3 * h8 <= i2 && i2 <= 3 * h8 && -3 * w8 <= j2 && j2 <= 3 * w8 ) {
- data[i][j] = 0xaa;
- } else {
- data[i][j] = 0xff;
- }
- }
-
- glTexImage2D( GL_TEXTURE_2D, 0,
- GL_ALPHA8,
- 32, 32, 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, data );
- }
-
- glGenTextures(1, &Texture);
- glActiveTextureARB(GL_TEXTURE0_ARB + 2);
- glBindTexture(GL_TEXTURE_2D, Texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- ResetTexture();
-
- glClearColor(.1, .3, .5, 0);
-}
-
-
-
-
-static void args(int argc, char *argv[])
-{
- GLint i;
-
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-fps") == 0) {
- show_fps = 1;
- }
- else if (i == argc - 1) {
- filename = argv[i];
- }
- else {
- usage(argv[0]);
- exit(1);
- }
- }
-}
-
-
-
-
-
-static void Reshape(int width, int height)
-{
-
- glViewport(0, 0, (GLint)width, (GLint)height);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
- glMatrixMode(GL_MODELVIEW);
-}
-
-static void CleanUp(void)
-{
- glDeleteShader(fragShader);
- glDeleteShader(vertShader);
- glDeleteProgram(program);
-}
-
-static void Key(unsigned char key, int x, int y)
-{
-
- switch (key) {
- case 27:
- CleanUp();
- exit(1);
- default:
- break;
- }
-
- glutPostRedisplay();
-}
-
-static void Display(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
-
- glUseProgram(program);
- glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 1.0, 1.0, 0.0, 0.0);
- glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 0.0, 0.0, 1.0, 1.0);
- glBegin(GL_TRIANGLES);
-
- glColor3f(0,0,1);
- glTexCoord3f(1,1,0);
- glVertex3f( 0.9, -0.9, -30.0);
-
- glColor3f(1,0,0);
- glTexCoord3f(1,-1,0);
- glVertex3f( 0.9, 0.9, -30.0);
-
- glColor3f(0,1,0);
- glTexCoord3f(-1,0,0);
- glVertex3f(-0.9, 0.0, -30.0);
- glEnd();
-
- glFlush();
- if (show_fps) {
- ++frame_cnt;
- glutPostRedisplay();
- }
-}
-
-
-int main(int argc, char **argv)
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(250, 250);
- glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
- args(argc, argv);
- glutCreateWindow(filename ? filename : "fp-tri");
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Display);
- prepare_shaders();
- Init();
-#ifndef WIN32
- if (show_fps) {
- signal(SIGALRM, alarmhandler);
- alarm(5);
- }
-#endif
- glutMainLoop();
- return 0;
-}
diff --git a/progs/fpglsl/mov-imm.glsl b/progs/fpglsl/mov-imm.glsl
deleted file mode 100644
index cbb75ce342c..00000000000
--- a/progs/fpglsl/mov-imm.glsl
+++ /dev/null
@@ -1,3 +0,0 @@
-void main() {
- gl_FragColor = vec4(1,0,1,1);
-}
diff --git a/progs/fpglsl/mov.glsl b/progs/fpglsl/mov.glsl
deleted file mode 100644
index 4a1f185ba44..00000000000
--- a/progs/fpglsl/mov.glsl
+++ /dev/null
@@ -1,3 +0,0 @@
-void main() {
- gl_FragColor = gl_Color;
-}
diff --git a/progs/fpglsl/simpleif.glsl b/progs/fpglsl/simpleif.glsl
deleted file mode 100644
index 922421b4108..00000000000
--- a/progs/fpglsl/simpleif.glsl
+++ /dev/null
@@ -1,6 +0,0 @@
-void main() {
- // this should always be true
- if (gl_FragCoord.x >= 0.0) {
- gl_FragColor = vec4(0.5, 0.0, 0.5, 1.0);
- }
-}
diff --git a/progs/fpglsl/tex-multi.glsl b/progs/fpglsl/tex-multi.glsl
deleted file mode 100644
index 5220b7efaf2..00000000000
--- a/progs/fpglsl/tex-multi.glsl
+++ /dev/null
@@ -1,15 +0,0 @@
-// Multi-texture fragment shader
-// Brian Paul
-
-// Composite second texture over first.
-// We're assuming the 2nd texture has a meaningful alpha channel.
-
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-
-void main()
-{
- vec4 t1 = texture2D(tex1, gl_Color.xy);
- vec4 t2 = texture2D(tex2, gl_Color.yz);
- gl_FragColor = mix(t1, t2, t2.w);
-}
diff --git a/progs/fpglsl/tex.glsl b/progs/fpglsl/tex.glsl
deleted file mode 100644
index 4302fabe2d5..00000000000
--- a/progs/fpglsl/tex.glsl
+++ /dev/null
@@ -1,6 +0,0 @@
-uniform sampler2D tex1;
-
-void main()
-{
- gl_FragColor = texture2D(tex1, gl_Color.xy);
-}
diff --git a/progs/fpglsl/while.glsl b/progs/fpglsl/while.glsl
deleted file mode 100644
index 05fb860ddcf..00000000000
--- a/progs/fpglsl/while.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-void main() {
- float sum = 0.0;
- while (sum < 0.499999) {
- sum += 0.1;
- }
- gl_FragColor = vec4(sum);
-}
diff --git a/progs/fpglsl/while2.glsl b/progs/fpglsl/while2.glsl
deleted file mode 100644
index 19c8904e283..00000000000
--- a/progs/fpglsl/while2.glsl
+++ /dev/null
@@ -1,9 +0,0 @@
-void main() {
- float sum = 0.0;
- while (true) {
- sum += 0.1;
- if (sum > 0.8)
- break;
- }
- gl_FragColor = vec4(sum);
-}