summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2009-04-22 21:41:57 +1000
committerDave Airlie <airlied@linux.ie>2009-04-22 21:41:57 +1000
commit466c78c93538f2853449124c06274d538830cd5a (patch)
treea6bd88060ba328d8bed1ff2ea1a37ee741a90a17 /progs
parent65fe0c86ffcff99f9f09606d462bf3731ea0c308 (diff)
parentf057f6543da469f231d551cb5728d98df8add4fa (diff)
Merge remote branch 'origin/master' into radeon-rewrite
Diffstat (limited to 'progs')
-rw-r--r--progs/demos/.gitignore7
-rw-r--r--progs/demos/Makefile8
-rw-r--r--progs/demos/SConscript10
-rw-r--r--progs/demos/dinoshade.c (renamed from progs/tests/dinoshade.c)6
-rw-r--r--progs/demos/fbotexture.c (renamed from progs/tests/fbotexture.c)0
-rw-r--r--progs/demos/projtex.c (renamed from progs/tests/projtex.c)60
-rw-r--r--progs/fp/swz3.txt5
-rw-r--r--progs/glsl/.gitignore3
-rw-r--r--progs/glsl/Makefile274
-rw-r--r--progs/glsl/array.c261
-rw-r--r--progs/glsl/bump.c3
-rw-r--r--progs/glsl/linktest.c2
-rw-r--r--progs/glsl/noise2.c (renamed from progs/demos/glslnoise.c)0
-rw-r--r--progs/glsl/texaaline.c369
-rw-r--r--progs/samples/blendeq.c2
-rw-r--r--progs/tests/Makefile13
-rw-r--r--progs/tests/SConscript9
-rw-r--r--progs/tests/afsmultiarb.c2
-rw-r--r--progs/tests/glutfx.c (renamed from progs/demos/glutfx.c)0
-rw-r--r--progs/tests/jkrahntest.c2
-rw-r--r--progs/tests/mipmap_view.c15
-rw-r--r--progs/tests/occlude.c (renamed from progs/demos/occlude.c)0
-rw-r--r--progs/tests/shader_api.c8
-rw-r--r--progs/tests/streaming_rect.c (renamed from progs/demos/streaming_rect.c)0
-rw-r--r--progs/tests/texcompress2.c23
-rw-r--r--progs/tests/texdown.c (renamed from progs/demos/texdown.c)0
-rw-r--r--progs/tests/texobj.c (renamed from progs/demos/texobj.c)0
-rw-r--r--progs/tests/vparray.c2
-rw-r--r--progs/tests/vptest1.c2
-rw-r--r--progs/trivial/tri-viewport.c237
-rw-r--r--progs/wgl/SConscript2
-rw-r--r--progs/wgl/wglinfo.c737
32 files changed, 1835 insertions, 227 deletions
diff --git a/progs/demos/.gitignore b/progs/demos/.gitignore
index d59d175212..f3c7091bcc 100644
--- a/progs/demos/.gitignore
+++ b/progs/demos/.gitignore
@@ -5,10 +5,12 @@ bounce
clearspd
copypix
cubemap
+dinoshade
drawpix
engine
extfuncs.h
fbo_firecube
+fbotexture
fire
fogcoord
fplight
@@ -27,11 +29,9 @@ isosurf
lodbias
morph3d
multiarb
-occlude
-osdemo
paltex
-pixeltex
pointblast
+projtex
rain
ray
readpix
@@ -61,4 +61,5 @@ trispd
tunnel
tunnel2
vao_demo
+Windows
winpos
diff --git a/progs/demos/Makefile b/progs/demos/Makefile
index 32c6072123..c17595ec79 100644
--- a/progs/demos/Makefile
+++ b/progs/demos/Makefile
@@ -19,9 +19,11 @@ PROGS = \
clearspd \
copypix \
cubemap \
+ dinoshade \
drawpix \
engine \
fbo_firecube \
+ fbotexture \
fire \
fogcoord \
fplight \
@@ -32,9 +34,7 @@ PROGS = \
geartrain \
glinfo \
gloss \
- glslnoise \
gltestperf \
- glutfx \
isosurf \
ipers \
lodbias \
@@ -42,6 +42,7 @@ PROGS = \
multiarb \
paltex \
pointblast \
+ projtex \
rain \
ray \
readpix \
@@ -49,7 +50,6 @@ PROGS = \
renormal \
shadowtex \
singlebuffer \
- streaming_rect \
spectex \
spriteblast \
stex3d \
@@ -57,9 +57,7 @@ PROGS = \
terrain \
tessdemo \
texcyl \
- texdown \
texenv \
- texobj \
textures \
trispd \
tunnel \
diff --git a/progs/demos/SConscript b/progs/demos/SConscript
index bc166dd789..f851870bcf 100644
--- a/progs/demos/SConscript
+++ b/progs/demos/SConscript
@@ -39,11 +39,9 @@ progs = [
'geartrain',
'glinfo',
'gloss',
- 'glslnoise',
'gltestperf',
- 'glutfx',
- 'isosurf',
'ipers',
+ 'isosurf',
'lodbias',
'morph3d',
'multiarb',
@@ -55,7 +53,6 @@ progs = [
'renormal',
'shadowtex',
'singlebuffer',
- 'streaming_rect',
'spectex',
'spriteblast',
'stex3d',
@@ -63,15 +60,16 @@ progs = [
'terrain',
'tessdemo',
'texcyl',
- 'texdown',
'texenv',
- 'texobj',
'textures',
'trispd',
'tunnel',
'tunnel2',
'vao_demo',
'winpos',
+ 'dinoshade',
+ 'fbotexture',
+ 'projtex',
]
for prog in progs:
diff --git a/progs/tests/dinoshade.c b/progs/demos/dinoshade.c
index fb7c3f4535..451da2ec89 100644
--- a/progs/tests/dinoshade.c
+++ b/progs/demos/dinoshade.c
@@ -165,7 +165,7 @@ enum {
};
/* Create a matrix that will project the desired shadow. */
-void
+static void
shadowMatrix(GLfloat shadowMat[4][4],
GLfloat groundplane[4],
GLfloat lightpos[4])
@@ -201,7 +201,7 @@ shadowMatrix(GLfloat shadowMat[4][4],
}
/* Find the plane equation given 3 points. */
-void
+static void
findPlane(GLfloat plane[4],
GLfloat v0[3], GLfloat v1[3], GLfloat v2[3])
{
@@ -224,7 +224,7 @@ findPlane(GLfloat plane[4],
plane[D] = -(plane[A] * v0[X] + plane[B] * v0[Y] + plane[C] * v0[Z]);
}
-void
+static void
extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize,
GLdouble thickness, GLuint side, GLuint edge, GLuint whole)
{
diff --git a/progs/tests/fbotexture.c b/progs/demos/fbotexture.c
index 50a4b00afc..50a4b00afc 100644
--- a/progs/tests/fbotexture.c
+++ b/progs/demos/fbotexture.c
diff --git a/progs/tests/projtex.c b/progs/demos/projtex.c
index 800d81ecd6..99154d7bdc 100644
--- a/progs/tests/projtex.c
+++ b/progs/demos/projtex.c
@@ -20,11 +20,7 @@
#include <math.h>
#include <GL/glew.h>
#include <GL/glut.h>
-#if 0
-#include "texture.h"
-#else
-#include "../util/readtex.c"
-#endif
+#include "readtex.h"
/* Some <math.h> files do not define M_PI... */
@@ -67,14 +63,15 @@ GLfloat zoomFactor = 1.0;
/*****************************************************************/
-void ActiveTexture(int i)
+static void
+ActiveTexture(int i)
{
glActiveTextureARB(i);
}
/* matrix = identity */
-void
+static void
matrixIdentity(GLfloat matrix[16])
{
matrix[0] = 1.0;
@@ -96,7 +93,7 @@ matrixIdentity(GLfloat matrix[16])
}
/* matrix2 = transpose(matrix1) */
-void
+static void
matrixTranspose(GLfloat matrix2[16], GLfloat matrix1[16])
{
matrix2[0] = matrix1[0];
@@ -167,7 +164,7 @@ imgLoad(char *filenameIn, int borderIn, GLfloat borderColorIn[4],
/*****************************************************************/
/* Load the image file specified on the command line as the current texture */
-void
+static void
loadImageTextures(void)
{
GLfloat borderColor[4] =
@@ -252,7 +249,7 @@ loadImageTextures(void)
}
/* Create a simple spotlight pattern and make it the current texture */
-void
+static void
loadSpotlightTexture(void)
{
static int texWidth = 64, texHeight = 64;
@@ -302,7 +299,7 @@ loadSpotlightTexture(void)
/*****************************************************************/
-void
+static void
checkErrors(void)
{
GLenum error;
@@ -311,7 +308,7 @@ checkErrors(void)
}
}
-void
+static void
drawCube(void)
{
glBegin(GL_QUADS);
@@ -360,7 +357,7 @@ drawCube(void)
glEnd();
}
-void
+static void
drawDodecahedron(void)
{
#define A (0.5 * 1.61803) /* (sqrt(5) + 1) / 2 */
@@ -446,7 +443,7 @@ drawDodecahedron(void)
}
}
-void
+static void
drawSphere(void)
{
int numMajor = 24;
@@ -573,7 +570,7 @@ drawTextureProjection(void)
/*****************************************************************/
-void
+static void
initialize(void)
{
GLfloat light0Pos[4] =
@@ -670,7 +667,7 @@ initialize(void)
}
}
-void
+static void
display(void)
{
int i;
@@ -755,10 +752,10 @@ display(void)
/*****************************************************************/
/* simple trackball-like motion control */
-float lastPos[3];
-int lastTime;
+static float lastPos[3];
+static int lastTime;
-void
+static void
ptov(int x, int y, int width, int height, float v[3])
{
float d, a;
@@ -774,7 +771,7 @@ ptov(int x, int y, int width, int height, float v[3])
v[2] *= a;
}
-void
+static void
startMotion(int x, int y, int but, int time)
{
if (but == GLUT_LEFT_BUTTON) {
@@ -789,13 +786,13 @@ startMotion(int x, int y, int but, int time)
ptov(x, y, winWidth, winHeight, lastPos);
}
-void
+static void
animate(void)
{
glutPostRedisplay();
}
-void
+static void
vis(int visible)
{
if (visible == GLUT_VISIBLE) {
@@ -807,7 +804,7 @@ vis(int visible)
}
}
-void
+static void
stopMotion(int but, int time)
{
if ((but == GLUT_LEFT_BUTTON && mode == MoveView) ||
@@ -829,7 +826,7 @@ stopMotion(int but, int time)
}
}
-void
+static void
trackMotion(int x, int y)
{
float curPos[3], dx, dy, dz;
@@ -854,7 +851,7 @@ trackMotion(int x, int y)
/*****************************************************************/
-void
+static void
object(void)
{
static int object;
@@ -881,7 +878,7 @@ nop(void)
{
}
-void
+static void
texture(void)
{
static int texture = 0;
@@ -912,7 +909,7 @@ texture(void)
}
}
-void
+static void
help(void)
{
printf("'h' - help\n");
@@ -927,7 +924,7 @@ help(void)
}
/* ARGSUSED1 */
-void
+static void
key(unsigned char key, int x, int y)
{
switch (key) {
@@ -966,7 +963,7 @@ key(unsigned char key, int x, int y)
glutPostRedisplay();
}
-void
+static void
mouse(int button, int state, int x, int y)
{
if (state == GLUT_DOWN)
@@ -976,7 +973,7 @@ mouse(int button, int state, int x, int y)
glutPostRedisplay();
}
-void
+static void
reshape(int w, int h)
{
winWidth = w;
@@ -985,7 +982,7 @@ reshape(int w, int h)
}
-void
+static void
menu(int selection)
{
if (selection == 666) {
@@ -1005,6 +1002,7 @@ main(int argc, char **argv)
assert(NumTextures <= MAX_TEX);
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
+ glutInitWindowSize(500,500);
(void) glutCreateWindow("projtex");
glewInit();
diff --git a/progs/fp/swz3.txt b/progs/fp/swz3.txt
new file mode 100644
index 0000000000..382f5880d3
--- /dev/null
+++ b/progs/fp/swz3.txt
@@ -0,0 +1,5 @@
+!!ARBfp1.0
+TEMP R0, R1;
+MOV R0, -fragment.color;
+SWZ result.color, R0, -y, -x, z, 1;
+END
diff --git a/progs/glsl/.gitignore b/progs/glsl/.gitignore
index d3e31163d8..39d90c23ac 100644
--- a/progs/glsl/.gitignore
+++ b/progs/glsl/.gitignore
@@ -1,3 +1,4 @@
+array
bitmap
brick
bump
@@ -11,6 +12,7 @@ mandelbrot
multinoise
multitex
noise
+noise2
pointcoord
points
readtex.c
@@ -21,6 +23,7 @@ shaderutil.c
shaderutil.h
shadow_sampler
skinning
+texaaline
texdemo1
toyball
trirast
diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
index 0f1a299570..71db895d1d 100644
--- a/progs/glsl/Makefile
+++ b/progs/glsl/Makefile
@@ -5,46 +5,69 @@ include $(TOP)/configs/current
INCDIR = $(TOP)/include
-LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+LIB_DEP = \
+ $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) \
+ $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+ $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
-PROGS = \
- bitmap \
- brick \
- bump \
- convolutions \
- deriv \
- identity \
- fragcoord \
- linktest \
- mandelbrot \
- multinoise \
- multitex \
- noise \
- points \
- pointcoord \
- samplers \
- samplers_array \
- shadow_sampler \
- skinning \
- texdemo1 \
- toyball \
- twoside \
- trirast \
- vert-or-frag-only \
- vert-tex
+INCLUDE_DIRS = -I$(TOP)/progs/util
+
+DEMO_SOURCES = \
+ array.c \
+ bitmap.c \
+ brick.c \
+ bump.c \
+ convolutions.c \
+ deriv.c \
+ fragcoord.c \
+ identity.c \
+ linktest.c \
+ mandelbrot.c \
+ multinoise.c \
+ multitex.c \
+ noise.c \
+ noise2.c \
+ pointcoord.c \
+ points.c \
+ samplers.c \
+ shadow_sampler.c \
+ skinning.c \
+ texaaline.c \
+ texdemo1.c \
+ toyball.c \
+ trirast.c \
+ twoside.c \
+ vert-or-frag-only.c \
+ vert-tex.c
+
+UTIL_HEADERS = \
+ extfuncs.h \
+ shaderutil.h \
+ readtex.h
+
+UTIL_SOURCES = \
+ shaderutil.c \
+ readtex.c
+
+UTIL_OBJS = $(UTIL_SOURCES:.c=.o)
+
+
+PROGS = $(DEMO_SOURCES:%.c=%)
+
##### RULES #####
-.SUFFIXES:
-.SUFFIXES: .c
+# make .o file from .c file:
+.c.o:
+ $(APP_CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@
-# make executable from .c file:
-.c: $(LIB_DEP)
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
+# make executable from .o files
+.o:
+ $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(UTIL_OBJS) $(LIBS) -o $@
##### TARGETS #####
@@ -52,188 +75,163 @@ PROGS = \
default: $(PROGS)
+clean:
+ -rm -f $(PROGS)
+ -rm -f *.o *~
+ -rm -f extfuncs.h
+ -rm -f shaderutil.*
+
+
##### Extra dependencies
-extfuncs.h: $(TOP)/progs/util/extfuncs.h
- cp $< .
+extfuncs.h:
+ cp $(TOP)/progs/util/extfuncs.h .
+readtex.c:
+ cp $(TOP)/progs/util/readtex.c .
-readtex.c: $(TOP)/progs/util/readtex.c
- cp $< .
+readtex.h:
+ cp $(TOP)/progs/util/readtex.h .
-readtex.h: $(TOP)/progs/util/readtex.h
- cp $< .
+shaderutil.c:
+ cp $(TOP)/progs/util/shaderutil.c .
-readtex.o: readtex.c readtex.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
+shaderutil.h:
+ cp $(TOP)/progs/util/shaderutil.h .
-shaderutil.c: $(TOP)/progs/util/shaderutil.c
- cp $< .
-shaderutil.h: $(TOP)/progs/util/shaderutil.h
- cp $< .
+array.o: $(UTIL_HEADERS)
-shaderutil.o: shaderutil.c shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) shaderutil.c
+array: array.o $(UTIL_OBJS)
+bitmap.o: $(UTIL_HEADERS)
-bitmap.o: bitmap.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) bitmap.c
+bitmap: bitmap.o $(UTIL_OBJS)
-bitmap: bitmap.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bitmap.o shaderutil.o $(LIBS) -o $@
+brick.o: $(UTIL_HEADERS)
-brick.o: brick.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) brick.c
+brick: brick.o $(UTIL_OBJS)
-brick: brick.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) brick.o shaderutil.o $(LIBS) -o $@
+bump.o: $(UTIL_HEADERS)
-bump.o: bump.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) bump.c
+bump: bump.o $(UTIL_OBJS)
-bump: bump.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bump.o shaderutil.o $(LIBS) -o $@
+convolutions.o: $(UTIL_HEADERS)
-convolutions.o: convolutions.c readtex.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c
+convolutions: convolutions.o $(UTIL_OBJS)
-convolutions: convolutions.o readtex.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) convolutions.o readtex.o $(LIBS) -o $@
+deriv.o: deriv.c $(UTIL_HEADERS)
-deriv.o: deriv.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) deriv.c
+deriv: deriv.o $(UTIL_OBJS)
-deriv: deriv.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@
+identity.o: $(UTIL_HEADERS)
-identity.o: identity.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) identity.c
+identity: identity.o $(UTIL_OBJS)
-identity: identity.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) identity.o shaderutil.o $(LIBS) -o $@
+fragcoord.o: $(UTIL_HEADERS)
-fragcoord.o: fragcoord.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c
+fragcoord: fragcoord.o $(UTIL_OBJS)
-fragcoord: fragcoord.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@
+linktest.o: $(UTIL_HEADERS)
-linktest.o: linktest.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) linktest.c
+linktest: linktest.o $(UTIL_OBJS)
-linktest: linktest.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) linktest.o shaderutil.o $(LIBS) -o $@
-mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c
+mandelbrot.o: $(UTIL_HEADERS)
-mandelbrot: mandelbrot.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) mandelbrot.o shaderutil.o $(LIBS) -o $@
+mandelbrot: mandelbrot.o $(UTIL_OBJS)
-multitex.o: multitex.c extfuncs.h readtex.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) multitex.c
-multitex: multitex.o readtex.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) multitex.o readtex.o shaderutil.o $(LIBS) -o $@
+multinoise.o: $(UTIL_HEADERS)
+multinoise: multinoise.o $(UTIL_OBJS)
-noise.o: noise.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) noise.c
-noise: noise.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) noise.o shaderutil.o $(LIBS) -o $@
+multitex.o: $(UTIL_HEADERS)
+multitex: multitex.o $(UTIL_OBJS)
-points.o: points.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) points.c
-points: points.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) points.o shaderutil.o $(LIBS) -o $@
+noise.o: $(UTIL_HEADERS)
+noise: noise.o $(UTIL_OBJS)
-pointcoord.o: pointcoord.c readtex.h extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) pointcoord.c
-pointcoord: pointcoord.o readtex.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) pointcoord.o readtex.o shaderutil.o $(LIBS) -o $@
+noise2.o: $(UTIL_HEADERS)
+noise2: noise2.o $(UTIL_OBJS)
-samplers.o: samplers.c readtex.h extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) samplers.c
-samplers: samplers.o readtex.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers.o readtex.o shaderutil.o $(LIBS) -o $@
+points.o: $(UTIL_HEADERS)
-samplers_array.o: samplers.c readtex.h extfuncs.h shaderutil.h
- $(APP_CC) -c -DSAMPLERS_ARRAY -I$(INCDIR) $(CFLAGS) samplers.c -o samplers_array.o
+points: points.o $(UTIL_OBJS)
-samplers_array: samplers_array.o readtex.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers_array.o readtex.o shaderutil.o $(LIBS) -o $@
-skinning.o: skinning.c readtex.h extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) skinning.c
+pointcoord.o: $(UTIL_HEADERS)
-skinning: skinning.o readtex.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) skinning.o readtex.o shaderutil.o $(LIBS) -o $@
+pointcoord: pointcoord.o $(UTIL_OBJS)
-texdemo1.o: texdemo1.c readtex.h extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
+samplers.o: $(UTIL_HEADERS)
-texdemo1: texdemo1.o readtex.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o shaderutil.o $(LIBS) -o $@
+samplers: samplers.o $(UTIL_OBJS)
-toyball.o: toyball.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) toyball.c
+samplers_array.o: $(UTIL_HEADERS)
-toyball: toyball.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) toyball.o shaderutil.o $(LIBS) -o $@
+samplers_array: samplers_array.o $(UTIL_OBJS)
-twoside.o: twoside.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) twoside.c
+shadow_sampler.o: $(UTIL_HEADERS)
-twoside: twoside.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) twoside.o shaderutil.o $(LIBS) -o $@
+shadow_sampler: shadow_sampler.o $(UTIL_OBJS)
-trirast.o: trirast.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trirast.c
+skinning.o: $(UTIL_HEADERS)
-trirast: trirast.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@
+skinning: skinning.o $(UTIL_OBJS)
-vert-or-frag-only.o: vert-or-frag-only.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-or-frag-only.c
+texaaline.o: $(UTIL_HEADERS)
-vert-or-frag-only: vert-or-frag-only.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@
+texaaline: texaaline.o $(UTIL_OBJS)
-vert-tex.o: vert-tex.c extfuncs.h shaderutil.h
- $(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c
+texdemo1.o: $(UTIL_HEADERS)
-vert-tex: vert-tex.o shaderutil.o
- $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-tex.o shaderutil.o $(LIBS) -o $@
+texdemo1: texdemo1.o $(UTIL_OBJS)
+toyball.o: $(UTIL_HEADERS)
+toyball: toyball.o $(UTIL_OBJS)
-clean:
- -rm -f $(PROGS)
- -rm -f *.o *~
- -rm -f extfuncs.h
- -rm -f shaderutil.*
+
+twoside.o: $(UTIL_HEADERS)
+
+twoside: twoside.o $(UTIL_OBJS)
+
+
+trirast.o: $(UTIL_HEADERS)
+
+trirast: trirast.o $(UTIL_OBJS)
+
+
+vert-or-frag-only.o: $(UTIL_HEADERS)
+
+vert-or-frag-only: vert-or-frag-only.o $(UTIL_OBJS)
+
+
+vert-tex.o: $(UTIL_HEADERS)
+
+vert-tex: vert-tex.o $(UTIL_OBJS)
diff --git a/progs/glsl/array.c b/progs/glsl/array.c
new file mode 100644
index 0000000000..46ef8043bc
--- /dev/null
+++ b/progs/glsl/array.c
@@ -0,0 +1,261 @@
+/**
+ * Test variable array indexing in a vertex shader.
+ * Brian Paul
+ * 17 April 2009
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+/**
+ * The vertex position.z is used as a (variable) index into an
+ * array which returns a new Z value.
+ */
+static const char *VertShaderText =
+ "uniform sampler2D tex1; \n"
+ "uniform float HeightArray[20]; \n"
+ "void main() \n"
+ "{ \n"
+ " vec4 pos = gl_Vertex; \n"
+ " int i = int(pos.z * 9.5); \n"
+ " pos.z = HeightArray[i]; \n"
+ " gl_Position = gl_ModelViewProjectionMatrix * pos; \n"
+ " gl_FrontColor = pos; \n"
+ "} \n";
+
+static const char *FragShaderText =
+ "void main() \n"
+ "{ \n"
+ " gl_FragColor = gl_Color; \n"
+ "} \n";
+
+
+static GLuint fragShader;
+static GLuint vertShader;
+static GLuint program;
+
+static GLint win = 0;
+static GLboolean Anim = GL_TRUE;
+static GLboolean WireFrame = GL_TRUE;
+static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f;
+
+
+static void
+Idle(void)
+{
+ zRot = 90 + glutGet(GLUT_ELAPSED_TIME) * 0.05;
+ glutPostRedisplay();
+}
+
+
+/** z=f(x,y) */
+static float
+fz(float x, float y)
+{
+ return fabs(cos(1.5*x) + cos(1.5*y));
+}
+
+
+static void
+DrawMesh(void)
+{
+ GLfloat xmin = -2.0, xmax = 2.0;
+ GLfloat ymin = -2.0, ymax = 2.0;
+ GLuint xdivs = 20, ydivs = 20;
+ GLfloat dx = (xmax - xmin) / xdivs;
+ GLfloat dy = (ymax - ymin) / ydivs;
+ GLfloat ds = 1.0 / xdivs, dt = 1.0 / ydivs;
+ GLfloat x, y, s, t;
+ GLuint i, j;
+
+ y = ymin;
+ t = 0.0;
+ for (i = 0; i < ydivs; i++) {
+ x = xmin;
+ s = 0.0;
+ glBegin(GL_QUAD_STRIP);
+ for (j = 0; j < xdivs; j++) {
+ float z0 = fz(x, y), z1 = fz(x, y + dy);
+
+ glTexCoord2f(s, t);
+ glVertex3f(x, y, z0);
+
+ glTexCoord2f(s, t + dt);
+ glVertex3f(x, y + dy, z1);
+ x += dx;
+ s += ds;
+ }
+ glEnd();
+ y += dy;
+ t += dt;
+ }
+}
+
+
+static void
+Redisplay(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if (WireFrame)
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ else
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ glPushMatrix();
+ glRotatef(xRot, 1.0f, 0.0f, 0.0f);
+ glRotatef(yRot, 0.0f, 1.0f, 0.0f);
+ glRotatef(zRot, 0.0f, 0.0f, 1.0f);
+
+ glPushMatrix();
+ DrawMesh();
+ glPopMatrix();
+
+ glPopMatrix();
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0f, 0.0f, -15.0f);
+}
+
+
+static void
+CleanUp(void)
+{
+ glDeleteShader_func(fragShader);
+ glDeleteShader_func(vertShader);
+ glDeleteProgram_func(program);
+ glutDestroyWindow(win);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ const GLfloat step = 2.0;
+ (void) x;
+ (void) y;
+
+ switch(key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'w':
+ WireFrame = !WireFrame;
+ break;
+ case 'z':
+ zRot += step;
+ break;
+ case 'Z':
+ zRot -= step;
+ break;
+ case 27:
+ CleanUp();
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+ const GLfloat step = 2.0;
+
+ (void) x;
+ (void) y;
+
+ switch(key) {
+ case GLUT_KEY_UP:
+ xRot += step;
+ break;
+ case GLUT_KEY_DOWN:
+ xRot -= step;
+ break;
+ case GLUT_KEY_LEFT:
+ yRot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ yRot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ GLfloat HeightArray[20];
+ GLint u, i;
+
+ if (!ShadersSupported())
+ exit(1);
+
+ GetExtensionFuncs();
+
+ vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
+ fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
+ program = LinkShaders(vertShader, fragShader);
+
+ glUseProgram_func(program);
+
+ /* Setup the HeightArray[] uniform */
+ for (i = 0; i < 20; i++)
+ HeightArray[i] = i / 20.0;
+ u = glGetUniformLocation_func(program, "HeightArray");
+ glUniform1fv_func(u, 20, HeightArray);
+
+ assert(glGetError() == 0);
+
+ glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
+ glEnable(GL_DEPTH_TEST);
+ glColor3f(1, 1, 1);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowSize(500, 500);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Redisplay);
+ Init();
+ if (Anim)
+ glutIdleFunc(Idle);
+ glutMainLoop();
+ return 0;
+}
+
diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c
index b93ab44b5b..0ea1f8331f 100644
--- a/progs/glsl/bump.c
+++ b/progs/glsl/bump.c
@@ -150,10 +150,11 @@ Redisplay(void)
static void
Reshape(int width, int height)
{
+ float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -15.0f);
diff --git a/progs/glsl/linktest.c b/progs/glsl/linktest.c
index 601b24e893..988d082341 100644
--- a/progs/glsl/linktest.c
+++ b/progs/glsl/linktest.c
@@ -242,7 +242,7 @@ int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
- glutInitWindowPosition( 0, 0);
+ glutInitWindowSize(300, 300);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
Win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
diff --git a/progs/demos/glslnoise.c b/progs/glsl/noise2.c
index e972b62673..e972b62673 100644
--- a/progs/demos/glslnoise.c
+++ b/progs/glsl/noise2.c
diff --git a/progs/glsl/texaaline.c b/progs/glsl/texaaline.c
new file mode 100644
index 0000000000..0b3cc84958
--- /dev/null
+++ b/progs/glsl/texaaline.c
@@ -0,0 +1,369 @@
+/**
+ * AA lines with texture mapped quads
+ *
+ * Brian Paul
+ * 9 Feb 2008
+ */
+
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+
+
+static GLint WinWidth = 300, WinHeight = 300;
+static GLint win = 0;
+static GLfloat Width = 8.;
+
+/*
+ * Quad strip for line from v0 to v1:
+ *
+ 1 3 5 7
+ +---+---------------------+---+
+ | |
+ | *v0 v1* |
+ | |
+ +---+---------------------+---+
+ 0 2 4 6
+ */
+static void
+QuadLine(const GLfloat *v0, const GLfloat *v1, GLfloat width)
+{
+ GLfloat dx = v1[0] - v0[0];
+ GLfloat dy = v1[1] - v0[1];
+ GLfloat len = sqrt(dx*dx + dy*dy);
+ float dx0, dx1, dx2, dx3, dx4, dx5, dx6, dx7;
+ float dy0, dy1, dy2, dy3, dy4, dy5, dy6, dy7;
+
+ dx /= len;
+ dy /= len;
+
+ width *= 0.5; /* half width */
+ dx = dx * (width + 0.0);
+ dy = dy * (width + 0.0);
+
+ dx0 = -dx+dy; dy0 = -dy-dx;
+ dx1 = -dx-dy; dy1 = -dy+dx;
+
+ dx2 = 0+dy; dy2 = -dx+0;
+ dx3 = 0-dy; dy3 = +dx+0;
+
+ dx4 = 0+dy; dy4 = -dx+0;
+ dx5 = 0-dy; dy5 = +dx+0;
+
+ dx6 = dx+dy; dy6 = dy-dx;
+ dx7 = dx-dy; dy7 = dy+dx;
+
+ /*
+ printf("dx, dy = %g, %g\n", dx, dy);
+ printf(" dx0, dy0: %g, %g\n", dx0, dy0);
+ printf(" dx1, dy1: %g, %g\n", dx1, dy1);
+ printf(" dx2, dy2: %g, %g\n", dx2, dy2);
+ printf(" dx3, dy3: %g, %g\n", dx3, dy3);
+ */
+
+ glBegin(GL_QUAD_STRIP);
+ glTexCoord2f(0, 0);
+ glVertex2f(v0[0] + dx0, v0[1] + dy0);
+ glTexCoord2f(0, 1);
+ glVertex2f(v0[0] + dx1, v0[1] + dy1);
+
+ glTexCoord2f(0.5, 0);
+ glVertex2f(v0[0] + dx2, v0[1] + dy2);
+ glTexCoord2f(0.5, 1);
+ glVertex2f(v0[0] + dx3, v0[1] + dy3);
+
+ glTexCoord2f(0.5, 0);
+ glVertex2f(v1[0] + dx2, v1[1] + dy2);
+ glTexCoord2f(0.5, 1);
+ glVertex2f(v1[0] + dx3, v1[1] + dy3);
+
+ glTexCoord2f(1, 0);
+ glVertex2f(v1[0] + dx6, v1[1] + dy6);
+ glTexCoord2f(1, 1);
+ glVertex2f(v1[0] + dx7, v1[1] + dy7);
+ glEnd();
+}
+
+
+static float Cos(float a)
+{
+ return cos(a * M_PI / 180.);
+}
+
+static float Sin(float a)
+{
+ return sin(a * M_PI / 180.);
+}
+
+static void
+Redisplay(void)
+{
+ int i;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor3f(1, 1, 1);
+
+ glEnable(GL_BLEND);
+ glEnable(GL_TEXTURE_2D);
+
+ for (i = 0; i < 360; i+=5) {
+ float v0[2], v1[2];
+ v0[0] = 150 + 40 * Cos(i);
+ v0[1] = 150 + 40 * Sin(i);
+ v1[0] = 150 + 130 * Cos(i);
+ v1[1] = 150 + 130 * Sin(i);
+ QuadLine(v0, v1, Width);
+ }
+
+ {
+ float v0[2], v1[2], x;
+ for (x = 0; x < 1.0; x += 0.2) {
+ v0[0] = 150 + x;
+ v0[1] = 150 + x * 40 - 20;
+ v1[0] = 150 + x + 5.0;
+ v1[1] = 150 + x * 40 - 20;
+ QuadLine(v0, v1, Width);
+ }
+ }
+
+ glDisable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, width, 0, height, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+static void
+CleanUp(void)
+{
+ glutDestroyWindow(win);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+
+ switch(key) {
+ case 'w':
+ Width -= 0.5;
+ break;
+ case 'W':
+ Width += 0.5;
+ break;
+ case 27:
+ CleanUp();
+ exit(0);
+ break;
+ }
+#if 0
+ if (Width < 3)
+ Width = 3;
+#endif
+ printf("Width = %g\n", Width);
+ glutPostRedisplay();
+}
+
+
+static float
+ramp4(GLint i, GLint size)
+{
+ float d;
+ if (i < 4 ) {
+ d = i / 4.0;
+ }
+ else if (i >= size - 5) {
+ d = 1.0 - (i - (size - 5)) / 4.0;
+ }
+ else {
+ d = 1.0;
+ }
+ return d;
+}
+
+static float
+ramp2(GLint i, GLint size)
+{
+ float d;
+ if (i < 2 ) {
+ d = i / 2.0;
+ }
+ else if (i >= size - 3) {
+ d = 1.0 - (i - (size - 3)) / 2.0;
+ }
+ else {
+ d = 1.0;
+ }
+ return d;
+}
+
+static float
+ramp1(GLint i, GLint size)
+{
+ float d;
+ if (i == 0 || i == size-1) {
+ d = 0.0;
+ }
+ else {
+ d = 1.0;
+ }
+ return d;
+}
+
+
+/**
+ * Make an alpha texture for antialiasing lines.
+ * Just a linear fall-off ramp for now.
+ * Should have a number of different textures for different line widths.
+ * Could try a bell-like-curve....
+ */
+static void
+MakeTexture(void)
+{
+#define SZ 8
+ GLfloat tex[SZ][SZ]; /* alpha tex */
+ int i, j;
+ for (i = 0; i < SZ; i++) {
+ for (j = 0; j < SZ; j++) {
+#if 0
+ float k = (SZ-1) / 2.0;
+ float dx = fabs(i - k) / k;
+ float dy = fabs(j - k) / k;
+ float d;
+
+ dx = 1.0 - dx;
+ dy = 1.0 - dy;
+ d = dx * dy;
+
+#else
+ float d = ramp1(i, SZ) * ramp1(j, SZ);
+ printf("%d, %d: %g\n", i, j, d);
+#endif
+ tex[i][j] = d;
+ }
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, SZ, SZ, 0, GL_ALPHA, GL_FLOAT, tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+#undef SZ
+}
+
+
+static void
+MakeMipmap(void)
+{
+#define SZ 64
+ GLfloat tex[SZ][SZ]; /* alpha tex */
+ int level;
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, SZ);
+ for (level = 0; level < 7; level++) {
+ int sz = 1 << (6 - level);
+ int i, j;
+ for (i = 0; i < sz; i++) {
+ for (j = 0; j < sz; j++) {
+ if (level == 6)
+ tex[i][j] = 1.0;
+ else if (level == 5)
+ tex[i][j] = 0.5;
+ else
+ tex[i][j] = ramp1(i, sz) * ramp1(j, sz);
+ }
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, level, GL_ALPHA,
+ sz, sz, 0, GL_ALPHA, GL_FLOAT, tex);
+ }
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
+ ////glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+#undef SZ
+}
+
+
+static void
+Init(void)
+{
+ const char *version;
+
+ (void) MakeTexture;
+ (void) ramp4;
+ (void) ramp2;
+
+ version = (const char *) glGetString(GL_VERSION);
+ if (version[0] != '2' || version[1] != '.') {
+ printf("This program requires OpenGL 2.x, found %s\n", version);
+ exit(1);
+ }
+
+ GetExtensionFuncs();
+
+ glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
+
+ printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#if 0
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+#elif 0
+ MakeTexture();
+#else
+ MakeMipmap();
+#endif
+}
+
+
+static void
+ParseOptions(int argc, char *argv[])
+{
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition( 0, 0);
+ glutInitWindowSize(WinWidth, WinHeight);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Redisplay);
+ ParseOptions(argc, argv);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/samples/blendeq.c b/progs/samples/blendeq.c
index cd0474c5ce..037d06fa52 100644
--- a/progs/samples/blendeq.c
+++ b/progs/samples/blendeq.c
@@ -100,7 +100,7 @@ static void PrintColorStrings( void )
{
GLubyte ubbuf[3];
int i, xleft, xright;
- char colorString[18];
+ char colorString[100];
xleft = 5 + windW/4;
xright = 5 + windW/2;
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index 58ea5690df..f5fbf374f7 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -37,19 +37,18 @@ SOURCES = \
copypixrate.c \
crossbar.c \
cva.c \
- dinoshade.c \
drawbuffers.c \
exactrast.c \
floattex.c \
fbotest1.c \
fbotest2.c \
- fbotexture.c \
fillrate.c \
fog.c \
fogcoord.c \
fptest1.c \
fptexture.c \
getprocaddress.c \
+ glutfx \
interleave.c \
invert.c \
jkrahntest.c \
@@ -66,7 +65,6 @@ SOURCES = \
packedpixels.c \
pbo.c \
prog_parameter.c \
- projtex.c \
quads.c \
random.c \
readrate.c \
@@ -77,12 +75,15 @@ SOURCES = \
stencil_twoside.c \
stencilwrap.c \
stencil_wrap.c \
+ streaming_rect \
subtex \
subtexrate.c \
tex1d.c \
texcompress2.c \
+ texdown \
texfilt.c \
texline.c \
+ texobj.c \
texobjshare.c \
texrect.c \
texwrap.c \
@@ -201,10 +202,10 @@ fillrate.o: fillrate.c readtex.h
floattex: floattex.o readtex.o shaderutil.o
- $(CC) $(CFLAGS) $(LDFLAGS) floattex.o readtex.o shaderutil.o $(LIBS) -o $@
+ $(APP_CC) $(CFLAGS) $(LDFLAGS) floattex.o readtex.o shaderutil.o $(LIBS) -o $@
floattex.o: floattex.c readtex.h shaderutil.h
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) floattex.c -o $@
+ $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) floattex.c -o $@
readtex.o: readtex.c
@@ -230,7 +231,7 @@ shaderutil.h: $(TOP)/progs/util/shaderutil.h
cp $< .
shaderutil.o: shaderutil.c shaderutil.h
- $(CC) -c -I$(INCDIR) $(CFLAGS) shaderutil.c
+ $(APP_CC) -c -I$(INCDIR) $(INCLUDES) $(CFLAGS) shaderutil.c
diff --git a/progs/tests/SConscript b/progs/tests/SConscript
index bf1e7f8a7d..4f22ca735c 100644
--- a/progs/tests/SConscript
+++ b/progs/tests/SConscript
@@ -42,8 +42,8 @@ progs = [
'arbfptest1',
'arbfptexture',
'arbfptrig',
- 'arbnpot-mipmap',
'arbnpot',
+ 'arbnpot-mipmap',
'arbvptest1',
'arbvptest3',
'arbvptorus',
@@ -61,19 +61,18 @@ progs = [
'copypixrate',
'crossbar',
'cva',
- 'dinoshade',
'drawbuffers',
'exactrast',
'ext422square',
'fbotest1',
'fbotest2',
- 'fbotexture',
'fillrate',
'floattex',
'fog',
'fogcoord',
'fptest1',
'fptexture',
+ 'glutfx',
'interleave',
'invert',
'lineclip',
@@ -91,7 +90,6 @@ progs = [
'packedpixels',
'pbo',
'prog_parameter',
- 'projtex',
'quads',
'random',
'readrate',
@@ -101,14 +99,17 @@ progs = [
'stencil_twoside',
'stencil_wrap',
'stencilwrap',
+ 'streaming_rect',
'subtex',
'subtexrate',
'tex1d',
'texcmp',
'texcompress2',
+ 'texdown',
'texfilt',
'texgenmix',
'texline',
+ 'texobj',
'texrect',
'texwrap',
'unfilledclip',
diff --git a/progs/tests/afsmultiarb.c b/progs/tests/afsmultiarb.c
index 162ab19493..ca25a4d75b 100644
--- a/progs/tests/afsmultiarb.c
+++ b/progs/tests/afsmultiarb.c
@@ -442,8 +442,8 @@ int main( int argc, char *argv[] )
glutInitWindowSize( 300, 300 );
glutInitWindowPosition( 0, 0 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
- glewInit();
glutCreateWindow(argv[0] );
+ glewInit();
Init( argc, argv );
diff --git a/progs/demos/glutfx.c b/progs/tests/glutfx.c
index 8bf5582389..8bf5582389 100644
--- a/progs/demos/glutfx.c
+++ b/progs/tests/glutfx.c
diff --git a/progs/tests/jkrahntest.c b/progs/tests/jkrahntest.c
index 08660b8932..3fef105fc2 100644
--- a/progs/tests/jkrahntest.c
+++ b/progs/tests/jkrahntest.c
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
if (argc < 2) {
fprintf(stderr, "This program tests GLX context switching.\n");
- fprintf(stderr, "Usage: cxbug <n>\n");
+ fprintf(stderr, "Usage: jkrahntest <n>\n");
fprintf(stderr, "Where n is:\n");
fprintf(stderr, "\t1) Use two contexts and swap only when the context is current (typical case).\n");
fprintf(stderr, "\t2) Use two contexts and swap at the same time.\n");
diff --git a/progs/tests/mipmap_view.c b/progs/tests/mipmap_view.c
index 16f3584f70..85fc67ac79 100644
--- a/progs/tests/mipmap_view.c
+++ b/progs/tests/mipmap_view.c
@@ -22,6 +22,7 @@ static int TexWidth = 256, TexHeight = 256;
static int WinWidth = 1044, WinHeight = 900;
static GLfloat Bias = 0.0;
static GLboolean ScaleQuads = GL_FALSE;
+static GLboolean Linear = GL_FALSE;
static GLint Win = 0;
@@ -53,6 +54,15 @@ Display(void)
glColor3f(1,1,1);
+ if (Linear) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+
y = WinHeight - 300;
x = 4;
@@ -132,6 +142,9 @@ Key(unsigned char key, int x, int y)
case 'B':
Bias += 10;
break;
+ case 'l':
+ Linear = !Linear;
+ break;
case '0':
case '1':
case '2':
@@ -222,8 +235,6 @@ Init(void)
/* mipmapping required for this extension */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &maxBias);
diff --git a/progs/demos/occlude.c b/progs/tests/occlude.c
index 8f7b90984e..8f7b90984e 100644
--- a/progs/demos/occlude.c
+++ b/progs/tests/occlude.c
diff --git a/progs/tests/shader_api.c b/progs/tests/shader_api.c
index a513ca6ba1..6453856345 100644
--- a/progs/tests/shader_api.c
+++ b/progs/tests/shader_api.c
@@ -321,10 +321,18 @@ static void run_test(const char *name, void (*callback)(void))
int main(int argc, char **argv)
{
+ const char *version;
+
glutInit(&argc, argv);
glutCreateWindow("Mesa bug demo");
glewInit();
+ version = (const char *) glGetString(GL_VERSION);
+ if (version[0] == '1') {
+ printf("Sorry, this test requires OpenGL 2.x GLSL support\n");
+ exit(0);
+ }
+
RUN_TEST(test_uniform_size_type);
RUN_TEST(test_attrib_size_type);
RUN_TEST(test_uniform_array_overflow);
diff --git a/progs/demos/streaming_rect.c b/progs/tests/streaming_rect.c
index f65ac4ce36..f65ac4ce36 100644
--- a/progs/demos/streaming_rect.c
+++ b/progs/tests/streaming_rect.c
diff --git a/progs/tests/texcompress2.c b/progs/tests/texcompress2.c
index cbb8f1d3a2..b95aca9fb9 100644
--- a/progs/tests/texcompress2.c
+++ b/progs/tests/texcompress2.c
@@ -51,7 +51,6 @@ TestSubTex(void)
GLboolean all = 0*GL_TRUE;
GLubyte *buffer;
GLint size, fmt;
- int i;
glGetTexLevelParameteriv(Target, 0,
GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &size);
@@ -83,6 +82,23 @@ TestSubTex(void)
static void
+TestGetTex(void)
+{
+ GLubyte *buffer;
+
+ buffer = (GLubyte *) malloc(3 * ImgWidth * ImgHeight);
+
+ glGetTexImage(GL_TEXTURE_2D,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_BYTE,
+ buffer);
+
+ free(buffer);
+}
+
+
+static void
LoadCompressedImage(const char *file)
{
const GLenum filter = GL_LINEAR;
@@ -146,7 +162,10 @@ LoadCompressedImage(const char *file)
glTexParameteri(Target, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(Target, GL_TEXTURE_MAG_FILTER, filter);
- TestSubTex();
+ if (0)
+ TestSubTex();
+ else
+ TestGetTex();
}
diff --git a/progs/demos/texdown.c b/progs/tests/texdown.c
index 7e46045832..7e46045832 100644
--- a/progs/demos/texdown.c
+++ b/progs/tests/texdown.c
diff --git a/progs/demos/texobj.c b/progs/tests/texobj.c
index 40bce6e569..40bce6e569 100644
--- a/progs/demos/texobj.c
+++ b/progs/tests/texobj.c
diff --git a/progs/tests/vparray.c b/progs/tests/vparray.c
index 9c2fad97d9..af9b62d33e 100644
--- a/progs/tests/vparray.c
+++ b/progs/tests/vparray.c
@@ -280,9 +280,9 @@ int main(int argc, char **argv)
glutInitWindowPosition(0, 0);
glutInitWindowSize(400, 400);
if (glutCreateWindow("Isosurface") <= 0) {
- glewInit();
exit(0);
}
+ glewInit();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
diff --git a/progs/tests/vptest1.c b/progs/tests/vptest1.c
index 5162919292..6e32b03346 100644
--- a/progs/tests/vptest1.c
+++ b/progs/tests/vptest1.c
@@ -128,7 +128,7 @@ static void Init( void )
glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
strlen(prog1),
(const GLubyte *) prog1);
- assert(!glIsProgramNV(1));
+ assert(glIsProgramNV(1));
glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 2,
strlen(prog2),
diff --git a/progs/trivial/tri-viewport.c b/progs/trivial/tri-viewport.c
index 8e5f155c7d..3e52449b47 100644
--- a/progs/trivial/tri-viewport.c
+++ b/progs/trivial/tri-viewport.c
@@ -29,6 +29,20 @@
GLenum doubleBuffer = 1;
int win;
+static float tx = 0;
+static float ty = 0;
+static float tw = 0;
+static float th = 0;
+static float z = -5;
+
+
+static float win_width = 250;
+static float win_height = 250;
+static enum {
+ ORTHO,
+ FRUSTUM,
+ MODE_MAX
+} mode = ORTHO;
static void Init(void)
{
@@ -37,44 +51,195 @@ static void Init(void)
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
fflush(stderr);
- glClearColor(0.3, 0.1, 0.3, 0.0);
+ glClearColor(0, 0, 0, 0.0);
}
static void Reshape(int width, int height)
{
- glViewport(width / -2.0, height / -2.0, width, height);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ win_width = width;
+ win_height = height;
+ glutPostRedisplay();
}
+
static void Key(unsigned char key, int x, int y)
{
switch (key) {
- case 27:
- exit(0);
- default:
- glutPostRedisplay();
- return;
+ case 27:
+ exit(0);
+ case 'w':
+ tw += 1.0;
+ break;
+ case 'W':
+ tw -= 1.0;
+ break;
+ case 'h':
+ th += 1.0;
+ break;
+ case 'H':
+ th -= 1.0;
+ break;
+
+ case 'z':
+ z += 1.0;
+ break;
+ case 'Z':
+ z -= 1.0;
+ break;
+ case 'm':
+ mode++;
+ mode %= MODE_MAX;
+ break;
+ case ' ':
+ tw = th = tx = ty = 0;
+ z = -5;
+ mode = ORTHO;
+ break;
+ default:
+ break;
}
+ glutPostRedisplay();
}
+
static void Draw(void)
{
+ int i;
+ float w = tw + win_width;
+ float h = th + win_height;
+
+ fprintf(stderr, "glViewport(%f %f %f %f)\n", tx, ty, w, h);
+ fprintf(stderr, "mode: %s\n", mode == FRUSTUM ? "FRUSTUM" : "ORTHO");
+ fprintf(stderr, "z: %f\n", z);
+ fflush(stderr);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ switch (mode) {
+ case FRUSTUM:
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ break;
+ case ORTHO:
+ default:
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ break;
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+
glClear(GL_COLOR_BUFFER_BIT);
+
+ /***********************************************************************
+ * Should be clipped to be no larger than the triangles:
+ */
+ glViewport(tx, ty, w, h);
+
+ glBegin(GL_POLYGON);
+ glColor3f(1,1,0);
+ glVertex3f(-100, -100, z);
+ glVertex3f(-100, 100, z);
+ glVertex3f(100, 100, z);
+ glVertex3f(100, -100, z);
+ glEnd();
+
+ glBegin(GL_POLYGON);
+ glColor3f(0,1,1);
+ glVertex3f(-10, -10, z);
+ glVertex3f(-10, 10, z);
+ glVertex3f(10, 10, z);
+ glVertex3f(10, -10, z);
+ glEnd();
+
+ glBegin(GL_POLYGON);
+ glColor3f(1,0,0);
+ glVertex3f(-2, -2, z);
+ glVertex3f(-2, 2, z);
+ glVertex3f(2, 2, z);
+ glVertex3f(2, -2, z);
+ glEnd();
+
+
+ glBegin(GL_POLYGON);
+ glColor3f(.5,.5,1);
+ glVertex3f(-1, -1, z);
+ glVertex3f(-1, 1, z);
+ glVertex3f(1, 1, z);
+ glVertex3f(1, -1, z);
+ glEnd();
+
+ /***********************************************************************
+ */
+ glViewport(0, 0, win_width, win_height);
+ glBegin(GL_LINES);
+ glColor3f(1,1,0);
+ glVertex3f(-1, 0, z);
+ glVertex3f(1, 0, z);
+
+ glVertex3f(0, -1, z);
+ glVertex3f(0, 1, z);
+ glEnd();
+
+
+ /***********************************************************************
+ */
+ glViewport(tx, ty, w, h);
glBegin(GL_TRIANGLES);
- glColor3f(.8,0,0);
- glVertex3f(-0.9, 0.9, -30.0);
- glColor3f(0,.9,0);
- glVertex3f( 0.9, 0.9, -30.0);
- glColor3f(0,0,.7);
- glVertex3f( 0.0, -0.9, -30.0);
+ glColor3f(1,0,0);
+ glVertex3f(-1, -1, z);
+ glVertex3f(0, -1, z);
+ glVertex3f(-.5, -.5, z);
+
+ glColor3f(1,1,1);
+ glVertex3f(0, -1, z);
+ glVertex3f(1, -1, z);
+ glVertex3f(.5, -.5, z);
+
+ glVertex3f(-.5, -.5, z);
+ glVertex3f(.5, -.5, z);
+ glVertex3f(0, 0, z);
+
+
+ glColor3f(0,1,0);
+ glVertex3f(1, 1, z);
+ glVertex3f(0, 1, z);
+ glVertex3f(.5, .5, z);
+
+ glColor3f(1,1,1);
+ glVertex3f(0, 1, z);
+ glVertex3f(-1, 1, z);
+ glVertex3f(-.5, .5, z);
+
+ glVertex3f(.5, .5, z);
+ glVertex3f(-.5, .5, z);
+ glVertex3f( 0, 0, z);
+
glEnd();
+
+ glViewport(0, 0, win_width, win_height);
+
+ glBegin(GL_LINES);
+ glColor3f(.5,.5,0);
+ for (i = -10; i < 10; i++) {
+ float f = i / 10.0;
+
+ if (i == 0)
+ continue;
+
+ glVertex3f(-1, f, z);
+ glVertex3f(1, f, z);
+
+ glVertex3f(f, -1, z);
+ glVertex3f(f, 1, z);
+ }
+ glEnd();
+
+
+
glFlush();
if (doubleBuffer) {
@@ -86,6 +251,13 @@ static GLenum Args(int argc, char **argv)
{
GLint i;
+ if (getenv("VPX"))
+ tx = atof(getenv("VPX"));
+
+ if (getenv("VPY"))
+ ty = atof(getenv("VPY"));
+
+
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
doubleBuffer = GL_FALSE;
@@ -99,6 +271,30 @@ static GLenum Args(int argc, char **argv)
return GL_TRUE;
}
+
+static void
+special(int k, int x, int y)
+{
+ switch (k) {
+ case GLUT_KEY_UP:
+ ty += 1.0;
+ break;
+ case GLUT_KEY_DOWN:
+ ty -= 1.0;
+ break;
+ case GLUT_KEY_LEFT:
+ tx -= 1.0;
+ break;
+ case GLUT_KEY_RIGHT:
+ tx += 1.0;
+ break;
+ default:
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
int main(int argc, char **argv)
{
GLenum type;
@@ -123,7 +319,8 @@ int main(int argc, char **argv)
Init();
glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(special);
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
diff --git a/progs/wgl/SConscript b/progs/wgl/SConscript
index b7cf35b7fc..31f61676de 100644
--- a/progs/wgl/SConscript
+++ b/progs/wgl/SConscript
@@ -21,3 +21,5 @@ for prog in progs:
target = prog,
source = prog + '/' + prog + '.c',
)
+
+env.Program('wglinfo', ['wglinfo.c'])
diff --git a/progs/wgl/wglinfo.c b/progs/wgl/wglinfo.c
new file mode 100644
index 0000000000..881d35b297
--- /dev/null
+++ b/progs/wgl/wglinfo.c
@@ -0,0 +1,737 @@
+/*
+ * Copyright (C) 2009 VMware, Inc.
+ * Copyright (C) 1999-2006 Brian Paul
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * This program is a work-alike of the GLX glxinfo program.
+ * Command line options:
+ * -t print wide table
+ * -v print verbose information
+ * -b only print ID of "best" visual on screen 0
+ * -l print interesting OpenGL limits (added 5 Sep 2002)
+ */
+
+#include <windows.h>
+
+#include <GL/gl.h>
+#include <GL/glext.h>
+#include <GL/wglext.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+typedef enum
+{
+ Normal,
+ Wide,
+ Verbose
+} InfoMode;
+
+
+/*
+ * Print a list of extensions, with word-wrapping.
+ */
+static void
+print_extension_list(const char *ext)
+{
+ const char *indentString = " ";
+ const int indent = 4;
+ const int max = 79;
+ int width, i, j;
+
+ if (!ext || !ext[0])
+ return;
+
+ width = indent;
+ printf(indentString);
+ i = j = 0;
+ while (1) {
+ if (ext[j] == ' ' || ext[j] == 0) {
+ /* found end of an extension name */
+ const int len = j - i;
+ if (width + len > max) {
+ /* start a new line */
+ printf("\n");
+ width = indent;
+ printf(indentString);
+ }
+ /* print the extension name between ext[i] and ext[j] */
+ while (i < j) {
+ printf("%c", ext[i]);
+ i++;
+ }
+ /* either we're all done, or we'll continue with next extension */
+ width += len + 1;
+ if (ext[j] == 0) {
+ break;
+ }
+ else {
+ i++;
+ j++;
+ if (ext[j] == 0)
+ break;
+ printf(", ");
+ width += 2;
+ }
+ }
+ j++;
+ }
+ printf("\n");
+}
+
+
+/**
+ * Print interesting limits for vertex/fragment programs.
+ */
+static void
+print_program_limits(GLenum target)
+{
+#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
+ struct token_name {
+ GLenum token;
+ const char *name;
+ };
+ static const struct token_name limits[] = {
+ { GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" },
+ { GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" },
+ { GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" },
+ { GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" },
+ { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" },
+ { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" },
+ { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" },
+ { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" },
+ { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" },
+ { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" },
+ { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" },
+ { (GLenum) 0, NULL }
+ };
+ PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC)
+ wglGetProcAddress("glGetProgramivARB");
+ GLint max[1];
+ int i;
+
+ if (target == GL_VERTEX_PROGRAM_ARB) {
+ printf(" GL_VERTEX_PROGRAM_ARB:\n");
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ printf(" GL_FRAGMENT_PROGRAM_ARB:\n");
+ }
+ else {
+ return; /* something's wrong */
+ }
+
+ for (i = 0; limits[i].token; i++) {
+ GetProgramivARB_func(target, limits[i].token, max);
+ if (glGetError() == GL_NO_ERROR) {
+ printf(" %s = %d\n", limits[i].name, max[0]);
+ }
+ }
+#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */
+}
+
+
+/**
+ * Print interesting limits for vertex/fragment shaders.
+ */
+static void
+print_shader_limits(GLenum target)
+{
+ struct token_name {
+ GLenum token;
+ const char *name;
+ };
+#if defined(GL_ARB_vertex_shader)
+ static const struct token_name vertex_limits[] = {
+ { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" },
+ { GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" },
+ { GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" },
+ { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
+ { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" },
+ { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" },
+ { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
+ { (GLenum) 0, NULL }
+ };
+#endif
+#if defined(GL_ARB_fragment_shader)
+ static const struct token_name fragment_limits[] = {
+ { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" },
+ { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
+ { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
+ { (GLenum) 0, NULL }
+ };
+#endif
+ GLint max[1];
+ int i;
+
+#if defined(GL_ARB_vertex_shader)
+ if (target == GL_VERTEX_SHADER_ARB) {
+ printf(" GL_VERTEX_SHADER_ARB:\n");
+ for (i = 0; vertex_limits[i].token; i++) {
+ glGetIntegerv(vertex_limits[i].token, max);
+ if (glGetError() == GL_NO_ERROR) {
+ printf(" %s = %d\n", vertex_limits[i].name, max[0]);
+ }
+ }
+ }
+#endif
+#if defined(GL_ARB_fragment_shader)
+ if (target == GL_FRAGMENT_SHADER_ARB) {
+ printf(" GL_FRAGMENT_SHADER_ARB:\n");
+ for (i = 0; fragment_limits[i].token; i++) {
+ glGetIntegerv(fragment_limits[i].token, max);
+ if (glGetError() == GL_NO_ERROR) {
+ printf(" %s = %d\n", fragment_limits[i].name, max[0]);
+ }
+ }
+ }
+#endif
+}
+
+
+/**
+ * Print interesting OpenGL implementation limits.
+ */
+static void
+print_limits(const char *extensions)
+{
+ struct token_name {
+ GLuint count;
+ GLenum token;
+ const char *name;
+ };
+ static const struct token_name limits[] = {
+ { 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH" },
+ { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH" },
+ { 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES" },
+ { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH" },
+ { 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES" },
+ { 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES" },
+ { 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER" },
+ { 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS" },
+ { 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING" },
+ { 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH" },
+ { 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH" },
+ { 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE" },
+ { 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH" },
+ { 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH" },
+ { 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE" },
+ { 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE" },
+ { 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS" },
+ { 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE" },
+ { 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE" },
+ { 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE" },
+ { 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE" },
+#if defined(GL_ARB_texture_cube_map)
+ { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB" },
+#endif
+#if defined(GLX_NV_texture_rectangle)
+ { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV" },
+#endif
+#if defined(GL_ARB_texture_compression)
+ { 1, GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB" },
+#endif
+#if defined(GL_ARB_multitexture)
+ { 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB" },
+#endif
+#if defined(GL_EXT_texture_lod_bias)
+ { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT" },
+#endif
+#if defined(GL_EXT_texture_filter_anisotropic)
+ { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT" },
+#endif
+#if defined(GL_ARB_draw_buffers)
+ { 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB" },
+#endif
+ { 0, (GLenum) 0, NULL }
+ };
+ GLint i, max[2];
+
+ printf("OpenGL limits:\n");
+ for (i = 0; limits[i].count; i++) {
+ glGetIntegerv(limits[i].token, max);
+ if (glGetError() == GL_NO_ERROR) {
+ if (limits[i].count == 1)
+ printf(" %s = %d\n", limits[i].name, max[0]);
+ else /* XXX fix if we ever query something with more than 2 values */
+ printf(" %s = %d, %d\n", limits[i].name, max[0], max[1]);
+ }
+ }
+
+#if defined(GL_EXT_convolution)
+ {
+ PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC glGetConvolutionParameterivEXT_func =
+ (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)wglGetProcAddress("glGetConvolutionParameterivEXT");
+ if(glGetConvolutionParameterivEXT_func) {
+ /* these don't fit into the above mechanism, unfortunately */
+ glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_WIDTH, max);
+ glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_HEIGHT, max+1);
+ if (glGetError() == GL_NONE) {
+ printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]);
+ }
+ }
+ }
+#endif
+
+#if defined(GL_ARB_vertex_program)
+ if (strstr(extensions, "GL_ARB_vertex_program")) {
+ print_program_limits(GL_VERTEX_PROGRAM_ARB);
+ }
+#endif
+#if defined(GL_ARB_fragment_program)
+ if (strstr(extensions, "GL_ARB_fragment_program")) {
+ print_program_limits(GL_FRAGMENT_PROGRAM_ARB);
+ }
+#endif
+#if defined(GL_ARB_vertex_shader)
+ if (strstr(extensions, "GL_ARB_vertex_shader")) {
+ print_shader_limits(GL_VERTEX_SHADER_ARB);
+ }
+#endif
+#if defined(GL_ARB_fragment_shader)
+ if (strstr(extensions, "GL_ARB_fragment_shader")) {
+ print_shader_limits(GL_FRAGMENT_SHADER_ARB);
+ }
+#endif
+}
+
+
+static LRESULT CALLBACK
+WndProc(HWND hWnd,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam )
+{
+ switch (uMsg) {
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ default:
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ }
+
+ return 0;
+}
+
+
+static void
+print_screen_info(HDC _hdc, GLboolean limits)
+{
+ WNDCLASS wc;
+ HWND win;
+ HGLRC ctx;
+ int visinfo;
+ int width = 100, height = 100;
+ HDC hdc;
+ PIXELFORMATDESCRIPTOR pfd;
+
+ memset(&wc, 0, sizeof wc);
+ wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ wc.lpfnWndProc = WndProc;
+ wc.lpszClassName = "wglinfo";
+ wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
+ RegisterClass(&wc);
+
+ win = CreateWindowEx(0,
+ wc.lpszClassName,
+ "wglinfo",
+ WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ width,
+ height,
+ NULL,
+ NULL,
+ wc.hInstance,
+ NULL);
+ if (!win) {
+ fprintf(stderr, "Couldn't create window");
+ exit(1);
+ }
+
+ hdc = GetDC(win);
+ if (!hdc) {
+ fprintf(stderr, "Couldn't obtain HDC");
+ return;
+ }
+
+ pfd.cColorBits = 3;
+ pfd.cRedBits = 1;
+ pfd.cGreenBits = 1;
+ pfd.cBlueBits = 1;
+ pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
+ pfd.iLayerType = PFD_MAIN_PLANE;
+ pfd.iPixelType = PFD_TYPE_RGBA;
+ pfd.nSize = sizeof(pfd);
+ pfd.nVersion = 1;
+
+ visinfo = ChoosePixelFormat(hdc, &pfd);
+ if (!visinfo) {
+ pfd.dwFlags |= PFD_DOUBLEBUFFER;
+ visinfo = ChoosePixelFormat(hdc, &pfd);
+ }
+
+ if (!visinfo) {
+ fprintf(stderr, "Error: couldn't find RGB WGL visual\n");
+ return;
+ }
+
+ SetPixelFormat(hdc, visinfo, &pfd);
+ ctx = wglCreateContext(hdc);
+ if (!ctx) {
+ fprintf(stderr, "Error: wglCreateContext failed\n");
+ return;
+ }
+
+ if (wglMakeCurrent(hdc, ctx)) {
+#if defined(WGL_ARB_extensions_string)
+ PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_func =
+ (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
+#endif
+ const char *glVendor = (const char *) glGetString(GL_VENDOR);
+ const char *glRenderer = (const char *) glGetString(GL_RENDERER);
+ const char *glVersion = (const char *) glGetString(GL_VERSION);
+ const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS);
+
+#if defined(WGL_ARB_extensions_string)
+ if(wglGetExtensionsStringARB_func) {
+ const char *wglExtensions = wglGetExtensionsStringARB_func(hdc);
+ if(wglExtensions) {
+ printf("WGL extensions:\n");
+ print_extension_list(wglExtensions);
+ }
+ }
+#endif
+ printf("OpenGL vendor string: %s\n", glVendor);
+ printf("OpenGL renderer string: %s\n", glRenderer);
+ printf("OpenGL version string: %s\n", glVersion);
+#ifdef GL_VERSION_2_0
+ if (glVersion[0] >= '2' && glVersion[1] == '.') {
+ char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
+ printf("OpenGL shading language version string: %s\n", v);
+ }
+#endif
+
+ printf("OpenGL extensions:\n");
+ print_extension_list(glExtensions);
+ if (limits)
+ print_limits(glExtensions);
+ }
+ else {
+ fprintf(stderr, "Error: wglMakeCurrent failed\n");
+ }
+
+ DestroyWindow(win);
+}
+
+
+static const char *
+visual_render_type_name(BYTE iPixelType)
+{
+ switch (iPixelType) {
+ case PFD_TYPE_RGBA:
+ return "rgba";
+ case PFD_TYPE_COLORINDEX:
+ return "ci";
+ default:
+ return "";
+ }
+}
+
+static void
+print_visual_attribs_verbose(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
+{
+ printf("Visual ID: %x generic=%d native=%d\n",
+ iPixelFormat,
+ ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
+ ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0);
+ printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
+ 0 /* ppfd->bufferSize */, 0 /* ppfd->level */,
+ visual_render_type_name(ppfd->dwFlags),
+ ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
+ ppfd->dwFlags & PFD_STEREO ? 1 : 0);
+ printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
+ ppfd->cRedBits, ppfd->cGreenBits,
+ ppfd->cBlueBits, ppfd->cAlphaBits);
+ printf(" cAuxBuffers=%d cDepthBits=%d cStencilBits=%d\n",
+ ppfd->cAuxBuffers, ppfd->cDepthBits, ppfd->cStencilBits);
+ printf(" accum: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
+ ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
+ ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits);
+ printf(" multiSample=%d multiSampleBuffers=%d\n",
+ 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */);
+}
+
+
+static void
+print_visual_attribs_short_header(void)
+{
+ printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n");
+ printf(" id gen nat sp sz l ci b ro r g b a bf th cl r g b a ns b eat\n");
+ printf("-----------------------------------------------------------------------\n");
+}
+
+
+static void
+print_visual_attribs_short(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
+{
+ char *caveat = "None";
+
+ printf("0x%02x %2d %2d %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d",
+ iPixelFormat,
+ ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
+ ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
+ 0,
+ 0 /* ppfd->bufferSize */,
+ 0 /* ppfd->level */,
+ ppfd->iPixelType == PFD_TYPE_RGBA ? 'r' : ' ',
+ ppfd->iPixelType == PFD_TYPE_COLORINDEX ? 'c' : ' ',
+ ppfd->dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.',
+ ppfd->dwFlags & PFD_STEREO ? 'y' : '.',
+ ppfd->cRedBits, ppfd->cGreenBits,
+ ppfd->cBlueBits, ppfd->cAlphaBits,
+ ppfd->cAuxBuffers,
+ ppfd->cDepthBits,
+ ppfd->cStencilBits
+ );
+
+ printf(" %2d %2d %2d %2d %2d %1d %s\n",
+ ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
+ ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits,
+ 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */,
+ caveat
+ );
+}
+
+
+static void
+print_visual_attribs_long_header(void)
+{
+ printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n");
+ printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n");
+ printf("----------------------------------------------------------------------------------------------------\n");
+}
+
+
+static void
+print_visual_attribs_long(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
+{
+ printf("0x%2x %2d %11d %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d",
+ iPixelFormat,
+ ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
+ ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
+ 0,
+ 0 /* ppfd->bufferSize */,
+ 0 /* ppfd->level */,
+ visual_render_type_name(ppfd->iPixelType),
+ ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
+ ppfd->dwFlags & PFD_STEREO ? 1 : 0,
+ ppfd->cRedBits, ppfd->cGreenBits,
+ ppfd->cBlueBits, ppfd->cAlphaBits
+ );
+
+ printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n",
+ ppfd->cAuxBuffers,
+ ppfd->cDepthBits,
+ ppfd->cStencilBits,
+ ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
+ ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits,
+ 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */
+ );
+}
+
+
+static void
+print_visual_info(HDC hdc, InfoMode mode)
+{
+ PIXELFORMATDESCRIPTOR pfd;
+ int numVisuals, numWglVisuals;
+ int i;
+
+ numVisuals = DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
+ if (numVisuals == 0)
+ return;
+
+ numWglVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
+ continue;
+
+ //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
+ // continue;
+
+ ++numWglVisuals;
+ }
+
+ printf("%d WGL Visuals\n", numWglVisuals);
+
+ if (mode == Normal)
+ print_visual_attribs_short_header();
+ else if (mode == Wide)
+ print_visual_attribs_long_header();
+
+ for (i = 0; i < numVisuals; i++) {
+ if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
+ continue;
+
+ //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
+ // continue;
+
+ if (mode == Verbose)
+ print_visual_attribs_verbose(i, &pfd);
+ else if (mode == Normal)
+ print_visual_attribs_short(i, &pfd);
+ else if (mode == Wide)
+ print_visual_attribs_long(i, &pfd);
+ }
+ printf("\n");
+}
+
+
+/*
+ * Examine all visuals to find the so-called best one.
+ * We prefer deepest RGBA buffer with depth, stencil and accum
+ * that has no caveats.
+ */
+static int
+find_best_visual(HDC hdc)
+{
+#if 0
+ XVisualInfo theTemplate;
+ XVisualInfo *visuals;
+ int numVisuals;
+ long mask;
+ int i;
+ struct visual_attribs bestVis;
+
+ /* get list of all visuals on this screen */
+ theTemplate.screen = scrnum;
+ mask = VisualScreenMask;
+ visuals = XGetVisualInfo(hdc, mask, &theTemplate, &numVisuals);
+
+ /* init bestVis with first visual info */
+ get_visual_attribs(hdc, &visuals[0], &bestVis);
+
+ /* try to find a "better" visual */
+ for (i = 1; i < numVisuals; i++) {
+ struct visual_attribs vis;
+
+ get_visual_attribs(hdc, &visuals[i], &vis);
+
+ /* always skip visuals with caveats */
+ if (vis.visualCaveat != GLX_NONE_EXT)
+ continue;
+
+ /* see if this vis is better than bestVis */
+ if ((!bestVis.supportsGL && vis.supportsGL) ||
+ (bestVis.visualCaveat != GLX_NONE_EXT) ||
+ (bestVis.iPixelType != vis.iPixelType) ||
+ (!bestVis.doubleBuffer && vis.doubleBuffer) ||
+ (bestVis.cRedBits < vis.cRedBits) ||
+ (bestVis.cGreenBits < vis.cGreenBits) ||
+ (bestVis.cBlueBits < vis.cBlueBits) ||
+ (bestVis.cAlphaBits < vis.cAlphaBits) ||
+ (bestVis.cDepthBits < vis.cDepthBits) ||
+ (bestVis.cStencilBits < vis.cStencilBits) ||
+ (bestVis.cAccumRedBits < vis.cAccumRedBits)) {
+ /* found a better visual */
+ bestVis = vis;
+ }
+ }
+
+ return bestVis.id;
+#else
+ return 0;
+#endif
+}
+
+
+static void
+usage(void)
+{
+ printf("Usage: glxinfo [-v] [-t] [-h] [-i] [-b] [-display <dname>]\n");
+ printf("\t-v: Print visuals info in verbose form.\n");
+ printf("\t-t: Print verbose table.\n");
+ printf("\t-h: This information.\n");
+ printf("\t-b: Find the 'best' visual and print it's number.\n");
+ printf("\t-l: Print interesting OpenGL limits.\n");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ HDC hdc;
+ InfoMode mode = Normal;
+ GLboolean findBest = GL_FALSE;
+ GLboolean limits = GL_FALSE;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-t") == 0) {
+ mode = Wide;
+ }
+ else if (strcmp(argv[i], "-v") == 0) {
+ mode = Verbose;
+ }
+ else if (strcmp(argv[i], "-b") == 0) {
+ findBest = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-l") == 0) {
+ limits = GL_TRUE;
+ }
+ else if (strcmp(argv[i], "-h") == 0) {
+ usage();
+ return 0;
+ }
+ else {
+ printf("Unknown option `%s'\n", argv[i]);
+ usage();
+ return 0;
+ }
+ }
+
+ hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
+
+ if (findBest) {
+ int b;
+ b = find_best_visual(hdc);
+ printf("%d\n", b);
+ }
+ else {
+ print_screen_info(hdc, limits);
+ printf("\n");
+ print_visual_info(hdc, mode);
+ }
+
+ return 0;
+}