static void Display(void) { char str[100]; glBindTexture(GL_TEXTURE_2D, TexObj); if (NearestFilter) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); } else { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } if (HaveAniso) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, AnisoMax); } glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias); glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef(0.0, 0.0, Zpos); glRotatef(Zrot, 0, 0, 1); DrawTunnel(); glPopMatrix(); glColor3f(1, 1, 1); glWindowPos2i(10, 10); if (HaveAniso) sprintf(str, "LOD bias (b/B): %.3f MaxAnisotropy: %.3f", LodBias, AnisoMax); else sprintf(str, "LOD bias (b/B): %.3f", LodBias); PrintString(str); glutSwapBuffers(); }
/* draw the screensaver once */ ENTRYPOINT void draw_atunnel(ModeInfo * mi) { atunnelstruct *sa = &Atunnel[MI_SCREEN(mi)]; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if (!sa->glx_context) return; glXMakeCurrent(display, window, *(sa->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); DrawTunnel(sa->ts, do_texture, do_light, sa->texture); SplashScreen(sa->ts, do_wire, do_texture, do_light); glFlush(); /* manage framerate display */ if (MI_IS_FPS(mi)) do_fps (mi); glXSwapBuffers(display, window); }
int main() { int t; effect_tunnel_state ets; u_int16_t *framebuffer1 = (u_int16_t *)0x4c000000; #ifdef TUNNEL_DBL_BUFFER u_int16_t *framebuffer2 = (u_int16_t *)0x4c400000; #endif /* TUNNEL_DBL_BUFFER */ task_register_cons *trc; const char *task_name; portTickType last_wake; const portTickType delay = 1000 * portTICK_RATE_MS / 25; trc = task_get_current_trc(); if (trc == NULL) { printf("tunnel effect: could not find trc.\n"); goto error; } task_name = trc->name; printf("%s: Initializing tunnel effect...\n", task_name); InitializeScreen640x480(RGB16BitMode,framebuffer1); if (init_width == 0xffff || init_height == 0xffff || init_w_offset == 0xffff || init_h_offset == 0xffff) { printf("%s: Config parameters not setup.\n", task_name); goto error; } if (!InitializeTunnel(&ets, init_width, init_height, 640, 480, init_w_offset, init_h_offset)) { printf("%s: Could not initiate tunnel effect.\n", task_name); goto error; } int lasttime=0; printf("%s: Starting rendering tunnel effect...\n", task_name); last_wake = xTaskGetTickCount(); #ifdef TUNNEL_DBL_BUFFER for(t=0;;t+=2) { #else /* TUNNEL_DBL_BUFFER */ for(t=0;;t++) { #endif /* TUNNEL_DBL_BUFFER */ if (tm_requested) { TASK_IN_SAFE_STATE(); last_wake = xTaskGetTickCount(); tm_requested = 0; } if((t % 32)==0) { int time=xTaskGetTickCount(); int fps=10*32*1000/(time-lasttime); printf("%s: %d.%01d FPS\n",task_name,fps/10,fps%10); lasttime=time; } #ifdef TUNNEL_DBL_BUFFER taskYIELD(); SetScreenFrameBuffer(framebuffer1); DrawTunnel(&ets, framebuffer2); vTaskDelayUntil(&last_wake, delay); SetScreenFrameBuffer(framebuffer2); DrawTunnel(&ets, framebuffer1); #else /* TUNNEL_DBL_BUFFER */ DrawTunnel(&ets, framebuffer1); #endif /* TUNNEL_DBL_BUFFER */ if (last_wake + delay < xTaskGetTickCount()) { last_wake += delay / 2; } vTaskDelayUntil(&last_wake, delay); } error: while (1) { printf("Tunnel effect in error state.\n"); vTaskSuspend(NULL); } }