1 /* ______ ___ ___ 2 * /\ _ \ /\_ \ /\_ \ 3 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ 4 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ 5 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ 6 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ 7 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ 8 * /\____/ 9 * \_/__/ 10 * 11 * Main header file for all OpenGL drivers. 12 * 13 * By Milan Mimica. 14 * 15 */ 16 17 18 #ifndef __al_included_allegro5_allegro_opengl_h 19 #define __al_included_allegro5_allegro_opengl_h 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #if defined(ALLEGRO_WINDOWS) 26 #include <windows.h> 27 #endif 28 29 #if defined ALLEGRO_IPHONE 30 31 #ifdef ALLEGRO_CFG_OPENGLES1 32 #include <OpenGLES/ES1/gl.h> 33 #include <OpenGLES/ES1/glext.h> 34 #elif defined(ALLEGRO_CFG_OPENGLES3) 35 #include <OpenGLES/ES3/gl.h> 36 #include <OpenGLES/ES3/glext.h> 37 #elif defined(ALLEGRO_CFG_OPENGLES2) 38 #include <OpenGLES/ES2/gl.h> 39 #include <OpenGLES/ES2/glext.h> 40 #endif 41 42 #ifdef ALLEGRO_CFG_OPENGLES1 43 /* Apple defines OES versions for these - however the separated alpha ones 44 * don't seem to work on the device and just crash. 45 */ 46 #define glBlendEquation glBlendEquationOES 47 #define glBlendFuncSeparate glBlendFuncSeparateOES 48 #define glBlendEquationSeparate glBlendEquationSeparateOES 49 #define glRenderbufferStorageMultisampleEXT glRenderbufferStorageMultisampleAPPLE 50 #ifdef GL_FUNC_ADD 51 #undef GL_FUNC_ADD 52 #undef GL_FUNC_SUBTRACT 53 #undef GL_FUNC_REVERSE_SUBTRACT 54 #endif 55 #define GL_FUNC_ADD GL_FUNC_ADD_OES 56 #define GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_OES 57 #define GL_FUNC_REVERSE_SUBTRACT GL_FUNC_REVERSE_SUBTRACT_OES 58 59 #elif defined(ALLEGRO_CFG_OPENGLES3) 60 61 #define glRenderbufferStorageMultisampleEXT glRenderbufferStorageMultisample 62 63 #endif 64 65 #elif defined(ALLEGRO_MACOSX) 66 67 #include <OpenGL/OpenGL.h> 68 #include <OpenGL/gl.h> 69 #include <OpenGL/glext.h> 70 71 #ifndef GL_GLEXT_PROTOTYPES 72 #define GL_GLEXT_PROTOTYPES 73 #endif 74 75 #elif defined(ALLEGRO_CFG_OPENGLES1) 76 77 #include <GLES/gl.h> 78 #include <GLES/glext.h> 79 80 #define GL_FUNC_ADD GL_FUNC_ADD_OES 81 #define GL_FUNC_SUBTRACT GL_FUNC_SUBTRACT_OES 82 #define GL_FUNC_REVERSE_SUBTRACT GL_FUNC_REVERSE_SUBTRACT_OES 83 84 #define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_OES 85 #define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES 86 #define GL_RENDERBUFFER_EXT GL_RENDERBUFFER_OES 87 #define glBlendEquation glBlendEquationOES 88 #define glBlendFuncSeparate glBlendFuncSeparateOES 89 #define glBlendEquationSeparate glBlendEquationSeparateOES 90 #define glGenerateMipmapEXT glGenerateMipmapOES 91 #define glBindFramebufferEXT glBindFramebufferOES 92 #define glDeleteFramebuffersEXT glDeleteFramebuffersOES 93 #define GL_DEPTH_COMPONENT16 GL_DEPTH_COMPONENT16_OES 94 #define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES 95 #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES 96 #define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES 97 98 #elif defined(ALLEGRO_CFG_OPENGLES3) 99 100 #include <GLES3/gl3.h> 101 #include <GLES3/gl3ext.h> 102 103 // TODO: should defines from GLES2 be there as well? 104 // TODO: Also, how does it relate to src/opengl/ogl_helpers.h ? 105 106 #define glRenderbufferStorageMultisampleEXT glRenderbufferStorageMultisample 107 108 #elif defined(ALLEGRO_CFG_OPENGLES2) 109 110 #include <GLES2/gl2.h> 111 #include <GLES2/gl2ext.h> 112 113 #define GL_RGBA8 GL_RGBA8_OES 114 115 #define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING 116 #define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER 117 #define glGenerateMipmapEXT glGenerateMipmap 118 #define glBindFramebufferEXT glBindFramebuffer 119 #define glDeleteFramebuffersEXT glDeleteFramebuffers 120 121 #else 122 123 /* HACK: Prevent both Mesa and SGI's broken headers from screwing us */ 124 #define __glext_h_ 125 #define __gl_glext_h_ 126 #define __glxext_h_ 127 #define __glx_glxext_h_ 128 #include <GL/gl.h> 129 #undef __glext_h_ 130 #undef __gl_glext_h_ 131 #undef __glxext_h_ 132 #undef __glx_glxext_h_ 133 134 #endif 135 136 #ifdef ALLEGRO_RASPBERRYPI 137 #include <EGL/egl.h> 138 #include <EGL/eglext.h> 139 #endif 140 141 #include "allegro5/bitmap.h" 142 #include "allegro5/display.h" 143 #include "allegro5/shader.h" 144 #include "allegro5/opengl/gl_ext.h" 145 146 #ifdef ALLEGRO_WINDOWS 147 148 /* Missing #defines from Mingw */ 149 #ifndef PFD_SWAP_LAYER_BUFFERS 150 #define PFD_SWAP_LAYER_BUFFERS 0x00000800 151 #endif 152 153 #ifndef PFD_GENERIC_ACCELERATED 154 #define PFD_GENERIC_ACCELERATED 0x00001000 155 #endif 156 157 #ifndef PFD_SUPPORT_DIRECTDRAW 158 #define PFD_SUPPORT_DIRECTDRAW 0x00002000 159 #endif 160 161 #ifndef CDS_FULLSCREEN 162 #define CDS_FULLSCREEN 0x00000004 163 #endif 164 165 #ifndef ENUM_CURRENT_SETTINGS 166 #define ENUM_CURRENT_SETTINGS ((DWORD)-1) 167 #endif 168 169 #endif /* ALLEGRO_WINDOWS */ 170 171 #if defined ALLEGRO_WINDOWS 172 #define ALLEGRO_DEFINE_PROC_TYPE(type, name, args) \ 173 typedef type (APIENTRY * name) args; 174 #else 175 #define ALLEGRO_DEFINE_PROC_TYPE(type, name, args) \ 176 typedef type (*name) args; 177 #endif 178 179 /* 180 * Public OpenGL-related API 181 */ 182 183 /* ALLEGRO_OPENGL_VARIANT 184 */ 185 typedef enum ALLEGRO_OPENGL_VARIANT { 186 ALLEGRO_DESKTOP_OPENGL = 0, 187 ALLEGRO_OPENGL_ES 188 } ALLEGRO_OPENGL_VARIANT; 189 190 AL_FUNC(uint32_t, al_get_opengl_version, (void)); 191 AL_FUNC(bool, al_have_opengl_extension, (const char *extension)); 192 AL_FUNC(void*, al_get_opengl_proc_address, (const char *name)); 193 AL_FUNC(ALLEGRO_OGL_EXT_LIST*, al_get_opengl_extension_list, (void)); 194 AL_FUNC(GLuint, al_get_opengl_texture, (ALLEGRO_BITMAP *bitmap)); 195 AL_FUNC(void, al_remove_opengl_fbo, (ALLEGRO_BITMAP *bitmap)); 196 AL_FUNC(GLuint, al_get_opengl_fbo, (ALLEGRO_BITMAP *bitmap)); 197 AL_FUNC(bool, al_get_opengl_texture_size, (ALLEGRO_BITMAP *bitmap, 198 int *w, int *h)); 199 AL_FUNC(void, al_get_opengl_texture_position, (ALLEGRO_BITMAP *bitmap, 200 int *u, int *v)); 201 AL_FUNC(GLuint, al_get_opengl_program_object, (ALLEGRO_SHADER *shader)); 202 AL_FUNC(void, al_set_current_opengl_context, (ALLEGRO_DISPLAY *display)); 203 AL_FUNC(int, al_get_opengl_variant, (void)); 204 205 #ifdef __cplusplus 206 } 207 #endif 208 209 #endif 210