static mpdm_t kde4_drv_startup(mpdm_t a, mpdm_t ctxt) /* driver initialization */ { register_functions(); build_font(1); build_colors(); window = new MPWindow(); window->show(); return NULL; }
/** does dirty work drawing scene, moving pieces */ ENTRYPOINT void draw_chess(ModeInfo *mi) { Chesscreen *cs = &qs[MI_SCREEN(mi)]; Window w = MI_WINDOW(mi); Display *disp = MI_DISPLAY(mi); if(!cs->glx_context) return; glXMakeCurrent(disp, w, *(cs->glx_context)); /** code for moving a piece */ if(cs->moving && ++cs->steps == 100) { cs->moving = cs->count = cs->steps = cs->take = 0; cs->game.board[cs->game.moves[cs->mc][2]][cs->game.moves[cs->mc][3]] = cs->mpiece; ++cs->mc; if(cs->mc == cs->game.movecount) { cs->done = 1; cs->mc = 0; } } if(++cs->count == 100) { if(!cs->done) { cs->mpiece = cs->game.board[cs->game.moves[cs->mc][0]][cs->game.moves[cs->mc][1]]; cs->game.board[cs->game.moves[cs->mc][0]][cs->game.moves[cs->mc][1]] = NONE; if((cs->tpiece = cs->game.board[cs->game.moves[cs->mc][2]][cs->game.moves[cs->mc][3]])) { cs->game.board[cs->game.moves[cs->mc][2]][cs->game.moves[cs->mc][3]] = NONE; cs->take = 1; } cs->from[0] = cs->game.moves[cs->mc][0]; cs->from[1] = cs->game.moves[cs->mc][1]; cs->to[0] = cs->game.moves[cs->mc][2]; cs->to[1] = cs->game.moves[cs->mc][3]; cs->dz = (cs->to[0] - cs->from[0]) / 100; cs->dx = (cs->to[1] - cs->from[1]) / 100; cs->steps = 0; cs->moving = 1; } else if(cs->done == 1) { int newgame = cs->oldgame; while(newgame == cs->oldgame) newgame = random()%GAMES; /* mod the mod */ cs->mod = 0.6 + (random()%20)/10.0; /* same old game */ cs->oldgame = newgame; cs->game = games[cs->oldgame]; build_colors(cs); cs->done = 2; cs->count = 0; } else { cs->done = 0; cs->count = 0; } } /* set lighting */ if(cs->done) { glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, cs->done == 1 ? 1.0+0.1*cs->count : 100.0/cs->count); glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, cs->done == 1 ? 1.0+0.1*cs->count : 100.0/cs->count); glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.14); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.14); } display(mi, cs); if(mi->fps_p) do_fps(mi); glFinish(); glXSwapBuffers(disp, w); }