diff options
author | Keith Whitwell <keithw@vmware.com> | 2009-01-19 10:15:04 +0000 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-01-19 10:15:04 +0000 |
commit | b5db6b039c34117be4e441a2b95abbf97df928c3 (patch) | |
tree | 8efb8698304b70f67cc408e8d12b93ae01a13015 /progs | |
parent | 8f3fac6107460b6d9b011b5c76246468bb16004b (diff) | |
parent | 76753e30781e88912c0465642616ab16bbc1b4f3 (diff) |
Merge commit 'origin/gallium-0.2' into gallium-xlib-rework
Diffstat (limited to 'progs')
-rw-r--r-- | progs/egl/.gitignore | 1 | ||||
-rw-r--r-- | progs/egl/Makefile | 6 | ||||
-rw-r--r-- | progs/egl/eglinfo.c | 6 | ||||
-rw-r--r-- | progs/egl/eglscreen.c | 119 | ||||
-rw-r--r-- | progs/glsl/Makefile | 6 | ||||
-rw-r--r-- | progs/glsl/samplers.c | 12 | ||||
-rw-r--r-- | progs/trivial/SConscript | 1 |
7 files changed, 149 insertions, 2 deletions
diff --git a/progs/egl/.gitignore b/progs/egl/.gitignore index 497b0ebbe3..793c6c0f61 100644 --- a/progs/egl/.gitignore +++ b/progs/egl/.gitignore @@ -3,6 +3,7 @@ demo2 demo3 eglgears eglinfo +eglscreen egltri peglgears xeglgears diff --git a/progs/egl/Makefile b/progs/egl/Makefile index f31c21e87e..e1fdb1ce63 100644 --- a/progs/egl/Makefile +++ b/progs/egl/Makefile @@ -15,6 +15,7 @@ PROGRAMS = \ egltri \ eglinfo \ eglgears \ + eglscreen \ peglgears \ xeglgears \ xegl_tri @@ -69,6 +70,11 @@ eglgears: eglgears.o $(TOP)/$(LIB_DIR)/libEGL.so eglgears.o: eglgears.c $(HEADERS) $(CC) -c $(CFLAGS) -I$(TOP)/include eglgears.c +eglscreen: eglscreen.o $(TOP)/$(LIB_DIR)/libEGL.so + $(CC) $(CFLAGS) $(LDFLAGS) eglscreen.o -L$(TOP)/$(LIB_DIR) -lEGL -lGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@ + +eglscreen.o: eglscreen.c $(HEADERS) + $(CC) -c $(CFLAGS) -I$(TOP)/include eglscreen.c peglgears: peglgears.o $(TOP)/$(LIB_DIR)/libEGL.so $(CC) $(CFLAGS) peglgears.o -L$(TOP)/$(LIB_DIR) -lEGL -lGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@ diff --git a/progs/egl/eglinfo.c b/progs/egl/eglinfo.c index 14620a9759..feae954b75 100644 --- a/progs/egl/eglinfo.c +++ b/progs/egl/eglinfo.c @@ -24,8 +24,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#define EGL_EGLEXT_PROTOTYPES #include <EGL/egl.h> +#include <EGL/eglext.h> #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -35,7 +37,6 @@ #define MAX_MODES 1000 #define MAX_SCREENS 10 - /** * Print table of all available configurations. */ @@ -146,7 +147,8 @@ int main(int argc, char *argv[]) { int maj, min; - EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY); + //EGLDisplay d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915"); + EGLDisplay d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915"); if (!eglInitialize(d, &maj, &min)) { printf("eglinfo: eglInitialize failed\n"); diff --git a/progs/egl/eglscreen.c b/progs/egl/eglscreen.c new file mode 100644 index 0000000000..c0b5a210a4 --- /dev/null +++ b/progs/egl/eglscreen.c @@ -0,0 +1,119 @@ +/* + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Stolen from eglgears + * + * Creates a surface and show that on the first screen + */ + +#define EGL_EGLEXT_PROTOTYPES + +#include <assert.h> +#include <math.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <GL/gl.h> +#include <EGL/egl.h> +#include <EGL/eglext.h> + +#define MAX_CONFIGS 10 +#define MAX_MODES 100 + +int +main(int argc, char *argv[]) +{ + int maj, min; + EGLSurface screen_surf; + EGLConfig configs[MAX_CONFIGS]; + EGLint numConfigs, i; + EGLBoolean b; + EGLDisplay d; + EGLint screenAttribs[10]; + EGLModeMESA mode[MAX_MODES]; + EGLScreenMESA screen; + EGLint count, chosenMode; + EGLint width = 0, height = 0; + + d = eglGetDisplay((EGLNativeDisplayType)"!EGL_i915"); + assert(d); + + if (!eglInitialize(d, &maj, &min)) { + printf("eglscreen: eglInitialize failed\n"); + exit(1); + } + + printf("eglscreen: EGL version = %d.%d\n", maj, min); + printf("eglscreen: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR)); + + /* XXX use ChooseConfig */ + eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); + eglGetScreensMESA(d, &screen, 1, &count); + + if (!eglGetModesMESA(d, screen, mode, MAX_MODES, &count) || count == 0) { + printf("eglscreen: eglGetModesMESA failed!\n"); + return 0; + } + + /* Print list of modes, and find the one to use */ + printf("eglscreen: Found %d modes:\n", count); + for (i = 0; i < count; i++) { + EGLint w, h; + eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w); + eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h); + printf("%3d: %d x %d\n", i, w, h); + if (w > width && h > height) { + width = w; + height = h; + chosenMode = i; + } + } + printf("eglscreen: Using screen mode/size %d: %d x %d\n", chosenMode, width, height); + + /* build up screenAttribs array */ + i = 0; + screenAttribs[i++] = EGL_WIDTH; + screenAttribs[i++] = width; + screenAttribs[i++] = EGL_HEIGHT; + screenAttribs[i++] = height; + screenAttribs[i++] = EGL_NONE; + + screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs); + if (screen_surf == EGL_NO_SURFACE) { + printf("eglscreen: Failed to create screen surface\n"); + return 0; + } + + b = eglShowScreenSurfaceMESA(d, screen, screen_surf, mode[chosenMode]); + if (!b) { + printf("eglscreen: Show surface failed\n"); + return 0; + } + + usleep(5000000); + + eglDestroySurface(d, screen_surf); + eglTerminate(d); + + return 0; +} diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index a39170b8c9..7099eeadbd 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -24,6 +24,7 @@ PROGS = \ points \ pointcoord \ samplers \ + samplers_array \ skinning \ texdemo1 \ toyball \ @@ -166,6 +167,11 @@ samplers.o: samplers.c readtex.h extfuncs.h shaderutil.h samplers: samplers.o readtex.o shaderutil.o $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers.o readtex.o shaderutil.o $(LIBS) -o $@ +samplers_array.o: samplers.c readtex.h extfuncs.h shaderutil.h + $(APP_CC) -c -DSAMPLERS_ARRAY -I$(INCDIR) $(CFLAGS) samplers.c -o samplers_array.o + +samplers_array: samplers_array.o readtex.o shaderutil.o + $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers_array.o readtex.o shaderutil.o $(LIBS) -o $@ skinning.o: skinning.c readtex.h extfuncs.h shaderutil.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) skinning.c diff --git a/progs/glsl/samplers.c b/progs/glsl/samplers.c index d214009729..3fb8577d5e 100644 --- a/progs/glsl/samplers.c +++ b/progs/glsl/samplers.c @@ -245,14 +245,22 @@ GenFragmentShader(GLint numSamplers) int s; p += sprintf(p, "// Generated fragment shader:\n"); +#ifndef SAMPLERS_ARRAY for (s = 0; s < numSamplers; s++) { p += sprintf(p, "uniform sampler2D tex%d;\n", s); } +#else + p += sprintf(p, "uniform sampler2D tex[%d];\n", numSamplers); +#endif p += sprintf(p, "void main()\n"); p += sprintf(p, "{\n"); p += sprintf(p, " vec4 color = vec4(0.0);\n"); for (s = 0; s < numSamplers; s++) { +#ifndef SAMPLERS_ARRAY p += sprintf(p, " color += texture2D(tex%d, gl_TexCoord[0].xy);\n", s); +#else + p += sprintf(p, " color += texture2D(tex[%d], gl_TexCoord[0].xy);\n", s); +#endif } p += sprintf(p, " gl_FragColor = color;\n"); p += sprintf(p, "}\n"); @@ -302,7 +310,11 @@ InitProgram(void) char uname[10]; GLint loc; +#ifndef SAMPLERS_ARRAY sprintf(uname, "tex%d", s); +#else + sprintf(uname, "tex[%d]", s); +#endif loc = glGetUniformLocation_func(Program, uname); assert(loc >= 0); diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript index edb8386c5b..76826d9be0 100644 --- a/progs/trivial/SConscript +++ b/progs/trivial/SConscript @@ -81,6 +81,7 @@ progs = [ 'tri-blend-sub', 'tri-blend', 'tri-clip', + 'tri-clear', 'tri-cull-both', 'tri-cull', 'tri-dlist', |