X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FOpenGL_Windows.cpp;h=2f92938789c3df346b2195183bbbf06eac6f6c80;hb=0e68eb62170f14f5b2aa89864e437fc2287e7565;hp=a0ace20b7ac291148281b2d202ae3841fc8c20bb;hpb=24004d6ab1e68faaf85ece11b566449997da5013;p=lugaru.git diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index a0ace20..2f92938 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -194,7 +194,7 @@ void initGL() glDisable( GL_ALPHA_TEST); glDisable( GL_BLEND); glDisable( GL_DEPTH_TEST); - // glDisable( GL_DITHER); + //glDisable( GL_DITHER); glDisable( GL_FOG); glDisable( GL_LIGHTING); glDisable( GL_LOGIC_OP); @@ -215,13 +215,13 @@ void initGL() glClearDepth( 1.0f); glDepthFunc( GL_LEQUAL); glDepthMask( GL_TRUE); - // glDepthRange( FRONT_CLIP, BACK_CLIP); + //glDepthRange( FRONT_CLIP, BACK_CLIP); glEnable( GL_DEPTH_TEST); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glCullFace( GL_FRONT); glEnable( GL_CULL_FACE); glEnable( GL_LIGHTING); -// glEnable( GL_LIGHT_MODEL_AMBIENT); + //glEnable( GL_LIGHT_MODEL_AMBIENT); glEnable( GL_DITHER); glEnable( GL_COLOR_MATERIAL); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -296,7 +296,6 @@ Boolean SetUp () texdetail = 4; slomospeed = 0.25; slomofreq = 8012; - numplayers = 1; DefaultSettings(); @@ -446,26 +445,29 @@ void DoFrameRate (int update) AbsoluteTime currTime = UpTime (); double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime); - if (0 > deltaTime) // if negative microseconds + if (0 > deltaTime) // if negative microseconds deltaTime /= -1000000.0; - else // else milliseconds + else // else milliseconds deltaTime /= 1000.0; multiplier = deltaTime; - if (multiplier < .001) multiplier = .001; - if (multiplier > 10) multiplier = 10; - if (update) frametime = currTime; // reset for next time interval + if (multiplier < .001) + multiplier = .001; + if (multiplier > 10) + multiplier = 10; + if (update) + frametime = currTime; // reset for next time interval deltaTime = (float) AbsoluteDeltaToDuration (currTime, time); - if (0 > deltaTime) // if negative microseconds + if (0 > deltaTime) // if negative microseconds deltaTime /= -1000000.0; - else // else milliseconds + else // else milliseconds deltaTime /= 1000.0; frames++; - if (0.001 <= deltaTime) { // has update interval passed + if (0.001 <= deltaTime) { // has update interval passed if (update) { - time = currTime; // reset for next time interval + time = currTime; // reset for next time interval frames = 0; } } @@ -479,20 +481,26 @@ void DoUpdate () static float oldmult; DoFrameRate(1); - if (multiplier > .6)multiplier = .6; + if (multiplier > .6) + multiplier = .6; fps = 1 / multiplier; count = multiplier * sps; - if (count < 2)count = 2; + if (count < 2) + count = 2; realmultiplier = multiplier; multiplier *= gamespeed; - if (difficulty == 1)multiplier *= .9; - if (difficulty == 0)multiplier *= .8; - - if (loading == 4)multiplier *= .00001; - if (slomo && !mainmenu)multiplier *= slomospeed; + if (difficulty == 1) + multiplier *= .9; + if (difficulty == 0) + multiplier *= .8; + + if (loading == 4) + multiplier *= .00001; + if (slomo && !mainmenu) + multiplier *= slomospeed; oldmult = multiplier; multiplier /= (float)count; @@ -507,38 +515,38 @@ void DoUpdate () TickOnceAfter(); /* - Debug code to test how many channels were active on average per frame - static long frames = 0; - - static AbsoluteTime start = {0,0}; - AbsoluteTime currTime = UpTime (); - static int num_channels = 0; - - num_channels += OPENAL_GetChannelsPlaying(); - double deltaTime = (float) AbsoluteDeltaToDuration (currTime, start); - - if (0 > deltaTime) // if negative microseconds - deltaTime /= -1000000.0; - else // else milliseconds - deltaTime /= 1000.0; - - ++frames; - - if (deltaTime >= 1) - { - start = currTime; - float avg_channels = (float)num_channels / (float)frames; - - ofstream opstream("log.txt",ios::app); - opstream << "Average frame count: "; - opstream << frames; - opstream << " frames - "; - opstream << avg_channels; - opstream << " per frame.\n"; - opstream.close(); - - frames = 0; - num_channels = 0; - } + static long frames = 0; + + static AbsoluteTime start = {0,0}; + AbsoluteTime currTime = UpTime (); + static int num_channels = 0; + + num_channels += OPENAL_GetChannelsPlaying(); + double deltaTime = (float) AbsoluteDeltaToDuration (currTime, start); + + if (0 > deltaTime) // if negative microseconds + deltaTime /= -1000000.0; + else // else milliseconds + deltaTime /= 1000.0; + + ++frames; + + if (deltaTime >= 1) + { + start = currTime; + float avg_channels = (float)num_channels / (float)frames; + + ofstream opstream("log.txt",ios::app); + opstream << "Average frame count: "; + opstream << frames; + opstream << " frames - "; + opstream << avg_channels; + opstream << " per frame.\n"; + opstream.close(); + + frames = 0; + num_channels = 0; + } */ if ( stereomode == stereoNone ) { DrawGLScene(stereoCenter); @@ -638,9 +646,11 @@ char *calcBaseDir(const char *argv0) } envr = getenv("PATH"); - if (!envr) return NULL; + if (!envr) + return NULL; envr = strdup(envr); - if (!envr) return NULL; + if (!envr) + return NULL; retval = findBinaryInPath(argv0, envr); free(envr); return(retval); @@ -792,8 +802,8 @@ static bool load_image(const char *file_name, TGAImageRec &tex) struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - jmp_buf setjmp_buffer; /* for return to caller */ + struct jpeg_error_mgr pub; /* "public" fields */ + jmp_buf setjmp_buffer; /* for return to caller */ }; typedef struct my_error_mgr * my_error_ptr; @@ -809,8 +819,8 @@ static bool load_jpg(const char *file_name, TGAImageRec &tex) { struct jpeg_decompress_struct cinfo; struct my_error_mgr jerr; - JSAMPROW buffer[1]; /* Output row buffer */ - int row_stride; /* physical row width in output buffer */ + JSAMPROW buffer[1]; /* Output row buffer */ + int row_stride; /* physical row width in output buffer */ FILE *infile = fopen(file_name, "rb"); if (infile == NULL)