egl.h revision deceeca18d3a3f18caeac980ad63fafd8bad709c
1#ifndef __egl_h_ 2#define __egl_h_ 3 4/* 5** Copyright 2002-2003 Promoters of the Khronos Group (3Dlabs, ARM Ltd., 6** ATI Technologies, Inc., Discreet, Ericsson Mobile, Imagination 7** Technologies Group plc, Motorola, Inc., Nokia, Silicon Graphics, Inc., 8** SK Telecom, and Sun Microsystems). 9** 10** This document is protected by copyright, and contains information 11** proprietary to The Khronos Group. Any copying, adaptation, distribution, 12** public performance, or public display of this document without the 13** express written consent of the copyright holders is strictly prohibited. 14** The receipt or possession of this document does not convey any rights to 15** reproduce, disclose, or distribute its contents, or to manufacture, use, 16** or sell anything that it may describe, in whole or in part. 17*/ 18 19#include <GLES/gl.h> 20#include <GLES/egltypes.h> 21 22 23/* 24** Versioning and extensions 25*/ 26#define EGL_VERSION_1_0 1 27#define EGL_VERSION_1_1 1 28 29/* 30** Boolean 31*/ 32#define EGL_FALSE 0 33#define EGL_TRUE 1 34 35/* 36** Errors 37*/ 38#define EGL_SUCCESS 0x3000 39#define EGL_NOT_INITIALIZED 0x3001 40#define EGL_BAD_ACCESS 0x3002 41#define EGL_BAD_ALLOC 0x3003 42#define EGL_BAD_ATTRIBUTE 0x3004 43#define EGL_BAD_CONFIG 0x3005 44#define EGL_BAD_CONTEXT 0x3006 45#define EGL_BAD_CURRENT_SURFACE 0x3007 46#define EGL_BAD_DISPLAY 0x3008 47#define EGL_BAD_MATCH 0x3009 48#define EGL_BAD_NATIVE_PIXMAP 0x300A 49#define EGL_BAD_NATIVE_WINDOW 0x300B 50#define EGL_BAD_PARAMETER 0x300C 51#define EGL_BAD_SURFACE 0x300D 52#define EGL_CONTEXT_LOST 0x300E 53/* 0x300F - 0x301F reserved for additional errors. */ 54 55/* 56** Config attributes 57*/ 58#define EGL_BUFFER_SIZE 0x3020 59#define EGL_ALPHA_SIZE 0x3021 60#define EGL_BLUE_SIZE 0x3022 61#define EGL_GREEN_SIZE 0x3023 62#define EGL_RED_SIZE 0x3024 63#define EGL_DEPTH_SIZE 0x3025 64#define EGL_STENCIL_SIZE 0x3026 65#define EGL_CONFIG_CAVEAT 0x3027 66#define EGL_CONFIG_ID 0x3028 67#define EGL_LEVEL 0x3029 68#define EGL_MAX_PBUFFER_HEIGHT 0x302A 69#define EGL_MAX_PBUFFER_PIXELS 0x302B 70#define EGL_MAX_PBUFFER_WIDTH 0x302C 71#define EGL_NATIVE_RENDERABLE 0x302D 72#define EGL_NATIVE_VISUAL_ID 0x302E 73#define EGL_NATIVE_VISUAL_TYPE 0x302F 74/*#define EGL_PRESERVED_RESOURCES 0x3030*/ 75#define EGL_SAMPLES 0x3031 76#define EGL_SAMPLE_BUFFERS 0x3032 77#define EGL_SURFACE_TYPE 0x3033 78#define EGL_TRANSPARENT_TYPE 0x3034 79#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 80#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 81#define EGL_TRANSPARENT_RED_VALUE 0x3037 82#define EGL_NONE 0x3038 /* Also a config value */ 83#define EGL_BIND_TO_TEXTURE_RGB 0x3039 84#define EGL_BIND_TO_TEXTURE_RGBA 0x303A 85#define EGL_MIN_SWAP_INTERVAL 0x303B 86#define EGL_MAX_SWAP_INTERVAL 0x303C 87 88/* 89** Config values 90*/ 91#define EGL_DONT_CARE ((EGLint) -1) 92 93#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */ 94#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* " */ 95#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */ 96#define EGL_NO_TEXTURE 0x305C /* EGL_TEXTURE_FORMAT/TARGET value */ 97#define EGL_TEXTURE_RGB 0x305D /* EGL_TEXTURE_FORMAT value */ 98#define EGL_TEXTURE_RGBA 0x305E /* " */ 99#define EGL_TEXTURE_2D 0x305F /* EGL_TEXTURE_TARGET value */ 100 101/* 102** Config attribute mask bits 103*/ 104#define EGL_PBUFFER_BIT 0x01 /* EGL_SURFACE_TYPE mask bit */ 105#define EGL_PIXMAP_BIT 0x02 /* " */ 106#define EGL_WINDOW_BIT 0x04 /* " */ 107 108/* 109** String names 110*/ 111#define EGL_VENDOR 0x3053 /* eglQueryString target */ 112#define EGL_VERSION 0x3054 /* " */ 113#define EGL_EXTENSIONS 0x3055 /* " */ 114 115/* 116** Surface attributes 117*/ 118#define EGL_HEIGHT 0x3056 119#define EGL_WIDTH 0x3057 120#define EGL_LARGEST_PBUFFER 0x3058 121#define EGL_TEXTURE_FORMAT 0x3080 /* For pbuffers bound as textures */ 122#define EGL_TEXTURE_TARGET 0x3081 /* " */ 123#define EGL_MIPMAP_TEXTURE 0x3082 /* " */ 124#define EGL_MIPMAP_LEVEL 0x3083 /* " */ 125 126/* 127** BindTexImage / ReleaseTexImage buffer target 128*/ 129#define EGL_BACK_BUFFER 0x3084 130 131/* 132** Current surfaces 133*/ 134#define EGL_DRAW 0x3059 135#define EGL_READ 0x305A 136 137/* 138** Engines 139*/ 140#define EGL_CORE_NATIVE_ENGINE 0x305B 141 142/* 0x305C-0x3FFFF reserved for future use */ 143 144/* 145** Functions 146*/ 147#ifdef __cplusplus 148extern "C" { 149#endif 150 151GLAPI EGLint APIENTRY eglGetError (void); 152 153GLAPI EGLDisplay APIENTRY eglGetDisplay (NativeDisplayType display); 154GLAPI EGLBoolean APIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); 155GLAPI EGLBoolean APIENTRY eglTerminate (EGLDisplay dpy); 156GLAPI const char * APIENTRY eglQueryString (EGLDisplay dpy, EGLint name); 157GLAPI void (APIENTRY * eglGetProcAddress (const char *procname))(); 158 159GLAPI EGLBoolean APIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); 160GLAPI EGLBoolean APIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); 161GLAPI EGLBoolean APIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); 162 163GLAPI EGLSurface APIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list); 164GLAPI EGLSurface APIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list); 165GLAPI EGLSurface APIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); 166GLAPI EGLBoolean APIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); 167GLAPI EGLBoolean APIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); 168 169/* EGL 1.1 render-to-texture APIs */ 170GLAPI EGLBoolean APIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); 171GLAPI EGLBoolean APIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); 172GLAPI EGLBoolean APIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); 173 174/* EGL 1.1 swap control API */ 175GLAPI EGLBoolean APIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval); 176 177GLAPI EGLContext APIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list); 178GLAPI EGLBoolean APIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); 179GLAPI EGLBoolean APIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); 180GLAPI EGLContext APIENTRY eglGetCurrentContext (void); 181GLAPI EGLSurface APIENTRY eglGetCurrentSurface (EGLint readdraw); 182GLAPI EGLDisplay APIENTRY eglGetCurrentDisplay (void); 183GLAPI EGLBoolean APIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); 184 185GLAPI EGLBoolean APIENTRY eglWaitGL (void); 186GLAPI EGLBoolean APIENTRY eglWaitNative (EGLint engine); 187GLAPI EGLBoolean APIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface draw); 188GLAPI EGLBoolean APIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target); 189 190#ifdef __cplusplus 191} 192#endif 193 194#endif /* ___egl_h_ */ 195 196 197 198/* usage 199 200 // ---------------------------------------------------------------------- 201 // Initialization 202 // ---------------------------------------------------------------------- 203 204 HDC hdc = GetDC(0); // the screen or window device context, for example 205 206 EGLDisplay display = eglGetDisplay(hdc); 207 208 EGLint major, minor; 209 210 if (!eglInitialize(display, &major, &minor)) { 211 // could not initialize display 212 } 213 214 EGLConfig configs[10]; 215 EGLint matchingConfigs; 216 EGLint attribList[] = { 0 }; // extend this 217 218 if (!eglChooseConfig(display, attribList, &configs, 10, &matchingConfigs)) { 219 // could not choose config 220 } 221 222 if (matchingConfigs < 1) { 223 // did not find a suitable configuration 224 } 225 226 EGLConfig config = configs[0]; // pick any 227 228 EGLSurface surface = eglCreatePbufferSurface(display, config, attribList); 229 230 // test for error 231 232 EGLContext context = eglCreateContext(display, config, 0, attribList); 233 234 // test for error 235 236 // ---------------------------------------------------------------------- 237 // Rendering Loop 238 // ---------------------------------------------------------------------- 239 240 eglMakeCurrent(display, surface, surface, context); 241 242 // actual GL rendering goes here 243 244 eglWait(); 245 eglSwapBuffers(display, surface); 246 247 // ---------------------------------------------------------------------- 248 // Cleanup 249 // ---------------------------------------------------------------------- 250 251 252 if (!eglDestoyContext(display, context)) { 253 // error deallocating context 254 } 255 256 if (!eglDestroySurface(display, surface)) { 257 // error deallocating surface 258 } 259 260 if (!eglTerminate(display)) { 261 // error while cleaning up display 262 } 263 264 265*/ 266