// Genesaver: copyright 2003 Sam Stafford. #ifndef WIN32 //Win32 builds use winmain.cpp instead. //This version uses GLUT and should run elsewhere, //but I haven't tried it out to be sure. #include <stdio.h> #include <stdlib.h> #include <GL/glut.h> #include <time.h> #include "globals.h" #include "util.h" #include "DNA.h" #include "World.h" #include "Jungle.h" int config(); void display(); void timer( int ); void kdone( unsigned char, int, int ); void mdone( int, int ); void loadsettings(); // mouse tracking for mdone() bool mstart; int mx, my; int main( int argc, char** argv ) { extern World *world; srand( time(NULL ) ); mstart = false; loadsettings(); glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DOUBLE | ( settings.AA ? GLUT_ALPHA : 0 ) ); glutCreateWindow( "Genesaver" ); //glutFullScreen(); if ( settings.lizard ) world = new Jungle(); else world = new World(); load(); glutSetCursor( GLUT_CURSOR_NONE ); if ( settings.AA ) { // Thanks to Adrian for making this work! // And thanks to Matt for helping me test the problem that // manifested only on his machine and noplace else. glEnable( GL_BLEND ); glEnable( GL_POLYGON_SMOOTH ); if ( settings.AAline) glEnable( GL_LINE_SMOOTH ); glBlendFunc (GL_SRC_ALPHA, GL_ONE); glHint( GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE ); } glShadeModel( settings.shade ? GL_SMOOTH : GL_FLAT ); glutDisplayFunc( display ); glutKeyboardFunc( kdone ); glutPassiveMotionFunc( mdone ); glutTimerFunc( 1, timer, 0 ); glutMainLoop(); return 0; } void display() { if ( draw() ) { glutSwapBuffers(); glFlush(); } } void timer( int val ) { extern World *world; world->Step(); glutPostRedisplay(); glutTimerFunc( 1, timer, 0 ); } void kdone( unsigned char c, int, int ) { extern World *world; switch ( c ) { case 'c': switch( settings.camera ) { case C_WORLD: settings.camera = C_CHASE; break; case C_GRAPH: settings.camera = C_WORLD; break; case C_CHASE: settings.camera = C_GRAPH; int rc = world->rgcount; world->rgcount = 1; world->RenderGraph(); glutSwapBuffers(); glFlush(); world->rgcount = rc; } break; case 'v': world->ViewChange(); break; case '+': case '=': if ( settings.zoom < 1000 ) settings.zoom += 5; break; case '_': case '-': if ( settings.zoom > 10 ) settings.zoom -= 5; break; default: exit( save() ); } } void mdone( int x, int y ) { if ( !mstart ) { mx = x; my = y; mstart = true; return; } // Exit if the mouse moves more than 100 pixels. // if ( (x-mx)*(x-mx)+(y-my)*(y-my) < 10000 ) return; // marc: keep it up in a window if necessary..? // exit( save() ); return; } #endif
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 28901 | marc_tooley | "" | ||
#2 | 4902 | marc |
Working Genesaver under NetBSD.. . Fixed all default-level compiler warnings such as: .. Missing newline at end of files; .. Eliminating NULLs in non-pointer comparisons; .. Fixing all case inconsistencies; .. Added appropriate includes for math-functions under NetBSD; .. Added missing extern World *world pointers; .. #ifdef'd redefinition of NULL .. Deleted :) unnecessary sln/vcproj/scc clutter (shh don't tell Sam) . Submitting advanced long-ish term creature DNA as a cheat for the impatient. (Move Genes.txt out of the way to see them evolve right from the start.) . Added Jamfile for building an in-place executable called 'gene' . Added a build.sh script for users who don't have access to Jam. . Made it into standard resizeable window operation (no fullsc) . Removed winmain.cpp because we don't need it for UNIX! :) |
||
#1 | 4899 | marc |
branch from Stafford's genesaver Intent is to get it working under NetBSD, my (current) favourite OS. |
||
//guest/sam_stafford/genesaver/src/main.cpp | |||||
#3 | 3354 | Sam Stafford |
Code refactoring - split "main" functions into main.cpp (non-Windows) and winmain.cpp (Windows), with all shared code going in util.cpp. No functional changes. |
||
#2 | 3353 | Sam Stafford |
Use Windows <scrnsave.h> and OpenGL functions instead of GLUT. This should fix all sorts of bugs involving the screensaver not terminating when it should, spawning new processes, et cetera. Code shuffling to follow, since right now it's a tangled mess. |
||
#1 | 3052 | Sam Stafford |
Add Genesaver to the Public Depot. It's not in any way Perforce-related, but it does share a bit of code with Jamgraph, and it feels strange to have an open-source project that's not in the PD. |