Esempio n. 1
0
void
draw_princess_room_stars (ALLEGRO_BITMAP *bitmap, enum vm vm)
{
  int i, min_x = INT_MAX, min_y = INT_MAX,
    max_x = INT_MIN, max_y = INT_MIN;

  static struct star s[6] = {
    {20,97,0}, {16,104,1}, {23,110,0},
    {17,116,1}, {24,120,2}, {18,128,2}};

  static struct stars stars = {.b = NULL, .s = s, .count = 6};

  if (! stars.b) {
    for (i = 0; i < 6; i++) {
      min_x = min_int (min_x, stars.s[i].x);
      min_y = min_int (min_y, stars.s[i].y);
      max_x = max_int (max_x, stars.s[i].x);
      max_y = max_int (max_y, stars.s[i].y);
    }

    stars.b = create_bitmap (max_x - min_x + 1, max_y - min_y + 1);
    clear_bitmap (stars.b, TRANSPARENT_COLOR);
    stars.c.x = min_x;
    stars.c.y = min_y;

    redraw_stars_bitmap (&stars, vm);
  }

  if (vm != mr.last.vm) redraw_stars_bitmap (&stars, vm);

  draw_stars (bitmap, &stars, vm);
}

void
draw_balcony_stars (ALLEGRO_BITMAP *bitmap, struct pos *p, enum vm vm)
{
  if (con (p)->bg != BALCONY) return;
  struct pos np; npos (p, &np);

  if (! np.room) return;

  struct stars *stars = &mr.cell[mr.dx][mr.dy].stars[np.floor][np.place];

  if (vm != mr.last.vm) redraw_stars_bitmap (stars, vm);

  draw_stars (bitmap, stars, vm);
}

static struct star *
star_coord (struct pos *p, int i, struct star *s)
{
  s->x = PLACE_WIDTH * p->place + 16 + prandom_pos_uniq (p, 2 * i, 1, 28);
  s->y = PLACE_HEIGHT * p->floor - 3 + prandom_pos_uniq (p, 2 * i + 1, 1, 21);
  return s;
}
Esempio n. 2
0
void
draw_princess_room_stars (ALLEGRO_BITMAP *bitmap, enum vm vm)
{
  int i, min_x = INT_MAX, min_y = INT_MAX,
    max_x = INT_MIN, max_y = INT_MIN;

  static struct star s[6] = {
    {20,97,0}, {16,104,1}, {23,110,0},
    {17,116,1}, {24,120,2}, {18,128,2}};

  static struct stars_bitmap sb = {.b = NULL};

  if (! sb.b) {
    for (i = 0; i < 6; i++) {
      min_x = min_int (min_x, s[i].x);
      min_y = min_int (min_y, s[i].y);
      max_x = max_int (max_x, s[i].x);
      max_y = max_int (max_y, s[i].y);
    }

    sb.b = create_bitmap (max_x - min_x + 1, max_y - min_y + 1);
    clear_bitmap (sb.b, TRANSPARENT_COLOR);
    sb.c.x = min_x;
    sb.c.y = min_y;

    redraw_stars_bitmap (&s[0], &sb, 6, vm);
  }

  if (vm != last_vm) {
    redraw_stars_bitmap (&s[0], &sb, 6, vm);
    last_vm = vm;
  }

  draw_stars (bitmap, s, &sb, 6, vm);
}
Esempio n. 3
0
render_external_scene(fix eye_offset)
{

	Viewer_eye = Viewer->pos;

	if (eye_offset)
		vm_vec_scale_add2(&Viewer_eye,&Viewer->orient.rvec,eye_offset);

	g3_set_view_matrix(&Viewer->pos,&Viewer->orient,Render_zoom);

	//g3_draw_horizon(BM_XRGB(0,0,0),BM_XRGB(16,16,16));		//,-1);
	gr_clear_canvas(BM_XRGB(0,0,0));

	g3_start_instance_matrix(&vmd_zero_vector,&surface_orient);
	draw_stars();
	g3_done_instance();

	{	//draw satellite

		vms_vector delta;
		g3s_point p,top_pnt;

		g3_rotate_point(&p,&satellite_pos);
		g3_rotate_delta_vec(&delta,&satellite_upvec);

		g3_add_delta_vec(&top_pnt,&p,&delta);

		if (! (p.p3_codes & CC_BEHIND)) {
			int save_im = Interpolation_method;
			//p.p3_flags &= ~PF_PROJECTED;
			//g3_project_point(&p);
			if (! (p.p3_flags & PF_OVERFLOW)) {
				Interpolation_method = 0;
				//gr_bitmapm(f2i(p.p3_sx)-32,f2i(p.p3_sy)-32,satellite_bitmap);
				g3_draw_rod_tmap(satellite_bitmap,&p,SATELLITE_WIDTH,&top_pnt,SATELLITE_WIDTH,f1_0);
				Interpolation_method = save_im;
			}
		}
	}

	#ifdef STATION_ENABLED
	draw_polygon_model(&station_pos,&vmd_identity_matrix,NULL,station_modelnum,0,f1_0,NULL,NULL);
	#endif

	render_terrain(&mine_ground_exit_point,exit_point_bmx,exit_point_bmy);

	draw_exit_model();
	if (ext_expl_playing)
		draw_fireball(&external_explosion);

	Lighting_on=0;
	render_object(ConsoleObject);
	Lighting_on=1;
}
int main(void){
  init_allegro();
  bool redraw = true;
  bool done = false;

  al_clear_to_color(al_map_rgb(0,0,0));
  al_flip_display();
  al_start_timer(timer);

  init_stars();

  while(!done){
    ALLEGRO_EVENT event;
    al_wait_for_event(event_queue, &event);

    switch (event.type) {
      case ALLEGRO_EVENT_TIMER:
        redraw = true;
        break;

      case ALLEGRO_EVENT_DISPLAY_CLOSE:
        done = true;
        break;

      case ALLEGRO_EVENT_KEY_UP:
        switch(event.keyboard.keycode){
          case ALLEGRO_KEY_MINUS:
            // decrease velocity of each plane
            velocity_1-=1;
            velocity_2-=2;
            velocity_3-=3;
            break;

          case ALLEGRO_KEY_EQUALS:
            // decrease velocity of each plane
            velocity_1+=1;
            velocity_2+=2;
            velocity_3+=3;
            break;

          case ALLEGRO_KEY_Q:
            done = true;
            break;
        }
    }

    if(redraw && al_is_event_queue_empty(event_queue)) {
      redraw = false;
      draw_stars();
    }
  }

  return 0;
}
Esempio n. 5
0
// Draw background image with parallax effect
void draw_backdrop(void) {
	SDL_Rect position;
	if (g_backdropy < 0) {
		g_backdropy += BACKDROP_SPEED;
	}
	position.x = g_backdropx;
	position.y = g_backdropy;
	SDL_BlitSurface(g_backdrop_img, NULL, screen, &position);

	draw_stars();
}
Esempio n. 6
0
File: level.c Progetto: callaa/luola
/* Draw the level for all players */
static inline void draw_level (void)
{
    int p;
    for (p = 0; p < 4; p++) {
        if (players[p].state==ALIVE || players[p].state==DEAD) {
            SDL_BlitSurface (lev_level.terrain, &cam_rects[p], screen,
                             &viewport_rects[p]);
            if(level_settings.stars)
                draw_stars (&cam_rects[p], &viewport_rects[p]);
        }
    }
}
Esempio n. 7
0
void
draw_balcony_stars (ALLEGRO_BITMAP *bitmap, struct pos *p,
                    enum vm vm)
{
  if (con (p)->bg != BALCONY) return;

  if (vm != last_vm) {
    redraw_stars_bitmap (star[p->floor + 1][p->place + 1],
                         &stars_bitmap [p->floor + 1][p->place + 1], STARS, vm);
    last_vm = vm;
  }

  draw_stars (bitmap, star[p->floor + 1][p->place + 1],
              &stars_bitmap [p->floor + 1][p->place + 1], STARS, vm);
}
Esempio n. 8
0
static void draw_scene()
{
    // stars: to simulate infinite distance,
    //        translate the sphere of stars to the eye
    //        and perform the arcball rotation around the eye
    //        (also disable depth test so they become the background)
    glPushMatrix();
    glDisable( GL_DEPTH_TEST );
    glTranslatef( eye.x, eye.y, eye.z );
    arcball_rotate();
    draw_stars();
    glEnable( GL_DEPTH_TEST );
    glPopMatrix();

    // now render the regular scene under the arcball rotation about 0,0,0
    // (generally you would want to render everything here)
    arcball_rotate();
    draw_sphere();
}
Esempio n. 9
0
ENTRYPOINT void
draw_planet (ModeInfo * mi)
{
  planetstruct *gp = &planets[MI_SCREEN(mi)];
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);
  double x, y, z;

  if (!gp->glx_context)
	return;

  glDrawBuffer(GL_BACK);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glXMakeCurrent (display, window, *(gp->glx_context));

  mi->polygon_count = 0;

  if (do_stars)
    {
      draw_stars (mi);
      mi->polygon_count += NUM_STARS;
    }

  if (do_light)   glEnable(GL_LIGHTING);
  if (do_texture) glEnable(GL_TEXTURE_2D);

  glEnable (GL_LINE_SMOOTH);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);
  glCullFace(GL_BACK); 

  glPushMatrix();

  get_position (gp->rot, &x, &y, &z, !gp->button_down_p);
  glTranslatef((x - 0.5) * 15,
               (y - 0.5) * 15,
               (z - 0.5) * 8);

  /* Do it twice because we don't track the device's orientation. */
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (gp->trackball);
  glRotatef(-current_device_rotation(), 0, 0, 1);

  glRotatef (90,1,0,0);

  if (do_roll)
    {
      get_rotation (gp->rot, &x, &y, 0, !gp->button_down_p);
      glRotatef (x * 360, 1.0, 0.0, 0.0);
      glRotatef (y * 360, 0.0, 1.0, 0.0);
    }

  glLightfv (GL_LIGHT0, GL_POSITION, gp->sunpos);

  glRotatef (gp->z * 360, 0.0, 0.0, 1.0);
  if (do_rotate && !gp->button_down_p)
    {
      gp->z -= 0.005;     /* the sun sets in the west */
      if (gp->z < 0) gp->z += 1;
    }

  glCallList (gp->platelist);
  mi->polygon_count += resolution*resolution;

  if (gp->button_down_p)
    {
      glCallList (gp->latlonglist);
      mi->polygon_count += 24*24;
    }
  glPopMatrix();

  if (mi->fps_p) do_fps (mi);
  glFinish();
  glXSwapBuffers(display, window);

  gp->star_theta += star_spin;
}
Esempio n. 10
0
ENTRYPOINT void
draw_sws (ModeInfo *mi)
{
  sws_configuration *sc = &scs[MI_SCREEN(mi)];
/*  XtAppContext app = XtDisplayToApplicationContext (sc->dpy);*/
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);
  int i;

  if (!sc->glx_context)
    return;

  glDrawBuffer (GL_BACK);
  glXMakeCurrent (dpy, window, *(sc->glx_context));

  glClear (GL_COLOR_BUFFER_BIT);

  draw_stars (mi);

  glMatrixMode (GL_MODELVIEW);
  glPushMatrix ();

# ifdef USE_IPHONE
  /* Need to do this every time to get device rotation right */
  reshape_sws (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
# endif

  if (debug_p)
    {
      int i;
      glPushMatrix ();
      if (textures_p) glDisable (GL_TEXTURE_2D);
      glLineWidth (1);
      glTranslatef (0,-1, 0);

      glColor3f(1, 0, 0);	/* Red line is where text appears */
      glPushMatrix();
      glTranslatef(0, -0.028, 0);
      glLineWidth (4);
      glBegin(GL_LINES);
      glVertex3f(-0.5,  1, 0);
      glVertex3f( 0.5,  1, 0);
      glVertex3f(-0.5, -1, 0);
      glVertex3f( 0.5, -1, 0);
      glEnd();
      glLineWidth (1);
      glPopMatrix();

      glColor3f (0.4, 0.4, 0.4);
      for (i = 0; i < 16; i++)
        {
          box (1, 1, 1);
          grid (1, 1, sc->char_width * sc->font_scale, sc->line_height, 0);
          glTranslatef(0, 1, 0);
        }
      if (textures_p) glEnable (GL_TEXTURE_2D);
      glPopMatrix ();
    }

  /* Scroll to current position */
  glTranslatef (0.0, sc->intra_line_scroll, 0.0);

  glColor3f (1.0, 1.0, 0.4);
  glCallList (sc->text_list);
  mi->polygon_count = sc->polygon_count;

  sc->intra_line_scroll += sc->line_height / scroll_steps;

  if (sc->intra_line_scroll >= sc->line_height)
    {
      sc->intra_line_scroll = 0;

      /* Drop the oldest line off the end. */
      if (sc->lines[0])
        free (sc->lines[0]);

      /* Scroll the contents of the lines array toward 0. */
      if (sc->total_lines > 0)
        {
          for (i = 1; i < sc->total_lines; i++)
            sc->lines[i-1] = sc->lines[i];
          sc->lines[--sc->total_lines] = 0;
        }

      /* Bring in new lines at the end. */
      get_more_lines (sc);

      if (sc->total_lines < max_lines)
        /* Oops, we ran out of text... well, insert some blank lines
           here so that new text still pulls in from the bottom of
           the screen, isntead of just appearing. */
        sc->total_lines = max_lines;

      glDeleteLists (sc->text_list, 1);
      sc->text_list = glGenLists (1);
      glNewList (sc->text_list, GL_COMPILE);
      sc->polygon_count = 0;
      glPushMatrix ();
      glScalef (sc->font_scale, sc->font_scale, sc->font_scale);
      for (i = 0; i < sc->total_lines; i++)
        {
          double fade = (fade_p ? 1.0 * i / sc->total_lines : 1.0);
          int offscreen_lines = 2;

          double x = -0.5;
          double y =  ((sc->total_lines - (i + offscreen_lines) - 1)
                       * sc->line_height);
          double xoff = 0;
          char *line = sc->lines[i];

          if (debug_p)
            {
              double xx = x * 1.4;  /* a little more to the left */
              char n[20];
              sprintf(n, "%d:", i);
              draw_string (sc, xx / sc->font_scale, y / sc->font_scale, n);
            }

          if (!line || !*line)
            continue;

          if (sc->line_thickness != 1 && !textures_p)
            {
              int max_thick_lines = MAX_THICK_LINES;
              GLfloat thinnest_line = 1.0;
              GLfloat thickest_line = sc->line_thickness;
              GLfloat range = thickest_line - thinnest_line;
              GLfloat thickness;

              int j = sc->total_lines - i - 1;

              if (j > max_thick_lines)
                thickness = thinnest_line;
              else
                thickness = (thinnest_line +
                             (range * ((max_thick_lines - j) /
                                       (GLfloat) max_thick_lines)));

              glLineWidth (thickness);
            }

          if (alignment >= 0)
            {
              int n = string_width (sc, line);
              xoff = 1.0 - (n * sc->font_scale);
            }

          if (alignment == 0)
            xoff /= 2;

          glColor3f (fade, fade, 0.5 * fade);
          draw_string (sc, (x + xoff) / sc->font_scale, y / sc->font_scale,
                       line);
          if (textures_p)
            sc->polygon_count += strlen (line);
        }
      glPopMatrix ();
      glEndList ();
    }

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();
  glXSwapBuffers(dpy, window);

  sc->star_theta += star_spin;
}
Esempio n. 11
0
int main (int argc, char* args[]) {
	
	//SDL Window setup
	if (init(SCREEN_WIDTH, SCREEN_HEIGHT) == 1) {
		
		return 0;
	}
	
	init_stars(snow, SCREEN_WIDTH, SCREEN_HEIGHT);

	//create circle image in pixel buffer and copy to a texture 
	draw_circle(&vb, vb.width / 2, vb.height / 2, 8, 0xffffffff);
	SDL_UpdateTexture(vector_ball, NULL, vb.pixels, vb.width * sizeof (uint32_t));

	int sleep = 0;
	int quit = 0;
	struct vector3d vel = {0, 0, -.005};		//snow movment vector
	Uint32 next_game_tick = SDL_GetTicks();
	Uint32 current_tick = next_game_tick;

	//render loop
	while(quit == 0) {
	
		//check for new events every frame
		SDL_PumpEvents();

		const Uint8 *state = SDL_GetKeyboardState(NULL);
		
		if (state[SDL_SCANCODE_ESCAPE]) {
		
			quit = 1;
		}

		clear_pixels(&pb, 0x00000000);
		SDL_UpdateTexture(screen, NULL, pb.pixels, pb.width * sizeof (uint32_t));

		//draw to the screen
		SDL_RenderClear(renderer);
		SDL_RenderCopy(renderer, screen, NULL, NULL);	//draw screen pixel_buffer

		draw_stars(renderer, vector_ball, snow);	//draw all snow flakes with vector ball texture
		SDL_RenderPresent(renderer);			//show fintal frame on the screen

		update_stars(snow, SCREEN_WIDTH, SCREEN_HEIGHT, &vel);
		
		//time it takes to render 1 frame in milliseconds
		next_game_tick += 1000 / 60;
		current_tick = SDL_GetTicks();
		sleep = next_game_tick - current_tick;
		
		if( sleep >= 0 ) {
            				
			SDL_Delay(sleep);
		}
	}

	//free the screen buffer
	free(pb.pixels);
	
	//free the vector_ball buffer
	free(vb.pixels);
	
	//free the source image
	SDL_FreeSurface(source);
	
	//Destroy window 
	SDL_DestroyWindow(window);

	//Quit SDL subsystems 
	SDL_Quit(); 
	 
	return 0;
}
Esempio n. 12
0
File: game.c Progetto: noox/Raketka
//funkce pro kresleni 
void draw_game() {
	float t;
	
	draw_stars();
	draw_enemies();
	draw_bullets();
	draw_particles();
	draw_bonuses();
	
	//mod pro koncovy screen hry
	if (playerdead) { 
		//smesovani barev
		glEnable(GL_BLEND);
		
		//vyber blendovaci funkce
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
		
		//zesednuti pozadi
		glColor4f(0, 0, 0, 0.6);
		glBegin(GL_QUADS);
		glVertex2f(-250, -350);
		glVertex2f(250, -350);
		glVertex2f(250, 350);
		glVertex2f(-250, 350);
		glEnd();
		
		glDisable(GL_BLEND);
		
		//kresleni statistik hry na konci hry
		glPushMatrix();
		glTranslatef(-240, 0, 0);
		glScalef(18, 18, 0);
		glColor3f(0, 1, 0);
		glPushMatrix();
			glTranslatef(2, 5, 0);
			glScalef(4, 4, 0);
			draw_string("GAME OVER");
			glColor3f(1, 1, 1);
			glTranslatef(0.03, 0.03, 0);
			draw_string("GAME OVER");
		glPopMatrix();
		draw_string("LEVEL");
		glTranslatef(3.5, 0, 0);
		draw_int(level);
		glTranslatef(-3.5, -1, 0);
		draw_string("SCORE");
		glTranslatef(3.5, 0, 0);
		draw_int(score);
		glTranslatef(-3.5, -5, 0);
		glPushMatrix();
			glTranslatef(0.3, -4, 0);
			glScalef(2, 2, 0);
			glColor3f(0, 1, 0);
			draw_string("PRESS FIRE TO RESTART");
		glPopMatrix();
		glPopMatrix();
	}
	else {
		//statistika hry v levem spodnim rohu
		glPushMatrix(); 
		glTranslatef(-240, -305, 0);
		glScalef(18, 18, 1);
		glColor3f(0, 1, 0);
		draw_string("POWER");
		glTranslatef(3.5, 0, 0);
		draw_int(plevel);
		glTranslatef(-3.5, -1, 0);
		draw_string("LEVEL");
		glTranslatef(3.5, 0, 0);
		draw_int(level);
		glTranslatef(-3.5, -1, 0);
		draw_string("SCORE");
		glTranslatef(3.5, 0, 0);
		draw_int(score);
		glPopMatrix();

		glTranslatef(posx, posy, 0);
		
		//raketka
		glBegin(GL_TRIANGLES); 
		glColor3f(0, 0, 1);
		glVertex2f(-20, -10);
		glColor3f(0.5, 0.5, 1);
		glVertex2f(0, 0);
		glVertex2f(0, 50);

		glVertex2f(0, 50);
		glVertex2f(0, 0);
		glColor3f(0, 0, 1);
		glVertex2f(20, -10);

		glColor3f(1, 0, 0);
		glVertex2f(0, 0);
		glColor3f(1, 1, 0);
		glVertex2f(-2.5, -6);
		glVertex2f(2.5, -6);
		glEnd();
		
		//pokud hrac sebere stitovy bonus
		if (shieldtimer>0) {
			//poslednich 5 vterin stit blika
			if (shieldtimer<5) 
				t=sinf(shieldtimer*20); 
			else t=1;
			
			glColor3f(0.3*t*t, 0.3*t*t, 0.6*t*t);
			
			//nakresleni trojuhelnikoveho stitu
			glBegin(GL_LINE_LOOP);
			glVertex2f(0, 55);
			glVertex2f(-25, -15);
			glVertex2f(25, -15);
			glEnd();
		}
	}
}
Esempio n. 13
0
int main(int argc, char *argv[])
{
	unsigned row, col, core;
	e_platform_t platform;
	e_epiphany_t dev;
  	int all_done, core_done;
	int i, x, y;
        int res;
        unsigned int *fp;


       fb = open(FB, O_RDWR);

       if (fb == -1) {
          perror("Unable to open fb " FB);
          return 1;
       }

       // rest here
       res = ioctl(fb, FBIOGET_FSCREENINFO, &fix);
       if (res != 0) {
          perror("getscreeninfo failed");
       	  close(fb);
          return 1;
       }

       //printf("framebuffer size %d @ %08x\n", fix.smem_len, fix.smem_start);

       res = ioctl(fb, FBIOGET_VSCREENINFO, &var);
       if (res != 0) {
          perror("getscreeninfo failed");
          close(fb);
          return 1;
       }

       //printf("size %dx%d @ %d bits per pixel\n", var.xres_virtual, var.yres_virtual, var.bits_per_pixel);

       fp = mmap(NULL, fix.smem_len, O_RDWR, MAP_SHARED, fb, 0);
       if (fp == (void *)-1) {
          perror("mmap failed");
          close(fb);
          return 1;
       }

       //printf("virtual @ %p\n", fp);

       int stride = var.xres_virtual;

	srand(time(NULL));
  	int nBodies = 30000;
	int startFlag = 0x00000001;
  	int iters = 5000;  // simulation iterations
  	const float dt = 0.05f; // time step
  	if (argc > 1) nBodies = atoi(argv[1]);
  	if (argc > 2) iters = atoi(argv[2]);


	Body *buf = (Body *) malloc(sizeof(Body) * nBodies);
	Body *bufOutput = (Body *) malloc(sizeof(Body) * nBodies);

  	randomizeBodies(buf, nBodies); // Init pos / vel data

	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);
	e_open(&dev, 0, 0, 4, 4);
	e_reset_group(&dev);
	e_load_group("e_rob_nbody.srec", &dev, 0, 0, 4, 4, E_FALSE);
    	for (row = 0; row < platform.rows; row++){
      		for (col = 0; col < platform.cols; col++){
			e_write(&dev, row, col, 0x00000004, &nBodies, sizeof(int));
      		}
    	}
	e_write(&dev, 0, 0, 0x1000, (Body *) buf, sizeof(Body) * nBodies);
	x = 0;
//	for(x = 0; x < iters; x++){
	while(1){
		//fprintf(stderr, "Iter %d\n", x);
    		for (row = 0; row < platform.rows; row++){
      			for (col = 0; col < platform.cols; col++){
				e_write(&dev, row, col, 0x00000008, &startFlag, sizeof(int));
      			}
    		}
		e_start_group(&dev);
  		//Check if all cores are done
  		while(1){
    			all_done = 0;
    			for (row = 0; row < platform.rows; row++){
      				for (col = 0; col < platform.cols; col++){
					e_read(&dev, row, col, 0x00000008, &core_done, sizeof(int));
					all_done += core_done;
      				}
    			}
    			if(all_done == 0){
      				break;
    			}
  		}
		e_read(&dev, 0, 0, 0x1000, (Body *) bufOutput, sizeof(Body) * nBodies);
		if(x != 0){
			draw_stars(buf, nBodies, fp, stride, 0x00000000);
		}
		else{
			x = 1;
		}
		draw_stars(bufOutput, nBodies, fp, stride, 0x00ffffff);
		memcpy(buf, bufOutput, sizeof(Body) * nBodies);
	}
	e_close(&dev);

	// Release the allocated buffer and finalize the
	// e-platform connection.
	e_finalize();

	return 0;
}
Esempio n. 14
0
void display(int d) {
	int i;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);

	glLoadIdentity();

	if(lock) {
		if(eye[0] < -23.0 - 28.0*tan(M_PI/6)) eye[0] = -23.0 - 28.0*tan(M_PI/6);
		if(eye[0] > 33.0) eye[0] = 33.0;
		if(eye[1] < -28.0 - 26.5*tan(M_PI/6)) eye[1] = -28.0 - 26.5*tan(M_PI/6);
		if(eye[1] > 25.0) eye[1] = 25.0;
		if(eye[2] < -25.0) eye[2] = -25.0;
		if(eye[2] > 51.0 + 65.0*tan(M_PI/6)) eye[2] = 51.0 + 65.0*tan(M_PI/6);
	}

        if(!helmet) {
		for(i=0; i < 3; i++)
			view[i] = (2 * negview * eye[i]);
		up[0] = 0;
		up[1] = negup * 1.0;
		up[2] = 0;
	} 

        if(d==D_LEFT) {
		glTranslatef(-2.5, 0.0, 0.0);
	} else if(d==D_RIGHT) {
		glTranslatef(2.5, 0.0, 0.0);
	}

	gluLookAt(eye[0], eye[1], eye[2], view[0], view[1], view[2],
		up[0], up[1], up[2]);
	glTranslatef(global_translate[0], global_translate[1],
			global_translate[2]);

	
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	glPushMatrix();

/*		glRotatef(theta, 0.0, 1.0, 0.0);
		glRotatef(phi, 1.0, 0.0, 0.0);*/

		glColor3f(1.0, 1.0, 1.0);

		if(wireframe) {
			glPolygonMode(GL_FRONT, GL_LINE);
			glDisable(GL_CULL_FACE);
		}
		else {
			glPolygonMode(GL_FRONT, GL_FILL);
			glEnable(GL_CULL_FACE);
		}

		/* Draw coordinate axes */
		glDisable(GL_LIGHTING);
		glDisable(GL_TEXTURE_2D);
		if(axes) {
                        glPushMatrix();
			glTranslatef(-global_translate[0], 
				-global_translate[1],
				-global_translate[2]);
			glBegin(GL_LINES);
				glVertex3f(-100.0, 0.0, 0.0);
				glVertex3f(100.0, 0.0, 0.0);
				glVertex3f(0.0, -100.0, 0.0);
				glVertex3f(0.0, 100.0, 0.0);
				glVertex3f(0.0, 0.0, -100.0);
				glVertex3f(0.0, 0.0, 100.0);
			glEnd();
                        glPopMatrix();
		}
		if(texture) glEnable(GL_TEXTURE_2D);
		if(lighting) glEnable(GL_LIGHTING);
                if(!smooth) {glDisable(GL_SMOOTH); glShadeModel(GL_FLAT); glEnable(GL_FLAT);}
                 else {glDisable(GL_FLAT); glShadeModel(GL_SMOOTH); glEnable(GL_SMOOTH);}
		if(filtering) {
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
			                GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
					GL_LINEAR);
		} else {
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
			                GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
					GL_NEAREST);
		}

		draw_scene();

		glDisable(GL_LIGHTING);
		glDisable(GL_TEXTURE_2D);
		if(terrain) draw_terrain();		/* Draw w/o lighting */
		if(stars) draw_stars();

	glPopMatrix();
	glPopAttrib();

	/* And swap buffers to display the image */
	glutSwapBuffers();

/*	if(helmet) child(1);*/
}