AllegroGL 0.4.4

alleggl.h

Go to the documentation of this file.
00001 
00005 #ifndef _allegrogl_included_alleggl_h
00006 #define _allegrogl_included_alleggl_h
00007 
00008 #include <allegro.h>
00009 
00010 #ifdef ALLEGRO_WINDOWS
00011 
00012 #ifndef WIN32_LEAN_AND_MEAN
00013 #define WIN32_LEAN_AND_MEAN
00014 #define WIN32_LEAN_AND_MEAN_defined
00015 #endif /* WIN32_LEAN_AND_MEAN */
00016 
00017 #ifdef ALLEGRO_DMC
00018 typedef int32_t INT32;
00019 typedef __int64 INT64;
00020 #endif
00021 
00022 #include <winalleg.h>
00023 
00024 #ifdef WIN32_LEAN_AND_MEAN_defined
00025 #undef WIN32_LEAN_AND_MEAN_defined
00026 #undef WIN32_LEAN_AND_MEAN
00027 #endif /* WIN32_LEAN_AND_MEAN_defined */
00028 
00029 #endif /* ALLEGRO_WINDOWS */
00030 
00031 
00032 #if (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS)
00033     #ifdef ALLEGRO_GL_SRC_BUILD
00034         #define _AGL_DLL __declspec(dllexport)
00035     #else
00036         #define _AGL_DLL __declspec(dllimport)
00037     #endif /* ALLEGRO_GL_SRC_BUILD */
00038 #else
00039     #define _AGL_DLL
00040 #endif /* (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS) */
00041 
00042 #define AGL_VAR(type, name) extern _AGL_DLL type name
00043 
00044 #if (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS)
00045     #define AGL_FUNC(type, name, args) extern _AGL_DLL type __cdecl name args
00046 #else
00047     #define AGL_FUNC(type, name, args) extern type name args
00048 #endif /* (defined ALLEGRO_GL_DYNAMIC) && (defined ALLEGRO_WINDOWS) */
00049 
00050 
00051 #ifdef ALLEGRO_MACOSX
00052 
00053 #include <OpenGL/OpenGL.h>
00054 #include <OpenGL/gl.h>
00055 #include <OpenGL/glext.h>
00056 
00057 #ifndef GL_GLEXT_PROTOTYPES
00058 #define GL_GLEXT_PROTOTYPES
00059 #endif
00060 
00061 #else /* ALLEGRO_MACOSX */
00062 
00063 /* HACK: Prevent both Mesa and SGI's broken headers from screwing us */
00064 #define __glext_h_
00065 #define __glxext_h_
00066 #include <GL/gl.h>
00067 #undef  __glext_h_
00068 #undef  __glxext_h_
00069 
00070 #endif /* ALLEGRO_MACOSX */
00071 
00072 
00073 #include "allegrogl/gl_ext.h"
00074 
00075 #ifdef ALLEGRO_WITH_XWINDOWS
00076 #if (ALLEGRO_SUB_VERSION == 2) && (ALLEGRO_WIP_VERSION < 2)
00077 #   ifndef HAVE_LIBPTHREAD
00078 #      error AllegroGL requires Allegro to have pthread support enabled!
00079 #   endif
00080 #else
00081 #   ifndef ALLEGRO_HAVE_LIBPTHREAD
00082 #      error AllegroGL requires Allegro to have pthread support enabled!
00083 #   endif
00084 #endif
00085 #include "allegrogl/alleggl_config.h"
00086 #endif
00087 
00088 
00093 #define AGL_VERSION     0            ///< Major version number
00094 #define AGL_SUB_VERSION 4            ///< Minor version number
00095 #define AGL_WIP_VERSION 4            ///< Work-In-Progress version number
00096 #define AGL_VERSION_STR "0.4.4"      ///< Version description string
00097 
00100 /* Version Check */
00101 #if (ALLEGRO_VERSION < 4 || (ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION < 2))
00102     #error AllegroGL requires Allegro 4.2.0 or later to compile!
00103 #endif
00104 #ifndef GL_VERSION_1_1
00105     #error AllegroGL requires OpenGL 1.1 libraries or later to compile!
00106 #endif
00107 
00108 
00109 #ifdef __cplusplus
00110 extern "C" {
00111 #endif
00112 
00113 #ifdef ALLEGRO_WINDOWS
00114     
00115 /* Missing #defines from Mingw */
00116 #ifndef PFD_SWAP_LAYER_BUFFERS
00117 #define PFD_SWAP_LAYER_BUFFERS  0x00000800
00118 #endif
00119 
00120 #ifndef PFD_GENERIC_ACCELERATED
00121 #define PFD_GENERIC_ACCELERATED 0x00001000
00122 #endif
00123 
00124 #ifndef PFD_SUPPORT_DIRECTDRAW
00125 #define PFD_SUPPORT_DIRECTDRAW  0x00002000
00126 #endif
00127 
00128 #ifndef CDS_FULLSCREEN
00129 #define CDS_FULLSCREEN      0x00000004
00130 #endif
00131 
00132 #ifndef ENUM_CURRENT_SETTINGS
00133 #define ENUM_CURRENT_SETTINGS       ((DWORD)-1)
00134 #endif
00135 
00136 #endif
00137 
00138 
00139 #define AGL_ERROR_SIZE 256
00140 AGL_VAR(char, allegro_gl_error[AGL_ERROR_SIZE]);
00141 
00142 
00152 AGL_FUNC(int, install_allegro_gl, (void));
00153 AGL_FUNC(void, remove_allegro_gl, (void));
00154 
00155 AGL_FUNC(void, allegro_gl_flip, (void));
00156 AGL_FUNC(float, allegro_gl_opengl_version, (void));
00157 
00166 #define allegro_gl_begin() ;
00167 
00176 #define allegro_gl_end() ;
00177 
00189 #define AGL_ALLEGRO_FORMAT  0x00000001
00190 
00195 #define AGL_RED_DEPTH       0x00000002
00196 
00201 #define AGL_GREEN_DEPTH     0x00000004
00202 
00207 #define AGL_BLUE_DEPTH      0x00000008
00208 
00214 #define AGL_ALPHA_DEPTH     0x00000010
00215 
00219 #define AGL_COLOR_DEPTH     0x00000020
00220 
00221 
00227 #define AGL_ACC_RED_DEPTH   0x00000040
00228 
00234 #define AGL_ACC_GREEN_DEPTH 0x00000080
00235 
00236 
00242 #define AGL_ACC_BLUE_DEPTH  0x00000100
00243 
00244 
00250 #define AGL_ACC_ALPHA_DEPTH 0x00000200
00251 
00256 #define AGL_DOUBLEBUFFER    0x00000400
00257 
00265 #define AGL_STEREO          0x00000800
00266 
00267 
00271 #define AGL_AUX_BUFFERS     0x00001000
00272 
00273 
00278 #define AGL_Z_DEPTH         0x00002000
00279 
00280 
00287 #define AGL_STENCIL_DEPTH   0x00004000
00288 
00292 #define AGL_WINDOW_X        0x00008000
00293 
00296 #define AGL_WINDOW_Y        0x00010000
00297 
00306 #define AGL_RENDERMETHOD    0x00020000
00307 
00311 #define AGL_FULLSCREEN      0x00040000
00312 
00316 #define AGL_WINDOWED        0x00080000
00317 
00333 #define AGL_VIDEO_MEMORY_POLICY     0x00100000
00334 
00357 #define AGL_SAMPLE_BUFFERS  0x00200000
00358 
00365 #define AGL_SAMPLES        0x00400000
00366 
00371 #define AGL_FLOAT_COLOR    0x00800000
00372 
00375 #define AGL_FLOAT_Z        0x01000000
00376 
00377 
00378 
00379 /* XXX <rohannessian> I'm reserving 2 bits here for later expansion. DO NOT USE
00380  * without consulting me first.
00381  */
00382 #define AGL_CONFIG_RESRVED 0xA000000
00383 
00384 
00387 #define AGL_DONTCARE   0 ///< Ignore these settings
00388 #define AGL_SUGGEST   -1 ///< Prefer the assigned values for these settings
00389 #define AGL_REQUIRE   -2 ///< Reject other values for these settings
00390 
00395 #define AGL_KEEP    1 ///< Keep internal texture in video memory
00396 #define AGL_RELEASE 2 ///< Release video memory occupied by internal texture
00397 
00402 AGL_FUNC(void, allegro_gl_clear_settings, (void));
00403 AGL_FUNC(void, allegro_gl_set, (int option, int value));
00404 AGL_FUNC(int,  allegro_gl_get, (int option));
00405 AGL_FUNC(void, allegro_gl_save_settings, (void));
00406 AGL_FUNC(void, allegro_gl_load_settings, (void));
00423 #if defined DOXYGEN  /* Is this a documentation scan? */
00424 
00429 # define GFX_OPENGL_WINDOWED
00430 
00431 # define GFX_OPENGL_FULLSCREEN
00432 
00433   #define GFX_OPENGL
00434 
00437 #else
00438 
00439 #if defined ALLEGROGL_GENERIC_DRIVER
00440   /* Allegro is able to determine at run-time if windowed or fullscreen modes
00441      are available */
00442   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
00443   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
00444 
00445 #else
00446 #if defined _WIN32
00447   /* Windows always supports fullscreen */
00448   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
00449   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
00450 
00451 #elif defined ALLEGRO_WITH_XWINDOWS
00452   /* X always supports fullscreen */
00453   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
00454   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
00455   
00456 #elif defined ALLEGRO_MACOSX
00457   /* MacOS X always supports fullscreen */
00458   #define GFX_OPENGL_WINDOWED               AL_ID('O','G','L','W')
00459   #define GFX_OPENGL_FULLSCREEN             AL_ID('O','G','L','F')
00460 
00461 #else
00462   #warning Unknown or unsupported platform.
00463 #endif
00464 #endif
00465 
00466 #define GFX_OPENGL                  AL_ID('O','G','L','D')
00467 
00468 #endif
00469 
00470 
00471 /* Declare graphics driver objects */
00472 extern GFX_DRIVER gfx_allegro_gl_default;
00473 #ifdef GFX_OPENGL_WINDOWED
00474 extern GFX_DRIVER gfx_allegro_gl_windowed;
00475 #endif
00476 #ifdef GFX_OPENGL_FULLSCREEN
00477 extern GFX_DRIVER gfx_allegro_gl_fullscreen;
00478 #endif
00479 
00480 
00488 AGL_FUNC(GLint, allegro_gl_set_video_bitmap_color_depth, (int bpp));
00500 AGL_FUNC(int, allegro_gl_use_mipmapping, (int enable));
00501 AGL_FUNC(int, allegro_gl_use_alpha_channel, (int enable));
00502 AGL_FUNC(int, allegro_gl_flip_texture, (int enable));
00503 AGL_FUNC(int, allegro_gl_check_texture, (BITMAP *bmp));
00504 AGL_FUNC(int, allegro_gl_check_texture_ex, (int flags, BITMAP *bmp,
00505                                        GLint internal_format));
00506 AGL_FUNC(GLint, allegro_gl_get_texture_format, (BITMAP *bmp));
00507 AGL_FUNC(GLint, allegro_gl_set_texture_format, (GLint format));
00508 AGL_FUNC(GLenum, allegro_gl_get_bitmap_type, (BITMAP *bmp));
00509 AGL_FUNC(GLenum, allegro_gl_get_bitmap_color_format, (BITMAP *bmp));
00510 AGL_FUNC(GLuint, allegro_gl_make_texture, (BITMAP *bmp));
00511 AGL_FUNC(GLuint, allegro_gl_make_masked_texture, (BITMAP *bmp));
00512 AGL_FUNC(GLuint, allegro_gl_make_texture_ex,(int flags, BITMAP *bmp,
00513                                          GLint internal_format));
00514 
00515 
00518 #define AGL_TEXTURE_MIPMAP      0x01
00519 
00523 #define AGL_TEXTURE_HAS_ALPHA   0x02
00524 
00529 #define AGL_TEXTURE_FLIP        0x04
00530 
00534 #define AGL_TEXTURE_MASKED      0x08
00535 
00540 #define AGL_TEXTURE_RESCALE     0x10
00541 
00542 
00545 #define AGL_TEXTURE_ALPHA_ONLY  0x20
00546 
00557 AGL_FUNC(void, allegro_gl_set_allegro_mode, (void));
00558 AGL_FUNC(void, allegro_gl_unset_allegro_mode, (void));
00559 AGL_FUNC(void, allegro_gl_set_projection, (void));
00560 AGL_FUNC(void, allegro_gl_unset_projection, (void));
00574 AGL_FUNC(void, allegro_gl_MATRIX_to_GLfloat, (MATRIX *m, GLfloat gl[16]));
00575 AGL_FUNC(void, allegro_gl_MATRIX_to_GLdouble, (MATRIX *m, GLdouble gl[16]));
00576 AGL_FUNC(void, allegro_gl_MATRIX_f_to_GLfloat, (MATRIX_f *m, GLfloat gl[16]));
00577 AGL_FUNC(void, allegro_gl_MATRIX_f_to_GLdouble, (MATRIX_f *m, GLdouble gl[16]));
00578 
00579 AGL_FUNC(void, allegro_gl_GLfloat_to_MATRIX, (GLfloat gl[16], MATRIX *m));
00580 AGL_FUNC(void, allegro_gl_GLdouble_to_MATRIX, (GLdouble gl[16], MATRIX *m));
00581 AGL_FUNC(void, allegro_gl_GLfloat_to_MATRIX_f, (GLfloat gl[16], MATRIX_f *m));
00582 AGL_FUNC(void, allegro_gl_GLdouble_to_MATRIX_f, (GLdouble gl[16], MATRIX_f *m));
00583 
00588 AGL_FUNC(void, allegro_gl_apply_quat, (QUAT *q));
00589 AGL_FUNC(void, allegro_gl_quat_to_glrotatef, (QUAT *q, float *angle,
00590                                          float *x, float *y, float *z));
00591 AGL_FUNC(void, allegro_gl_quat_to_glrotated, (QUAT *q, double *angle,
00592                                          double *x, double *y, double *z));
00614 /* These define the supported font types */
00618 #define AGL_FONT_TYPE_DONT_CARE     -1
00619 
00629 #define AGL_FONT_TYPE_BITMAP         0
00630 
00641 #define AGL_FONT_TYPE_OUTLINE        1
00642 
00653 #define AGL_FONT_TYPE_TEXTURED       2
00654 
00655 
00656 /* These defines the font styles for system generated fonts */
00661 #define AGL_FONT_STYLE_BOLD          1
00662 
00666 #define AGL_FONT_STYLE_BLACK         2
00667 
00671 #define AGL_FONT_STYLE_ITALIC        4
00672 
00676 #define AGL_FONT_STYLE_UNDERLINE     8
00677 
00681 #define AGL_FONT_STYLE_STRIKEOUT    16
00682 
00688 #define AGL_FONT_STYLE_ANTI_ALIASED 32
00689 
00696 #define AGL_FONT_POLYGONS 1
00697 
00698 
00705 #define AGL_FONT_LINES    2
00706 
00707 
00708 AGL_FUNC(int, allegro_gl_printf, (AL_CONST FONT *f, float x, float y, float z,
00709                              int color, AL_CONST char *format, ...));
00710 AGL_FUNC(int, allegro_gl_printf_ex, (AL_CONST FONT *f, float x, float y, float z,
00711                              AL_CONST char *format, ...));
00712 AGL_FUNC(FONT*, allegro_gl_convert_allegro_font, (FONT *f, int type, float scale));
00713 AGL_FUNC(FONT*, allegro_gl_convert_allegro_font_ex, (FONT *f, int type, float scale,
00714                                                 GLint format));
00715 
00716 AGL_FUNC(void, allegro_gl_set_font_generation_mode, (int mode));
00717 AGL_FUNC(FONT*, allegro_gl_load_system_font, (char *name, int style, int w, int h));
00718 AGL_FUNC(FONT*, allegro_gl_load_system_font_ex, (char *name, int type, int style,
00719                                  int w, int h, float depth, int start, int end));
00720 AGL_FUNC(void, allegro_gl_destroy_font, (FONT *f));
00721 AGL_FUNC(size_t, allegro_gl_list_font_textures, (FONT *f, GLuint *ids, size_t max_num_id));
00743 #if defined DOXYGEN  /* Is this a documentation scan? */
00744 
00751 #define AGL_DEFINE_PROC_TYPE
00752 
00753 #else
00754 
00755 AGL_FUNC(int, allegro_gl_is_extension_supported, (const char *));
00756 AGL_FUNC(void*, allegro_gl_get_proc_address, (const char *));
00757 
00758 #if defined ALLEGRO_WINDOWS
00759     #define AGL_DEFINE_PROC_TYPE(type, name, args) \
00760         typedef type (APIENTRY * name) args;
00761 #else
00762     #define AGL_DEFINE_PROC_TYPE(type, name, args) \
00763         typedef type (*name) args;
00764 #endif
00765 
00766 #endif
00767 
00789 AGL_FUNC(int, algl_do_dialog, (DIALOG *dialog, int focus_obj));
00790 AGL_FUNC(int, algl_popup_dialog, (DIALOG *dialog, int focus_obj));
00791 AGL_FUNC(void, algl_draw_mouse, (void));
00792 AGL_FUNC(void, algl_set_mouse_drawer, (void (*user_draw_mouse)(void)));
00793 AGL_FUNC(int, algl_alert, (AL_CONST char *s1, AL_CONST char *s2, AL_CONST char *s3,
00794                       AL_CONST char *b1, AL_CONST char *b2, int c1, int c2));
00795 AGL_FUNC(int, algl_alert3, (AL_CONST char *s1, AL_CONST char *s2, AL_CONST char *s3,
00796                        AL_CONST char *b1, AL_CONST char *b2, AL_CONST char *b3,
00797                        int c1, int c2, int c3));
00798 AGL_FUNC(int, d_algl_viewport_proc, (int msg, DIALOG *d, int c));
00799 
00804 #ifdef __cplusplus
00805 }
00806 #endif
00807 
00808 
00809 /* Fixes to MS's (or SGI?) broken GL headers */
00810 #ifdef GL_VERSION_1_1
00811 #ifndef GL_TEXTURE_BINDING_2D
00812 
00813 #ifdef GL_TEXTURE_2D_BINDING
00814 #define GL_TEXTURE_BINDING_2D GL_TEXTURE_2D_BINDING
00815 #endif
00816 
00817 #else
00818 
00819 #ifdef GL_TEXTURE_BINDING_2D
00820 #define GL_TEXTURE_2D_BINDING GL_TEXTURE_BINDING_2D
00821 #endif
00822 
00823 #endif
00824 
00825 #ifndef GL_TEXTURE_BINDING_2D
00826 #warning "GL_TEXTURE_BINDING_2D or GL_TEXTURE_2D_BINDING isn't defined by your"
00827 #warning "OpenGL headers. Make sure you have a genuine set of headers for"
00828 #warning "OpenGL 1.1 (or greater)"
00829 #endif
00830 #endif
00831 
00832 #endif
00833