From cf90a5c0c173d017a80cde057da57c365b3b1a40 Mon Sep 17 00:00:00 2001
From: Frank Binns <frank.binns@imgtec.com>
Date: Fri, 29 Jun 2012 12:00:26 +0100
Subject: [PATCH 2/2] mesa-demos: Query display for EGL_MESA_screen_surface
 extension before using it

This code makes heavy use of the EGL_MESA_screen_surface extension so 
check the display to determine if it's supported by the underlying EGL 
implementation. If it doesn't then bail.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
---
 src/egl/opengl/demo1.c     |    6 ++++++
 src/egl/opengl/eglscreen.c |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/egl/opengl/demo1.c b/src/egl/opengl/demo1.c
index 3a3564c..06e2138 100644
--- a/src/egl/opengl/demo1.c
+++ b/src/egl/opengl/demo1.c
@@ -110,6 +110,12 @@ 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, NULL, 0, &numConfigs);
    configs = malloc(sizeof(*configs) *numConfigs);
    eglGetConfigs(d, configs, numConfigs, &numConfigs);
diff --git a/src/egl/opengl/eglscreen.c b/src/egl/opengl/eglscreen.c
index 82bb2aa..b7726cb 100644
--- a/src/egl/opengl/eglscreen.c
+++ b/src/egl/opengl/eglscreen.c
@@ -68,6 +68,12 @@ main(int argc, char *argv[])
 	printf("eglscreen: EGL version = %d.%d\n", maj, min);
 	printf("eglscreen: 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);
+	}
+
 #ifdef EGL_MESA_screen_surface
 	/* XXX use ChooseConfig */
 	eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
-- 
1.7.5.4

