summaryrefslogtreecommitdiff
path: root/progs/demos/fslight.c
diff options
context:
space:
mode:
Diffstat (limited to 'progs/demos/fslight.c')
-rw-r--r--progs/demos/fslight.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/progs/demos/fslight.c b/progs/demos/fslight.c
index e6d83bf8fb..f0d76a4a06 100644
--- a/progs/demos/fslight.c
+++ b/progs/demos/fslight.c
@@ -105,6 +105,7 @@ Redisplay(void)
GLfloat fps = frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n",
frames, seconds, fps);
+ fflush(stdout);
t0 = t;
frames = 0;
}
@@ -225,33 +226,6 @@ static void
TestFunctions(void)
{
printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
- {
- GLfloat pos[3];
- printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
- printf("Light pos %g %g %g\n", pos[0], pos[1], pos[2]);
- }
-
-
- {
- GLfloat m[16], result[16];
- GLint mPos;
- int i;
-
- for (i = 0; i < 16; i++)
- m[i] = (float) i;
-
- mPos = glGetUniformLocation_func(program, "m");
- printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
- glUniformMatrix4fv_func(mPos, 1, GL_FALSE, m);
- printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
-
- glGetUniformfv_func(program, mPos, result);
- printf("Error 0x%x at line %d\n", glGetError(), __LINE__);
-
- for (i = 0; i < 16; i++) {
- printf("%8g %8g\n", m[i], result[i]);
- }
- }
assert(glIsProgram_func(program));
assert(glIsShader_func(fragShader));
@@ -280,6 +254,22 @@ TestFunctions(void)
glGetProgramInfoLog_func(program, 1000, &len, log);
printf("Program Info Log: %s\n", log);
}
+
+ /* active uniforms */
+ {
+ GLint n, max, i;
+ glGetProgramiv_func(program, GL_ACTIVE_UNIFORMS, &n);
+ glGetProgramiv_func(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max);
+ printf("Num uniforms: %d Max name length: %d\n", n, max);
+ for (i = 0; i < n; i++) {
+ GLint size, len;
+ GLenum type;
+ char name[100];
+ glGetActiveUniform_func(program, i, 100, &len, &size, &type, name);
+ printf(" %d: %s nameLen=%d size=%d type=0x%x\n",
+ i, name, len, size, type);
+ }
+ }
}
@@ -512,7 +502,9 @@ Init(void)
glUniform4fv_func(uDiffuse, 1, diffuse);
glUniform4fv_func(uSpecular, 1, specular);
/* assert(glGetError() == 0);*/
+#if TEXTURE
glUniform1i_func(uTexture, 2); /* use texture unit 2 */
+#endif
/*assert(glGetError() == 0);*/
if (CoordAttrib) {
@@ -591,10 +583,14 @@ ParseOptions(int argc, char *argv[])
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-fs") == 0) {
- FragProgFile = argv[i+1];
+ FragProgFile = argv[++i];
}
else if (strcmp(argv[i], "-vs") == 0) {
- VertProgFile = argv[i+1];
+ VertProgFile = argv[++i];
+ }
+ else {
+ fprintf(stderr, "unknown option %s\n", argv[i]);
+ break;
}
}
}