maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
RetroGLU Overlay API

Convenience macros for drawing a 2D overlay using transparent textures. More...

Collaboration diagram for RetroGLU Overlay API:

Macros

#define retroglu_push_overlay(x, y, x_f, y_f, aspect_f)
 Push current projection modelview and prepare useful parameters for drawing a textured overlay.
 
#define retroglu_whf(w, h, w_f, h_f, aspect_f)
 Convert width/height in pixels to proportional float values for OpenGL.
 
#define retroglu_pop_overlay()
 Restore projection modelview previously pushed using retroglu_push().
 

Detailed Description

Convenience macros for drawing a 2D overlay using transparent textures.

Macro Definition Documentation

◆ retroglu_pop_overlay

#define retroglu_pop_overlay ( )
Value:
glPopMatrix(); \
glMatrixMode( GL_MODELVIEW );

Restore projection modelview previously pushed using retroglu_push().

◆ retroglu_push_overlay

#define retroglu_push_overlay ( x,
y,
x_f,
y_f,
aspect_f )
Value:
/* Switch to projection setup. */ \
glMatrixMode( GL_PROJECTION ); \
glPushMatrix(); \
/* Lighting makes overlay text hard to see. */ \
retroglu_disable_lightning(); \
/* Use ortho for overlay. */ \
glLoadIdentity(); \
aspect_f = (float)retroflat_screen_w() / (float)retroflat_screen_h(); \
/* Switch to ortho projection proportional to screen size. */ \
glOrtho( -1.0f * aspect_f, aspect_f, -1.0f, 1.0f, 0, 10.0f ); \
/* -1 to 1 is 2! */ \
aspect_f *= 2.0f; \
/* Assuming width > height for aspect ratio. */ \
x_f = ((x) * aspect_f / retroflat_screen_w()) - (aspect_f / 2); \
/* Vertical coords also need to be inverted because OpenGL. */ \
y_f = 1.0f - ((y) * 2.0f / retroflat_screen_h()); \
#define retroflat_screen_h()
Get the current screen height in pixels.
Definition retpltd.h:38
#define retroflat_screen_w()
Get the current screen width in pixels.
Definition retpltd.h:35

Push current projection modelview and prepare useful parameters for drawing a textured overlay.

◆ retroglu_whf

#define retroglu_whf ( w,
h,
w_f,
h_f,
aspect_f )
Value:
w_f = ((w) * aspect_f / retroflat_screen_w()); \
h_f = ((h) * 2.0f / retroflat_screen_h());

Convert width/height in pixels to proportional float values for OpenGL.

Parameters
wWidth of an overlay in pixels (read-only int).
hHeight of an overlay in pixels (read-only int).
w_fFloat to assign proportional width of the overlay.
h_fFloat to assign proportional height of the overlay.