Exemplo n.º 1
0
void render()
{
    GameState* gamestate;
    
    if( !should_render() )
        return;
    
    // Get the gamestate
    gamestate = get_gamestate();
    
    // Set the default buffer colour to black
    glClearColor( SKY_R, SKY_G, SKY_B, 1.0f );
    
    // Clear the colour and depth buffers
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
    // Draw player 1's viewport
    render_viewport( player1_viewport, gamestate );
    // Draw player 2's viewport
    render_viewport( player2_viewport, gamestate );
    
    // Turn off depth buffering for the minimap and HUD
    glDisable(GL_DEPTH_TEST);
    render_viewport( minimap, gamestate );
    render_hud( hud, gamestate );
    glEnable(GL_DEPTH_TEST);
    
    // Swap the buffers
    glutSwapBuffers();

    // Calculate the framerate
    calc_fps();
}
Exemplo n.º 2
0
static void set_res(struct v4l2_subdev *sd)
{
	struct mt9v011 *core = to_mt9v011(sd);
	unsigned vstart, hstart;

	/*
	 * The mt9v011 doesn't have scaling. So, in order to select the desired
	 * resolution, we're cropping at the middle of the sensor.
	 * hblank and vblank should be adjusted, in order to warrant that
	 * we'll preserve the line timings for 30 fps, no matter what resolution
	 * is selected.
	 * NOTE: datasheet says that width (and height) should be filled with
	 * width-1. However, this doesn't work, since one pixel per line will
	 * be missing.
	 */

	hstart = 20 + (640 - core->width) / 2;
	mt9v011_write(sd, R02_MT9V011_COLSTART, hstart);
	mt9v011_write(sd, R04_MT9V011_WIDTH, core->width);
	mt9v011_write(sd, R05_MT9V011_HBLANK, 771 - core->width);

	vstart = 8 + (480 - core->height) / 2;
	mt9v011_write(sd, R01_MT9V011_ROWSTART, vstart);
	mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height);
	mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height);

	calc_fps(sd, NULL, NULL);
};
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
	// to prevent gcc from complaining about unused variables
	(void) argc; (void) argv;
	
	if (init() == -1)
		return 0;
	
	while (!config.quit)
	{
		get_input();
		
		// delta_time needs to be set right before calculating moves
		calc_fps();
		process();
		
		draw_all();
		
		//usleep(5 * 1000);
		SDL_Delay(5);
	}
	
	clean_up();
	
	return 0;
}
Exemplo n.º 4
0
static void
msg_loop()
{
    unsigned int previous_time;

    SDL_Event event;
    while( framework_running ) {
	SDL_PumpEvents();
	keyboard_update();
	mouse_update();
	while( SDL_PollEvent( &event ) ) {
	    switch( event.type ) {
		case SDL_MOUSEMOTION:
		    handle_mouse(&event.motion);
		    break;
		case SDL_VIDEORESIZE:
		    handle_resize(event.resize.w, event.resize.h);
		    break;
		default:
		    break;
	    }
	}
	previous_time = SDL_GetTicks();
	draw_frame(delta_time);
	SDL_GL_SwapBuffers();	
	delta_time = SDL_GetTicks() - previous_time;
	calc_fps();
    }
}
Exemplo n.º 5
0
Arquivo: pixel.c Projeto: zhoukk/pixel
void pixel_frame(float t) {
	lua_State *L = P.L;
	lua_pushvalue(L, 3);
	call(L, 0, 0);
	lua_settop(L, 3);
	calc_fps(t);
	pixel_flush(L);
}
Exemplo n.º 6
0
static int mt9v011_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
{
	struct v4l2_captureparm *cp = &parms->parm.capture;

	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;

	memset(cp, 0, sizeof(struct v4l2_captureparm));
	cp->capability = V4L2_CAP_TIMEPERFRAME;
	calc_fps(sd,
		 &cp->timeperframe.numerator,
		 &cp->timeperframe.denominator);

	return 0;
}
Exemplo n.º 7
0
static void set_res(struct v4l2_subdev *sd)
{
	struct mt9v011 *core = to_mt9v011(sd);
	unsigned vstart, hstart;


	hstart = 20 + (640 - core->width) / 2;
	mt9v011_write(sd, R02_MT9V011_COLSTART, hstart);
	mt9v011_write(sd, R04_MT9V011_WIDTH, core->width);
	mt9v011_write(sd, R05_MT9V011_HBLANK, 771 - core->width);

	vstart = 8 + (480 - core->height) / 2;
	mt9v011_write(sd, R01_MT9V011_ROWSTART, vstart);
	mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height);
	mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height);

	calc_fps(sd, NULL, NULL);
};
Exemplo n.º 8
0
static int mt9v011_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
{
	struct v4l2_captureparm *cp = &parms->parm.capture;
	struct v4l2_fract *tpf = &cp->timeperframe;
	u16 speed;

	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -EINVAL;
	if (cp->extendedmode != 0)
		return -EINVAL;

	speed = calc_speed(sd, tpf->numerator, tpf->denominator);

	mt9v011_write(sd, R0A_MT9V011_CLK_SPEED, speed);
	v4l2_dbg(1, debug, sd, "Setting speed to %d\n", speed);

	/* Recalculate and update fps info */
	calc_fps(sd, &tpf->numerator, &tpf->denominator);

	return 0;
}
Exemplo n.º 9
0
int App::dump_fps()
{
	// Calculate time since last update
	static int start_time = CL_System::get_time();
	static int fps_dump_time = 0;

	int cur_time = CL_System::get_time();
	int delta_time = cur_time - start_time;
	start_time = cur_time;
	
	int fps = calc_fps(delta_time);

	fps_dump_time += delta_time;
	if(fps_dump_time >= 1000)
	{
		CL_Console::write_line("fps:" + CL_StringHelp::int_to_text(fps));
		fps_dump_time = 0;
	}

	return delta_time;
}
Exemplo n.º 10
0
int App::dump_fps()
{
	// Calculate time since last update
	static int start_time = CL_System::get_time();
	static int fps_dump_time = 0;

	int cur_time = CL_System::get_time();
	int delta_time = cur_time - start_time;
	start_time = cur_time;
	
	int fps = calc_fps(delta_time);

	fps_dump_time += delta_time;
	if(fps_dump_time >= 1000)
	{
		std::cout << "fps:" << fps << std::endl;			

		fps_dump_time = 0;
	}

	return delta_time;
}
void CalcFps::Fps() {
    if (debug_fps_level > 0)
        calc_fps(ns2us(systemTime()));
}