Ejemplo n.º 1
0
void run_game(){
/* THE GAME RUNS WITHIN THIS TRUE WHILE LOOP */
	while (!0)
    {
    while(speed_limit > 0)
    {
         speed_limit --;
    /*============================================*/
        draw_court();               // GAME STEP 1
        show_mouse(court);
        set_mouse_range(0,0,court->w,court->h);
       	check_keyboard_entry();     // GAME STEP 2
    	control_bats();             // GAME STEP 3
        check_collision();          // GAME STEP 4
        update_cock_position();     // GAME STEP 5
		
        draw_bats_and_cock();       // GAME STEP 6
        draw_speed_meter();         // GAME STEP 7
        display_game_status();      // GAME STEP 8
        draw_buffer();              // GAME STEP 9
    /*============================================*/
    }
    // Speed limiting loop ends
    }
    deinitialize_game();
}
Ejemplo n.º 2
0
void carray_paint(t_carray *x, t_object *view)
{
	t_rect rect;
	ebox_get_rect_for_view((t_ebox *)x, &rect);
    draw_background(x, view, &rect);
    draw_buffer(x, view, &rect);
}
Ejemplo n.º 3
0
void
redraw(channel *c)
{
	if (!draw) return;

	if (draw & D_RESIZE) resize();

	if (draw & D_BUFFER) draw_buffer(c);
	if (draw & D_CHANS)  draw_chans(c);
	if (draw & D_INPUT)  draw_input(c);
	if (draw & D_STATUS) draw_status(c);

	draw = 0;

	fflush(stdout);
}
Ejemplo n.º 4
0
void
redraw(channel *c)
{
	if (!draw) return;

	if (draw & D_RESIZE) resize();

	struct state const* st = get_state();

	//TODO: pass st to other draw functions
	if (draw & D_BUFFER) draw_buffer(c);
	if (draw & D_CHANS)  draw_nav(st);
	if (draw & D_INPUT)  draw_input(c);
	if (draw & D_STATUS) draw_status(c);

	draw = 0;

	fflush(stdout);
}
Ejemplo n.º 5
0
bool
ViewDrawingArea::on_configure_event (GdkEventConfigure *event)
{
#ifdef DEBUG
	std::cerr << "on_configure_event()" << std::endl << std::flush;
#endif
	if (_pixmap)
		_pixmap.clear();

	const Gtk::Allocation& all = get_allocation();
	_pixmap = Gdk::Pixmap::create (get_window(),
		all.get_width(),
		all.get_height());

	if (AppContext::get().get_feed() == NULL)
	{
		Cairo::RefPtr<Cairo::Context> cr = _pixmap->create_cairo_context();
		cr->set_source_rgb (1.0, 1.0, 1.0);
		cr->paint();
		cr->show_page();
	}
	else
	{
		const AppContext& ac = AppContext::get();
		if (ac.get_display_type() == FULL)
			ac.get_curr_item()->reset_display_unit();
		else
		{
			Feed *feed = ac.get_feed();
			const item_list_t items = feed->get_items();
			for_each (items.begin(), items.end(), 
				std::mem_fun (&Item::reset_display_unit));
		}
	}

	draw_buffer();

	return true;
}
Ejemplo n.º 6
0
///-----------------------------------------------------------------
/// Called when vertical view scrollbar changes value.
void
ViewDrawingArea::on_vvalue_changed()
{
	draw_buffer();
	queue_draw();
}
Ejemplo n.º 7
0
void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
                       const float min[3], const float max[3],
                        const float viewnormal[3])
{
	if (!sds->tex || !sds->tex_shadow) {
		fprintf(stderr, "Could not allocate 3D texture for volume rendering!\n");
		return;
	}

	const bool use_fire = (sds->active_fields & SM_ACTIVE_FIRE) && sds->tex_flame;

	GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_SMOKE);

	if (!shader) {
		fprintf(stderr, "Unable to create GLSL smoke shader.\n");
		return;
	}

	GPUShader *fire_shader = NULL;
	if (use_fire) {
		fire_shader = GPU_shader_get_builtin_shader(GPU_SHADER_SMOKE_FIRE);

		if (!fire_shader) {
			fprintf(stderr, "Unable to create GLSL fire shader.\n");
			return;
		}
	}

	const float ob_sizei[3] = {
	    1.0f / fabsf(ob->size[0]),
	    1.0f / fabsf(ob->size[1]),
	    1.0f / fabsf(ob->size[2])
	};

	const float size[3] = { max[0] - min[0], max[1] - min[1], max[2] - min[2] };
	const float invsize[3] = { 1.0f / size[0], 1.0f / size[1], 1.0f / size[2] };

#ifdef DEBUG_DRAW_TIME
	TIMEIT_START(draw);
#endif

	/* setup slicing information */

	const int max_slices = 256;
	const int max_points = max_slices * 12;

	VolumeSlicer slicer;
	copy_v3_v3(slicer.min, min);
	copy_v3_v3(slicer.max, max);
	copy_v3_v3(slicer.size, size);
	slicer.verts = MEM_mallocN(sizeof(float) * 3 * max_points, "smoke_slice_vertices");

	const int num_points = create_view_aligned_slices(&slicer, max_slices, viewnormal);

	/* setup buffer and draw */

	int gl_depth = 0, gl_blend = 0, gl_depth_write = 0;
	glGetBooleanv(GL_BLEND, (GLboolean *)&gl_blend);
	glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth);
	glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&gl_depth_write);

	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_FALSE);
	glEnable(GL_BLEND);

	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	draw_buffer(sds, shader, &slicer, ob_sizei, invsize, num_points, false);

	/* Draw fire separately (T47639). */
	if (use_fire) {
		glBlendFunc(GL_ONE, GL_ONE);
		draw_buffer(sds, fire_shader, &slicer, ob_sizei, invsize, num_points, true);
	}

#ifdef DEBUG_DRAW_TIME
	printf("Draw Time: %f\n", (float)TIMEIT_VALUE(draw));
	TIMEIT_END(draw);
#endif

	MEM_freeN(slicer.verts);

	glDepthMask(gl_depth_write);

	if (!gl_blend) {
		glDisable(GL_BLEND);
	}

	if (gl_depth) {
		glEnable(GL_DEPTH_TEST);
	}
}
Ejemplo n.º 8
0
void draw_shiny_buffer(shiny_buffer * buffer, shiny_loc loc, shiny_size size) {
//	resize_buffer(buffer->buffer, size.width, size.height);
	draw_buffer(buffer->buffer, loc);
}
Ejemplo n.º 9
0
struct pipe_context *
softpipe_create_context(struct pipe_screen *screen,
			void *priv, unsigned flags)
{
   struct softpipe_screen *sp_screen = softpipe_screen(screen);
   struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
   uint i, sh;

   util_init_math();

   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
      softpipe->tgsi.sampler[i] = sp_create_tgsi_sampler();
   }

   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
      softpipe->tgsi.image[i] = sp_create_tgsi_image();
   }

   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
      softpipe->tgsi.buffer[i] = sp_create_tgsi_buffer();
   }

   softpipe->dump_fs = debug_get_bool_option( "SOFTPIPE_DUMP_FS", FALSE );
   softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", FALSE );

   softpipe->pipe.screen = screen;
   softpipe->pipe.destroy = softpipe_destroy;
   softpipe->pipe.priv = priv;

   /* state setters */
   softpipe_init_blend_funcs(&softpipe->pipe);
   softpipe_init_clip_funcs(&softpipe->pipe);
   softpipe_init_query_funcs( softpipe );
   softpipe_init_rasterizer_funcs(&softpipe->pipe);
   softpipe_init_sampler_funcs(&softpipe->pipe);
   softpipe_init_shader_funcs(&softpipe->pipe);
   softpipe_init_streamout_funcs(&softpipe->pipe);
   softpipe_init_texture_funcs( &softpipe->pipe );
   softpipe_init_vertex_funcs(&softpipe->pipe);
   softpipe_init_image_funcs(&softpipe->pipe);

   softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;

   softpipe->pipe.draw_vbo = softpipe_draw_vbo;

   softpipe->pipe.clear = softpipe_clear;
   softpipe->pipe.flush = softpipe_flush_wrapped;
   softpipe->pipe.texture_barrier = softpipe_texture_barrier;
   softpipe->pipe.memory_barrier = softpipe_memory_barrier;
   softpipe->pipe.render_condition = softpipe_render_condition;
   
   /*
    * Alloc caches for accessing drawing surfaces and textures.
    * Must be before quad stage setup!
    */
   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
      softpipe->cbuf_cache[i] = sp_create_tile_cache( &softpipe->pipe );
   softpipe->zsbuf_cache = sp_create_tile_cache( &softpipe->pipe );

   /* Allocate texture caches */
   for (sh = 0; sh < Elements(softpipe->tex_cache); sh++) {
      for (i = 0; i < Elements(softpipe->tex_cache[0]); i++) {
         softpipe->tex_cache[sh][i] = sp_create_tex_tile_cache(&softpipe->pipe);
         if (!softpipe->tex_cache[sh][i])
            goto fail;
      }
   }

   softpipe->fs_machine = tgsi_exec_machine_create();

   /* setup quad rendering stages */
   softpipe->quad.shade = sp_quad_shade_stage(softpipe);
   softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
   softpipe->quad.blend = sp_quad_blend_stage(softpipe);
   softpipe->quad.pstipple = sp_quad_polygon_stipple_stage(softpipe);


   /*
    * Create drawing context and plug our rendering stage into it.
    */
   if (sp_screen->use_llvm)
      softpipe->draw = draw_create(&softpipe->pipe);
   else
      softpipe->draw = draw_create_no_llvm(&softpipe->pipe);
   if (!softpipe->draw) 
      goto fail;

   draw_texture_sampler(softpipe->draw,
                        PIPE_SHADER_VERTEX,
                        (struct tgsi_sampler *)
                           softpipe->tgsi.sampler[PIPE_SHADER_VERTEX]);

   draw_texture_sampler(softpipe->draw,
                        PIPE_SHADER_GEOMETRY,
                        (struct tgsi_sampler *)
                           softpipe->tgsi.sampler[PIPE_SHADER_GEOMETRY]);

   draw_image(softpipe->draw,
              PIPE_SHADER_VERTEX,
              (struct tgsi_image *)
              softpipe->tgsi.image[PIPE_SHADER_VERTEX]);

   draw_image(softpipe->draw,
              PIPE_SHADER_GEOMETRY,
              (struct tgsi_image *)
              softpipe->tgsi.image[PIPE_SHADER_GEOMETRY]);

   draw_buffer(softpipe->draw,
              PIPE_SHADER_VERTEX,
              (struct tgsi_buffer *)
              softpipe->tgsi.buffer[PIPE_SHADER_VERTEX]);

   draw_buffer(softpipe->draw,
              PIPE_SHADER_GEOMETRY,
              (struct tgsi_buffer *)
              softpipe->tgsi.buffer[PIPE_SHADER_GEOMETRY]);

   if (debug_get_bool_option( "SOFTPIPE_NO_RAST", FALSE ))
      softpipe->no_rast = TRUE;

   softpipe->vbuf_backend = sp_create_vbuf_backend(softpipe);
   if (!softpipe->vbuf_backend)
      goto fail;

   softpipe->vbuf = draw_vbuf_stage(softpipe->draw, softpipe->vbuf_backend);
   if (!softpipe->vbuf)
      goto fail;

   draw_set_rasterize_stage(softpipe->draw, softpipe->vbuf);
   draw_set_render(softpipe->draw, softpipe->vbuf_backend);

   softpipe->blitter = util_blitter_create(&softpipe->pipe);
   if (!softpipe->blitter) {
      goto fail;
   }

   /* must be done before installing Draw stages */
   util_blitter_cache_all_shaders(softpipe->blitter);

   /* plug in AA line/point stages */
   draw_install_aaline_stage(softpipe->draw, &softpipe->pipe);
   draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe);

   /* Do polygon stipple w/ texture map + frag prog? */
#if DO_PSTIPPLE_IN_DRAW_MODULE
   draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe);
#endif

   draw_wide_point_sprites(softpipe->draw, TRUE);

   sp_init_surface_functions(softpipe);

#if DO_PSTIPPLE_IN_HELPER_MODULE
   /* create the polgon stipple sampler */
   softpipe->pstipple.sampler = util_pstipple_create_sampler(&softpipe->pipe);
#endif

   return &softpipe->pipe;

 fail:
   softpipe_destroy(&softpipe->pipe);
   return NULL;
}