iOS/buildlibs/armv7/allegro-4.4.2/addons/allegrogl/examp/exgui.c
/* This callback function demonstrates how to use the d_algl_viewport_proc 
 * object.
 */
This callback function demonstrates how to use the d_algl_viewport_proc
object.
This callback function demonstrates how to use the d_algl_viewport_proc object .
int glviewport_callback(BITMAP* viewport, int msg, int c)
{
	static int focus = TRUE;
	static float prevx = 0, prevy = 0;	
	static float zoom = 30; 		
	int ret = 0;
	if (msg == MSG_GOTMOUSE) {
		focus = TRUE;
	}
	if (msg == MSG_LOSTMOUSE) {
		focus = FALSE;
	}
	if (msg == MSG_IDLE) {
		rest(2);
		ret = D_O_K;
	}
	if (msg == MSG_DRAW) {
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(zoom, VIEW_ASPECT, 1,100);
		glMatrixMode(GL_MODELVIEW);
		glTranslatef(0,0,-30);
		glRotatef(display_info.phi, 1., 0., 0.);
		glRotatef(display_info.theta, 0., 1., 0.);
		glPolygonMode(GL_FRONT_AND_BACK, display_info.polygon_mode);
		display();
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		allegro_gl_set_allegro_mode();
		rect(viewport, 5, 5, viewport->w - 5, viewport->h - 5,
		     focus ? makecol(255,0,0) : makecol(255, 255, 255));
		textprintf_ex(viewport, font, 10, 445, makecol(255, 255, 255), -1,
		           "Click & drag");
		allegro_gl_unset_allegro_mode();
		ret = D_O_K;
	}
	if ((mouse_b & 1) && focus) {
		float x,y;
		x = mouse_x;
		y = mouse_y;
		display_info.theta += x - prevx;
		display_info.phi += y - prevy;
		ret = D_O_K;
	}
	if ((mouse_b & 2) && focus) {
		zoom += ((mouse_y - prevy) / viewport->h) * 40;
		if (zoom < 5)
			zoom = 5;
		if (zoom > 120)
			zoom = 120;
		ret = D_O_K;
	}
	prevx = mouse_x;
	prevy = mouse_y;
	return ret;
}
int glviewport_callback ( BITMAP * viewport , int msg , int c ) { static int focus = TRUE ; static float prevx = 0 , prevy = 0 ; static float zoom = 30 ; int ret = 0 ; if ( msg == MSG_GOTMOUSE ) { focus = TRUE ; } if ( msg == MSG_LOSTMOUSE ) { focus = FALSE ; } if ( msg == MSG_IDLE ) { rest ( 2 ) ; ret = D_O_K ; } if ( msg == MSG_DRAW ) { glMatrixMode ( GL_MODELVIEW ) ; glLoadIdentity ( ) ; glMatrixMode ( GL_PROJECTION ) ; glLoadIdentity ( ) ; gluPerspective ( zoom , VIEW_ASPECT , 1 , 100 ) ; glMatrixMode ( GL_MODELVIEW ) ; glTranslatef ( 0 , 0 , -30 ) ; glRotatef ( display_info . phi , 1. , 0. , 0. ) ; glRotatef ( display_info . theta , 0. , 1. , 0. ) ; glPolygonMode ( GL_FRONT_AND_BACK , display_info . polygon_mode ) ; display ( ) ; glPolygonMode ( GL_FRONT_AND_BACK , GL_FILL ) ; allegro_gl_set_allegro_mode ( ) ; rect ( viewport , 5 , 5 , viewport -> w - 5 , viewport -> h - 5 , focus ? makecol ( 255 , 0 , 0 ) : makecol ( 255 , 255 , 255 ) ) ; textprintf_ex ( viewport , font , 10 , 445 , makecol ( 255 , 255 , 255 ) , -1 , " " ) ; allegro_gl_unset_allegro_mode ( ) ; ret = D_O_K ; } if ( ( mouse_b & 1 ) && focus ) { float x , y ; x = mouse_x ; y = mouse_y ; display_info . theta += x - prevx ; display_info . phi += y - prevy ; ret = D_O_K ; } if ( ( mouse_b & 2 ) && focus ) { zoom += ( ( mouse_y - prevy ) / viewport -> h ) * 40 ; if ( zoom < 5 ) zoom = 5 ; if ( zoom > 120 ) zoom = 120 ; ret = D_O_K ; } prevx = mouse_x ; prevy = mouse_y ; return ret ; }
This callback function demonstrates how to use the d_algl_viewport_proc
 object.
This callback function demonstrates how to use the d_algl_viewport_proc object .
/* position of mouse */ /* field of view in degrees */ /* Determine if the mouse is on the object */ /* Apply the rotations */ /* Display the 3D object */ /* Display of 2D objects is also possible */ /* drag in progress, simulate trackball */ /* zooming drag */