1 #if defined(__ANDROID__) || defined(__ODROID__)
8 int eglWidth, eglHeight;
10 #if defined(__ANDROID__)
11 static bool egl_init_display(ANativeWindow* window)
13 static bool egl_init_display(uint window)
16 const EGLint attribs[] =
18 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
22 EGL_DEPTH_SIZE, 16, //24,
23 /*EGL_SAMPLE_BUFFERS, 1,
24 EGL_SAMPLES, 0, //2,*/
33 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
34 eglInitialize(display, 0, 0);
35 eglChooseConfig(display, attribs, &config, 1, &numConfigs);
36 eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
38 surface = eglCreateWindowSurface(display, config, window, null);
39 context = eglCreateContext(display, config, null, null);
41 if(!eglMakeCurrent(display, surface, surface, context))
44 eglQuerySurface(display, surface, EGL_WIDTH, &w);
45 eglQuerySurface(display, surface, EGL_HEIGHT, &h);
53 glEnableClientState(GL_VERTEX_ARRAY);
55 // Initialize GL state.
56 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
57 glEnable(GL_CULL_FACE);
58 glShadeModel(GL_SMOOTH);
59 glDisable(GL_DEPTH_TEST);
61 glDisable(GL_CULL_FACE);
62 glDisable(GL_DEPTH_TEST);
64 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
67 matrixStack[0][0].Identity();
68 matrixStack[1][0].Identity();
69 matrixStack[2][0].Identity();
71 glmsMatrixMode(GL_MODELVIEW);
72 glScaled(1.0, 1.0, -1.0);
73 glmsMatrixMode(GL_PROJECTION);
74 glShadeModel(GL_FLAT);
76 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
77 glFogi(GL_FOG_MODE, GL_EXP);
78 glFogf(GL_FOG_DENSITY, 0);
79 glEnable(GL_NORMALIZE);
82 glDisable(GL_MULTISAMPLE_ARB);
86 glOrtho(0,w,h,0,0.0,1.0);
88 glabCurArrayBuffer = 0;
89 glabCurElementBuffer = 0;
93 static void egl_term_display()
97 glDeleteTextures(1, &stippleTexture);
100 if(eglDisplay != EGL_NO_DISPLAY)
102 eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
103 if(eglContext != EGL_NO_CONTEXT)
104 eglDestroyContext(eglDisplay, eglContext);
105 if(eglSurface != EGL_NO_SURFACE)
106 eglDestroySurface(eglDisplay, eglSurface);
107 eglTerminate(eglDisplay);
109 eglDisplay = EGL_NO_DISPLAY;
110 eglContext = EGL_NO_CONTEXT;
111 eglSurface = EGL_NO_SURFACE;