Пример #1
0
//Input for States
void
state_input (ALLEGRO_EVENT * event)
{
// check special cases
  if (state_switched)
    return;
  if (state_terminated)
    return;

// process input
  handlers[state].proc_input (event);

  // give to GUI.
  gui_input (event);
}
Пример #2
0
void main_loop(void)
{
#ifndef __APPLE__
	gpuinfo_tick();
#endif
	for(int i=0; i<4; i++)
	{
		joy[i].fflarge = joy[i].lt;
		joy[i].ffsmall = joy[i].rt;
	}

	pos.w = 0.5 / (float)vid_width;

	float3 req = {0,0,0};
	float nice = 0.007;

	if(keys[KEY_ESCAPE])
	{
		killme=1;
	}
	if(keys[KEY_W])
	{
		req.z -= nice;
	}
	if(keys[KEY_S])
	{
		req.z += nice;
	}
	if(keys[KEY_A])
	{
		req.x -= nice;
	}
	if(keys[KEY_D])
	{
		req.x += nice;
	}
	if(keys[KEY_LCONTROL])
	{
		req.y -= nice;
	}
	if(keys[KEY_SPACE])
	{
		req.y += nice;
	}

	if(mouse[2]) /// right mouse
	{
		angle.x += mickey_y * 0.003;
		angle.y += mickey_x * 0.003;
	}
	if(keys[KEY_O])
	{
		p_swim = !p_swim;
		keys[KEY_S] = 0;
		printf("Swimming is %s.\n", p_swim ? "engaged" : "off");
	}
	if(keys[KEY_P])
	{
		printf("float4 pos = {%f, %f, %f, 0.0};\n", pos.x, pos.y, pos.z);
		printf("float4 angle = {%f, %f, %f, M_PI*0.5};\n", angle.x, angle.y, angle.z);
	}

	if(p_swim)
	{
		float cx = cos(angle.x), sx = sin(angle.x), ty = req.y;
		req.y = req.y * cx - req.z * sx;	// around x
		req.z = ty * sx + req.z * cx;
	}


	float cy = cos(angle.y), sy = sin(angle.y), tx = req.x;
	req.x = req.x * cy + req.z * sy;	// around y
	req.z = tx * sy - req.z * cy;


	F3ADD(pos, pos, req);


	time = (float)(sys_time() - time_start)/(float)sys_ticksecond;

	glClearColor(0.3f, 0.3f, 0.32f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	gui_input();
//	voxel_loop();
	ocl_loop();
	gui_draw();
	http_loop();
}