/* * draws a robot with a given size, using the various parameters *(orientation, * position, ..) from the robot struct */ void draw_robot(cairo_t* cr, struct robot* myRobot, double size) { double x1 = -70, y1 = -30, y2 = 10, x4 = 70, x5 = 0, y5 = -100; double px2 = -70, py2 = 100, px3 = 70, py3 = 100, px4 = 70, py4 = 10; cairo_save(cr); cairo_translate(cr, myRobot->x, myRobot->y); cairo_scale(cr, size, size); cairo_save(cr); cairo_rotate(cr, degtorad(90 + myRobot->degree)); cairo_set_source_rgba(cr, myRobot->color[0], myRobot->color[1], myRobot->color[2], 0.6); cairo_set_line_width(cr, 2); cairo_move_to(cr, x1, y1); cairo_line_to(cr, x1, y2); cairo_curve_to(cr, px2, py2, px3, py3, px4, py4); cairo_line_to(cr, x4, y1); cairo_line_to(cr, x5, y5); cairo_close_path(cr); cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD); cairo_move_to(cr, 30, 0); cairo_arc_negative(cr, 0, 0, 30, 0, -2 * M_PI); cairo_fill_preserve(cr); cairo_set_source_rgba(cr, 0.1, 0.7, 0.5, 0.5); cairo_stroke(cr); cairo_restore(cr); /* pop rotate */ draw_cannon(cr, degtorad(270 + myRobot->cannon_degree)); draw_radar(cr, degtorad(270 + myRobot->radar_degree)); cairo_restore(cr); /* pop translate/scale */ shot_animation(cr, size, degtorad(myRobot->cannon_degree), &myRobot->cannon[0]); shot_animation(cr, size, degtorad(myRobot->cannon_degree), &myRobot->cannon[1]); }
static void cloak_draw(void *data) { switch (opt.cloak_anim) { case 0: { blank_buf(); break; } case 1: { load_val = (opt.quality / 2); draw_flame(); break; } case 2: { draw_radar(); break; } case 3: { draw_aa_radar(); break; } case 4: { draw_aa_triangle(); break; } case 5: { draw_aa_star(); break; } case 6: { draw_starfield(); break; } case 7: { draw_aa_starfield(); break; } case 8: { draw_rotator(); break; } case 9: { draw_scanner(); break; } case 10: { draw_colorwarp(); break; } case 11: { draw_ball(); break; } case 12: { draw_atoms(); break; } case 13: { draw_text(); break; } case 14: { draw_sine(); break; } case 15: { draw_funky_rotator(); break; } default: { blank_buf(); break; } } Epplet_paste_buf(buf, win, 0, 0); Epplet_timer(cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER"); return; data = NULL; }
void NETHER::draw(int width,int height) { float lightpos2[4]={0,0,1000,0}; float tmpls[4]={1.0F,1.0F,1.0F,1.0}; float tmpld[4]={0.6F,0.6F,0.6F,1.0}; float tmpla[4]={0.2F,0.2F,0.2F,1.0}; float ratio; int split = int((width*25.0F)/32.0F); int splity = 0; if (show_radar) splity = int((height*2.0F)/15.0F)+1; else splity = 0; /* Enable Lights, etc.: */ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0,GL_AMBIENT,tmpla); glLightfv(GL_LIGHT0,GL_DIFFUSE,tmpld); glLightfv(GL_LIGHT0,GL_SPECULAR,tmpls); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glShadeModel( GL_SMOOTH ); glCullFace( GL_BACK ); glFrontFace( GL_CCW ); glEnable( GL_CULL_FACE ); glEnable( GL_SCISSOR_TEST ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glClearStencil(0); /* Draw the GAME screen: */ glLightfv(GL_LIGHT0,GL_POSITION,lightpos); glClearColor(0,0,0,0.0); glViewport(0,splity,split,height-splity); ratio=float(split)/float(height-splity); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); gluPerspective( 30.0, ratio, 1.0, 1024.0 ); glScissor(0,splity,split,height-splity); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); draw_game(false); if (shadows) { /* Set STENCIL Buffer: */ glStencilMask(1); glEnable(GL_STENCIL_TEST); glDepthMask(GL_FALSE); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glStencilFunc(GL_ALWAYS,1,1); glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); draw_game(true); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); /* Draw shadow poligon: */ glDepthFunc(GL_ALWAYS); glDisable(GL_CULL_FACE); glColor4f(0.0,0.0,0.0,0.4f); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glStencilFunc(GL_NOTEQUAL,0,1); glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glBegin(GL_TRIANGLE_STRIP); glVertex3f(-1.0, 1.0,0.0); glVertex3f(-1.0,-1.0,0.0); glVertex3f( 1.0, 1.0,0.0); glVertex3f( 1.0,-1.0,0.0); glEnd(); glPopMatrix(); glDisable(GL_BLEND); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glEnable(GL_CULL_FACE); glDisable(GL_STENCIL_TEST); } /* if */ if (game_started>0) { glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); gluPerspective( 30.0, ratio, 1.0, 1024.0 ); gluLookAt(0,0,30,0,0,0,0,1,0); glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if (game_started>40) glTranslatef(0,0,(game_started-40)*2); if (game_started<20) glTranslatef(0,0,(20-game_started)*2); message_tile[0]->draw(1.0,1.0,1.0); } /* if */ if (game_finished>100) { glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); gluPerspective( 30.0, ratio, 1.0, 1024.0 ); gluLookAt(0,0,30,0,0,0,0,1,0); glClear(GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if (game_finished<120) glTranslatef(0,0,(120-game_finished)*2); if (game_finished>240) glTranslatef(0,0,(game_finished-240)*2); if (statistics[0][0]==0) message_tile[2]->draw(1.0,1.0,1.0); else message_tile[1]->draw(1.0,1.0,1.0); } /* if */ /* Draw the RADAR screen: */ if (show_radar && redrawradar<=1) { glLightfv(GL_LIGHT0,GL_POSITION,lightpos2); glClearColor(0.0,0.0,0,0); glViewport(0,0,split,splity); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); glOrtho(0,float(split),0,float(splity),-100,100); glScissor(0,0,split,splity); glScalef(width/640.0,height/480.0,1); draw_radar(); } /* if */ redrawradar--; if (redrawradar<0) redrawradar=3; /* Draw the STATUS screen: */ if (redrawmenu!=0) { redrawmenu--; glLightfv(GL_LIGHT0,GL_POSITION,lightpos2); glClearColor(0,0,0.2,0); glViewport(split,0,width-split,height); glMatrixMode( GL_PROJECTION ); glLoadIdentity( ); glOrtho(0,float(width-split),0,height,-100,100); glScissor(split,0,width-split,height); glScalef(width/640.0,height/480.0,1); draw_status(); /* glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glTranslatef(70.0,10.0,0); glColor3f(1.0f,1.0f,1.0f); scaledglprintf(0.1f,0.1f,"FPS: %i",frames_per_sec); glPopMatrix(); */ } /* if */ } /* NETHER::draw */
void Renderer::draw_radar(const Vec2 &position, float size /* = 150.f */, float stroke_width /* = 1.f */, Color outline_color /* = 0UL */, Color rect_color /* = 0UL */) { return draw_radar(render_list, position, size, stroke_width, outline_color, rect_color); }