diff options
Diffstat (limited to 'progs/vp')
-rw-r--r-- | progs/vp/Makefile | 8 | ||||
-rw-r--r-- | progs/vp/SConscript | 13 | ||||
-rw-r--r-- | progs/vp/exp.txt | 6 | ||||
-rw-r--r-- | progs/vp/log.txt | 7 | ||||
-rwxr-xr-x | progs/vp/run.sh | 7 | ||||
-rw-r--r-- | progs/vp/vp-tris.c | 85 | ||||
-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 |
9 files changed, 263 insertions, 16 deletions
diff --git a/progs/vp/Makefile b/progs/vp/Makefile index 28d63237a45..58a0dacb22e 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 00000000000..640c5dd8470 --- /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/exp.txt b/progs/vp/exp.txt new file mode 100644 index 00000000000..53ce71db965 --- /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 00000000000..6b4e94ed0ed --- /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/run.sh b/progs/vp/run.sh new file mode 100755 index 00000000000..fdd43d4a52b --- /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 5dbe5ac8359..87cb12b9846 100644 --- a/progs/vp/vp-tris.c +++ b/progs/vp/vp-tris.c @@ -5,7 +5,13 @@ #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; @@ -18,8 +24,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 +59,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 +92,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 +128,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); + } } @@ -147,8 +199,6 @@ static void Display( void ) glClearColor(0.3, 0.3, 0.3, 1); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glEnable(GL_VERTEX_PROGRAM_NV); - glBegin(GL_TRIANGLES); @@ -168,7 +218,11 @@ static void Display( void ) glEnd(); - glFlush(); + glFlush(); + if (show_fps) { + ++frame_cnt; + glutPostRedisplay(); + } } @@ -205,12 +259,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 00000000000..76de5cfd7ff --- /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 00000000000..adca2c50731 --- /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 00000000000..d1548f1f10d --- /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 |