void myKeyboard(unsigned char key, int xx, int yy) { switch (key) { case 13 : if (paused == 1) {paused = 0;} else if (paused == 0) {paused = 1;} break; case 'q' : if (pabsorb == 1) {pabsorb = 0;} else if (pabsorb == 0) {pabsorb = 1;} break; case ']' : grid_amp *= 2; break; case '[' : grid_amp /= 2; break; case '.' : grid_fov -= 1; myReshape(winx, winy); break; case ',' : grid_fov += 1; myReshape(winx, winy); break; case 'w' : grid_look_y -= 0.05; break; case 's' : grid_look_y += 0.05; break; case 'a' : grid_look_x += 0.05; break; case 'd' : grid_look_x -= 0.05; break; } }
void myinit(void) { int i; srandom(getpid()); glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_LINE_SMOOTH); glShadeModel(GL_FLAT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for (i = 0; i < N_SHAPES; i++) initshapes(i); myReshape(200, 200); }
void myinit(void) { float f[20]; #ifdef STEREO /* check if GL_STEREO quad-buffered page-flipping display enabled ? */ if (bStereoRequested) glGetBooleanv(GL_STEREO, &bStereoEnabled); /* lower background contrast to reduce ghosting in LCS glasses */ if (bStereoEnabled) glClearColor(0.2, 0.2, 0.2, 0.0); else #endif glClearColor(0.0, 0.0, 0.0, 0.0); myReshape(640, 480); /* glShadeModel(GL_FLAT); */ glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_LIGHTING); glLightf(GL_LIGHT0, GL_SHININESS, 1.0); f[0] = 1.3; f[1] = 1.3; f[2] = -3.3; f[3] = 1.0; glLightfv(GL_LIGHT0, GL_POSITION, f); f[0] = 0.8; f[1] = 1.0; f[2] = 0.83; f[3] = 1.0; glLightfv(GL_LIGHT0, GL_SPECULAR, f); glLightfv(GL_LIGHT0, GL_DIFFUSE, f); glEnable(GL_LIGHT0); glLightf(GL_LIGHT1, GL_SHININESS, 1.0); f[0] = -2.3; f[1] = 0.3; f[2] = -7.3; f[3] = 1.0; glLightfv(GL_LIGHT1, GL_POSITION, f); f[0] = 1.0; f[1] = 0.8; f[2] = 0.93; f[3] = 1.0; glLightfv(GL_LIGHT1, GL_SPECULAR, f); glLightfv(GL_LIGHT1, GL_DIFFUSE, f); glEnable(GL_LIGHT1); /* gear material */ f[0] = 0.1; f[1] = 0.15; f[2] = 0.2; f[3] = 1.0; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, f); f[0] = 0.9; f[1] = 0.3; f[2] = 0.3; f[3] = 1.0; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, f); f[0] = 0.4; f[1] = 0.9; f[2] = 0.6; f[3] = 1.0; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, f); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 4); }
void CALLBACK dis3 (void) { persp=1-persp; myReshape(ow,oh); }
void CALLBACK dis2 (void) { maxcor*=1.2; myReshape(ow,oh); }
void CALLBACK dis1 (void) { maxcor/=1.2; myReshape(ow,oh); }
int mechTest( GA_HGLRC glrc, int width, int height) { ibool done = false; int initPageCount = 5; int fpsRate = 0,key = 0,waitVRT = gaWaitVRT,pageCount = initPageCount; ulong lastCount = 0,newCount; event_t evt; myinit(); myReshape(width,height); LZTimerOn(); while (!done) { animation(); display(); gmoveto(0,0); gprintf("%d x %d %d bit %s (%d.%d fps)",(int)maxX+1,(int)maxY+1, (int)modeInfo.BitsPerPixel, (cntMode & gaLinearBuffer) ? "Linear" : "Banked", fpsRate / 10, fpsRate % 10); if (softwareOnly) gprintf("Rendering to system memory back buffer"); switch (waitVRT) { case gaTripleBuffer: gprintf("Triple buffering - should be no flicker"); gprintf("Frame rate *must* max at refresh rate"); break; case gaWaitVRT: gprintf("Double buffering - should be no flicker"); gprintf("Frame rate *must* lock to multiple of refresh"); break; default: gprintf("Page flipping (no wait) - may flicker"); gprintf("Frame rate *must* max at hardware limit"); break; } glFuncs.SwapBuffers(glrc,waitVRT); if (EVT_kbhit()) { EVT_getNext(&evt,EVT_KEYDOWN | EVT_KEYREPEAT); EVT_flush(EVT_KEYREPEAT); key = EVT_asciiCode(evt.message); if (key == 'v' || key == 'V') { waitVRT -= 1; if (modeInfo.Attributes & gaHaveTripleBuffer) { if (waitVRT < gaTripleBuffer) waitVRT = gaDontWait; } else { if (waitVRT < gaWaitVRT) waitVRT = gaDontWait; } } else if (key == 0x1B || key == 0x0D || key == ' ') { done = true; } else { handleASCIICode(key); handleScanCode(EVT_scanCode(evt.message)); } } /* Compute the frames per second rate after going through a large * number of pages. */ if (--pageCount == 0) { newCount = LZTimerLap(); fpsRate = (int)(10000000L / (newCount - lastCount)) * initPageCount; lastCount = newCount; pageCount = initPageCount; } } LZTimerOff(); if (quadObj) { gluDeleteQuadric(quadObj); quadObj = NULL; } return key; }
int gears2Test( GA_HGLRC glrc, int width, int height) { ibool done = false; int initPageCount = 5; int fpsRate = 0,key = 0,waitVRT = gaWaitVRT,pageCount = initPageCount; ulong lastCount = 0,newCount; myinit(); myReshape(width,height); LZTimerOn(); while (!done) { oneFrame(); gmoveto(0,0); gprintf("%d x %d %d bit %s (%d.%d fps)",(int)maxX+1,(int)maxY+1, (int)modeInfo.BitsPerPixel, (cntMode & gaLinearBuffer) ? "Linear" : "Banked", fpsRate / 10, fpsRate % 10); if (softwareOnly) gprintf("Rendering to system memory back buffer"); switch (waitVRT) { case gaTripleBuffer: gprintf("Triple buffering - should be no flicker"); gprintf("Frame rate *must* max at refresh rate"); break; case gaWaitVRT: gprintf("Double buffering - should be no flicker"); gprintf("Frame rate *must* lock to multiple of refresh"); break; default: gprintf("Page flipping (no wait) - may flicker"); gprintf("Frame rate *must* max at hardware limit"); break; } glFuncs.SwapBuffers(glrc,waitVRT); if (EVT_kbhit()) { key = EVT_getch(); /* Swallow keypress */ if (key == 'v' || key == 'V') { waitVRT -= 1; if (modeInfo.Attributes & gaHaveTripleBuffer) { if (waitVRT < gaTripleBuffer) waitVRT = gaDontWait; } else { if (waitVRT < gaWaitVRT) waitVRT = gaDontWait; } } else break; } /* Compute the frames per second rate after going through a large * number of pages. */ if (--pageCount == 0) { newCount = LZTimerLap(); fpsRate = (int)(10000000L / (newCount - lastCount)) * initPageCount; lastCount = newCount; pageCount = initPageCount; } } LZTimerOff(); return key; }