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/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 37fa312c30..b9cae66815 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -14,7 +14,8 @@ PROGS = \ mandelbrot \ noise \ toyball \ - texdemo1 + texdemo1 \ + convolutions ##### RULES ##### @@ -62,6 +63,12 @@ texdemo1: texdemo1.o readtex.o texdemo1.o: texdemo1.c readtex.h extfuncs.h $(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c +convolutions: convolutions.o readtex.o + $(CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@ + +convolutions.o: convolutions.c readtex.h + $(CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c + clean: -rm -f $(PROGS) -- cgit v1.2.3 From 90c93bbeeec1a8ca75b68004afc5d8cb689860bc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Sep 2008 11:00:54 -0600 Subject: define new APP_CC configuration variable for building apps/demos/tests For Cell, need to use different compilers for the libraries vs. the demos/tests to avoid strange link error regarding "_Unwind_GetIPInfo@GCC_4.2.0" --- configs/default | 4 ++++ configs/linux-cell | 4 +++- progs/demos/Makefile | 28 ++++++++++++++-------------- progs/glsl/Makefile | 12 ++++++------ progs/redbook/Makefile | 2 +- progs/samples/Makefile | 8 ++++---- progs/tests/Makefile | 40 ++++++++++++++++++++-------------------- progs/trivial/Makefile | 16 ++++++++-------- progs/xdemos/Makefile | 22 +++++++++++----------- 9 files changed, 71 insertions(+), 65 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/configs/default b/configs/default index cd2c39c365..94582d8274 100644 --- a/configs/default +++ b/configs/default @@ -23,6 +23,10 @@ CFLAGS = -O CXXFLAGS = -O GLU_CFLAGS = +# Compiler for building demos/tests/etc +APP_CC = $(CC) +APP_CXX = $(CXX) + # Misc tools and flags MKLIB_OPTIONS = MKDEP = makedepend diff --git a/configs/linux-cell b/configs/linux-cell index cdaa17c663..86651b83d7 100644 --- a/configs/linux-cell +++ b/configs/linux-cell @@ -12,6 +12,8 @@ GALLIUM_DRIVER_DIRS += cell CC = ppu32-gcc CXX = ppu32-g++ HOST_CC = gcc +APP_CC = gcc +APP_CXX = g++ OPT_FLAGS = -O3 @@ -19,7 +21,7 @@ OPT_FLAGS = -O3 ## For SDK 2.1: (plus, remove -DSPU_MAIN_PARAM_LONG_LONG below) #SDK = /opt/ibm/cell-sdk/prototype/sysroot/usr ## For SDK 3.0: -SDK = /opt/cell/sdk/usr/ +SDK = /opt/cell/sdk/usr CFLAGS = $(OPT_FLAGS) -Wall -Winline -fPIC -m32 -mabi=altivec -maltivec \ diff --git a/progs/demos/Makefile b/progs/demos/Makefile index 43874ecdaa..fe0e0fbd91 100644 --- a/progs/demos/Makefile +++ b/progs/demos/Makefile @@ -74,7 +74,7 @@ PROGS = \ # make executable from .c file: .c: $(LIB_DEP) readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -90,7 +90,7 @@ readtex.h: $(TOP)/progs/util/readtex.h cp $< . readtex.o: readtex.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c showbuffer.c: $(TOP)/progs/util/showbuffer.c @@ -100,7 +100,7 @@ showbuffer.h: $(TOP)/progs/util/showbuffer.h cp $< . showbuffer.o: showbuffer.c showbuffer.h - $(CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c trackball.c: $(TOP)/progs/util/trackball.c @@ -110,7 +110,7 @@ trackball.h: $(TOP)/progs/util/trackball.h cp $< . trackball.o: trackball.c trackball.h - $(CC) -c -I$(INCDIR) $(CFLAGS) trackball.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trackball.c extfuncs.h: $(TOP)/progs/util/extfuncs.h @@ -118,38 +118,38 @@ extfuncs.h: $(TOP)/progs/util/extfuncs.h reflect: reflect.o showbuffer.o readtex.o - $(CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ reflect.o: reflect.c showbuffer.h - $(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) reflect.c shadowtex: shadowtex.o showbuffer.o - $(CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ shadowtex.o: shadowtex.c showbuffer.h - $(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c gloss: gloss.o trackball.o readtex.o - $(CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ gloss.o: gloss.c trackball.h - $(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) gloss.c engine: engine.o trackball.o readtex.o - $(CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ engine.o: engine.c trackball.h - $(CC) -c -I$(INCDIR) $(CFLAGS) engine.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c fslight: fslight.o - $(CC) fslight.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) fslight.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ fslight.o: fslight.c extfuncs.h - $(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) fslight.c diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index b9cae66815..9c1d3f8126 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -26,7 +26,7 @@ PROGS = \ # make executable from .c file: .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -47,7 +47,7 @@ readtex.h: $(TOP)/progs/util/readtex.h cp $< . readtex.o: readtex.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c brick.c: extfuncs.h @@ -58,16 +58,16 @@ mandelbrot.c: extfuncs.h toyball.c: extfuncs.h texdemo1: texdemo1.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@ texdemo1.o: texdemo1.c readtex.h extfuncs.h - $(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c convolutions: convolutions.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@ convolutions.o: convolutions.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c clean: diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile index febc74441b..956c398873 100644 --- a/progs/redbook/Makefile +++ b/progs/redbook/Makefile @@ -24,7 +24,7 @@ PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ diff --git a/progs/samples/Makefile b/progs/samples/Makefile index 063008dccf..25ce14740a 100644 --- a/progs/samples/Makefile +++ b/progs/samples/Makefile @@ -18,7 +18,7 @@ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -27,10 +27,10 @@ default: $(PROGS) sphere: sphere.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@ sphere.o: sphere.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) sphere.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) sphere.c readtex.c: $(TOP)/progs/util/readtex.c cp $< . @@ -39,7 +39,7 @@ readtex.h: $(TOP)/progs/util/readtex.h cp $< . readtex.o: readtex.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@ + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@ clean: diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 3bead54e20..9c81f870d8 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -103,13 +103,13 @@ UTIL_FILES = readtex.h readtex.c .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ .c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ ##### TARGETS ##### @@ -129,58 +129,58 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress. python getprocaddress.py > getproclist.h arraytexture: arraytexture.o readtex.o - $(CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@ arraytexture.o: arraytexture.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ afsmultiarb: afsmultiarb.o readtex.o - $(CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@ afsmultiarb.o: afsmultiarb.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ drawbuffers: drawbuffers.o - $(CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@ drawbuffers.o: drawbuffers.c extfuncs.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ texrect: texrect.o readtex.o - $(CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@ texrect.o: texrect.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ bug_3195: bug_3195.o readtex.o - $(CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@ bug_3195.o: bug_3195.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ invert: invert.o readtex.o - $(CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@ invert.o: invert.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ mipmap_view: mipmap_view.o readtex.o - $(CC) $(CFLAGS) mipmap_view.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) mipmap_view.o readtex.o $(LIBS) -o $@ mipmap_view.o: mipmap_view.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ fillrate: fillrate.o readtex.o - $(CC) $(CFLAGS) fillrate.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) fillrate.o readtex.o $(LIBS) -o $@ fillrate.o: fillrate.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.o: readtex.c - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.h: $(TOP)/progs/util/readtex.h diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index d745fefbbf..c868ab6e6f 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -139,13 +139,13 @@ UTIL_FILES = readtex.h readtex.c .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ .c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ ##### TARGETS ##### @@ -166,19 +166,19 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress. texrect: texrect.o readtex.o - $(CC) texrect.o readtex.o $(LIBS) -o $@ + $(APP_CC) texrect.o readtex.o $(LIBS) -o $@ texrect.o: texrect.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ invert: invert.o readtex.o - $(CC) invert.o readtex.o $(LIBS) -o $@ + $(APP_CC) invert.o readtex.o $(LIBS) -o $@ invert.o: invert.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.o: readtex.c - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.h: $(TOP)/progs/util/readtex.h diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile index 896b160878..38f3884d58 100644 --- a/progs/xdemos/Makefile +++ b/progs/xdemos/Makefile @@ -39,7 +39,7 @@ PROGS = glthreads \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -54,32 +54,32 @@ clean: # special cases pbinfo: pbinfo.o pbutil.o - $(CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ pbdemo: pbdemo.o pbutil.o - $(CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ pbinfo.o: pbinfo.c pbutil.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c pbdemo.o: pbdemo.c pbutil.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c pbutil.o: pbutil.c pbutil.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c glxgears_fbconfig: glxgears_fbconfig.o pbutil.o - $(CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h - $(CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c + $(APP_CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c xrotfontdemo: xrotfontdemo.o xuserotfont.o - $(CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ xuserotfont.o: xuserotfont.c xuserotfont.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c xrotfontdemo.o: xrotfontdemo.c xuserotfont.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c -- cgit v1.2.3 From 52a9dfd4feae7d5d20519d48e72f3e38de4e2332 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 12 Sep 2008 10:02:16 +0100 Subject: use APP_CC, remove redundant target --- progs/glsl/Makefile | 67 ++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 37 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 5cb2a044c7..9999d6c08a 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -24,8 +24,7 @@ PROGS = \ toyball \ twoside \ trirast \ - texdemo1 \ - convolutions + texdemo1 ##### RULES ##### @@ -68,113 +67,107 @@ 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) $(CFLAGS) shaderutil.c bitmap.o: bitmap.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) bitmap.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) bitmap.c bitmap: bitmap.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bitmap.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bitmap.o shaderutil.o $(LIBS) -o $@ brick.o: brick.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) brick.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) brick.c brick: brick.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) brick.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) brick.o shaderutil.o $(LIBS) -o $@ bump.o: bump.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) bump.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) bump.c bump: bump.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bump.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bump.o shaderutil.o $(LIBS) -o $@ convolutions.o: convolutions.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c convolutions: convolutions.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) convolutions.o readtex.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) convolutions.o readtex.o $(LIBS) -o $@ deriv.o: deriv.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) deriv.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) deriv.c deriv: deriv.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@ mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c mandelbrot: mandelbrot.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) mandelbrot.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) mandelbrot.o shaderutil.o $(LIBS) -o $@ multitex.o: multitex.c extfuncs.h readtex.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) multitex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) multitex.c multitex: multitex.o readtex.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) multitex.o readtex.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) multitex.o readtex.o shaderutil.o $(LIBS) -o $@ noise.o: noise.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) noise.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) noise.c noise: noise.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) noise.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) noise.o shaderutil.o $(LIBS) -o $@ points.o: points.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) points.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) points.c points: points.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) points.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) points.o shaderutil.o $(LIBS) -o $@ pointcoord.o: pointcoord.c readtex.h extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) pointcoord.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) pointcoord.c pointcoord: pointcoord.o readtex.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) pointcoord.o readtex.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) pointcoord.o readtex.o shaderutil.o $(LIBS) -o $@ texdemo1.o: texdemo1.c readtex.h extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c texdemo1: texdemo1.o readtex.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o shaderutil.o $(LIBS) -o $@ toyball.o: toyball.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) toyball.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) toyball.c toyball: toyball.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) toyball.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) toyball.o shaderutil.o $(LIBS) -o $@ twoside.o: twoside.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) twoside.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) twoside.c twoside: twoside.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) twoside.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) twoside.o shaderutil.o $(LIBS) -o $@ trirast.o: trirast.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) trirast.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trirast.c trirast: trirast.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@ -convolutions: convolutions.o readtex.o - $(APP_CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@ - -convolutions.o: convolutions.c readtex.h - $(APP_CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c - clean: -rm -f $(PROGS) -- cgit v1.2.3 From 6f29c2ff2dc4b3aefe282133376caed68b65a3d0 Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Tue, 7 Oct 2008 23:42:36 +0200 Subject: Progs: hook the glsl identity example into the makefile. --- progs/glsl/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 9999d6c08a..eacd6dfe09 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -15,6 +15,7 @@ PROGS = \ bump \ convolutions \ deriv \ + identity \ mandelbrot \ multitex \ noise \ -- cgit v1.2.3 From b99c39ea7bf7ff3d6c0fe8599ce25a6b6bf154fd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 7 Oct 2008 16:24:43 -0600 Subject: mesa: use the shaderutil.c helper functions --- progs/glsl/Makefile | 7 ++++ progs/glsl/identity.c | 94 ++++++--------------------------------------------- 2 files changed, 17 insertions(+), 84 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index eacd6dfe09..04c1d25ed7 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -107,6 +107,13 @@ deriv: deriv.o shaderutil.o $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@ +identity.o: identity.c extfuncs.h shaderutil.h + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) identity.c + +identity: identity.o shaderutil.o + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) identity.o shaderutil.o $(LIBS) -o $@ + + mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c diff --git a/progs/glsl/identity.c b/progs/glsl/identity.c index a2a1991529..dce140fc64 100644 --- a/progs/glsl/identity.c +++ b/progs/glsl/identity.c @@ -1,10 +1,6 @@ /** * Test very basic glsl functionality (identity vertex and fragment shaders). - * Brian Paul - * 2 May 2007 - * - * NOTE: resize the window to observe how the partial derivatives of - * the texcoords change. + * Brian Paul & Stephane Marchesin */ @@ -17,6 +13,7 @@ #include #include #include "extfuncs.h" +#include "shaderutil.h" static char *FragProgFile = NULL; @@ -29,6 +26,7 @@ static GLboolean anim = GL_TRUE; static GLfloat xRot = 0.0f, yRot = 0.0f; static int w,h; + static void Redisplay(void) { @@ -128,69 +126,6 @@ SpecialKey(int key, int x, int y) } - - -static void -LoadAndCompileShader(GLuint shader, const char *text) -{ - GLint stat; - - glShaderSource_func(shader, 1, (const GLchar **) &text, NULL); - - glCompileShader_func(shader); - - glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetShaderInfoLog_func(shader, 1000, &len, log); - fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log); - exit(1); - } -} - - -/** - * Read a shader from a file. - */ -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, "fslight: Unable to open shader file %s\n", filename); - exit(1); - } - - n = fread(buffer, 1, max, f); - printf("fslight: 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_func(prog, GL_LINK_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetProgramInfoLog_func(prog, 1000, &len, log); - fprintf(stderr, "Linker error:\n%s\n", log); - } -} - - static void Init(void) { @@ -202,33 +137,24 @@ Init(void) "void main() {\n" " gl_Position = gl_Vertex;\n" "}\n"; - const char *version; - version = (const char *) glGetString(GL_VERSION); - if (version[0] != '2' || version[1] != '.') { - printf("This program requires OpenGL 2.x, found %s\n", version); + if (!ShadersSupported()) exit(1); - } GetExtensionFuncs(); - fragShader = glCreateShader_func(GL_FRAGMENT_SHADER); if (FragProgFile) - ReadShader(fragShader, FragProgFile); + fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile); else - LoadAndCompileShader(fragShader, fragShaderText); + fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText); - vertShader = glCreateShader_func(GL_VERTEX_SHADER); if (VertProgFile) - ReadShader(vertShader, VertProgFile); + vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile); else - LoadAndCompileShader(vertShader, vertShaderText); + vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText); + + program = LinkShaders(vertShader, fragShader); - program = glCreateProgram_func(); - glAttachShader_func(program, fragShader); - glAttachShader_func(program, vertShader); - glLinkProgram_func(program); - CheckLink(program); glUseProgram_func(program); /*assert(glGetError() == 0);*/ -- cgit v1.2.3 From 2c204bbf7749ed0517c5826e2aae66997a0c4623 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 5 Nov 2008 17:14:23 -0700 Subject: use APP_CC, not CC for skinning demo --- progs/glsl/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 0874cfc59e..c5d62d2370 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -150,10 +150,10 @@ pointcoord: pointcoord.o readtex.o shaderutil.o skinning.o: skinning.c readtex.h extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) skinning.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) skinning.c skinning: skinning.o readtex.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) skinning.o readtex.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) skinning.o readtex.o shaderutil.o $(LIBS) -o $@ texdemo1.o: texdemo1.c readtex.h extfuncs.h shaderutil.h -- cgit v1.2.3 From 80301866f613960850ebd872a08e8fb03c4760c1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 21 Nov 2008 10:03:19 -0700 Subject: added progs/demos/fragcoord.c - tests gl_FragCoord attribute in fragment shader Fragment's red/greenb/blue is a function gl_FragCoord.xyz --- progs/glsl/Makefile | 8 +++ progs/glsl/fragcoord.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 progs/glsl/fragcoord.c (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index c5d62d2370..9f5a2b7df5 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -16,6 +16,7 @@ PROGS = \ convolutions \ deriv \ identity \ + fragcoord \ mandelbrot \ multitex \ noise \ @@ -115,6 +116,13 @@ identity: identity.o shaderutil.o $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) identity.o shaderutil.o $(LIBS) -o $@ +fragcoord.o: fragcoord.c extfuncs.h shaderutil.h + $(CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c + +fragcoord: fragcoord.o shaderutil.o + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@ + + mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c diff --git a/progs/glsl/fragcoord.c b/progs/glsl/fragcoord.c new file mode 100644 index 0000000000..0b7561f3e4 --- /dev/null +++ b/progs/glsl/fragcoord.c @@ -0,0 +1,185 @@ +/** + * Test GLSL gl_FragCoord fragment program attribute. + * Color the quad's fragments according to their window position. + * + * Brian Paul + * 20 Nov 2008 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "extfuncs.h" +#include "shaderutil.h" + + +static GLint WinWidth = 200, WinHeight = 200; +static char *FragProgFile = NULL; +static char *VertProgFile = NULL; +static GLuint fragShader; +static GLuint vertShader; +static GLuint program; +static GLint win = 0; +static GLboolean Anim = GL_TRUE; +static GLfloat PosX = 0.0, PosY = 0.0; + + +static void +Idle(void) +{ + float r = (WinWidth < WinHeight) ? WinWidth : WinHeight; + float a = glutGet(GLUT_ELAPSED_TIME) * 0.001; + r *= 0.25; + PosX = WinWidth / 2 + r * cos(a); + PosY = WinHeight / 2 + r * sin(a); + + glutPostRedisplay(); +} + + +static void +Redisplay(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + glTranslatef(PosX, PosY, 0.0); +#if 0 + glBegin(GL_POLYGON); + glVertex2f(-50, -50); + glVertex2f( 50, -50); + glVertex2f( 50, 50); + glVertex2f(-50, 50); + glEnd(); +#else + glutSolidSphere(50, 20, 10); +#endif + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width, 0, height, -55, 55); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + WinWidth = width; + WinHeight = height; +} + + +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) +{ + (void) x; + (void) y; + + switch(key) { + case ' ': + case 'a': + Anim = !Anim; + glutIdleFunc(Anim ? Idle : NULL); + break; + case 27: + CleanUp(); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + static const char *fragShaderText = + "void main() { \n" + " vec4 scale = vec4(.005, 0.005, 0.5, 1.0);\n" + " gl_FragColor = gl_FragCoord * scale; \n" + "}\n"; + static const char *vertShaderText = + "void main() {\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + "}\n"; + + if (!ShadersSupported()) + exit(1); + + GetExtensionFuncs(); + + vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText); + fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText); + program = LinkShaders(vertShader, fragShader); + + glUseProgram_func(program); + + /*assert(glGetError() == 0);*/ + + glClearColor(0.3f, 0.3f, 0.3f, 0.0f); + + printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); + + assert(glIsProgram_func(program)); + assert(glIsShader_func(fragShader)); + assert(glIsShader_func(vertShader)); + + glColor3f(1, 0, 0); +} + + +static void +ParseOptions(int argc, char *argv[]) +{ + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-fs") == 0) { + FragProgFile = argv[i+1]; + } + else if (strcmp(argv[i], "-vs") == 0) { + VertProgFile = argv[i+1]; + } + } +} + + +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(); + glutIdleFunc(Anim ? Idle : NULL); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 77762801bc260d1e9f43f684c35f4546350fc76d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 24 Nov 2008 14:31:41 -0700 Subject: remove some redundant rules from prev merge --- progs/glsl/Makefile | 7 ------- 1 file changed, 7 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 5419dfc7f4..9f5a2b7df5 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -123,13 +123,6 @@ fragcoord: fragcoord.o shaderutil.o $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@ -fragcoord.o: fragcoord.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c - -fragcoord: fragcoord.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@ - - mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c -- cgit v1.2.3 From e8a1b31ddf39f0b09eb85653cebb9808a5daf0a9 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Mon, 8 Dec 2008 15:03:29 +0000 Subject: fix conflict breakage --- progs/glsl/Makefile | 4 ---- 1 file changed, 4 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index ce82468168..488a4e9951 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -189,9 +189,6 @@ trirast.o: trirast.c extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trirast.c trirast: trirast.o shaderutil.o -<<<<<<< HEAD:progs/glsl/Makefile - $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@ -======= $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@ @@ -201,7 +198,6 @@ vert-tex.o: vert-tex.c extfuncs.h shaderutil.h vert-tex: vert-tex.o shaderutil.o $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-tex.o shaderutil.o $(LIBS) -o $@ ->>>>>>> origin/master:progs/glsl/Makefile -- cgit v1.2.3 From bde3b3a16487a3939b732e9fd53b6e347fa2f94b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 17 Dec 2008 13:58:31 -0700 Subject: demos: add test of vertex-only and fragment-only shader programs --- progs/glsl/Makefile | 9 ++ progs/glsl/vert-or-frag-only.c | 191 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 progs/glsl/vert-or-frag-only.c (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 71ca0af941..d21dcb6560 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -28,6 +28,7 @@ PROGS = \ toyball \ twoside \ trirast \ + vert-or-frag-only \ vert-tex @@ -193,6 +194,14 @@ trirast: trirast.o shaderutil.o $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@ +vert-or-frag-only.o: vert-or-frag-only.c extfuncs.h shaderutil.h + $(CC) -c -I$(INCDIR) $(CFLAGS) vert-or-frag-only.c + +vert-or-frag-only: vert-or-frag-only.o shaderutil.o + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@ + + + vert-tex.o: vert-tex.c extfuncs.h shaderutil.h $(CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c diff --git a/progs/glsl/vert-or-frag-only.c b/progs/glsl/vert-or-frag-only.c new file mode 100644 index 0000000000..f6eedd8327 --- /dev/null +++ b/progs/glsl/vert-or-frag-only.c @@ -0,0 +1,191 @@ +/** + * Draw two quads, one using only a vertex shader, the other only with a + * fragment shader. They should appear the same. + * 17 Dec 2008 + * Brian Paul + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "extfuncs.h" +#include "shaderutil.h" + + +static char *FragProgFile = NULL; +static char *VertProgFile = NULL; +static GLuint FragShader; +static GLuint VertShader; +static GLuint VertProgram; /* w/out vertex shader */ +static GLuint FragProgram; /* w/out fragment shader */ +static GLint Win = 0; + + +static void +DrawQuadColor(void) +{ + glBegin(GL_QUADS); + glColor3f(1, 0, 0); glVertex2f(-1, -1); + glColor3f(0, 1, 0); glVertex2f( 1, -1); + glColor3f(0, 0, 1); glVertex2f( 1, 1); + glColor3f(1, 0, 1); glVertex2f(-1, 1); + glEnd(); +} + + +/** as above, but specify color via texcoords */ +static void +DrawQuadTex(void) +{ + glBegin(GL_QUADS); + glTexCoord3f(1, 0, 0); glVertex2f(-1, -1); + glTexCoord3f(0, 1, 0); glVertex2f( 1, -1); + glTexCoord3f(0, 0, 1); glVertex2f( 1, 1); + glTexCoord3f(1, 0, 1); glVertex2f(-1, 1); + glEnd(); +} + + +static void +Redisplay(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* render with vertex shader only */ + glUseProgram_func(VertProgram); + glPushMatrix(); + glTranslatef(-1.5, 0, 0); + DrawQuadTex(); + glPopMatrix(); + + /* render with fragment shader only */ + glUseProgram_func(FragProgram); + glPushMatrix(); + glTranslatef(+1.5, 0, 0); + DrawQuadColor(); + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-4, 4, -2, 2, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +CleanUp(void) +{ + glDeleteShader_func(FragShader); + glDeleteShader_func(VertShader); + glDeleteProgram_func(VertProgram); + glDeleteProgram_func(FragProgram); + glutDestroyWindow(Win); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch(key) { + case 27: + CleanUp(); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + static const char *fragShaderText = + "void main() {\n" + " gl_FragColor = gl_Color;\n" + "}\n"; + static const char *vertShaderText = + "void main() {\n" + " gl_Position = ftransform();\n" + " gl_FrontColor = gl_MultiTexCoord0;\n" /* see DrawQuadTex() */ + "}\n"; + + if (!ShadersSupported()) + exit(1); + + GetExtensionFuncs(); + + if (FragProgFile) + FragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile); + else + FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText); + + if (VertProgFile) + VertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile); + else + VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText); + + VertProgram = LinkShaders(VertShader, 0); + FragProgram = LinkShaders(0, FragShader); + + glClearColor(0.3f, 0.3f, 0.3f, 0.0f); + glEnable(GL_DEPTH_TEST); + + printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); + + assert(glIsProgram_func(VertProgram)); + assert(glIsProgram_func(FragProgram)); + assert(glIsShader_func(FragShader)); + assert(glIsShader_func(VertShader)); + + glColor3f(1, 0, 0); +} + + +static void +ParseOptions(int argc, char *argv[]) +{ + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-fs") == 0) { + FragProgFile = argv[i+1]; + } + else if (strcmp(argv[i], "-vs") == 0) { + VertProgFile = argv[i+1]; + } + } +} + + +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]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Redisplay); + ParseOptions(argc, argv); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From aae74c36982b98f1f54a12a6512f78006bf4fd0d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 19 Dec 2008 07:57:09 -0700 Subject: mesa: s/CC/APP_CC/ in progs/glsl/Makefile --- progs/glsl/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index d21dcb6560..0849223cd8 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -191,22 +191,22 @@ trirast.o: trirast.c extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trirast.c trirast: trirast.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@ vert-or-frag-only.o: vert-or-frag-only.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) vert-or-frag-only.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-or-frag-only.c vert-or-frag-only: vert-or-frag-only.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@ vert-tex.o: vert-tex.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c vert-tex: vert-tex.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-tex.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-tex.o shaderutil.o $(LIBS) -o $@ -- cgit v1.2.3 From 84cffc2e7fbeab8ed5dfb0b6b8d3829e0654ab02 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 2 Jan 2009 16:52:00 -0700 Subject: mesa: replace CC with APP_CC in progs/glsl/Makefile --- progs/glsl/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 9c31ef67b0..4d4da31dc1 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -120,10 +120,10 @@ identity: identity.o shaderutil.o fragcoord.o: fragcoord.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c fragcoord: fragcoord.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@ mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h @@ -161,10 +161,10 @@ pointcoord: pointcoord.o readtex.o shaderutil.o samplers.o: samplers.c readtex.h extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) samplers.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) samplers.c samplers: samplers.o readtex.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers.o readtex.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers.o readtex.o shaderutil.o $(LIBS) -o $@ skinning.o: skinning.c readtex.h extfuncs.h shaderutil.h @@ -211,10 +211,10 @@ vert-or-frag-only: vert-or-frag-only.o shaderutil.o vert-or-frag-only.o: vert-or-frag-only.c extfuncs.h shaderutil.h - $(CC) -c -I$(INCDIR) $(CFLAGS) vert-or-frag-only.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-or-frag-only.c vert-or-frag-only: vert-or-frag-only.o shaderutil.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@ -- cgit v1.2.3 From fa4fec2d1bfa459d46601b2f1e104b9533bf679f Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 23 Dec 2008 15:46:25 -0600 Subject: demos: remove redundant Makefile lines from prev merge --- progs/glsl/Makefile | 8 -------- 1 file changed, 8 deletions(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 4d4da31dc1..69e15398dc 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -210,14 +210,6 @@ vert-or-frag-only: vert-or-frag-only.o shaderutil.o -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 - -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 $@ - - - vert-tex.o: vert-tex.c extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c -- cgit v1.2.3 From b2e9d415ed56b856289f4e815cc9c56e8b0cc401 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 5 Jan 2009 11:49:45 +0100 Subject: progs/glsl: Remove double target def for vert-or-frag-only --- progs/glsl/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 69e15398dc..a39170b8c9 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -209,7 +209,6 @@ 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 $@ - vert-tex.o: vert-tex.c extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c -- cgit v1.2.3 From e82784559e00cb534993c01309ad1832e9b3e56b Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Wed, 14 Jan 2009 17:01:16 +0000 Subject: mesa: add new samplers_array test --- progs/glsl/Makefile | 6 ++++++ progs/glsl/samplers.c | 12 ++++++++++++ 2 files changed, 18 insertions(+) (limited to 'progs/glsl/Makefile') diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index a39170b8c9..7099eeadbd 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -24,6 +24,7 @@ PROGS = \ points \ pointcoord \ samplers \ + samplers_array \ skinning \ texdemo1 \ toyball \ @@ -166,6 +167,11 @@ samplers.o: samplers.c readtex.h extfuncs.h shaderutil.h samplers: samplers.o readtex.o shaderutil.o $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers.o readtex.o shaderutil.o $(LIBS) -o $@ +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 + +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 diff --git a/progs/glsl/samplers.c b/progs/glsl/samplers.c index d214009729..3fb8577d5e 100644 --- a/progs/glsl/samplers.c +++ b/progs/glsl/samplers.c @@ -245,14 +245,22 @@ GenFragmentShader(GLint numSamplers) int s; p += sprintf(p, "// Generated fragment shader:\n"); +#ifndef SAMPLERS_ARRAY for (s = 0; s < numSamplers; s++) { p += sprintf(p, "uniform sampler2D tex%d;\n", s); } +#else + p += sprintf(p, "uniform sampler2D tex[%d];\n", numSamplers); +#endif p += sprintf(p, "void main()\n"); p += sprintf(p, "{\n"); p += sprintf(p, " vec4 color = vec4(0.0);\n"); for (s = 0; s < numSamplers; s++) { +#ifndef SAMPLERS_ARRAY p += sprintf(p, " color += texture2D(tex%d, gl_TexCoord[0].xy);\n", s); +#else + p += sprintf(p, " color += texture2D(tex[%d], gl_TexCoord[0].xy);\n", s); +#endif } p += sprintf(p, " gl_FragColor = color;\n"); p += sprintf(p, "}\n"); @@ -302,7 +310,11 @@ InitProgram(void) char uname[10]; GLint loc; +#ifndef SAMPLERS_ARRAY sprintf(uname, "tex%d", s); +#else + sprintf(uname, "tex[%d]", s); +#endif loc = glGetUniformLocation_func(Program, uname); assert(loc >= 0); -- cgit v1.2.3