OpenGL ES & Mobile Devices
by Richard S. Wright Jr.

Listing One

case WM_CREATE:
    {
    hDisplay = eglGetDisplay(EGL_NO_DISPLAY);
    eglInitialize(hDisplay, NULL, NULL);
    eglChooseConfig(hDisplay, attrs, NULL, 0, &nConfigs);
    pConfigs = (EGLConfig *)malloc(nConfigs * sizeof(EGLConfig));
    eglChooseConfig(hDisplay, attrs, pConfigs, nConfigs, &nConfigs);
    hSurface = eglCreateWindowSurface(hDisplay, *pConfigs, hWnd, NULL);
    hContext = eglCreateContext(hDisplay, *pConfigs, 0, 0);
    eglMakeCurrent(hDisplay, hSurface, hSurface, hContext);
    SetupRC();
    }
case WM_DESTROY:
    ShutdownRC();
    eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, 
         EGL_NO_SURFACE, EGL_NO_CONTEXT);
    eglDestroyContext(hDisplay, hContext);
    eglDestroySurface(hDisplay, hSurface);
    eglTerminate(hDisplay);
    free(pConfigs);
    PostQuitMessage(0);
    break;
case WM_SIZE:
         {
    int iWidth = LOWORD(lParam);
    int iHeight = HIWORD(lParam);
    ChangeSize(iWidth, iHeight);
    }
    break;
case WM_PAINT:
    {
    Render();
    eglSwapBuffers(hDisplay, hSurface);
    InvalidateRect(hWnd, NULL, FALSE);
    }
    break;

============================================


#include <gl/egl.h>
#include <gl/egltypes.h>
#include <gl/gl.h>

============================================

EGLDisplay hDisplay = NULL;
EGLint	attrs[3] = { EGL_DEPTH_SIZE, 16, EGL_NONE };
EGLint	nConfigs;
EGLConfig *pConfigs;
EGLSurface hSurface;
EGLContext hContext;






1


