iOS/buildlibs/armv7/allegro-4.4.2/addons/allegrogl/src/gui.c
/**
 * \ingroup gui
 * \brief Creates a viewport object where OpenGL commands can be performed.
 *
 *  The viewport and the scissor are updated so that this GUI object behaves
 *  somewhat like a window. The dp field of the DIALOG object points to a
 *  callback function : int (*callback)(BITMAP* viewport, int msg, int c) where:
 *  viewport is a sub-bitmap of the screen limited to the area of the
 *  DIALOG object. msg and c are the values that come from the GUI manager.
 *  The callback function must return a sensible value to the GUI manager
 *  like D_O_K if everything went right or D_EXIT to close the dialog.
 */
\ingroup gui
\brief Creates a viewport object where OpenGL commands can be performed.

The viewport and the scissor are updated so that this GUI object behaves
somewhat like a window. The dp field of the DIALOG object points to a
callback function : int (*callback)(BITMAP* viewport, int msg, int c) where:
viewport is a sub-bitmap of the screen limited to the area of the
DIALOG object. msg and c are the values that come from the GUI manager.
The callback function must return a sensible value to the GUI manager
like D_O_K if everything went right or D_EXIT to close the dialog.
\ ingroup gui \ brief Creates a viewport object where OpenGL commands can be performed . The viewport and the scissor are updated so that this GUI object behaves somewhat like a window . The dp field of the DIALOG object points to a callback function : int ( * callback ) ( BITMAP * viewport int msg int c ) where : viewport is a sub - bitmap of the screen limited to the area of the DIALOG object . msg and c are the values that come from the GUI manager . The callback function must return a sensible value to the GUI manager like D_O_K if everything went right or D_EXIT to close the dialog .
int d_algl_viewport_proc(int msg, DIALOG *d, int c)
{
	int ret = D_O_K;
	typedef int (*_callback)(BITMAP*, int, int);
	_callback callback = (_callback) d->dp;
	BITMAP *viewport = create_sub_bitmap(screen, d->x, d->y, d->w, d->h);
	AGL_LOG(3, "d_algl_viewport_proc\n");
	if (msg == MSG_DRAW) {
		clear_to_color(viewport, d->bg);
	}
	allegro_gl_unset_allegro_mode();
	glPushAttrib(GL_SCISSOR_BIT | GL_VIEWPORT_BIT);
	glViewport(d->x, SCREEN_H - d->y - d->h, d->w, d->h);
	glScissor(d->x, SCREEN_H - d->y - d->h, d->w, d->h);
	glEnable(GL_SCISSOR_TEST);
	if (msg == MSG_DRAW) {
		glClear(GL_DEPTH_BUFFER_BIT);
	}
	if (callback)
		ret = callback(viewport, msg, c);
	glPopAttrib();
	allegro_gl_set_allegro_mode();
	destroy_bitmap(viewport);
	if (msg == MSG_IDLE) {
		glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		broadcast_dialog_message (MSG_DRAW, 0);
		algl_draw_mouse();
		allegro_gl_flip();
	}
	return ret;
}
int d_algl_viewport_proc ( int msg , DIALOG * d , int c ) { int ret = D_O_K ; typedef int ( * _callback ) ( BITMAP * , int , int ) ; _callback callback = ( _callback ) d -> dp ; BITMAP * viewport = create_sub_bitmap ( screen , d -> x , d -> y , d -> w , d -> h ) ; AGL_LOG ( 3 , " \n " ) ; if ( msg == MSG_DRAW ) { clear_to_color ( viewport , d -> bg ) ; } allegro_gl_unset_allegro_mode ( ) ; glPushAttrib ( GL_SCISSOR_BIT | GL_VIEWPORT_BIT ) ; glViewport ( d -> x , SCREEN_H - d -> y - d -> h , d -> w , d -> h ) ; glScissor ( d -> x , SCREEN_H - d -> y - d -> h , d -> w , d -> h ) ; glEnable ( GL_SCISSOR_TEST ) ; if ( msg == MSG_DRAW ) { glClear ( GL_DEPTH_BUFFER_BIT ) ; } if ( callback ) ret = callback ( viewport , msg , c ) ; glPopAttrib ( ) ; allegro_gl_set_allegro_mode ( ) ; destroy_bitmap ( viewport ) ; if ( msg == MSG_IDLE ) { glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; broadcast_dialog_message ( MSG_DRAW , 0 ) ; algl_draw_mouse ( ) ; allegro_gl_flip ( ) ; } return ret ; }
\ingroup gui
 \brief Creates a viewport object where OpenGL commands can be performed.
\ ingroup gui \ brief Creates a viewport object where OpenGL commands can be performed .
/* Draws the background */ /* First we get back into a 3D mode */ /* Save the Viewport and Scissor states */ /* Adapt the viewport to the object size */ /* Clear the depth buffer for this scissor region */ /* Call the callback function */ /* Restore the previous state */ /* Redraw the GUI every frame */ /* Draw the mouse cursor */ /* Flip buffers */