diff options
author | Chia-I Wu <olvaffe@gmail.com> | 2009-09-15 14:16:22 +0800 |
---|---|---|
committer | Chia-I Wu <olvaffe@gmail.com> | 2009-09-15 14:16:22 +0800 |
commit | e2ba90a9cc762cf00a168f0a59d31e7dc52fc42e (patch) | |
tree | fe3206d7602ad935296884742980f3c4d30bd867 /progs/vp | |
parent | 11a4292d4eb515813b82b8d688a318adef66b3e6 (diff) | |
parent | b4b8800315637d9218a81c76f09df7d601710d29 (diff) |
Merge commit 'eee/mesa-es' into android
Diffstat (limited to 'progs/vp')
-rw-r--r-- | progs/vp/Makefile | 8 | ||||
-rw-r--r-- | progs/vp/SConscript | 13 | ||||
-rw-r--r-- | progs/vp/addimm.txt | 5 | ||||
-rw-r--r-- | progs/vp/arl-static.txt | 7 | ||||
-rw-r--r-- | progs/vp/arl-unused.txt | 7 | ||||
-rw-r--r-- | progs/vp/exp-no-w.txt | 6 | ||||
-rw-r--r-- | progs/vp/exp.txt | 6 | ||||
-rw-r--r-- | progs/vp/log.txt | 7 | ||||
-rw-r--r-- | progs/vp/msk.txt | 7 | ||||
-rw-r--r-- | progs/vp/psiz-imm.txt | 5 | ||||
-rw-r--r-- | progs/vp/psiz-mul-clamp.txt | 9 | ||||
-rw-r--r-- | progs/vp/psiz-mul.txt | 6 | ||||
-rw-r--r-- | progs/vp/psiz-param-clamp.txt | 10 | ||||
-rwxr-xr-x | progs/vp/run.sh | 7 | ||||
-rw-r--r-- | progs/vp/vp-tris.c | 138 | ||||
-rw-r--r-- | progs/vp/windows/vp2003.sln | 21 | ||||
-rw-r--r-- | progs/vp/windows/vp2003.vcproj | 121 | ||||
-rw-r--r-- | progs/vp/xform.txt | 11 |
18 files changed, 375 insertions, 19 deletions
diff --git a/progs/vp/Makefile b/progs/vp/Makefile index 28d63237a4..58a0dacb22 100644 --- a/progs/vp/Makefile +++ b/progs/vp/Makefile @@ -8,7 +8,7 @@ TOP = ../.. include $(TOP)/configs/current -LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) SOURCES = \ vp-tris.c @@ -26,13 +26,13 @@ INCLUDES = -I. -I$(TOP)/include -I../samples .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@ + $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(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 ##### diff --git a/progs/vp/SConscript b/progs/vp/SConscript new file mode 100644 index 0000000000..640c5dd847 --- /dev/null +++ b/progs/vp/SConscript @@ -0,0 +1,13 @@ +Import('env') + +if not env['GLUT']: + Return() + +env = env.Clone() + +env.Prepend(LIBS = ['$GLUT_LIB']) + +env.Program( + target = 'vp-tris', + source = ['vp-tris.c'], + ) diff --git a/progs/vp/addimm.txt b/progs/vp/addimm.txt new file mode 100644 index 0000000000..f5796d7810 --- /dev/null +++ b/progs/vp/addimm.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +TEMP R0; +ADD result.color, vertex.color, {.5}.x; +MOV result.position, vertex.position; +END diff --git a/progs/vp/arl-static.txt b/progs/vp/arl-static.txt new file mode 100644 index 0000000000..83aebf689e --- /dev/null +++ b/progs/vp/arl-static.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +PARAM arr[7] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}}; +ADDRESS addr; +ARL addr.x, {3}.x; +MOV result.color, arr[addr.x]; +MOV result.position, vertex.position; +END diff --git a/progs/vp/arl-unused.txt b/progs/vp/arl-unused.txt new file mode 100644 index 0000000000..c2afe3c092 --- /dev/null +++ b/progs/vp/arl-unused.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +PARAM arr[7] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}}; +ADDRESS addr; +ARL addr.x, {3}.x; # not actually used +MOV result.color, arr[3]; +MOV result.position, vertex.position; +END diff --git a/progs/vp/exp-no-w.txt b/progs/vp/exp-no-w.txt new file mode 100644 index 0000000000..98ed4b7a98 --- /dev/null +++ b/progs/vp/exp-no-w.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +EXP R0, vertex.color.x; +SUB result.color, R0.z, {1.0}.x; +MOV result.position, vertex.position; +END diff --git a/progs/vp/exp.txt b/progs/vp/exp.txt new file mode 100644 index 0000000000..53ce71db96 --- /dev/null +++ b/progs/vp/exp.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +TEMP R0; +EXP R0, vertex.color.x; +SUB result.color, R0.z, R0.w; +MOV result.position, vertex.position; +END diff --git a/progs/vp/log.txt b/progs/vp/log.txt new file mode 100644 index 0000000000..6b4e94ed0e --- /dev/null +++ b/progs/vp/log.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +TEMP R0; +ADD R0, vertex.color, vertex.color; +ADD R0, R0, R0; +LOG result.color, R0.x; +MOV result.position, vertex.position; +END diff --git a/progs/vp/msk.txt b/progs/vp/msk.txt new file mode 100644 index 0000000000..9e925aca11 --- /dev/null +++ b/progs/vp/msk.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +TEMP R0; +MOV R0.xz, vertex.color; +MOV R0.yw, {0.5}.x; +MOV result.color, R0; +MOV result.position, vertex.position; +END diff --git a/progs/vp/psiz-imm.txt b/progs/vp/psiz-imm.txt new file mode 100644 index 0000000000..18de2498d6 --- /dev/null +++ b/progs/vp/psiz-imm.txt @@ -0,0 +1,5 @@ +!!ARBvp1.0 +MOV result.color, vertex.color; +MOV result.pointsize, {2.0, 0, 0, 1}; +MOV result.position, vertex.position; +END diff --git a/progs/vp/psiz-mul-clamp.txt b/progs/vp/psiz-mul-clamp.txt new file mode 100644 index 0000000000..284c032d79 --- /dev/null +++ b/progs/vp/psiz-mul-clamp.txt @@ -0,0 +1,9 @@ +!!ARBvp1.0 +TEMP R0; +MOV result.color, vertex.color; +MUL R0.x, vertex.color.x, {10.0}.x; +MAX R0.x, R0.x, {2.0}.x; +MIN result.pointsize.x, R0.x, {4.0}.x; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/psiz-mul.txt b/progs/vp/psiz-mul.txt new file mode 100644 index 0000000000..a74df66de2 --- /dev/null +++ b/progs/vp/psiz-mul.txt @@ -0,0 +1,6 @@ +!!ARBvp1.0 +MOV result.color, vertex.color; +MUL result.pointsize, vertex.color.x, {10.0}.x; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/psiz-param-clamp.txt b/progs/vp/psiz-param-clamp.txt new file mode 100644 index 0000000000..7f83fc4516 --- /dev/null +++ b/progs/vp/psiz-param-clamp.txt @@ -0,0 +1,10 @@ +!!ARBvp1.0 +TEMP R0; +TEMP R1; +MOV result.color, vertex.color; +MUL R0.x, vertex.color.x, {10.0}.x; +MAX R0.x, R0.x, {2.0}.x; +MIN result.pointsize.x, R0.x, {4.0}.x; +MOV result.position, vertex.position; +END + diff --git a/progs/vp/run.sh b/progs/vp/run.sh new file mode 100755 index 0000000000..fdd43d4a52 --- /dev/null +++ b/progs/vp/run.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +for i in *.txt ; do +echo $i +./vp-tris $i +done + diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c index 5dbe5ac835..97995accdd 100644 --- a/progs/vp/vp-tris.c +++ b/progs/vp/vp-tris.c @@ -5,11 +5,21 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES + +#ifndef WIN32 +#include <unistd.h> +#include <signal.h> +#endif + +#include <GL/glew.h> #include <GL/glut.h> static const char *filename = NULL; static GLuint nr_steps = 4; +static GLuint prim = GL_TRIANGLES; +static GLfloat psz = 1.0; +static GLboolean pointsmooth = 0; +static GLboolean program_point_size = 0; static void usage( char *name ) { @@ -18,8 +28,29 @@ static void usage( char *name ) fprintf( stderr, "options:\n" ); fprintf( stderr, " -f flat shaded\n" ); fprintf( stderr, " -nNr subdivision steps\n" ); + fprintf( stderr, " -fps show frames per second\n" ); } +unsigned show_fps = 0; +unsigned int frame_cnt = 0; + +#ifndef WIN32 + +void alarmhandler(int); + +void alarmhandler (int sig) +{ + if (sig == SIGALRM) { + printf("%d frames in 5.0 seconds = %.3f FPS\n", frame_cnt, + frame_cnt / 5.0); + + frame_cnt = 0; + } + signal(SIGALRM, alarmhandler); + alarm(5); +} + +#endif static void args(int argc, char *argv[]) { @@ -32,6 +63,9 @@ static void args(int argc, char *argv[]) else if (strcmp(argv[i], "-f") == 0) { glShadeModel(GL_FLAT); } + else if (strcmp(argv[i], "-fps") == 0) { + show_fps = 1; + } else if (i == argc - 1) { filename = argv[i]; } @@ -62,19 +96,31 @@ static void Init( void ) exit(1); } - sz = fread(buf, 1, sizeof(buf), f); + sz = (GLuint) fread(buf, 1, sizeof(buf), f); if (!feof(f)) { fprintf(stderr, "file too long\n"); exit(1); } fprintf(stderr, "%.*s\n", sz, buf); - - glGenProgramsARB(1, &prognum); - glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); - glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - sz, (const GLubyte *) buf); + if (strncmp( buf, "!!VP", 4 ) == 0) { + glEnable( GL_VERTEX_PROGRAM_NV ); + glGenProgramsNV( 1, &prognum ); + glBindProgramNV( GL_VERTEX_PROGRAM_NV, prognum ); + glLoadProgramNV( GL_VERTEX_PROGRAM_NV, prognum, sz, (const GLubyte *) buf ); + assert( glIsProgramNV( prognum ) ); + } + else { + glEnable(GL_VERTEX_PROGRAM_ARB); + + glGenProgramsARB(1, &prognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + sz, (const GLubyte *) buf); + assert(glIsProgramARB(prognum)); + } errno = glGetError(); printf("glGetError = %d\n", errno); @@ -86,7 +132,17 @@ static void Init( void ) printf("errorpos: %d\n", errorpos); printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); } - assert(glIsProgramARB(prognum)); + + { + const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 }; + const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 }; + const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 }; + const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 }; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission); + } } @@ -134,6 +190,14 @@ static void subdiv( union vert *v0, } } +static void enable( GLenum value, GLboolean flag ) +{ + if (flag) + glEnable(value); + else + glDisable(value); +} + /** Assignment */ #define ASSIGN_3V( V, V0, V1, V2 ) \ do { \ @@ -146,10 +210,12 @@ static void Display( void ) { glClearColor(0.3, 0.3, 0.3, 1); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glPointSize(psz); - glEnable(GL_VERTEX_PROGRAM_NV); + enable( GL_POINT_SMOOTH, pointsmooth ); + enable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB, program_point_size ); - glBegin(GL_TRIANGLES); + glBegin(prim); { @@ -168,7 +234,11 @@ static void Display( void ) glEnd(); - glFlush(); + glFlush(); + if (show_fps) { + ++frame_cnt; + glutPostRedisplay(); + } } @@ -189,9 +259,40 @@ static void Key( unsigned char key, int x, int y ) (void) x; (void) y; switch (key) { - case 27: - exit(0); - break; + case 'p': + prim = GL_POINTS; + break; + case 't': + prim = GL_TRIANGLES; + break; + case 's': + psz += .5; + break; + case 'S': + if (psz > .5) + psz -= .5; + break; + case 'm': + pointsmooth = !pointsmooth; + break; + case 'z': + program_point_size = !program_point_size; + break; + case '+': + nr_steps++; + break; + case '-': + if (nr_steps) + nr_steps--; + break; + case ' ': + psz = 1.0; + prim = GL_TRIANGLES; + nr_steps = 4; + break; + case 27: + exit(0); + break; } glutPostRedisplay(); } @@ -205,12 +306,19 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); - glutCreateWindow(argv[0]); + glutCreateWindow(argv[argc-1]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); args( argc, argv ); Init(); +#ifndef WIN32 + if (show_fps) { + signal(SIGALRM, alarmhandler); + alarm(5); + } +#endif glutMainLoop(); return 0; } diff --git a/progs/vp/windows/vp2003.sln b/progs/vp/windows/vp2003.sln new file mode 100644 index 0000000000..76de5cfd7f --- /dev/null +++ b/progs/vp/windows/vp2003.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vp2003", "vp2003.vcproj", "{E1C70416-98E7-4282-B6B2-6C9CF90B12C0}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Debug.ActiveCfg = Debug|Win32 + {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Debug.Build.0 = Debug|Win32 + {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Release.ActiveCfg = Release|Win32 + {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/progs/vp/windows/vp2003.vcproj b/progs/vp/windows/vp2003.vcproj new file mode 100644 index 0000000000..adca2c5073 --- /dev/null +++ b/progs/vp/windows/vp2003.vcproj @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="vp2003" + ProjectGUID="{E1C70416-98E7-4282-B6B2-6C9CF90B12C0}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="glut32.lib" + OutputFile="$(OutDir)/vp2003.exe" + LinkIncremental="2" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="$(OutDir)/vp2003.pdb" + SubSystem="1" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="4" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="glut32.lib" + OutputFile="$(OutDir)/vp2003.exe" + LinkIncremental="1" + GenerateDebugInformation="TRUE" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="..\vp-tris.c"> + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/progs/vp/xform.txt b/progs/vp/xform.txt new file mode 100644 index 0000000000..d1548f1f10 --- /dev/null +++ b/progs/vp/xform.txt @@ -0,0 +1,11 @@ +!!ARBvp1.0 +PARAM Emission = state.material.emission; +PARAM Ambient = state.material.ambient; +PARAM Diffuse = state.material.diffuse; +PARAM Specular = state.material.specular; +DP4 result.position.x, Ambient, vertex.position; +DP4 result.position.y, Diffuse, vertex.position; +DP4 result.position.z, Specular, vertex.position; +DP4 result.position.w, Emission, vertex.position; +MOV result.color, vertex.color; +END |