void GameTicTacToe_DrawGameField(BYTE G[2][9]) { int Pos; int x; int y; BYTE Color; BYTE Mode; Color = LCD_COLOR_B; Mode = DRAW_PUT; for(Pos=0; Pos<9; Pos++) { // x = Pos % 3; // y = Pos / 3; y = 0; x = Pos; while(x >= 3) { x -= 3; y++; } if(G[0][Pos]) { //Computer (O) draw_disc(16+14 + (x*33), 16+14 + (y*33), 11, Color, Mode); draw_disc(16+14 + (x*33), 16+14 + (y*33), 8, Color, DRAW_XOR); } else { if(G[1][Pos]) { //Player (X) draw_line(16+3 + (x*33), 16+3 + (y*33)+2, 16+3 + (x*33) + 23-2, 16+3 + (y*33) + 23, Color, Mode); draw_line(16+3 + (x*33), 16+3 + (y*33)+1, 16+3 + (x*33) + 23-1, 16+3 + (y*33) + 23, Color, Mode); draw_line(16+3 + (x*33), 16+3 + (y*33), 16+3 + (x*33) + 23, 16+3 + (y*33) + 23, Color, Mode); draw_line(16+3 + (x*33)+1, 16+3 + (y*33), 16+3 + (x*33) + 23, 16+3 + (y*33) + 23-1, Color, Mode); draw_line(16+3 + (x*33)+2, 16+3 + (y*33), 16+3 + (x*33) + 23, 16+3 + (y*33) + 23-2, Color, Mode); draw_line(16+3-1+(x*33)+2, 16+3+(y*33)+23+1, 16+3+(x*33)+23, 16+3 + (y*33)+2, Color, Mode); draw_line(16+3-1+(x*33)+1, 16+3+(y*33)+23+1, 16+3+(x*33)+23, 16+3 + (y*33)+1, Color, Mode); draw_line(16+3-1+(x*33), 16+3+(y*33)+23+1, 16+3+(x*33)+23, 16+3 + (y*33), Color, Mode); draw_line(16+3-1+(x*33), 16+3+(y*33)+23+1-1, 16+3+(x*33)+23-1, 16+3 + (y*33), Color, Mode); draw_line(16+3-1+(x*33), 16+3+(y*33)+23+1-2, 16+3+(x*33)+23-2, 16+3 + (y*33), Color, Mode); } } } }
static void draw_satellite(lemuria_engine_t * e, lemuria_object_t * obj) { int i; float theta_1; float theta_2; float z_n_1; float z_n_2; float r_n_1; float r_n_2; float z_1, r_1, z_2, r_2; float x_1, x_2, y, z; glLineWidth(2.0); glShadeModel(GL_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glEnable(GL_LINE_SMOOTH); // glEnable(GL_CULL_FACE); lemuria_set_material(&satellite_material, GL_FRONT_AND_BACK); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); // lemuria_set_light(&satellite_light, GL_LIGHT0); // lemuria_rotator_update(&obj->rotator); glRotatef(obj->data.satellite.rotation[0], 1.0, 0.0, 0.0); glRotatef(obj->data.satellite.rotation[1], 0.0, 1.0, 0.0); glRotatef(obj->data.satellite.rotation[2], 0.0, 0.0, 1.0); /* Draw main body */ draw_rotation_strip(SATELLITE_RADIUS, SATELLITE_RADIUS, -0.5 * SATELLITE_HEIGHT, 0.5 * SATELLITE_HEIGHT, 0.0, 0.0, 1.0, 1.0); draw_disc(SATELLITE_RADIUS, 0.5 * SATELLITE_HEIGHT, 1.0); draw_disc(SATELLITE_RADIUS, -0.5 * SATELLITE_HEIGHT, -1.0); /* Draw antenna */ theta_1 = 0.0; z_n_1 = 1.0; r_n_1 = 0.0; z_1 = 0.5 * SATELLITE_HEIGHT; r_1 = 0.0; lemuria_set_material(&satellite_antenna_material, GL_FRONT_AND_BACK); for(i = 0; i < SATELLITE_ANTENNA_THETA_STEPS; i++) { theta_2 = M_PI * SATELLITE_ANTENNA_ANGLE / 180.0 * (float)i / (float)(SATELLITE_ANTENNA_THETA_STEPS-1); z_n_2 = cos(theta_2); r_n_2 = -sin(theta_2); r_2 = sin(theta_2) * SATELLITE_ANTENNA_RADIUS; z_2 = 0.5 * SATELLITE_HEIGHT + SATELLITE_ANTENNA_RADIUS * (1.0 - cos(theta_2)); draw_rotation_strip(r_2, r_1, z_2, z_1, z_n_2, z_n_1, r_n_2, r_n_1); z_n_1 = z_n_2; r_n_1 = r_n_2; z_1 = z_2; r_1 = r_2; } /* Draw solar cells */ lemuria_set_material(&satellite_solar_material, GL_FRONT_AND_BACK); x_1 = SATELLITE_RADIUS + SATELLITE_SOLAR_OFFSET; x_2 = SATELLITE_RADIUS + SATELLITE_SOLAR_OFFSET + SATELLITE_SOLAR_LENGTH; y = SATELLITE_SOLAR_WIDTH * cos(SATELLITE_SOLAR_ANGLE * M_PI / 180.0); z = SATELLITE_SOLAR_WIDTH * sin(SATELLITE_SOLAR_ANGLE * M_PI / 180.0); glBegin(GL_QUADS); glVertex3f(x_1, -y, -z); glVertex3f(x_2, -y, -z); glVertex3f(x_2, y, z); glVertex3f(x_1, y, z); glVertex3f(-x_2, -y, -z); glVertex3f(-x_1, -y, -z); glVertex3f(-x_1, y, z); glVertex3f(-x_2, y, z); glEnd(); /* Draw the top of the antenna */ r_1 = SATELLITE_ANTENNA_TOP_RADIUS; r_2 = SATELLITE_ANTENNA_TOP_RADIUS; r_n_1 = 1.0; r_n_2 = 1.0; z_n_1 = 0.0; z_n_2 = 0.0; z_1 = 0.5 * SATELLITE_HEIGHT + SATELLITE_ANTENNA_RADIUS - 0.5 * SATELLITE_ANTENNA_TOP_HEIGHT; z_2 = 0.5 * SATELLITE_HEIGHT + SATELLITE_ANTENNA_RADIUS + 0.5 * SATELLITE_ANTENNA_TOP_HEIGHT; lemuria_set_material(&satellite_antenna_material, GL_FRONT); draw_rotation_strip(r_1, r_2, z_1, z_2, z_n_1, z_n_2, r_n_1, r_n_2); draw_disc(SATELLITE_ANTENNA_TOP_RADIUS, z_1, -1.0); draw_disc(SATELLITE_ANTENNA_TOP_RADIUS, z_2, 1.0); /* Draw line stuff */ glColor4f(0.7, 0.7, 0.7, 1.0); lemuria_set_material(&satellite_antenna_material, GL_FRONT_AND_BACK); glBegin(GL_LINES); r_1 = SATELLITE_ANTENNA_RADIUS * sin(M_PI * SATELLITE_ANTENNA_ANGLE / 180.0); z_1 = 0.5 * SATELLITE_HEIGHT + SATELLITE_ANTENNA_RADIUS * (1.0 - cos(M_PI * SATELLITE_ANTENNA_ANGLE / 180.0)); z_2 = 0.5 * SATELLITE_HEIGHT + SATELLITE_ANTENNA_RADIUS; glNormal3f(0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, 0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, r_1 / SATELLITE_ANTENNA_RADIUS); glVertex3f(0.707 * r_1, 0.707 * r_1, z_1); glVertex3f(0.0, 0.0, z_2); glNormal3f(-0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, 0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, r_1 / SATELLITE_ANTENNA_RADIUS); glVertex3f(-0.707 * r_1, 0.707 * r_1, z_1); glVertex3f(0.0, 0.0, z_2); glNormal3f(-0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, -0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, r_1 / SATELLITE_ANTENNA_RADIUS); glVertex3f(-0.707 * r_1, -0.707 * r_1, z_1); glVertex3f(0.0, 0.0, z_2); glNormal3f(0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, -0.707 * (z_2 - z_1)/SATELLITE_ANTENNA_RADIUS, r_1 / SATELLITE_ANTENNA_RADIUS); glVertex3f(0.707 * r_1, -0.707 * r_1, z_1); glVertex3f(0.0, 0.0, z_2); /* Draw supports for the solar cells */ glVertex3f(SATELLITE_RADIUS, 0.0, 0.0); glVertex3f(SATELLITE_RADIUS + SATELLITE_SOLAR_OFFSET, 0.0, 0.0); glVertex3f(-SATELLITE_RADIUS, 0.0, 0.0); glVertex3f(-SATELLITE_RADIUS - SATELLITE_SOLAR_OFFSET, 0.0, 0.0); glEnd(); glDisable(GL_POLYGON_SMOOTH); glDisable(GL_LINE_SMOOTH); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0); // glDisable(GL_CULL_FACE); }
int main(void) { tga_init(128,64); ucg_Init(&ucg, &ucg_dev_tga, ucg_ext_none, (ucg_com_fnptr)0); ucg_SetFontMode(&ucg, UCG_FONT_MODE_TRANSPARENT); ucg_SetColor(&ucg, 0, 0, 0, 0); ucg_DrawBox(&ucg, 0, 0, 128, 64); ucg_SetFont(&ucg, ucg_font_ncenB18_tf); ucg_SetColor(&ucg, 0, 0, 0, 255); ucg_DrawPixel(&ucg, 70,20); ucg_SetColor(&ucg, 0, 255, 0, 0); //ucg_SetFontPosBottom(&ucg); /* ucg_DrawGlyph(&ucg, 70, 20, 0, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 1, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 2, 'A'); ucg_DrawGlyph(&ucg, 70, 20, 3, 'A'); ucg_SetColor(&ucg, 0, 255, 255, 255); vrule(&ucg, 30, 0, 20, 1); vrule(&ucg, 30, 0, 20, 0); */ //pos(&ucg, 70, 20, 0); //hrule(&ucg, 0, 20, 70, 1); //hrule(&ucg, 0, 20, 70, 0); ucg_SetColor(&ucg, 0, 255, 0, 0); ucg_SetColor(&ucg, 1, 0, 255, 0); ucg_SetColor(&ucg, 2, 255, 0, 255); ucg_SetColor(&ucg, 3, 0, 255, 255); ucg_DrawGradientLine(&ucg, 10, 40, 100, 0); ucg_DrawGradientBox(&ucg, 10, 43, 100, 20); tga_save("test.tga"); draw_pixel(&ucg); draw_hline(&ucg); draw_vline(&ucg); set_clip_range(&ucg); draw_text_baseline(&ucg); draw_text_bottom(&ucg); draw_text_top(&ucg); draw_text_center(&ucg); draw_text_ascent_descent(&ucg); draw_text_dir1(&ucg); draw_box(&ucg); draw_frame(&ucg); draw_rbox(&ucg); draw_rframe(&ucg); draw_gradient_box(&ucg); draw_gradient_line(&ucg); draw_disc(&ucg); draw_circle(&ucg); draw_triangle(&ucg); set_scale2x2(&ucg); set_font_mode_1(&ucg); set_font_mode_2(&ucg); solid_font_variants(&ucg); string_overwrite(&ucg, 1); string_overwrite(&ucg, 5); string_overwrite(&ucg, 10); return 0; }
static void generate_bottle (ModeInfo *mi) { lavalite_configuration *bp = &bps[MI_SCREEN(mi)]; int wire = MI_IS_WIREFRAME(mi); int faces = resolution * 1.5; Bool smooth = do_smooth; Bool have_texture = False; const lamp_geometry *top_slice = bp->model; const char *current_texture = 0; lamp_part last_part = 0; if (faces < 3) faces = 3; else if (wire && faces > 20) faces = 20; else if (faces > 60) faces = 60; bp->bottle_poly_count = 0; glNewList (bp->bottle_list, GL_COMPILE); glPushMatrix(); glRotatef (90, 1, 0, 0); glTranslatef (0, -0.5, 0); /* All parts of the lamp use the same specularity and shininess. */ glMaterialfv (GL_FRONT, GL_SPECULAR, lava_spec); glMateriali (GL_FRONT, GL_SHININESS, lava_shininess); while (1) { const lamp_geometry *bot_slice = top_slice + 1; const char *texture = 0; GLfloat *color = 0; GLfloat t0, t1; glDisable (GL_LIGHT2); switch (top_slice->part) { case CAP: case BASE: texture = base_tex; color = base_color; break; case BOTTLE: texture = fluid_tex; color = fluid_color; if (!wire) glEnable (GL_LIGHT2); /* light2 affects only fluid */ break; default: abort(); break; } have_texture = False; if (!wire && texture && texture != current_texture) { current_texture = texture; have_texture = load_texture (mi, current_texture); } /* Color the discs darker than the tube walls. */ glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, foot_color); /* Do a top disc if this is the first slice of the CAP or BASE. */ if ((top_slice->part == CAP && last_part == 0) || (top_slice->part == BASE && last_part == BOTTLE)) bp->bottle_poly_count += draw_disc (top_slice->radius, top_slice->elevation, faces, True, wire); /* Do a bottom disc if this is the last slice of the CAP or BASE. */ if ((top_slice->part == CAP && bot_slice->part == BOTTLE) || (top_slice->part == BASE && bot_slice->part == 0)) { const lamp_geometry *sl = (bot_slice->part == 0 ? top_slice : bot_slice); bp->bottle_poly_count += draw_disc (sl->radius, sl->elevation, faces, False, wire); } if (bot_slice->part == 0) /* done! */ break; /* Do a tube or cone */ glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color); t0 = top_slice->texture_elevation; t1 = bot_slice->texture_elevation; /* Restart the texture coordinates for the glass. */ if (top_slice->part == BOTTLE) { Bool first_p = (top_slice[-1].part != BOTTLE); Bool last_p = (bot_slice->part != BOTTLE); if (first_p) t0 = 0; if (last_p) t1 = 1; } bp->bottle_poly_count += draw_tube (top_slice->radius, bot_slice->radius, top_slice->elevation, bot_slice->elevation, t0, t1, faces, (top_slice->part == BOTTLE), smooth, wire); last_part = top_slice->part; top_slice++; } if (bp->style == ROCKET) { int i; for (i = 0; i < 3; i++) { glPushMatrix(); glRotatef (120 * i, 0, 1, 0); glTranslatef (0.14, -0.05, 0); bp->bottle_poly_count += draw_wing (0.4, 0.95, 0.02, wire); glPopMatrix(); } glTranslatef (0, -0.1, 0); /* move floor down a little */ } have_texture = !wire && load_texture (mi, table_tex); glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, table_color); bp->bottle_poly_count += draw_table (top_slice->elevation, wire); glPopMatrix (); glDisable (GL_TEXTURE_2D); /* done with textured objects */ glEndList (); }
/* * redraw_screen * * This function is called once per time around the main loop. It redraws the * screen with all players in the correct positions. * * Parameters: screen - The screen object on which we are drawing. * match_state - The unique objects in a match. */ void redraw_screen(SCREEN *screen, MATCH_STATE *match_state, FONT *font) { /* * Local Variables. */ char score_string[10]; char game_time_string[10]; /* * Clear the screen before doing any drawing. */ glClear(GL_COLOR_BUFFER_BIT); draw_pitch_background(screen, match_state->pitch); /* * Draw the pitch outline. This is the lines and the 'permanent' markings. */ draw_pitch_lines(screen, match_state->pitch); /* * After drawing the screen iterate over the list of players in both teams * and if they have new positions then update them. */ draw_players(match_state->teams, match_state->players_per_team, match_state->animation_handler); /* * Draw the disc on top of the players. */ draw_disc(match_state->disc, 50.0f); /* * Put the score on the screen as text. We make this independent of scaling * and screen movement so that the text is on a fixed position on the screen * regardless of the orientation etc. */ glPushMatrix(); glLoadIdentity(); convert_score_to_text(match_state->match_stats->team_a_score, match_state->match_stats->team_b_score, score_string); draw_text(score_string, 250, 10, font); glPopMatrix(); /* * Put the current game time in the top left of the screen. This counts up. */ glPushMatrix(); glLoadIdentity(); convert_timer_to_text(match_state->match_stats->game_timer, game_time_string); draw_text(game_time_string, 10, 10, font); glPopMatrix(); /* * This performs the actual update of the screen so until this line nothing * we have done will be rendered each time around the render loop. */ SDL_GL_SwapBuffers(); }