iOS/buildlibs/armv7/allegro-4.4.2/addons/allegrogl/src/gui.c
/**
 * \ingroup gui
 * \brief AllegroGL-friendly version of popup_dialog
 *
 * This routine is likely to be very slow.  It has to take a copy of the
 * screen on entry, then where algl_do_dialog() would just clear the screen,
 * this routine has to blit that copy back again after clearing.  This is
 * the only way to do overlays without knowing what type of flipping is
 * going on.
 *
 * Also, note that we don't save the depth buffer or anything like that so
 * don't go around thinking that algl_popup_dialog won't affect anything
 * when it's gone.
 *
 * So, unless you need overlays, it's recommended that you just use
 * algl_do_dialog(), and if you do need overlays, it's recommended that you
 * just use algl_do_dialog() and redraw the thing you're overlaying yourself.
 * If you're lazy or that's impossible, use this routine...
 *
 * \param dialog an array of dialog objects terminated by one with a NULL 
 * dialog procedure.
 * \param focus_obj index of the object on which the focus is set (-1 if you
 * don't want anything to have the focus
 *
 * \sa algl_do_dialog, algl_draw_mouse
 */
\ingroup gui
\brief AllegroGL-friendly version of popup_dialog

This routine is likely to be very slow.  It has to take a copy of the
screen on entry, then where algl_do_dialog() would just clear the screen,
this routine has to blit that copy back again after clearing.  This is
the only way to do overlays without knowing what type of flipping is
going on.

Also, note that we don't save the depth buffer or anything like that so
don't go around thinking that algl_popup_dialog won't affect anything
when it's gone.

So, unless you need overlays, it's recommended that you just use
algl_do_dialog(), and if you do need overlays, it's recommended that you
just use algl_do_dialog() and redraw the thing you're overlaying yourself.
If you're lazy or that's impossible, use this routine

\param dialog an array of dialog objects terminated by one with a NULL
dialog procedure.
\param focus_obj index of the object on which the focus is set (-1 if you
don't want anything to have the focus


\ ingroup gui \ brief AllegroGL - friendly version of popup_dialog This routine is likely to be very slow . It has to take a copy of the screen on entry then where algl_do_dialog () would just clear the screen this routine has to blit that copy back again after clearing . This is the only way to do overlays without knowing what type of flipping is going on . Also note that we don ' t save the depth buffer or anything like that so don ' t go around thinking that algl_popup_dialog won ' t affect anything when it ' s gone . So unless you need overlays it ' s recommended that you just use algl_do_dialog () and if you do need overlays it ' s recommended that you just use algl_do_dialog () and redraw the thing you ' re overlaying yourself . If you ' re lazy or that ' s impossible use this routine \ param dialog an array of dialog objects terminated by one with a NULL dialog procedure . \ param focus_obj index of the object on which the focus is set ( - 1 if you don ' t want anything to have the focus
int algl_popup_dialog (DIALOG *dialog, int focus_obj)
{
	void *backdrop;
	DIALOG_PLAYER *player;
	GLint read_buffer;
	AGL_LOG(2, "allegro_gl_popup_dialog\n");
	allegro_gl_set_allegro_mode();
	glGetIntegerv(GL_READ_BUFFER, &read_buffer);
	glReadBuffer (GL_FRONT); 
	glDisable(GL_DEPTH_TEST);
	backdrop = malloc (SCREEN_W * SCREEN_H * 3 * 4);
	glReadPixels (0, 0, SCREEN_W, SCREEN_H, GL_RGB, GL_UNSIGNED_BYTE, backdrop);
	glReadBuffer(read_buffer);
	player = init_dialog (dialog, focus_obj);
	show_mouse(screen);
	while (update_dialog (player)) {
		glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glRasterPos2f (0., SCREEN_H-.5); 
		glDrawPixels (SCREEN_W, SCREEN_H, GL_RGB, GL_UNSIGNED_BYTE, backdrop);
		broadcast_dialog_message (MSG_DRAW, 0);
		algl_draw_mouse();
		allegro_gl_flip();
	}
	glRasterPos2f (0., SCREEN_H-.5); 
	glDrawPixels (SCREEN_W, SCREEN_H, GL_RGB, GL_UNSIGNED_BYTE, backdrop);
	glEnable(GL_DEPTH_TEST);
	free (backdrop);
	show_mouse(NULL);
	allegro_gl_unset_allegro_mode();
	return shutdown_dialog (player);
}
int algl_popup_dialog ( DIALOG * dialog , int focus_obj ) { void * backdrop ; DIALOG_PLAYER * player ; GLint read_buffer ; AGL_LOG ( 2 , " \n " ) ; allegro_gl_set_allegro_mode ( ) ; glGetIntegerv ( GL_READ_BUFFER , & read_buffer ) ; glReadBuffer ( GL_FRONT ) ; glDisable ( GL_DEPTH_TEST ) ; backdrop = malloc ( SCREEN_W * SCREEN_H * 3 * 4 ) ; glReadPixels ( 0 , 0 , SCREEN_W , SCREEN_H , GL_RGB , GL_UNSIGNED_BYTE , backdrop ) ; glReadBuffer ( read_buffer ) ; player = init_dialog ( dialog , focus_obj ) ; show_mouse ( screen ) ; while ( update_dialog ( player ) ) { glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; glRasterPos2f ( 0. , SCREEN_H - .5 ) ; glDrawPixels ( SCREEN_W , SCREEN_H , GL_RGB , GL_UNSIGNED_BYTE , backdrop ) ; broadcast_dialog_message ( MSG_DRAW , 0 ) ; algl_draw_mouse ( ) ; allegro_gl_flip ( ) ; } glRasterPos2f ( 0. , SCREEN_H - .5 ) ; glDrawPixels ( SCREEN_W , SCREEN_H , GL_RGB , GL_UNSIGNED_BYTE , backdrop ) ; glEnable ( GL_DEPTH_TEST ) ; free ( backdrop ) ; show_mouse ( NULL ) ; allegro_gl_unset_allegro_mode ( ) ; return shutdown_dialog ( player ) ; }
\ingroup gui
 \brief AllegroGL-friendly version of popup_dialog
\ ingroup gui \ brief AllegroGL - friendly version of popup_dialog
/* Allegro GUI routines generally use the 2D gfx functions therefore
	   we set default behaviour to allegro_gl_set_allegro_mode so that we
	   can use the GUI functions "as is" */ /* TODO: don't clobber */ /* Redraw the GUI every frame */ /* TODO: don't clobber */ /* Draw the mouse cursor */ /* Flip buffers */ /* TODO: don't clobber */ /* restore previous projection matrices */