AllegroGL: Allegro Interfacing

# Allegro Interfacing

## Allegro Interfacing routines

- void allegro_gl_set_allegro_mode (void)
    Prepares for Allegro drawing to the screen.
- void allegro_gl_unset_allegro_mode (void)
    Restores previous OpenGL settings.
- void allegro_gl_set_projection (void)
    Prepares for Allegro drawing to the screen.
- void allegro_gl_unset_projection (void)
    Restores previously saved projection.

## Function Documentation

void allegro_gl_set_allegro_mode | ( | void |  | ) |

Prepares for Allegro drawing to the screen.

Since AllegroGL actually calls OpenGL commands to perform Allegro functions for 2D drawing, some OpenGL capabilities may interfer with those operations In order to obtain the expected results, allegro_gl_set_allegro_mode() must be called to disable the depth test, texturing, fog and lighting and set the view matrices to an appropriate state. Call allegro_gl_unset_allegro_mode() to restore OpenGL in its previous state.

You should encapsulate all Allegro code dealing with the screen in between allegro_gl_set_allegro_mode() and allegro_gl_unset_allegro_mode().

If you need to use regular OpenGL commands in between, you may do so, but you can get unexpected results. This is generally not recommended. You should first call allegro_gl_unset_allegro_mode() to restore the original OpenGL matrices. After that, you may freely call any OpenGL command. Don't forget to call back allegro_gl_set_allegro_mode() to switch back to Allegro commands.

AllegroGL saves the current OpenGL state with glPushAttrib so you should make sure that at least one level is available in the attribute stack otherwise the next call to allegro_gl_unset_allegro_mode() may fail.

Also note that allegro_gl_set_allegro_mode() implicitely calls allegro_gl_set_projection() so you do not need to do it yourself.

See also:
  allegro_gl_unset_allegro_mode() allegro_gl_set_projection()

  allegro_gl_unset_projection()

Definition at line 2422 of file glvtable.c.

References allegro_gl_set_projection().

Referenced by algl_do_dialog(), algl_popup_dialog(), and d_algl_viewport_proc().

void allegro_gl_unset_allegro_mode | ( | void |  | ) |

Restores previous OpenGL settings.

Restores the OpenGL state that have saved during the last call of allegro_gl_set_allegro_mode().

Note that allegro_gl_unset_allegro_mode implicitely calls allegro_gl_unset_projection() so you do not need to do it yourself.

See also:
  allegro_gl_set_allegro_mode() allegro_gl_set_projection()

  allegro_gl_unset_projection()

Definition at line 2491 of file glvtable.c.

References AGL_KEEP, AGL_RELEASE, and allegro_gl_unset_projection().

Referenced by algl_do_dialog(), algl_popup_dialog(), and d_algl_viewport_proc().

void allegro_gl_set_projection | ( | void |  | ) |

Prepares for Allegro drawing to the screen.

This function sets the OpenGL projection and modelview matrices so that 2D OpenGL coordinates match the usual Allegro coordinate system.

OpenGL uses a completely different coordinate system than Allegro. So to be able to use Allegro operations on the screen, you first need to properly set up the OpenGL projection and modelview matrices. AllegroGL provides this set of functions to allow proper alignment of OpenGL coordinates with their Allegro counterparts.

Since AllegroGL actually calls OpenGL commands to perform Allegro functions for 2D drawing, some OpenGL capabilities such as texturing or depth testing may interfer with those operations. In order to prevent such inconveniences, you should call allegro_gl_set_allegro_mode() instead of allegro_gl_set_projection()

allegro_gl_set_projection() and allegro_gl_unset_projection() are not nestable, which means that you should not call allegro_gl_set_projection() inside another allegro_gl_set_projection() block. Similarly for allegro_gl_unset_projection().

Have a look at examp/exalleg.c for an example of combining Allegro drawing commands and OpenGL.

See also:
  allegro_gl_unset_projection() allegro_gl_set_allegro_mode()

  allegro_gl_unset_allegro_mode()

Definition at line 2540 of file glvtable.c.

Referenced by allegro_gl_set_allegro_mode().

void allegro_gl_unset_projection | ( | void |  | ) |

Restores previously saved projection.

This function returns the projection and modelview matrices to their state before the last allegro_gl_set_projection() was called.

See also:
  allegro_gl_set_projection() allegro_gl_set_allegro_mode()

  allegro_gl_unset_allegro_mode()

Definition at line 2567 of file glvtable.c.

Referenced by allegro_gl_unset_allegro_mode().