1 /** \file alleggl.h
2   * \brief Main header file for AllegroGL
3   */
4 
5 #ifndef _allegrogl_included_alleggl_h
6 #define _allegrogl_included_alleggl_h
7 
8 #include <allegro.h>
9 
10 #ifdef ALLEGRO_WINDOWS
11 
12 #ifndef WIN32_LEAN_AND_MEAN
13 #define WIN32_LEAN_AND_MEAN
14 #define WIN32_LEAN_AND_MEAN_defined
15 #endif /* WIN32_LEAN_AND_MEAN */
16 
17 #ifdef ALLEGRO_DMC
18 typedef int32_t INT32;
19 typedef __int64 INT64;
20 #endif
21 
22 #include <winalleg.h>
23 
24 #ifdef WIN32_LEAN_AND_MEAN_defined
25 #undef WIN32_LEAN_AND_MEAN_defined
26 #undef WIN32_LEAN_AND_MEAN
27 #endif /* WIN32_LEAN_AND_MEAN_defined */
28 
29 #endif /* ALLEGRO_WINDOWS */
30 
31 
32 #if (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS)
33 	#ifdef ALLEGRO_GL_SRC_BUILD
34 		#define _AGL_DLL __declspec(dllexport)
35 	#else
36 		#define _AGL_DLL __declspec(dllimport)
37 	#endif /* ALLEGRO_GL_SRC_BUILD */
38 #else
39 	#define _AGL_DLL
40 #endif /* (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS) */
41 
42 #define AGL_VAR(type, name) extern _AGL_DLL type name
43 
44 #if (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS)
45 	#define AGL_FUNC(type, name, args) extern _AGL_DLL type __cdecl name args
46 #else
47 	#define AGL_FUNC(type, name, args) extern type name args
48 #endif /* (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS) */
49 
50 
51 #ifdef ALLEGRO_MACOSX
52 
53 #include <OpenGL/OpenGL.h>
54 #include <OpenGL/gl.h>
55 #include <OpenGL/glext.h>
56 
57 #ifndef GL_GLEXT_PROTOTYPES
58 #define GL_GLEXT_PROTOTYPES
59 #endif
60 
61 #else /* ALLEGRO_MACOSX */
62 
63 /* HACK: Prevent both Mesa and SGI's broken headers from screwing us */
64 #define __glext_h_
65 #define __gl_glext_h_
66 #define __glxext_h_
67 #define __glx_glxext_h_
68 #include <GL/gl.h>
69 #undef  __glext_h_
70 #undef  __gl_glext_h_
71 #undef  __glxext_h_
72 #undef  __glx_glxext_h_
73 
74 #endif /* ALLEGRO_MACOSX */
75 
76 
77 #include "allegrogl/gl_ext.h"
78 
79 #ifdef ALLEGRO_WITH_XWINDOWS
80 #if (ALLEGRO_SUB_VERSION == 2) && (ALLEGRO_WIP_VERSION < 2)
81 #   ifndef HAVE_LIBPTHREAD
82 #      error AllegroGL requires Allegro to have pthread support enabled!
83 #   endif
84 #else
85 #   ifndef ALLEGRO_HAVE_LIBPTHREAD
86 #      error AllegroGL requires Allegro to have pthread support enabled!
87 #   endif
88 #endif
89 #include "allegrogl/alleggl_config.h"
90 #endif
91 
92 
93 /** \defgroup version Version information
94   * \{ */
95 /** \name Version Information
96   * \{ */
97 #define AGL_VERSION     0            ///< Major version number
98 #define AGL_SUB_VERSION 4            ///< Minor version number
99 #define AGL_WIP_VERSION 4            ///< Work-In-Progress version number
100 #define AGL_VERSION_STR "0.4.4"      ///< Version description string
101 /** \} */
102 /** \} */
103 
104 /* Version Check */
105 #if (ALLEGRO_VERSION < 4 || (ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION < 2))
106 	#error AllegroGL requires Allegro 4.2.0 or later to compile!
107 #endif
108 #ifndef GL_VERSION_1_1
109 	#error AllegroGL requires OpenGL 1.1 libraries or later to compile!
110 #endif
111 
112 
113 #ifdef __cplusplus
114 extern "C" {
115 #endif
116 
117 #ifdef ALLEGRO_WINDOWS
118 
119 /* Missing #defines from Mingw */
120 #ifndef PFD_SWAP_LAYER_BUFFERS
121 #define PFD_SWAP_LAYER_BUFFERS  0x00000800
122 #endif
123 
124 #ifndef PFD_GENERIC_ACCELERATED
125 #define PFD_GENERIC_ACCELERATED 0x00001000
126 #endif
127 
128 #ifndef PFD_SUPPORT_DIRECTDRAW
129 #define PFD_SUPPORT_DIRECTDRAW  0x00002000
130 #endif
131 
132 #ifndef CDS_FULLSCREEN
133 #define CDS_FULLSCREEN      0x00000004
134 #endif
135 
136 #ifndef ENUM_CURRENT_SETTINGS
137 #define ENUM_CURRENT_SETTINGS       ((DWORD)-1)
138 #endif
139 
140 #endif
141 
142 
143 #define AGL_ERROR_SIZE 256
144 AGL_VAR(char, allegro_gl_error[AGL_ERROR_SIZE]);
145 
146 
147 /** \defgroup core Core routines
148  *  Basic AllegroGL functions. These functions allow you to initialize
149  *  AllegroGL, set up a rendering context via set_gfx_mode(), and allow
150  *  access to regular OpenGL functions.
151  *
152  */
153 /** \name Core Functions
154  *  \{
155  */
156 AGL_FUNC(int, install_allegro_gl, (void));
157 AGL_FUNC(void, remove_allegro_gl, (void));
158 
159 AGL_FUNC(void, allegro_gl_flip, (void));
160 AGL_FUNC(float, allegro_gl_opengl_version, (void));
161 
162 /** \ingroup core
163  *  Backward compatibility \#define for programs written
164  *  prior to AGL 0.0.22.
165  *  It isn't defined as anything meaningful, so you don't
166  *  need to put them in your program.
167  *
168  * \see allegro_gl_end()
169  */
170 #define allegro_gl_begin() ;
171 
172 /** \ingroup core
173  *  Backward compatibility \#define for programs written
174  *  prior to AGL 0.0.22.
175  *  It isn't defined as anything meaningful, so you don't
176  *  need to put them in your program.
177  *
178  * \see allegro_gl_begin()
179  */
180 #define allegro_gl_end() ;
181 
182 /** \} */
183 
184 
185 /** \addtogroup settings
186  *  \{ */
187 /** \name Frame Buffer Settings
188  *  \{ */
189 
190 /** Use Allegro-compatible framebuffer
191  * \deprecated This define is ignored.
192  */
193 #define AGL_ALLEGRO_FORMAT  0x00000001
194 
195 /** Select the red depth of the frame buffer. This defines the number of
196  *  bits for the red component you'd like. The driver may or may not find
197  *  a suitable mode
198  */
199 #define AGL_RED_DEPTH       0x00000002
200 
201 /** Select the green depth of the frame buffer. This defines the number of
202  *  bits for the green component you'd like. The driver may or may not find
203  *  a suitable mode
204  */
205 #define AGL_GREEN_DEPTH     0x00000004
206 
207 /** Select the blue depth of the frame buffer. This defines the number of
208  *  bits for the blue component you'd like. The driver may or may not find
209  *  a suitable mode
210  */
211 #define AGL_BLUE_DEPTH      0x00000008
212 
213 /** Select the alpha depth of the frame buffer. This defines the number of
214  *  bits for the alpha component you'd like. Not many video cards support
215  *  destination alpha, so be aware that the you may not get an alpha depth
216  *  at all.
217  */
218 #define AGL_ALPHA_DEPTH     0x00000010
219 
220 /** Specify the total color depth of the frame buffer. The driver is free to
221  *  select any combination of red, green, blue and alpha bits.
222  */
223 #define AGL_COLOR_DEPTH     0x00000020
224 
225 
226 /** Select the red depth of the accumulator buffer. This defines the number
227  *  of bits to use for the red component. The driver may or may not find a
228  *  suitable mode. Note that on many video cards, the accumulator buffer is
229  *  not accelerated.
230  */
231 #define AGL_ACC_RED_DEPTH   0x00000040
232 
233 /** Select the green depth of the accumulator buffer. This defines the number
234  *  of bits to use for the green component. The driver may or may not find a
235  *  suitable mode. Note that on many video cards, the accumulator buffer is
236  *  not accelerated.
237  */
238 #define AGL_ACC_GREEN_DEPTH 0x00000080
239 
240 
241 /** Select the blue depth of the accumulator buffer. This defines the number
242  *  of bits to use for the blue component. The driver may or may not find a
243  *  suitable mode. Note that on many video cards, the accumulator buffer is
244  *  not accelerated.
245  */
246 #define AGL_ACC_BLUE_DEPTH  0x00000100
247 
248 
249 /** Select the alpha depth of the accumulator buffer. This defines the number
250  *  of bits to use for the alpha component. The driver may or may not find a
251  *  suitable mode. Note that on many video cards, the accumulator buffer is
252  *  not accelerated. Not many cards support destination alpha either.
253  */
254 #define AGL_ACC_ALPHA_DEPTH 0x00000200
255 
256 /** Creates a backbuffer if set. The buffering mode may be double buffering
257   * or page flipping, depending on the driver settings. OpenGL programs cannot
258   * chose the buffering mode themselves.
259   */
260 #define AGL_DOUBLEBUFFER    0x00000400
261 
262 /** Creates seperate left/right buffers for stereo display. Stereo display
263  *  is used with special hardware (tipically glasses) for giving the illusion
264  *  of depth by drawing the left and right buffers with a slight horizontal
265  *  displacement. This makes the display appear to heavily flicker without
266  *  the special hardware.
267  *  Set to TRUE for enabling stereo viewing.
268  */
269 #define AGL_STEREO          0x00000800
270 
271 
272 /** Creates additional auxiliary buffers. This allows you to have more than
273  *  one rendering context. Few video cards support this feature.
274  */
275 #define AGL_AUX_BUFFERS     0x00001000
276 
277 
278 /** Select the depth of the z-buffer. The z-buffer is used to properly
279  *  display polygons in 3D without recurring to sorting. The higher the
280  *  depth of the z-buffer, the more precise it is.
281  */
282 #define AGL_Z_DEPTH         0x00002000
283 
284 
285 /** Select the depth of the stencil buffer. The stencil buffer is used to
286  *  to do per-pixel testing (like the z-buffer), but of an arbitrary
287  *  pattern instead of depth. Please see the OpenGL documentation for details.
288  *  Newer cards support stenciling in hardware, but older cards (TNT2s,
289  *  Voodoos, ATI Rage) do not.
290  */
291 #define AGL_STENCIL_DEPTH   0x00004000
292 
293 /** Requests a placement of the window to a specified pixel location.
294  *  The driver may or may not honnor the request.
295  */
296 #define AGL_WINDOW_X        0x00008000
297 
298 /** Same as AGL_WINDOW_X, but for the y-axis.
299  */
300 #define AGL_WINDOW_Y        0x00010000
301 
302 /** Set it if you'd like AllegroGL to pay special attention on whether
303  *  hardware acceleration is present or not. Notice however this
304  *  isn't a guarentee that the OpenGL operations will be accelerated, but
305  *  rather a request that the operations go through the video card's
306  *  drivers instead of Microsoft's software renderer. The video card
307  *  driver is free to drop back to software mode if it deems it necessary.
308  *  This setting has no effect in X.
309  */
310 #define AGL_RENDERMETHOD    0x00020000
311 
312 /** Set if you'd like a full screen mode. Full screen may or may not be
313  *  available on the current platform.
314  */
315 #define AGL_FULLSCREEN      0x00040000
316 
317 /** Set if you'd like a windowed mode. Windowed modes may or may not be
318  *  available on the current platform.
319  */
320 #define AGL_WINDOWED        0x00080000
321 
322 /** Define AllegroGL's policy relative to video memory usage.
323  *  Sometimes AllegroGL needs to create an internal 256x256 texture in order to
324  *  perform graphics operations like masked_blit, draw_sprite and so on.
325  *  This parameter defines the policy of AllegroGL relative to the management
326  *  of this texture.
327  *  Several options are available :
328  *  - AGL_RELEASE : internal texture is released in order to free video memory.
329  *  - AGL_KEEP : internal texture is kept in video memory. This option generally
330  *  accelerate graphics operations when allegro_gl_set_allegro_mode() and
331  *  allegro_gl_unset_allegro_mode() are often called.
332  *  System with few video memory should use AGL_RELEASE while others should use
333  *  AGL_KEEP since it allows the internal texture to be created once.
334  *  Default value is AGL_KEEP.
335  *
336  */
337 #define AGL_VIDEO_MEMORY_POLICY		0x00100000
338 
339 /** Define multisample parameters
340  *  Some OpenGL ICDs expose an extension called GL_ARB_multisample which
341  *  provides a mechanism to anti-alias all GL primitives: points, lines,
342  *  polygons, bitmaps and pixel rectangles.
343  *
344  *  In order to get an AllegroGL mode which supports multisample, you have to
345  *  set both #AGL_SAMPLE_BUFFERS to 1 and #AGL_SAMPLES to the number of desired
346  *  samples for multisampling.
347  *
348  *  Notice however that since this feature relies on several extensions
349  *  (GL_ARB_multisample and GLX_ARB_multisample or WGL_ARB_multisample),
350  *  it isn't guaranteed that AllegroGL will find a graphics mode that supports
351  *  multisample : many not-so-old video cards, like the GeForce 2, do not
352  *  support multisampling
353  *
354  *  Hence, if you want your app to be able to run on most platforms, you
355  *  should not require this parameter.
356  *
357  *  Set this value to 1 to enable multisampling.
358  *
359  *  \see AGL_SAMPLES
360  */
361 #define AGL_SAMPLE_BUFFERS	0x00200000
362 
363 /** Define multisample samples
364  *  Set this value to the number of samples that can be accepted in the
365  *  multisample buffers.
366  *
367  * \see AGL_SAMPLE_BUFFERS
368  */
369 #define AGL_SAMPLES        0x00400000
370 /** \} */
371 
372 
373 /** Floating-point Color buffer.
374  */
375 #define AGL_FLOAT_COLOR    0x00800000
376 
377 /** Floating-point Depth buffer.
378  */
379 #define AGL_FLOAT_Z        0x01000000
380 
381 
382 
383 /* XXX <rohannessian> I'm reserving 2 bits here for later expansion. DO NOT USE
384  * without consulting me first.
385  */
386 #define AGL_CONFIG_RESRVED 0xA000000
387 
388 
389 /** \name Mode selection priority options
390  *  \{ */
391 #define AGL_DONTCARE   0 ///< Ignore these settings
392 #define AGL_SUGGEST   -1 ///< Prefer the assigned values for these settings
393 #define AGL_REQUIRE   -2 ///< Reject other values for these settings
394 /** \} */
395 
396 
397 /** \name Video memory policy options
398  *  \{ */
399 #define AGL_KEEP	1 ///< Keep internal texture in video memory
400 #define AGL_RELEASE	2 ///< Release video memory occupied by internal texture
401 /** \} */
402 
403 
404 /** \name Mode selection functions
405  *  \{ */
406 AGL_FUNC(void, allegro_gl_clear_settings, (void));
407 AGL_FUNC(void, allegro_gl_set, (int option, int value));
408 AGL_FUNC(int,  allegro_gl_get, (int option));
409 AGL_FUNC(void, allegro_gl_save_settings, (void));
410 AGL_FUNC(void, allegro_gl_load_settings, (void));
411 /** \} */
412 /** \} */
413 
414 
415 /** \defgroup gfxdrv Graphics drivers
416   *
417   * Use set_gfx_mode to select an OpenGL mode as normal, but using e.g.
418   * GFX_OPENGL as the driver.  The virtual width and height are ignored.
419   * To set the colour depth, use allegro_gl_set (AGL_COLOR_DEPTH, xxx).
420   * However if the color depth is not set by allegro_gl_set(), AllegroGL
421   * will refer to the value set by the last call to set_color_depth().
422   *
423   * Allegro modes are still available. Use of GFX_AUTODETECT or
424   * GFX_AUTODETECT_WINDOWED will select Allegro modes, and not OpenGL modes.
425   */
426 
427 #if defined DOXYGEN  /* Is this a documentation scan? */
428   /** \ingroup gfxdrv
429    * \name Graphics drivers
430    * \{
431    */
432   /** Windowed OpenGL graphics driver for Allegro */
433 # define GFX_OPENGL_WINDOWED
434   /** Fullscreen OpenGL graphics driver for Allegro */
435 # define GFX_OPENGL_FULLSCREEN
436   /** Non-specific OpenGL graphics driver for Allegro */
437   #define GFX_OPENGL
438   /** \}
439    */
440 
441 #else
442 
443 #if defined ALLEGROGL_GENERIC_DRIVER
444   /* Allegro is able to determine at run-time if windowed or fullscreen modes
445      are available */
446   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
447   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
448 
449 #else
450 #if defined _WIN32
451   /* Windows always supports fullscreen */
452   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
453   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
454 
455 #elif defined ALLEGRO_WITH_XWINDOWS
456   /* X always supports fullscreen */
457   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
458   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
459 
460 #elif defined ALLEGRO_MACOSX
461   /* MacOS X always supports fullscreen */
462   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
463   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
464 
465 #else
466   #warning Unknown or unsupported platform.
467 #endif
468 #endif
469 
470 #define GFX_OPENGL      		    AL_ID('O','G','L','D')
471 
472 #endif
473 
474 
475 /* Declare graphics driver objects */
476 extern GFX_DRIVER gfx_allegro_gl_default;
477 #ifdef GFX_OPENGL_WINDOWED
478 extern GFX_DRIVER gfx_allegro_gl_windowed;
479 #endif
480 #ifdef GFX_OPENGL_FULLSCREEN
481 extern GFX_DRIVER gfx_allegro_gl_fullscreen;
482 #endif
483 
484 
485 /** \defgroup bitmap Bitmap Routines
486  *  AllegroGL provides a function to set color depth for video
487  *  bitmaps.
488  */
489 /** \{ */
490 /** \name Video Bitmap Rountines
491  *  \{ */
492 AGL_FUNC(GLint, allegro_gl_set_video_bitmap_color_depth, (int bpp));
493 /** \} */
494 /** \} */
495 
496 
497 /** \defgroup texture Texture Routines
498  *  AllegroGL provides functions to allow using Allegro BITMAP objects to
499  *  be used as OpenGL textures.
500  */
501 /** \{ */
502 /** \name Texture routines
503  *  \{ */
504 AGL_FUNC(int, allegro_gl_use_mipmapping, (int enable));
505 AGL_FUNC(int, allegro_gl_use_alpha_channel, (int enable));
506 AGL_FUNC(int, allegro_gl_flip_texture, (int enable));
507 AGL_FUNC(int, allegro_gl_check_texture, (BITMAP *bmp));
508 AGL_FUNC(int, allegro_gl_check_texture_ex, (int flags, BITMAP *bmp,
509                                        GLint internal_format));
510 AGL_FUNC(GLint, allegro_gl_get_texture_format, (BITMAP *bmp));
511 AGL_FUNC(GLint, allegro_gl_set_texture_format, (GLint format));
512 AGL_FUNC(GLenum, allegro_gl_get_bitmap_type, (BITMAP *bmp));
513 AGL_FUNC(GLenum, allegro_gl_get_bitmap_color_format, (BITMAP *bmp));
514 AGL_FUNC(GLuint, allegro_gl_make_texture, (BITMAP *bmp));
515 AGL_FUNC(GLuint, allegro_gl_make_masked_texture, (BITMAP *bmp));
516 AGL_FUNC(GLuint, allegro_gl_make_texture_ex,(int flags, BITMAP *bmp,
517                                          GLint internal_format));
518 
519 
520 /** AllegroGL will generate mipmaps for this texture.
521  */
522 #define AGL_TEXTURE_MIPMAP      0x01
523 
524 /** Tell AllegroGL that the bitmap had an alpha channel, so it should be
525  *  preserved when generating the texture.
526  */
527 #define AGL_TEXTURE_HAS_ALPHA   0x02
528 
529 /** Flip the texture on the x-axis. OpenGL uses the bottom-left corner of
530  *  the texture as (0,0), so if you need your texture to be flipped to make
531  *  (0,0) the top-left corner, you need to use this flag.
532  */
533 #define AGL_TEXTURE_FLIP        0x04
534 
535 /** Generate an alpha channel for this texture, based on the Allegro mask color.
536  *  Make sure the target format supports an alpha channel.
537  */
538 #define AGL_TEXTURE_MASKED      0x08
539 
540 /** Tell AllegroGL to allow rescaling of the bitmap. By default, AllegroGL
541  *  will not rescale the bitmap to fit into a texture. You can override this
542  *  behavior by using this flag.
543  */
544 #define AGL_TEXTURE_RESCALE     0x10
545 
546 
547 /** Tell AllegroGL that the specified BITMAP is an 8-bpp alpha-only BITMAP.
548  */
549 #define AGL_TEXTURE_ALPHA_ONLY  0x20
550 
551 /** \} */
552 /** \} */
553 
554 
555 
556 /** \addtogroup allegro Allegro Interfacing
557  *
558  * \{ */
559 /** \name Allegro Interfacing routines
560  *  \{ */
561 AGL_FUNC(void, allegro_gl_set_allegro_mode, (void));
562 AGL_FUNC(void, allegro_gl_unset_allegro_mode, (void));
563 AGL_FUNC(void, allegro_gl_set_projection, (void));
564 AGL_FUNC(void, allegro_gl_unset_projection, (void));
565 /** \} */
566 /** \} */
567 
568 
569 
570 /** \defgroup math Math conversion routines
571   * Routines to convert between OpenGL and Allegro math types
572   */
573 /** \{ */
574 
575 /** \name Matrix conversion routines
576  *  \{ */
577 
578 AGL_FUNC(void, allegro_gl_MATRIX_to_GLfloat, (MATRIX *m, GLfloat gl[16]));
579 AGL_FUNC(void, allegro_gl_MATRIX_to_GLdouble, (MATRIX *m, GLdouble gl[16]));
580 AGL_FUNC(void, allegro_gl_MATRIX_f_to_GLfloat, (MATRIX_f *m, GLfloat gl[16]));
581 AGL_FUNC(void, allegro_gl_MATRIX_f_to_GLdouble, (MATRIX_f *m, GLdouble gl[16]));
582 
583 AGL_FUNC(void, allegro_gl_GLfloat_to_MATRIX, (GLfloat gl[16], MATRIX *m));
584 AGL_FUNC(void, allegro_gl_GLdouble_to_MATRIX, (GLdouble gl[16], MATRIX *m));
585 AGL_FUNC(void, allegro_gl_GLfloat_to_MATRIX_f, (GLfloat gl[16], MATRIX_f *m));
586 AGL_FUNC(void, allegro_gl_GLdouble_to_MATRIX_f, (GLdouble gl[16], MATRIX_f *m));
587 
588 /** \} */
589 
590 /** \name Quaternion conversion routines
591  *  \{ */
592 AGL_FUNC(void, allegro_gl_apply_quat, (QUAT *q));
593 AGL_FUNC(void, allegro_gl_quat_to_glrotatef, (QUAT *q, float *angle,
594                                          float *x, float *y, float *z));
595 AGL_FUNC(void, allegro_gl_quat_to_glrotated, (QUAT *q, double *angle,
596                                          double *x, double *y, double *z));
597 /** \} */
598 /** \} */
599 
600 
601 /** \defgroup Text Text drawing and fonts.
602  *
603  *  AllegroGL now provides mechanisms for converting Allegro FONTs to
604  *  a format which is more usable in OpenGL. You can also load system
605  *  fonts (such as Arial and Courrier) and draw using those.
606  *  Allegro FONTs should still work if you use textout, textprintf, etc
607  *  on them. However, converted Allegro FONTs will not work with these
608  *  functions. You will have to use AllegroGL functions to work with
609  *  AllegroGL FONTs.
610  *
611  * \{ */
612 
613 /** \name Text Drawing and Font conversion
614  * \{
615  */
616 
617 
618 /* These define the supported font types */
619 /** Indicates that you don't really care how a font will be converted.
620  *  AGL will pick the best format for you.
621  */
622 #define AGL_FONT_TYPE_DONT_CARE     -1
623 
624 /** Indicates that you want fonts to be converted to a bitmap format.
625  *  Bitmaps are used to represent characters with one bit per pixel,
626  *  and are usually very slow to draw, as they stall the 3D pipeline.
627  *  Note that you can't scale, rotate or place text with a z coordinate
628  *  if you use this style.
629  *  A display list will be created.
630  *
631  *  \sa allegro_gl_convert_allegro_font(), allegro_gl_printf()
632  */
633 #define AGL_FONT_TYPE_BITMAP         0
634 
635 /** Indicates that you want fonts to be converted to an outline format.
636  *  Outlined mode is a vector-style font. Characters are represented by a
637  *  set of polygons and lines. This style of fonts is fast to draw, and can
638  *  be scaled, rotated, etc, since they are just vectors.
639  *  A display list will be created.
640  *
641  *  \deprecated Non-textured fonts will be dropped from AllegroGL.
642  *
643  *  \sa allegro_gl_convert_allegro_font(), allegro_gl_printf()
644  */
645 #define AGL_FONT_TYPE_OUTLINE        1
646 
647 /** Indicates that you want fonts to be converted to a texture format.
648  *  Each character is represented by a textured quad. The texture is
649  *  common for all characters of the same font, and it will automatically be
650  *  uploaded to the video card when needed. Drawing text with this
651  *  type of font is the fastest since only two triangles are needed per
652  *  character. Textured text can also be scaled and rotated.
653  *  A display list will be created.
654  *
655  *  \sa allegro_gl_convert_allegro_font(), allegro_gl_printf()
656  */
657 #define AGL_FONT_TYPE_TEXTURED       2
658 
659 
660 /* These defines the font styles for system generated fonts */
661 /** Creates a font with bold characters. System fonts only.
662  *
663  *  \deprecated Non-textured fonts will be dropped from AllegroGL
664  */
665 #define AGL_FONT_STYLE_BOLD          1
666 
667 /** Creates a font with black (strong bold) characters. System fonts only.
668  *  \deprecated Non-textured fonts will be dropped from AllegroGL.
669  */
670 #define AGL_FONT_STYLE_BLACK         2
671 
672 /** Creates a font with italicized characters. System fonts only.
673  * \deprecated Non-textured fonts will be dropped from AllegroGL.
674  */
675 #define AGL_FONT_STYLE_ITALIC        4
676 
677 /** Creates a font with underlined characters. System fonts only.
678  * \deprecated Non-textured fonts will be dropped from AllegroGL.
679  */
680 #define AGL_FONT_STYLE_UNDERLINE     8
681 
682 /** Creates a font with striked out characters. System fonts only.
683  * \deprecated Non-textured fonts will be dropped from AllegroGL.
684  */
685 #define AGL_FONT_STYLE_STRIKEOUT    16
686 
687 /** Creates a font with anti-aliased characters. System fonts only.
688  * Anti-aliasing may not be available, and no error will be reported
689  * if such is the case.
690  * \deprecated Non-textured fonts will be dropped from AllegroGL.
691  */
692 #define AGL_FONT_STYLE_ANTI_ALIASED 32
693 
694 /** Font generation mode. System fonts only.
695  * Indicates that you want outline system fonts to be generated using polygons.
696  * \deprecated Non-textured fonts will be dropped from AllegroGL.
697  *
698  * \sa allegro_gl_load_system_font(), allegro_gl_load_system_font_ex()
699  */
700 #define AGL_FONT_POLYGONS 1
701 
702 
703 /** Font generation mode. System fonts only.
704  * Indicates that you want outline system fonts to be generated using lines.
705  * \deprecated Non-textured fonts will be dropped from AllegroGL.
706  *
707  * \sa allegro_gl_load_system_font(), allegro_gl_load_system_font_ex()
708  */
709 #define AGL_FONT_LINES    2
710 
711 
712 AGL_FUNC(int, allegro_gl_printf, (AL_CONST FONT *f, float x, float y, float z,
713                              int color, AL_CONST char *format, ...));
714 AGL_FUNC(int, allegro_gl_printf_ex, (AL_CONST FONT *f, float x, float y, float z,
715                              AL_CONST char *format, ...));
716 AGL_FUNC(FONT*, allegro_gl_convert_allegro_font, (FONT *f, int type, float scale));
717 AGL_FUNC(FONT*, allegro_gl_convert_allegro_font_ex, (FONT *f, int type, float scale,
718                                                 GLint format));
719 
720 AGL_FUNC(void, allegro_gl_set_font_generation_mode, (int mode));
721 AGL_FUNC(FONT*, allegro_gl_load_system_font, (char *name, int style, int w, int h));
722 AGL_FUNC(FONT*, allegro_gl_load_system_font_ex, (char *name, int type, int style,
723                                  int w, int h, float depth, int start, int end));
724 AGL_FUNC(void, allegro_gl_destroy_font, (FONT *f));
725 AGL_FUNC(size_t, allegro_gl_list_font_textures, (FONT *f, GLuint *ids, size_t max_num_id));
726 /** \} */
727 /** \} */
728 
729 
730 /** \defgroup extensions OpenGL Extensions
731  * Management of the OpenGL extensions mechanism.
732  * AllegroGL provides two ways to access OpenGL extensions: It's native
733  * extension library and some versatile portable routines.
734  *
735  * If you want to get more control on extensions or if you want to use an
736  * extension that is not supported by AllegroGL then you can use the
737  * routines : allegro_gl_is_extension_supported() and
738  * allegro_gl_get_proc_address(). They provide a way to determine if an
739  * extension is available and to get its address. These routines are available
740  * on every platforms that AllegroGL supports
741  *
742  */
743 /** \{ */
744 /** \name OpenGL Extensions Management Functions
745  *  \{
746  */
747 #if defined DOXYGEN  /* Is this a documentation scan? */
748 /** OpenGL extensions handlers helper.
749  * Defines a function pointer type. This macro is almost equivalent to a
750  * \b typedef. It is intended to hide some platform-specific machinery in
751  * order to keep code portable.
752  *
753  * \sa allegro_gl_get_proc_address()
754  */
755 #define AGL_DEFINE_PROC_TYPE
756 
757 #else
758 
759 AGL_FUNC(int, allegro_gl_is_extension_supported, (const char *));
760 AGL_FUNC(void*, allegro_gl_get_proc_address, (const char *));
761 
762 #if defined ALLEGRO_WINDOWS
763 	#define AGL_DEFINE_PROC_TYPE(type, name, args) \
764 		typedef type (APIENTRY * name) args;
765 #else
766 	#define AGL_DEFINE_PROC_TYPE(type, name, args) \
767 		typedef type (*name) args;
768 #endif
769 
770 #endif
771 /** \} */
772 /** \} */
773 
774 
775 /** \defgroup gui Allegro-compatible GUI routines
776  *  AllegroGL GUI wrappers.
777  *  Due to several specificities of OpenGL, some of the Allegro's GUI routines
778  *  can not be used "as is". Indeed they are not designed to natively support
779  *  double-buffered graphics mode. Hence AllegroGL provides wrapper routines
780  *  of do_dialog, alert and so on...
781  *
782  *  AllegroGL GUI routines internally call allegro_gl_set_allegro_mode() and its
783  *  counterpart allegro_gl_unset_allegro_mode(). So the default drawing mode in
784  *  the GUI routines is the "2D Allegro mode" and functions like line() or
785  *  rect() can safely be called.
786  *
787  *  Additionnaly AllegroGL provides a new GUI object d_algl_viewport_proc()
788  *  which allows to have a 3D viewport that can safely coexist with other
789  *  "classical" 2D GUI objects : no need to call allegro_gl_set_allegro_mode()
790  *  or to save the current state of OpenGL.
791  */
792 /** \{ */
793 AGL_FUNC(int, algl_do_dialog, (DIALOG *dialog, int focus_obj));
794 AGL_FUNC(int, algl_popup_dialog, (DIALOG *dialog, int focus_obj));
795 AGL_FUNC(void, algl_draw_mouse, (void));
796 AGL_FUNC(void, algl_set_mouse_drawer, (void (*user_draw_mouse)(void)));
797 AGL_FUNC(int, algl_alert, (AL_CONST char *s1, AL_CONST char *s2, AL_CONST char *s3,
798                       AL_CONST char *b1, AL_CONST char *b2, int c1, int c2));
799 AGL_FUNC(int, algl_alert3, (AL_CONST char *s1, AL_CONST char *s2, AL_CONST char *s3,
800                        AL_CONST char *b1, AL_CONST char *b2, AL_CONST char *b3,
801                        int c1, int c2, int c3));
802 AGL_FUNC(int, d_algl_viewport_proc, (int msg, DIALOG *d, int c));
803 
804 /** \} */
805 
806 
807 
808 #ifdef __cplusplus
809 }
810 #endif
811 
812 
813 /* Fixes to MS's (or SGI?) broken GL headers */
814 #ifdef GL_VERSION_1_1
815 #ifndef GL_TEXTURE_BINDING_2D
816 
817 #ifdef GL_TEXTURE_2D_BINDING
818 #define GL_TEXTURE_BINDING_2D GL_TEXTURE_2D_BINDING
819 #endif
820 
821 #else
822 
823 #ifdef GL_TEXTURE_BINDING_2D
824 #define GL_TEXTURE_2D_BINDING GL_TEXTURE_BINDING_2D
825 #endif
826 
827 #endif
828 
829 #ifndef GL_TEXTURE_BINDING_2D
830 #warning "GL_TEXTURE_BINDING_2D or GL_TEXTURE_2D_BINDING isn't defined by your"
831 #warning "OpenGL headers. Make sure you have a genuine set of headers for"
832 #warning "OpenGL 1.1 (or greater)"
833 #endif
834 #endif
835 
836 #endif
837 
838