void render_col(t_event *e, t_raycast *rc, int x, float wall_dist) { int line_height; int draw[2]; float y; line_height = abs((int)(e->height / wall_dist)); draw[0] = -line_height / 2 + e->height / 2; if (draw[0] < 0) draw[0] = 0; draw[1] = line_height / 2 + e->height / 2; if (draw[1] >= e->height) draw[1] = e->height; calc_wall(e, rc); y = draw[0] - 1; while (++y <= draw[1]) { draw_wall(e, rc, get_vec2(x, y), line_height); } calc_ground(rc); y = draw[1] - 1; while (++y < e->height) { rc->cdist = e->height / (2.0 * y - e->height); rc->coef = rc->cdist / wall_dist; draw_ground(e, rc, x, y); } }
void draw() { // clear buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // render the HUD hud(); // draw the camera long cur_time = glutGet(GLUT_ELAPSED_TIME); camera_draw(camera, cur_time - last_draw); last_draw = cur_time; // set light position shit GLfloat lpos[] = { 56.0f, 30.0f, 56.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_POSITION, lpos); // draw the ground for (int x = 0; x < 56; x++) for (int z = 0; z < 0x39; z++) draw_ground(x, z, t2ground[x].column[z]); // swap buffers glutSwapBuffers(); }
//-------------------------------------------------------------- void testApp::draw(){ ofSetRectMode(OF_RECTMODE_CORNER); ofRect(boxArray[1].min.x,boxArray[1].min.y,400,400); ofSetColor(0,0,0); char infoString[255]; sprintf(infoString,"w: %i h: %i fps: %f", ofGetWidth(),ofGetHeight(), ofGetFrameRate()); arial.drawString(infoString, 20, 20); draw_objects(); draw_ground(); }
void scene_redraw(void) { really_look_at_it(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); /* Draw cube 1 */ glScalef(1.0, 1.0, 1.0); glTranslatef(-5.0, 0.0, -10.0); glRotatef(spin, 0.0, -1.0, 0.0); cube_material(); objSolidCube(); /* Draw cube 2 */ glLoadIdentity(); glScalef(0.2, 0.2, 0.2); glTranslatef(-5.0, 0.5, -10.0); glRotatef(spin, -0.5, 1.0, 0.0); teapot_material(); objSolidCube(); /* Draw ground */ glLoadIdentity(); glScalef(200.0/(GLfloat)GW, 4.0, 200.0/(GLfloat)GH); /* 2000.0 yeilds a semi-infinite ground */ glRotatef(90.0, 1.0, 0.0, 0.0); glTranslatef((GLfloat)-GW/2.0, (GLfloat)-GH/2.0, 5.0); draw_ground(); /* Draw icosahedron */ glLoadIdentity(); glTranslatef(0.0, 0.0, -50.0); glRotatef(spin*3, 1.0, 1.0, 0.0); icosahedron_material(); objSolidIcosahedron(); /* Draw tardis */ glLoadIdentity(); glTranslatef(0.1, 0.0, -2.0); objTardis(); /* Draw Stars */ glLoadIdentity(); glDisable(GL_LIGHTING); glColor3f(1.0, 1.0, 1.0); objStars(); glEnable(GL_LIGHTING); glPopMatrix(); /* glFlush();*/ }
void draw::draw_scene(){ //const dReal *ball_location = dBodyGetPosition(body_bag->getBallBody()); //draw_sky(); glPushMatrix(); draw_ground(); glPopMatrix(); /*glPushMatrix(); glTranslatef(ball_location[0], ball_location[1], ball_location[2]); glutSolidSphere(5, 10, 10); glPopMatrix();*/ glPushMatrix(); draw_dog(); glPopMatrix(); }
void draw_map() { extern t_client t; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(t.x_cam, t.z_cam, t.y_cam, t.x_position, t.y_position, t.z_position, 0, 0, 1); glRotated(45, 0, 0, 1); draw_ground(); glTranslated(-t.x_map, -t.y_map, 0); for (t.i = 0;t.contenu_map[t.i];t.i++) parse_case(); glFlush(); SDL_GL_SwapBuffers(); }
ENTRYPOINT void init_camera (ModeInfo *mi) { camera_configuration *bp; int wire = MI_IS_WIREFRAME(mi); int i; MI_INIT (mi, bps, 0); bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); reshape_camera (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); if (!wire) { GLfloat pos[4] = {0.4, 0.2, 0.4, 0.0}; GLfloat amb[4] = {0.2, 0.2, 0.2, 1.0}; GLfloat dif[4] = {1.0, 1.0, 1.0, 1.0}; GLfloat spc[4] = {1.0, 1.0, 1.0, 1.0}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_AMBIENT, amb); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); glLightfv(GL_LIGHT0, GL_SPECULAR, spc); } bp->user_trackball = gltrackball_init (False); bp->dlists = (GLuint *) calloc (countof(all_objs)+1, sizeof(GLuint)); for (i = 0; i < countof(all_objs); i++) bp->dlists[i] = glGenLists (1); for (i = 0; i < countof(all_objs); i++) { const struct gllist *gll = *all_objs[i]; char *key = 0; GLfloat spec1[4] = {1.00, 1.00, 1.00, 1.0}; GLfloat spec2[4] = {0.40, 0.40, 0.70, 1.0}; GLfloat *spec = spec1; GLfloat shiny = 20; glNewList (bp->dlists[i], GL_COMPILE); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glMatrixMode(GL_TEXTURE); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glRotatef (-90, 1, 0, 0); glRotatef (180, 0, 0, 1); glScalef (6, 6, 6); glBindTexture (GL_TEXTURE_2D, 0); switch (i) { case CAMERA_BODY: key = "bodyColor"; break; case CAMERA_CAP: key = "capColor"; break; case CAMERA_HINGE: key = "hingeColor"; break; case CAMERA_MOUNT: key = "mountColor"; break; case CAMERA_LENS: key = "lensColor"; spec = spec2; break; case GROUND: key = "groundColor"; spec = spec2; shiny = 128; break; default: abort(); break; } parse_color (mi, key, bp->component_colors[i]); glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, spec); glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shiny); switch (i) { case GROUND: if (! ground) ground = (struct gllist *) calloc (1, sizeof(*ground)); ground->points = draw_ground (mi, bp->component_colors[i]); break; default: renderList (gll, wire); /* glColor3f (1, 1, 1); renderListNormals (gll, 100, True); */ /* glColor3f (1, 1, 0); renderListNormals (gll, 100, False); */ break; } glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEndList (); } bp->ncameras = MI_COUNT(mi); if (bp->ncameras <= 0) bp->ncameras = 1; bp->cameras = (camera *) calloc (bp->ncameras, sizeof (camera)); { GLfloat range = (MI_COUNT(mi) <= 2) ? 4 : 5.5; GLfloat extent; GLfloat spacing = range / bp->ncameras; if (spacing < 0.7) spacing = 0.7; extent = spacing * (bp->ncameras - 1); for (i = 0; i < bp->ncameras; i++) { camera *c = &bp->cameras[i]; c->state = IDLE; c->pos.x = i*spacing - extent/2; c->pos.z += 0.7; if (spacing < 1.6) c->pos.z = (i & 1 ? 1.1 : -0.3); c->focus.x = c->pos.x; c->focus.y = c->pos.y + 1; c->focus.z = c->pos.z + BEAM_ZOFF; c->pitch = -50; } } # ifdef DEBUG if (!debug_p) # endif /* Let's tilt the floor a little. */ gltrackball_reset (bp->user_trackball, -0.70 + frand(1.58), -0.30 + frand(0.40)); }
int main(void) { /* Related object data */ system_t* system; player_t* player1; player_t* player2; alt_timestamp_start(); int start_time = alt_timestamp(); int wind; int restart = 0; /* initialize all hardware dev */ system = system_init(VIDEO_PIXEL_BUFFER_DMA_NAME, "/dev/video_character_buffer_with_dma_0", ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME, PS2_0_NAME); if (!alt_up_sd_card_is_Present()) { printf("SD card not present\n"); return -2; } else { printf("SD card detected.\n"); } if (!alt_up_sd_card_is_FAT16()) { printf("SD card is not FAT16.\n"); return -3; } else { printf("SD card is FAT 16.\n"); } fireSound = initSoundbank("shotgun.wav"); explosionSound = initSoundbank("big_bomb.wav"); printf("Done Initializing\n"); int end_time = alt_timestamp(); srand(end_time - start_time); clearScreen(system); printf("Press enter to start game"); restartGame(system); while (restart == 1) { /* initialize required objects */ player1 = makePlayer(1, "Lomash"); player2 = makePlayer(2, "TJ"); /* * Draw the screen for the first time. */ store_background_data(); draw_background(system); drawPlayers(system); draw_ground(system); draw_windbox(system); draw_player1GUI(system); draw_player2GUI(system); update_wind(system, wind); draw_health(player1, system); draw_health(player2, system); update_power(player1, system); update_power(player2, system); usleep(2000000); // sleep to wait for video buffer to load while (TRUE) { printf( "\n\n\n\n===========================================================\n"); printf("Player 1 Health = %d \t\t Player 2 Health = %d\n", player1->health, player2->health); wind = rand() % 11 - 5; draw_windbox(system); update_wind(system, wind); // Player 1's turn player_1_jump(system); player_1_jump(system); printf("Getting Player 1 Power.\n"); getKeyboardInput(1, player1, system); // Power skipOneEnter(system); printf("Getting Player 1 Angle.\n"); getKeyboardInput(2, player1, system); // Angle // Player 1 Animation printf("Starting animation\n"); clear_angle_drawer(system); animate_cannon1(system); playSound(fireSound, system->audio); switch (animateShooting(system, player1, wind)) { // different value for result case 1: { update_health(player2, system, -DAMAGE); printf( "Player 1 hit player 2.\n Remaining Health for Player 2: %d\n", player2->health); break; } case 2: { update_health(player1, system, -DAMAGE); printf( "Player 1 hit player 1.\n Remaining Health for Player 1: %d\n", player1->health); break; } default: { break; } } printf("Ended animation\n"); // Post-animation Calculation if (player1->health <= 0 || player2->health <= 0) { break; } // Player 2's turn wind = rand() % 11 - 5; draw_windbox(system); update_wind(system, wind); player_2_jump(system); player_2_jump(system); printf("Getting Player 2 Velocity.\n"); getKeyboardInput(1, player2, system); // Player 2 Angle-Selection skipOneEnter(system); printf("Getting Player 2 Angle.\n"); getKeyboardInput(2, player2, system); // Player 2 Animation printf("Starting animation\n"); clear_angle_drawer(system); animate_cannon2(system); playSound(fireSound, system->audio); // Post-animation Calculation switch (animateShooting(system, player2, wind)) { // different value for result case 1: { update_health(player1, system, -DAMAGE); printf( "Player 2 hit player 1.\n Remaining Health for Player 1: %d\n", player1->health); break; } case 2: { update_health(player2, system, -DAMAGE); printf( "Player 2 hit player 2.\n Remaining Health for Player 2: %d\n", player2->health); break; } default: { break; } } if (player1->health <= 0 || player2->health <= 0) { break; } }; /* * Find out who won. */ if (player1->health <= 0) { printf("Player 2 Wins!!! \n"); draw_P2WIN(system); } else if (player2->health <= 0) { printf("Player 1 Wins!!!\n"); draw_P1WIN(system); } else { printf("we shouldn't be here.\n"); } restart = restartGame(system); } return 0; // FIN }
void draw_billboard(void) { draw_skybox(); draw_ground(); }