r600: don't enable depth test if there is no depth buffer
[mesa.git] / progs / egl / demo2.c
index c95aaafa13a4a4dfbfe421649e3b1c9051a8f9f3..b9e92f62ac2eba822a0533d92c638aabef2369cb 100644 (file)
@@ -7,10 +7,11 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
-#include <GLES/egl.h>
-#include <GLES/eglext.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
 #include <GLES/gl.h>
 
 /*#define FRONTBUFFER*/
@@ -110,19 +111,12 @@ main(int argc, char *argv[])
       EGL_HEIGHT, 500,
       EGL_NONE
    };
-   const EGLint screenAttribs[] = {
-      EGL_WIDTH, 1024,
-      EGL_HEIGHT, 768,
-      EGL_NONE
-   };
+   EGLint screenAttribs[32];
    EGLModeMESA mode;
    EGLScreenMESA screen;
    EGLint count;
 
-   /*
    EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-   */
-   EGLDisplay d = eglGetDisplay((EGLNativeDisplayType) "!EGL_i915");
    assert(d);
 
    if (!eglInitialize(d, &maj, &min)) {
@@ -132,6 +126,11 @@ main(int argc, char *argv[])
 
    printf("EGL version = %d.%d\n", maj, min);
    printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
+   if (!strstr(eglQueryString(d, EGL_EXTENSIONS),
+               "EGL_MESA_screen_surface")) {
+      printf("EGL_MESA_screen_surface is not supported\n");
+      exit(1);
+   }
 
    eglGetConfigs(d, configs, 10, &numConfigs);
    printf("Got %d EGL configs:\n", numConfigs);
@@ -146,6 +145,7 @@ main(int argc, char *argv[])
    eglGetScreensMESA(d, &screen, 1, &count);
    eglGetModesMESA(d, screen, &mode, 1, &count);
 
+   eglBindAPI(EGL_OPENGL_API);
    ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
    if (ctx == EGL_NO_CONTEXT) {
       printf("failed to create context\n");
@@ -166,6 +166,13 @@ main(int argc, char *argv[])
 
    b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 
+   i = 0;
+   screenAttribs[i++] = EGL_WIDTH;
+   eglGetModeAttribMESA(d, mode, EGL_WIDTH, &screenAttribs[i++]);
+   screenAttribs[i++] = EGL_HEIGHT;
+   eglGetModeAttribMESA(d, mode, EGL_HEIGHT, &screenAttribs[i++]);
+   screenAttribs[i] = EGL_NONE;
+
    screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
    if (screen_surf == EGL_NO_SURFACE) {
       printf("failed to create screen surface\n");