[Piglit] [PATCH 5/7] Remove Glean framework.
Fabian Bieler
fabianbieler at fastmail.fm
Sat Dec 9 12:52:31 UTC 2017
---
tests/CMakeLists.txt | 6 -
tests/glean/CMakeLists.gl.txt | 56 ---
tests/glean/CMakeLists.txt | 1 -
tests/glean/basic.cpp | 64 ---
tests/glean/dsconfig.cpp | 1035 -----------------------------------------
tests/glean/dsconfig.h | 219 ---------
tests/glean/dsfilt.cpp | 707 ----------------------------
tests/glean/dsfilt.h | 276 -----------
tests/glean/dsurf.cpp | 276 -----------
tests/glean/dsurf.h | 103 ----
tests/glean/environ.cpp | 64 ---
tests/glean/environ.h | 76 ---
tests/glean/geomrend.cpp | 499 --------------------
tests/glean/geomrend.h | 146 ------
tests/glean/geomutil.cpp | 204 --------
tests/glean/geomutil.h | 80 ----
tests/glean/gl.cpp | 67 ---
tests/glean/glutils.cpp | 125 -----
tests/glean/glutils.h | 67 ---
tests/glean/glwrap.h | 74 ---
tests/glean/image.h | 238 ----------
tests/glean/image_misc.cpp | 242 ----------
tests/glean/lex.cpp | 169 -------
tests/glean/lex.h | 128 -----
tests/glean/main.cpp | 283 -----------
tests/glean/misc.cpp | 85 ----
tests/glean/misc.h | 50 --
tests/glean/options.cpp | 64 ---
tests/glean/options.h | 89 ----
tests/glean/pack.cpp | 262 -----------
tests/glean/rand.h | 125 -----
tests/glean/rc.cpp | 157 -------
tests/glean/rc.h | 68 ---
tests/glean/reg.cpp | 176 -------
tests/glean/stats.h | 91 ----
tests/glean/tbase.h | 370 ---------------
tests/glean/test.cpp | 83 ----
tests/glean/test.h | 114 -----
tests/glean/tmultitest.cpp | 111 -----
tests/glean/tmultitest.h | 77 ---
tests/glean/unpack.cpp | 271 -----------
tests/glean/version.h | 47 --
tests/glean/winsys.cpp | 255 ----------
tests/glean/winsys.h | 116 -----
44 files changed, 7816 deletions(-)
delete mode 100644 tests/glean/CMakeLists.gl.txt
delete mode 100644 tests/glean/CMakeLists.txt
delete mode 100644 tests/glean/basic.cpp
delete mode 100644 tests/glean/dsconfig.cpp
delete mode 100644 tests/glean/dsconfig.h
delete mode 100644 tests/glean/dsfilt.cpp
delete mode 100644 tests/glean/dsfilt.h
delete mode 100644 tests/glean/dsurf.cpp
delete mode 100644 tests/glean/dsurf.h
delete mode 100644 tests/glean/environ.cpp
delete mode 100644 tests/glean/environ.h
delete mode 100644 tests/glean/geomrend.cpp
delete mode 100644 tests/glean/geomrend.h
delete mode 100644 tests/glean/geomutil.cpp
delete mode 100644 tests/glean/geomutil.h
delete mode 100644 tests/glean/gl.cpp
delete mode 100644 tests/glean/glutils.cpp
delete mode 100644 tests/glean/glutils.h
delete mode 100644 tests/glean/glwrap.h
delete mode 100644 tests/glean/image.h
delete mode 100644 tests/glean/image_misc.cpp
delete mode 100644 tests/glean/lex.cpp
delete mode 100644 tests/glean/lex.h
delete mode 100644 tests/glean/main.cpp
delete mode 100644 tests/glean/misc.cpp
delete mode 100644 tests/glean/misc.h
delete mode 100644 tests/glean/options.cpp
delete mode 100644 tests/glean/options.h
delete mode 100644 tests/glean/pack.cpp
delete mode 100644 tests/glean/rand.h
delete mode 100644 tests/glean/rc.cpp
delete mode 100644 tests/glean/rc.h
delete mode 100644 tests/glean/reg.cpp
delete mode 100644 tests/glean/stats.h
delete mode 100644 tests/glean/tbase.h
delete mode 100644 tests/glean/test.cpp
delete mode 100644 tests/glean/test.h
delete mode 100644 tests/glean/tmultitest.cpp
delete mode 100644 tests/glean/tmultitest.h
delete mode 100644 tests/glean/unpack.cpp
delete mode 100644 tests/glean/version.h
delete mode 100644 tests/glean/winsys.cpp
delete mode 100644 tests/glean/winsys.h
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ae50d0a..2432d37 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -19,12 +19,6 @@ add_subdirectory (fast_color_clear)
add_subdirectory (perf)
add_subdirectory (wgl)
-if (NOT APPLE)
- # glean relies on AGL which is deprecated/broken on recent Mac OS X
- # versions
- add_subdirectory (glean)
-endif ()
-
IF(EGL_FOUND)
add_subdirectory (egl)
ENDIF(EGL_FOUND)
diff --git a/tests/glean/CMakeLists.gl.txt b/tests/glean/CMakeLists.gl.txt
deleted file mode 100644
index bd7e441..0000000
--- a/tests/glean/CMakeLists.gl.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-if (WIN32)
- add_definitions ( -D__WIN__ -D__MS__ )
-elseif (APPLE)
- add_definitions ( -D__AGL__ -D__UNIX__ )
- find_library (CARBON_LIBRARY Carbon)
- set (CMAKE_OSX_ARCHITECTURES i386)
-else ()
- add_definitions ( -D__X11__ -D__UNIX__ )
-endif ()
-
-include_directories(
- ${GLEXT_INCLUDE_DIR}
- ${OPENGL_INCLUDE_PATH}
- ${piglit_SOURCE_DIR}/tests/util
-)
-
-piglit_add_executable (glean
- dsconfig.cpp
- dsfilt.cpp
- dsurf.cpp
- environ.cpp
- geomrend.cpp
- geomutil.cpp
- glutils.cpp
- main.cpp
- misc.cpp
- options.cpp
- rc.cpp
- test.cpp
- tmultitest.cpp
- winsys.cpp
- gl.cpp
- image_misc.cpp
- pack.cpp
- reg.cpp
- unpack.cpp
- basic.cpp
- lex.cpp
- ../util/rgb9e5.c
-)
-
-target_link_libraries (glean
- piglitutil_${piglit_target_api}
- ${OPENGL_gl_LIBRARY}
-)
-
-if (WIN32)
-elseif (APPLE)
- target_link_libraries (glean
- ${CARBON_LIBRARY}
- )
-else ()
- target_link_libraries (glean
- ${X11_X11_LIB}
- )
-endif ()
diff --git a/tests/glean/CMakeLists.txt b/tests/glean/CMakeLists.txt
deleted file mode 100644
index 144a306..0000000
--- a/tests/glean/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-piglit_include_target_api()
diff --git a/tests/glean/basic.cpp b/tests/glean/basic.cpp
deleted file mode 100644
index af317bd..0000000
--- a/tests/glean/basic.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// basic.cpp: basic statistics utilities for glean
-
-#include <cfloat>
-#include <cmath>
-#include "stats.h"
-
-namespace GLEAN {
-
-void
-BasicStats::init() {
- _min = DBL_MAX;
- _max = -DBL_MAX;
- _sum = _sum2 = 0.0;
- _n = 0;
-}
-
-double
-BasicStats::mean() const {return _n? (_sum / _n): 0.0;}
-
-double
-BasicStats::variance() const {
- if (_n < 2)
- return 0.0;
- return (_sum2 - _sum * _sum / _n) / (_n - 1);
- // Not really numerically robust, but good enough for us.
-}
-double
-BasicStats::deviation() const {
- const double v = variance();
- return (v < 0.0)? 0.0: sqrt(v);
-}
-
-} // namespace GLEAN
diff --git a/tests/glean/dsconfig.cpp b/tests/glean/dsconfig.cpp
deleted file mode 100644
index 69b549d..0000000
--- a/tests/glean/dsconfig.cpp
+++ /dev/null
@@ -1,1035 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin All Rights Reserved.
-//
-// multisample changes: Copyright (c) 2008 VMware, Inc. 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-// dsconfig.cpp: Implementation of drawing surface configuration utilities
-#include "dsconfig.h"
-#include <iostream>
-#include <sstream>
-#include <cstring>
-#include <map>
-#include <limits.h>
-
-#ifdef _MSC_VER
-// disable the annoying warning : "forcing value to bool 'true' or 'false' (performance warning)"
-#pragma warning (disable : 4800)
-#endif
-
-
-#include "lex.h"
-
-
-
-namespace {
-
-#ifdef __X11__
-
-bool
-haveGLXExtension(::Display* dpy, const char* extName) {
- const char* extString =
- glXQueryExtensionsString(dpy, DefaultScreen(dpy));
- // We don't cache the result, so that subsequent calls
- // with different values of ``dpy'' will work correctly.
- // Would be nice to improve this, though.
-
- const char* start = extString;
- for (;;) {
- const char* where = strstr(start, extName);
- if (!where)
- return false;
-
- // Make sure we're not fooled by extensions whose names
- // have the desired extName as an initial substring:
- const char* terminator = where + strlen(extName);
- if ((where == start || where[-1] == ' ')
- && (*terminator == ' ' || *terminator == 0))
- return true;
-
- start = terminator;
- }
-
- return false;
-} // haveGLXExtension
-
-#endif
-
-typedef enum { // These variable tags are used as array indices,
- // so they should represent a small dense set of
- // nonnegative integers. 0 is reserved.
- VID = 1,
- VFBCID,
- VCANRGBA,
- VR,
- VG,
- VB,
- VA,
- VCANCI,
- VBUFSIZE,
- VLEVEL,
- VDB,
- VSTEREO,
- VAUX,
- VZ,
- VS,
- VACCUMR,
- VACCUMG,
- VACCUMB,
- VACCUMA,
- VSAMPLES,
- VCANWINDOW,
- VCANPIXMAP,
- VCANPBUFFER,
- VMAXPBUFFERWIDTH,
- VMAXPBUFFERHEIGHT,
- VMAXPBUFFERPIXELS,
- VCANWINSYSRENDER,
- VFAST,
- VCONFORMANT,
- VTRANSPARENT,
- VTRANSR,
- VTRANSG,
- VTRANSB,
- VTRANSA,
- VTRANSI,
- V_LAST
-} CanonVar;
-
-static struct {CanonVar var; const char* name;} varNames[] = {
- {VID, "id"},
- {VFBCID, "fbcID"},
- {VCANRGBA, "canRGBA"},
- {VR, "r"},
- {VG, "g"},
- {VB, "b"},
- {VA, "a"},
- {VCANCI, "canCI"},
- {VBUFSIZE, "bufSize"},
- {VLEVEL, "level"},
- {VDB, "db"},
- {VSTEREO, "stereo"},
- {VAUX, "aux"},
- {VZ, "z"},
- {VS, "s"},
- {VACCUMR, "accumR"},
- {VACCUMG, "accumG"},
- {VACCUMB, "accumB"},
- {VACCUMA, "accumA"},
- {VSAMPLES, "multisample"},
- {VCANWINDOW, "window"},
- {VCANPIXMAP, "pixmap"},
- {VCANPBUFFER, "pBuffer"},
- {VMAXPBUFFERWIDTH, "maxPBufferWidth"},
- {VMAXPBUFFERHEIGHT, "maxPBufferHeight"},
- {VMAXPBUFFERPIXELS, "maxPBufferPixels"},
- {VCANWINSYSRENDER, "winsys"},
- {VFAST, "fast"},
- {VCONFORMANT, "conformant"},
- {VTRANSPARENT, "transparent"},
- {VTRANSR, "transR"},
- {VTRANSG, "transG"},
- {VTRANSB, "transB"},
- {VTRANSA, "transA"},
- {VTRANSI, "transI"}
-};
-
-const char* mapVarToName[V_LAST];
-map<string, CanonVar> mapNameToVar;
-bool mapsInitialized = false;
-
-void
-initializeMaps() {
- for (unsigned i = 0; i < sizeof(varNames)/sizeof(varNames[0]); ++i) {
- mapVarToName[varNames[i].var] = varNames[i].name;
- mapNameToVar[varNames[i].name] = varNames[i].var;
- }
- mapsInitialized = true;
-} // initializeMaps
-
-template<class T> inline T abs(T a) {return (a < 0)? -a: a;}
-
-} // anonymous namespace
-
-
-namespace GLEAN {
-
-// init all config fields to zero
-void
-DrawingSurfaceConfig::zeroFields()
-{
-#if defined(__X11__)
- visID = 0;
-# if defined(GLX_VERSION_1_3)
- fbcID = 0;
-# endif
-#elif defined(__WIN__)
- pfdID = 0;
-#elif defined(__AGL__)
- pfID = 0;
-#else
-# error "what's the config ID?"
-#endif
- canRGBA = 0;
- canCI = 0;
- bufSize = 0;
- level = 0;
- db = 0;
- stereo = 0;
- aux = 0;
- r = 0;
- g = 0;
- b = 0;
- a = 0;
- z = 0;
- s = 0;
- accR = 0;
- accG = 0;
- accB = 0;
- accA = 0;
- samples = 0;
- canWindow = 0;
-#if defined(__X11__)
- canPixmap = 0;
-#if defined(GLX_VERSION_1_3)
- canPBuffer = 0;
- maxPBufferWidth = 0;
- maxPBufferHeight = 0;
- maxPBufferPixels = 0;
-#endif
-#endif
- canWinSysRender = 0;
- fast = 0;
- conformant = 0;
- transparent = 0;
- transR = 0;
- transG = 0;
- transB = 0;
- transA = 0;
- transI = 0;
-}
-
-
-#if defined(__X11__)
-
-DrawingSurfaceConfig::DrawingSurfaceConfig(::Display* dpy, ::XVisualInfo* pvi) {
- if (!mapsInitialized)
- initializeMaps();
-
- int var;
-
- vi = pvi;
- visID = vi->visualid;
-# if defined(GLX_VERSION_1_3)
- fbcID = 0;
-# endif
-
- glXGetConfig(dpy, vi, GLX_RGBA, &var);
- canRGBA = var;
- canCI = !var;
- // There is no dual-personality Visual support in early
- // versions of GLX.
-
- glXGetConfig(dpy, vi, GLX_BUFFER_SIZE, &bufSize);
-
- glXGetConfig(dpy, vi, GLX_LEVEL, &level);
-
- glXGetConfig(dpy, vi, GLX_DOUBLEBUFFER, &var);
- db = var;
-
- glXGetConfig(dpy, vi, GLX_STEREO, &var);
- stereo = var;
-
- glXGetConfig(dpy, vi, GLX_AUX_BUFFERS, &aux);
-
- if (canRGBA) {
- glXGetConfig(dpy, vi, GLX_RED_SIZE, &r);
- glXGetConfig(dpy, vi, GLX_GREEN_SIZE, &g);
- glXGetConfig(dpy, vi, GLX_BLUE_SIZE, &b);
- glXGetConfig(dpy, vi, GLX_ALPHA_SIZE, &a);
- } else
- r = g = b = a = 0;
-
- glXGetConfig(dpy, vi, GLX_DEPTH_SIZE, &z);
-
- glXGetConfig(dpy, vi, GLX_STENCIL_SIZE, &s);
-
- if (canRGBA) {
- glXGetConfig(dpy, vi, GLX_ACCUM_RED_SIZE, &accR);
- glXGetConfig(dpy, vi, GLX_ACCUM_GREEN_SIZE, &accG);
- glXGetConfig(dpy, vi, GLX_ACCUM_BLUE_SIZE, &accB);
- glXGetConfig(dpy, vi, GLX_ACCUM_ALPHA_SIZE, &accA);
- } else
- accR = accG = accB = accA = 0;
-
- // Note that samples=0 means no multisampling!
- // One might think that one sample per pixel means non-multisampling
- // but that's not the convention used here.
- samples = 0;
- if (canRGBA) {
- int sampBuf = 0;
- glXGetConfig(dpy, vi, GLX_SAMPLE_BUFFERS, &sampBuf);
- if (sampBuf) {
- glXGetConfig(dpy, vi, GLX_SAMPLES, &samples);
- }
- }
-
- canWindow = canPixmap = true;
- // Only guaranteed in early versions of GLX.
-
-# if defined(GLX_VERSION_1_3)
- canPBuffer = 0;
- maxPBufferWidth = 0;
- maxPBufferHeight = 0;
- maxPBufferPixels = 0;
-# endif
-
- canWinSysRender = true;
- // Only guaranteed in early versions of GLX.
-
- fast = true;
- conformant = true;
-# if defined(GLX_EXT_visual_rating)
- if (haveGLXExtension(dpy, "GLX_EXT_visual_rating")) {
- glXGetConfig(dpy, vi, GLX_VISUAL_CAVEAT_EXT, &var);
- if (var == GLX_SLOW_VISUAL_EXT)
- fast = false;
- else if (var == GLX_NON_CONFORMANT_VISUAL_EXT)
- conformant = false;
- }
-# endif
-
- transparent = false;
- transR = transG = transB = transA = transI = 0;
-# if defined(GLX_EXT_visual_info)
- if (haveGLXExtension(dpy, "GLX_EXT_visual_info")) {
- glXGetConfig(dpy, vi, GLX_TRANSPARENT_TYPE_EXT, &var);
- if (var == GLX_TRANSPARENT_RGB_EXT) {
- glXGetConfig(dpy, vi,
- GLX_TRANSPARENT_RED_VALUE_EXT, &transR);
- glXGetConfig(dpy, vi,
- GLX_TRANSPARENT_GREEN_VALUE_EXT, &transG);
- glXGetConfig(dpy, vi,
- GLX_TRANSPARENT_BLUE_VALUE_EXT, &transB);
- glXGetConfig(dpy, vi,
- GLX_TRANSPARENT_ALPHA_VALUE_EXT, &transA);
- } else
- glXGetConfig(dpy, vi,
- GLX_TRANSPARENT_INDEX_VALUE_EXT, &transI);
- }
-# endif
-} // DrawingSurfaceConfig::DrawingSurfaceConfig
-
-#if defined(GLX_VERSION_1_3)
-DrawingSurfaceConfig::DrawingSurfaceConfig(::Display* dpy, ::GLXFBConfig* pfbc)
-{
- // silence warnings about unused parameters:
- (void) dpy;
- (void) pfbc;
-
- if (!mapsInitialized)
- initializeMaps();
-// XXX Need to write drawing surface config code for GLX 1.3
- cerr << "GLX 1.3 version of DrawingSurfaceConfig constructor is not"
- "implemented.\n";
-} // DrawingSurfaceConfig::DrawingSurfaceConfig
-#endif
-
-#elif defined(__WIN__)
-
-DrawingSurfaceConfig::DrawingSurfaceConfig(int id, ::PIXELFORMATDESCRIPTOR *ppfd)
-{
- if (!mapsInitialized)
- initializeMaps();
-
- pfd = *ppfd;
- pfdID = id;
-
- canRGBA = pfd.iPixelType == PFD_TYPE_RGBA;
- canCI = pfd.iPixelType == PFD_TYPE_COLORINDEX;
-
- bufSize = pfd.cColorBits + pfd.cAlphaBits;
-
- level = 0;
-
- db = pfd.dwFlags & PFD_DOUBLEBUFFER;
-
- stereo = pfd.dwFlags & PFD_STEREO;
-
- aux = pfd.cAuxBuffers;
-
- if (canRGBA) {
- r = pfd.cRedBits;
- g = pfd.cGreenBits;
- b = pfd.cBlueBits;
- a = pfd.cAlphaBits;
- }
- else
- r = g = b = a = 0;
-
- z = pfd.cDepthBits;
- s = pfd.cStencilBits;
-
- accR = pfd.cAccumRedBits;
- accG = pfd.cAccumGreenBits;
- accB = pfd.cAccumBlueBits;
- accA = pfd.cAccumAlphaBits;
-
- samples = 0; // XXX implement properly for Windows!
-
- canWindow = pfd.dwFlags & PFD_DRAW_TO_WINDOW;
-
- canWinSysRender = pfd.dwFlags & PFD_SUPPORT_GDI;
-
- if (pfd.dwFlags & PFD_GENERIC_FORMAT)
- {
- if (pfd.dwFlags & PFD_GENERIC_ACCELERATED)
- {
- // it's an MCD - at least it has some acceleration
- fast = true;
- }
- else
- {
- // it's software
- fast = false;
- }
- }
- else
- {
- // it's an ICD
- fast = true;
- }
-
- // we'll assume that the OpenGL implementation thinks it is conformant
- conformant = true;
-
- // chromakeying isn't supported
- transparent = false;
- transR = transG = transB = transA = transI = 0;
-}
-#elif defined(__BEWIN__)
-
-DrawingSurfaceConfig::DrawingSurfaceConfig() {
-
- if (!mapsInitialized)
- initializeMaps();
-
- /* these values are estimates for the moment */
- level = 0;
- db = 1;
- stereo =0;
- r = g = b = a = 32;
-
- z = 30;
- accR = 32;
- accG = 32;
- accB = 32;
- accA = 32;
-
- samples = 0;
-
- canWindow = 1;
- canWinSysRender = 1;
-
- // This is a software-mode assumption
- fast = false;
-
- // we'll assume that the OpenGL implementation thinks it is conformant
- conformant = true;
-
- // chromakeying isn't supported
- transparent = false;
- transR = transG = transB = transA = transI = 0;
-}
-
-#elif defined(__AGL__)
-
-DrawingSurfaceConfig::DrawingSurfaceConfig(int id, ::AGLPixelFormat pfd)
-{
- int i;
-
- if (!mapsInitialized)
- initializeMaps();
-
- pf = pfd;
-
- if (aglDescribePixelFormat( pf, AGL_RGBA, &i))
- canRGBA = (i == GL_TRUE);
- canCI = (i == GL_FALSE);
-
- if (aglDescribePixelFormat( pf, AGL_BUFFER_SIZE, &i))
- bufSize = i;
-
- level = 0;
-
- if (aglDescribePixelFormat( pf, AGL_DOUBLEBUFFER, &i))
- db = (i == GL_TRUE);
- if (aglDescribePixelFormat( pf, AGL_STEREO, &i))
- stereo = (i == GL_TRUE);
- if (aglDescribePixelFormat( pf, AGL_AUX_BUFFERS, &i))
- aux = i;
-
- if (canRGBA) {
- aglDescribePixelFormat( pf, AGL_RED_SIZE, &r);
- aglDescribePixelFormat( pf, AGL_GREEN_SIZE, &g);
- aglDescribePixelFormat( pf, AGL_BLUE_SIZE, &b);
- aglDescribePixelFormat( pf, AGL_ALPHA_SIZE, &a);
-
- //this is a workaround for some versions of AGL
- if (r == 10)
- {
- r=g=b=8;
- bufSize = r + g + b + a;
- }
- }
- else
- r = g = b = a = 0;
-
- samples = 0; // XXX implement properly for AGL
-
- aglDescribePixelFormat( pf, AGL_DEPTH_SIZE, & z);
- aglDescribePixelFormat( pf, AGL_STENCIL_SIZE, & s);
-
- aglDescribePixelFormat( pf, AGL_ACCUM_RED_SIZE, & accR);
- aglDescribePixelFormat( pf, AGL_ACCUM_GREEN_SIZE, & accG);
- aglDescribePixelFormat( pf, AGL_ACCUM_BLUE_SIZE, & accB);
- aglDescribePixelFormat( pf, AGL_ACCUM_ALPHA_SIZE, & accA);
-
- aglDescribePixelFormat( pf, AGL_WINDOW, &i);
- canWindow = i;
- aglDescribePixelFormat( pf, AGL_OFFSCREEN, &i);
- canWinSysRender = i;
- aglDescribePixelFormat( pf, AGL_ACCELERATED, & i);
- fast = i;
-
- // we'll assume that the OpenGL implementation thinks it is conformant
- conformant = true;
-
- // chromakeying isn't supported
- transparent = false;
- transR = transG = transB = transA = transI = 0;
-}
-
-#endif
-
-DrawingSurfaceConfig::DrawingSurfaceConfig(string& str) {
- if (!mapsInitialized)
- initializeMaps();
-
- zeroFields();
-
- try {
- Lex lex(str.c_str());
-
- for (lex.next(); lex.token != Lex::END; lex.next()) {
- if (lex.token != Lex::ID)
- throw Syntax("expected variable name",
- lex.position());
- lex.next();
- if (lex.token != Lex::ICONST)
- throw Syntax("expected integer value",
- lex.position());
-
- // Yes, this is an unpleasantly verbose way to
- // handle this problem. However, it will be
- // necessary when we have to deal with attributes
- // that aren't all of a simple integral type.
-
- switch (mapNameToVar[lex.id]) {
- case VID:
-# if defined(__X11__)
- visID = lex.iValue;
-# endif
- break;
- case VFBCID:
-# if defined(GLX_VERSION_1_3)
- fbcID = lex.iValue;
-# endif
- break;
- case VCANRGBA:
- canRGBA = lex.iValue;
- break;
- case VR:
- r = lex.iValue;
- break;
- case VG:
- g = lex.iValue;
- break;
- case VB:
- b = lex.iValue;
- break;
- case VA:
- a = lex.iValue;
- break;
- case VCANCI:
- canCI = lex.iValue;
- break;
- case VBUFSIZE:
- bufSize = lex.iValue;
- break;
- case VLEVEL:
- level = lex.iValue;
- break;
- case VDB:
- db = lex.iValue;
- break;
- case VSTEREO:
- stereo = lex.iValue;
- break;
- case VAUX:
- aux = lex.iValue;
- break;
- case VZ:
- z = lex.iValue;
- break;
- case VS:
- s = lex.iValue;
- break;
- case VACCUMR:
- accR = lex.iValue;
- break;
- case VACCUMG:
- accG = lex.iValue;
- break;
- case VACCUMB:
- accB = lex.iValue;
- break;
- case VACCUMA:
- accA = lex.iValue;
- break;
- case VSAMPLES:
- samples = lex.iValue;
- break;
- case VCANWINDOW:
- canWindow = lex.iValue;
- break;
- case VCANPIXMAP:
-# if defined(__X11__)
- canPixmap = lex.iValue;
-# endif
- break;
- case VCANPBUFFER:
-# if defined(GLX_VERSION_1_3)
- canPBuffer = lex.iValue;
-# endif
- break;
- case VMAXPBUFFERWIDTH:
-# if defined(GLX_VERSION_1_3)
- maxPBufferWidth = lex.iValue;
-# endif
- break;
- case VMAXPBUFFERHEIGHT:
-# if defined(GLX_VERSION_1_3)
- maxPBufferHeight = lex.iValue;
-# endif
- break;
- case VMAXPBUFFERPIXELS:
-# if defined(GLX_VERSION_1_3)
- maxPBufferPixels = lex.iValue;
-# endif
- break;
- case VCANWINSYSRENDER:
- canWinSysRender = lex.iValue;
- break;
- case VFAST:
- fast = lex.iValue;
- break;
- case VCONFORMANT:
- conformant = lex.iValue;
- break;
- case VTRANSPARENT:
- transparent = lex.iValue;
- break;
- case VTRANSR:
- transR = lex.iValue;
- break;
- case VTRANSG:
- transG = lex.iValue;
- break;
- case VTRANSB:
- transB = lex.iValue;
- break;
- case VTRANSA:
- transA = lex.iValue;
- break;
- case VTRANSI:
- transI = lex.iValue;
- break;
- default:
- throw Syntax("unrecognized variable",
- lex.position());
- }
- }
- }
- catch (Lex::Lexical e) {
- throw Syntax(e.err, e.position);
- }
-} // DrawingSurfaceConfing::DrawingSurfaceConfig
-
-
-///////////////////////////////////////////////////////////////////////////////
-// canonicalDescription - return a description string that can be used
-// to reconstruct the essential attributes of a drawing surface
-// configuration. Note that visual ID numbers are included for
-// completeness, but they must be ignored when attempting to compare
-// two surface configurations; there's no guarantee that they'll be
-// valid (or even relevant, since they may have been created on another
-// OS).
-//
-// This is ugly code, but it keeps the names used here and in
-// the string-based constructor for DrawingSurfaceConfig in sync
-// automatically.
-///////////////////////////////////////////////////////////////////////////////
-string
-DrawingSurfaceConfig::canonicalDescription() {
- ostringstream s;
-
-# if defined(__X11__)
- s << mapVarToName[VID] << ' ' << visID;
-# if defined(GLX_VERSION_1_3)
- s << ' ' << mapVarToName[VFBCID] << ' ' << fbcID;
-# endif
-# elif defined(__WIN__)
- s << mapVarToName[VID] << ' ' << pfdID;
-# endif
-
- s << ' ' << mapVarToName[VCANRGBA] << ' ' << canRGBA;
- s << ' ' << mapVarToName[VR] << ' ' << r
- << ' ' << mapVarToName[VG] << ' ' << g
- << ' ' << mapVarToName[VB] << ' ' << b
- << ' ' << mapVarToName[VA] << ' ' << a;
-
- s << ' ' << mapVarToName[VCANCI] << ' ' << canCI;
-
- s << ' ' << mapVarToName[VBUFSIZE] << ' ' << bufSize;
-
- s << ' ' << mapVarToName[VLEVEL] << ' ' << level;
-
- s << ' ' << mapVarToName[VDB] << ' ' << db;
-
- s << ' ' << mapVarToName[VSTEREO] << ' '<< stereo;
-
- s << ' ' << mapVarToName[VAUX] << ' ' << aux;
-
- s << ' ' << mapVarToName[VZ] << ' ' << z;
-
- s << ' ' << mapVarToName[VS] << ' ' << DrawingSurfaceConfig::s;
-
- s << ' ' << mapVarToName[VACCUMR] << ' ' << accR
- << ' ' << mapVarToName[VACCUMG] << ' ' << accG
- << ' ' << mapVarToName[VACCUMB] << ' ' << accB
- << ' ' << mapVarToName[VACCUMA] << ' ' << accA;
-
- s << ' ' << mapVarToName[VSAMPLES] << ' ' << samples;
-
- s << ' ' << mapVarToName[VCANWINDOW] << ' ' << canWindow;
-
-# if defined(__X11__)
- s << ' ' << mapVarToName[VCANPIXMAP] << ' ' << canPixmap;
-
-# if defined(GLX_VERSION_1_3)
- s << ' ' << mapVarToName[VCANPBUFFER] << ' ' << canPBuffer;
- s << ' ' << mapVarToName[VMAXPBUFFERWIDTH] << ' ' << maxPBufferWidth;
- s << ' ' << mapVarToName[VMAXPBUFFERHEIGHT] << ' ' << maxPBufferHeight;
- s << ' ' << mapVarToName[VMAXPBUFFERPIXELS] << ' ' << maxPBufferPixels;
-# endif
-
-# endif
-
- s << ' ' << mapVarToName[VCANWINSYSRENDER] << ' ' << canWinSysRender;
-
- s << ' ' << mapVarToName[VFAST] << ' ' << fast;
-
- s << ' ' << mapVarToName[VCONFORMANT] << ' ' << conformant;
-
- s << ' ' << mapVarToName[VTRANSPARENT] << ' ' << transparent;
- s << ' ' << mapVarToName[VTRANSR] << ' ' << transR
- << ' ' << mapVarToName[VTRANSG] << ' ' << transG
- << ' ' << mapVarToName[VTRANSB] << ' ' << transB
- << ' ' << mapVarToName[VTRANSA] << ' ' << transA
- << ' ' << mapVarToName[VTRANSI] << ' ' << transI;
-
- return s.str();
-} // DrawingSurfaceConfig::canonicalDescription
-
-///////////////////////////////////////////////////////////////////////////////
-// conciseDescription - return a description string that's appropriate for
-// reading by humans, rather than parsing by machine.
-///////////////////////////////////////////////////////////////////////////////
-string
-DrawingSurfaceConfig::conciseDescription() {
- ostringstream s;
-
- if (canRGBA && canCI)
- s << "dual ";
-
- if (canRGBA) {
- if (a) {
- if (r == g && g == b && b == a)
- s << "rgba" << r;
- else
- s << "r" << r << "g" << g << "b" << b
- << "a" << a;
- } else {
- if (r == g && g == b)
- s << "rgb" << r;
- else
- s << "r" << r << "g" << g << "b" << b;
- }
- }
-
- if (canCI) {
- if (canRGBA) s << "+";
- s << "ci" << bufSize;
- }
-
- if (level < 0)
- s << ", underlay";
- else if (level > 0)
- s << ", overlay";
-
- if (db)
- s << ", db";
-
- if (stereo)
- s << ", stereo";
-
- if (aux)
- s << ", aux" << aux;
-
- if (z)
- s << ", z" << z;
-
- if (DrawingSurfaceConfig::s)
- s << ", s" << DrawingSurfaceConfig::s;
-
- if (accR) {
- if (accA) {
- if (accR == accG && accG == accB
- && accB == accA)
- s << ", accrgba" << accR;
- else
- s << ", accr" << accR << "g" << accG
- << "b" << accB << "a" << accA;
- } else {
- if (accR == accG && accG == accB)
- s << ", accrgb" << accR;
- else
- s << ", accr" << accR << "g" << accG
- << "b" << accB;
- }
- }
-
- if (samples) {
- s << ", samples" << samples;
- }
-
- {
- s << ", ";
- bool sep = false;
- if (canWindow) {
- s << "win";
- sep = true;
- }
-# if defined(__X11__)
- if (canPixmap) {
- if (sep)
- s << "+";
- s << "pmap";
- sep = true;
- }
-# endif
-# if defined(GLX_VERSION_1_3)
- if (canPBuffer) {
- if (sep)
- s << "+";
- s << "pbuf";
- }
-# endif
- }
-
- if (!fast)
- s << ", slow";
-
- if (!conformant)
- s << ", nonconformant";
-
- if (transparent) {
- if (canRGBA) {
- s << ", transrgba (" << transR << "," << transG
- << "," << transB << "," << transA << ")";
- }
- if (canCI) {
- s << ", transci (" << transI << ")";
- }
- }
-
-# if defined(__X11__)
- s << ", id " << visID;
-# if defined(GLX_VERSION_1_3)
- if (fbcID)
- s << ", fbcid " << fbcID;
-# endif
-# elif defined(__WIN__)
- s << ", id " << pfdID;
-# endif
-
- return s.str();
-} // DrawingSurfaceConfig::conciseDescription
-
-///////////////////////////////////////////////////////////////////////////////
-// match - select a config that ``matches'' the current config.
-// To keep this problem manageable, we'll assume that both the config
-// to be matched (call it the ``A'' config) and the vector of configs to
-// choose from (call them the ``B'' configs) were selected by a test
-// using a single filter. Thus we can ignore any differences in buffer
-// availability (because we know those are irrelevant to the test), and
-// concentrate on picking configs for which the available buffers are
-// (in some sense) closest in size.
-//
-// This will not be an acceptable solution in all cases, but it should
-// suffice for many.
-///////////////////////////////////////////////////////////////////////////////
-int
-DrawingSurfaceConfig::match(vector<DrawingSurfaceConfig*>& choices) {
- typedef vector<DrawingSurfaceConfig*>::iterator cptr;
-
- // first try finding an exact match
- for (cptr p = choices.begin(); p < choices.end(); ++p) {
- DrawingSurfaceConfig& c = **p;
- if (equal(c)) {
- int pos = static_cast<int>(p - choices.begin());
- return pos;
- }
- }
-
- // next try finding the closest match
- int best = -1;
- int bestError = INT_MAX;
-
- for (cptr p = choices.begin(); p < choices.end(); ++p) {
- DrawingSurfaceConfig& c = **p;
- int error = 0;
-
- if (bufSize && c.bufSize)
- error += abs(bufSize - c.bufSize);
- if (r && c.r)
- error += abs(r - c.r);
- if (g && c.g)
- error += abs(g - c.g);
- if (b && c.b)
- error += abs(b - c.b);
- if (a && c.a)
- error += abs(a - c.a);
- if (z && c.z)
- error += abs(z - c.z);
- if (s && c.s)
- error += abs(s - c.s);
- if (accR && c.accR)
- error += abs(accR - c.accR);
- if (accG && c.accG)
- error += abs(accG - c.accG);
- if (accB && c.accB)
- error += abs(accB - c.accB);
- if (accA && c.accA)
- error += abs(accA - c.accA);
- // Use a huge error value for multisample mismatch.
- // Not sure this is the best solution.
- if (samples != c.samples)
- error += 1000;
-
- if (error < bestError) {
- bestError = error;
- best = static_cast<int>(p - choices.begin());
- }
- }
-
- return best;
-} // DrawingSurfaceConfig::match
-
-// are two surface configs exactly the same?
-bool
-DrawingSurfaceConfig::equal(const DrawingSurfaceConfig &config) const
-{
- if (
-#if defined(__X11__)
- visID == config.visID &&
-# if defined(GLX_VERSION_1_3)
- fbcID == config.fbcID &&
-# endif
-#elif defined(__WIN__)
- pfdID == config.pfdID &&
-#elif defined(__AGL__)
- pfID == config.pfID &&
-#else
-# error "what's the config ID?"
-#endif
- canRGBA == config.canRGBA &&
- canCI == config.canCI &&
- bufSize == config.bufSize &&
- level == config.level &&
- db == config.db &&
- stereo == config.stereo &&
- aux == config.aux &&
- r == config.r &&
- g == config.g &&
- b == config.b &&
- a == config.a &&
- z == config.z &&
- s == config.s &&
- accR == config.accR &&
- accG == config.accG &&
- accB == config.accB &&
- accA == config.accA &&
- samples == config.samples &&
- canWindow == config.canWindow &&
-#if defined(__X11__)
- canPixmap == config.canPixmap &&
-#if defined(GLX_VERSION_1_3)
- canPBuffer == config.canPBuffer &&
- maxPBufferWidth == config.maxPBufferWidth &&
- maxPBufferHeight == config.maxPBufferHeight &&
- maxPBufferPixels == config.maxPBufferPixels &&
-#endif
-#endif
- canWinSysRender == config.canWinSysRender &&
- fast == config.fast &&
- conformant == config.conformant &&
- transparent == config.transparent &&
- transR == config.transR &&
- transG == config.transG &&
- transB == config.transB &&
- transA == config.transA &&
- transI == config.transI
- )
- return true;
- else
- return false;
-}
-
-} // namespace GLEAN
diff --git a/tests/glean/dsconfig.h b/tests/glean/dsconfig.h
deleted file mode 100644
index 8df2abc..0000000
--- a/tests/glean/dsconfig.h
+++ /dev/null
@@ -1,219 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin All Rights Reserved.
-//
-// multisample changes: Copyright (c) 2008 VMware, Inc. 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// dsconfig.h: Drawing surface configuration utilities
-
-// This class abstracts the basic characteristics of drawing surfaces
-// (size, depth, ancillary buffers, etc.) and operations on them. It
-// serves as a wrapper for X11 Visual and FBConfig information on
-// X11-based systems, and PixelFormatDescriptor information on
-// Win32-based systems.
-
-
-#ifndef __dsconfig_h__
-#define __dsconfig_h__
-
-#include <string>
-#include <vector>
-#include "glwrap.h"
-
-using namespace std;
-
-namespace GLEAN {
-
-class DrawingSurfaceConfig {
- public:
-
- // Constructors/Destructor:
-
-# if defined(__X11__)
- DrawingSurfaceConfig(::Display* dpy, ::XVisualInfo* pvi);
-# if defined(GLX_VERSION_1_3)
- DrawingSurfaceConfig(::Display* dpy, ::GLXFBConfig* pfbc);
-# endif
-# elif defined(__WIN__)
- DrawingSurfaceConfig(int id, ::PIXELFORMATDESCRIPTOR *ppfd);
-# elif defined(__BEWIN__)
- DrawingSurfaceConfig();
-# elif defined(__AGL__)
- DrawingSurfaceConfig(int id, ::AGLPixelFormat pfd);
-# endif
-
- DrawingSurfaceConfig(string& s); // s is a canonical description
-
- // Exceptions:
-
- struct Error { }; // Base class for errors.
- struct Syntax: public Error { // Syntax error in constructor string.
- const char* err;
- int position;
- Syntax(const char* e, int p) {
- err = e;
- position = p;
- }
- };
-
- // Attributes:
-
-# if defined(__X11__)
- ::XVisualInfo* vi; // XVisualInfo pointer
- ::XID visID; // Visual ID.
-# if defined(GLX_VERSION_1_3)
- ::GLXFBConfig* fbc;
- ::XID fbcID; // Framebuffer Config ID.
-# endif
-# elif defined(__WIN__)
- ::PIXELFORMATDESCRIPTOR pfd;
- int pfdID;
-# elif defined(__AGL__)
- AGLPixelFormat pf;
- int pfID;
-# endif
-
- bool canRGBA; // Can be used with RGBA contexts.
-
- bool canCI; // Can be used with color index
- // contexts.
-
- int bufSize; // Total depth of color buffer.
-
- int level; // Framebuffer level.
- // (<0 for underlay, 0 for main,
- // >0 for overlay)
-
- bool db; // True if double buffered.
-
- bool stereo; // True if stereo-capable.
-
- int aux; // Number of aux color buffers.
-
- int r; // Depth of red channel.
-
- int g; // Depth of green channel.
-
- int b; // Depth of blue channel.
-
- int a; // Depth of alpha channel.
-
- int z; // Depth of ``z'' (depth) buffer.
-
- int s; // Depth of stencil buffer.
-
- int accR; // Depth of accum buf red channel.
-
- int accG; // Depth of accum buf green channel.
-
- int accB; // Depth of accum buf blue channel.
-
- int accA; // Depth of accum buf alpha channel.
-
- int samples; // Number of samples per pixel.
- // Zero indicates a non-ms config.
-
- bool canWindow; // True if can be used for windows.
-
-# if defined(__X11__)
- bool canPixmap; // True if can be used for pixmaps.
-# if defined(GLX_VERSION_1_3)
- bool canPBuffer; // True if can be used for pbuffers.
-
- int maxPBufferWidth; // Maximum width of PBuffer that
- // may be created with this config.
-
- int maxPBufferHeight; // Maximum height of PBuffer that
- // may be created with this config.
-
- int maxPBufferPixels; // Maximum size (in pixels) of
- // PBuffer that may be created with
- // this config.
-# endif
-# endif
-
- bool canWinSysRender; // True if the native window system
- // can render to a drawable created
- // with this config.
-
- bool fast; // True if config is probably
- // hardware accelerated. (On GLX,
- // it must not be marked ``slow.'')
-
- bool conformant; // True if config is advertised as
- // conforming to the OpenGL spec.
-
- bool transparent; // True if config has some pixel value
- // that is transparent (e.g., for
- // overlays).
-
- int transR; // Transparent color red value.
-
- int transG; // Transparent color green value.
-
- int transB; // Transparent color blue value.
-
- int transA; // Transparent color alpha value.
-
- int transI; // Transparent color index value.
-
- // Utilities:
-
- void zeroFields();
-
- string canonicalDescription();
- // Return a string containing all the attributes in a
- // drawing surface configuration. This allows the config
- // to be stored and recreated (essentially for use by
- // configuration-matching algorithms in test result
- // comparisons).
-
- string conciseDescription();
- // Return a description string that elides default
- // attribute values and expresses some attributes in
- // compressed form. Intended to be more easily readable
- // for humans than the canonical description, at the
- // cost of some ambiguity.
-
- int match(vector<DrawingSurfaceConfig*>& choices);
- // Find the index of the config from ``choices'' that most
- // closely matches the config specified by ``*this''.
- // The matching scheme is heuristic, but intended to
- // be good enough that test results for configs on one
- // machine may be compared with test results for
- // configs on another machine.
-
- bool equal(const DrawingSurfaceConfig &config) const;
-
-}; // class DrawingSurfaceConfig
-
-} // namespace GLEAN
-
-#endif // __dsconfig_h__
diff --git a/tests/glean/dsfilt.cpp b/tests/glean/dsfilt.cpp
deleted file mode 100644
index 015aa64..0000000
--- a/tests/glean/dsfilt.cpp
+++ /dev/null
@@ -1,707 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin All Rights Reserved.
-//
-// multisample changes: Copyright (c) 2008 VMware, Inc. 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// dsfilt.cpp: Implementation of drawing surface configuration filtering
-
-#include <iostream>
-#include <ctype.h>
-#include <stdlib.h>
-#include <algorithm>
-#include "dsfilt.h"
-#include "dsconfig.h"
-
-namespace GLEAN {
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructor:
-///////////////////////////////////////////////////////////////////////////////
-DrawingSurfaceFilter::DrawingSurfaceFilter(const string& s):
- lex(s.c_str(), true) {
-
- if (!varTableInitialized)
- InitVarTable();
-
- try {
- GetSymbol();
- if (!ParseCriteria())
- throw Syntax("no criteria found", lex.position());
- }
- catch (Lex::Lexical e) {
- throw Syntax(e.err, e.position);
- }
-
- // Make the final sort in order of increasing ID number:
- EmitKey(MIN);
- EmitKey(VAR_ID);
-# if defined(GLX_VERSION_1_3)
- EmitKey(MIN);
- EmitKey(VAR_FBCID);
-# endif
-} // DrawingSurfaceFilter::DrawingSurfaceFilter
-
-///////////////////////////////////////////////////////////////////////////////
-// matches - determine if a drawing surface config matches the specified
-// criteria
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::matches(DrawingSurfaceConfig& c) {
- // Process the RPN expression in ``condition'', using the supplied
- // drawing surface configuration to determine values of variables.
-
- vector<int> stack;
-
- for (vector<int>::const_iterator p = condition.begin();
- p < condition.end(); ++p) {
- int right;
-
- switch (*p) {
- case ADD:
- right = stack.back(); stack.pop_back();
- stack.back() += right;
- break;
- case AND:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() && right;
- break;
- case DIV:
- right = stack.back(); stack.pop_back();
- stack.back() = (right == 0)? 0: stack.back() / right;
- break;
- case EQ:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() == right;
- break;
- case GE:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() >= right;
- break;
- case GT:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() > right;
- break;
- case LE:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() <= right;
- break;
- case LT:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() < right;
- break;
- case MOD:
- right = stack.back(); stack.pop_back();
- stack.back() = (right == 0)? 0: stack.back() % right;
- break;
- case MUL:
- right = stack.back(); stack.pop_back();
- stack.back() *= right;
- break;
- case NE:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() != right;
- break;
- case NEGATE:
- stack.back() = -stack.back();
- break;
- case NOT:
- stack.back() = !stack.back();
- break;
- case OR:
- right = stack.back(); stack.pop_back();
- stack.back() = stack.back() || right;
- break;
- case SUB:
- right = stack.back(); stack.pop_back();
- stack.back() -= right;
- break;
- case CONSTANT:
- stack.push_back(*++p);
- break;
- default:
- // Must be a variable.
- stack.push_back(FetchVariable(c,
- static_cast<Token>(*p)));
- break;
- }
- }
-
- return stack.back();
-} // DrawingSurfaceFilter::matches
-
-///////////////////////////////////////////////////////////////////////////////
-// filter - find and sort all matching drawing surface configurations
-///////////////////////////////////////////////////////////////////////////////
-vector<DrawingSurfaceConfig*>
-DrawingSurfaceFilter::filter(vector<DrawingSurfaceConfig*>& v) {
- return filter(v, ~0u);
-} // DrawingSurfaceFilter::filter
-
-///////////////////////////////////////////////////////////////////////////////
-// filter - filter as above, but limit number of results
-///////////////////////////////////////////////////////////////////////////////
-vector<DrawingSurfaceConfig*>
-DrawingSurfaceFilter::filter(vector<DrawingSurfaceConfig*>& v,
- unsigned int maxConfigs) {
- vector<DrawingSurfaceConfig*> result;
- unsigned count = 0;
- for (vector<DrawingSurfaceConfig*>::const_iterator p = v.begin();
- p < v.end() && count < maxConfigs; ++p) {
- if (matches(**p)) {
- result.push_back(*p);
- count++;
- }
- }
-
- sort(result.begin(), result.end(), ConfigSort(sortKeys));
- return result;
-} // DrawingSurfaceFilter::filter
-
-///////////////////////////////////////////////////////////////////////////////
-// ConfigSort operator() - sort comparison for final ordering of configurations
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ConfigSort::operator()
- (const DrawingSurfaceConfig* c1, const DrawingSurfaceConfig* c2) {
- for (vector<Token>::const_iterator p=keys.begin(); p<keys.end(); ++p) {
- Token dir = *p++;
- int d = FetchVariable(*c1, *p) - FetchVariable(*c2, *p);
- if (dir == MAX) // sort largest first?
- d = -d;
- if (d < 0)
- return true; // c1 goes before c2
- if (d > 0)
- return false; // c1 goes after c2
- }
- return false; // order doesn't matter
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// InitVarTable - initialize the table mapping variable names to token values
-///////////////////////////////////////////////////////////////////////////////
-
-map<string,DrawingSurfaceFilter::Token> DrawingSurfaceFilter::varTable;
-bool DrawingSurfaceFilter::varTableInitialized;
-
-void
-DrawingSurfaceFilter::InitVarTable() {
- varTable["r"] = VAR_R;
- varTable["g"] = VAR_G;
- varTable["b"] = VAR_B;
- varTable["a"] = VAR_A;
- varTable["rgb"] = VAR_RGB;
- varTable["rgba"] = VAR_RGBA;
- varTable["ci"] = VAR_CI;
- varTable["accumr"] = VAR_ACCUM_R;
- varTable["accumg"] = VAR_ACCUM_G;
- varTable["accumb"] = VAR_ACCUM_B;
- varTable["accuma"] = VAR_ACCUM_A;
- varTable["accumrgb"] = VAR_ACCUM_RGB;
- varTable["accumrgba"] = VAR_ACCUM_RGBA;
- varTable["samples"] = VAR_SAMPLES;
- varTable["aux"] = VAR_AUX;
- varTable["db"] = VAR_DB;
- varTable["sb"] = VAR_SB;
- varTable["id"] = VAR_ID;
- varTable["fbcid"] = VAR_FBCID;
- varTable["level"] = VAR_LEVEL;
- varTable["main"] = VAR_MAIN;
- varTable["overlay"] = VAR_OVERLAY;
- varTable["underlay"] = VAR_UNDERLAY;
- varTable["mono"] = VAR_MONO;
- varTable["stereo"] = VAR_STEREO;
- varTable["ms"] = VAR_MS;
- varTable["s"] = VAR_S;
- varTable["z"] = VAR_Z;
- varTable["fast"] = VAR_FAST;
- varTable["conformant"] = VAR_CONFORMANT;
- varTable["transparent"] = VAR_TRANSPARENT;
- varTable["transr"] = VAR_TRANS_R;
- varTable["transg"] = VAR_TRANS_G;
- varTable["transb"] = VAR_TRANS_B;
- varTable["transa"] = VAR_TRANS_A;
- varTable["transci"] = VAR_TRANS_CI;
- varTable["window"] = VAR_WINDOW;
- varTable["pbuffer"] = VAR_PBUFFER;
- varTable["pixmap"] = VAR_PIXMAP;
- varTable["glonly"] = VAR_GL_ONLY;
- varTable["max"] = MAX;
- varTable["min"] = MIN;
-
- varTableInitialized = true;
-} // DrawingSurfaceFilter::InitVarTable
-
-///////////////////////////////////////////////////////////////////////////////
-// FetchVariable - fetch the value of a variable from a
-// DrawingSurfaceConfig
-///////////////////////////////////////////////////////////////////////////////
-
-int
-DrawingSurfaceFilter::FetchVariable(const DrawingSurfaceConfig& c, Token v) {
- switch (v) {
- case VAR_R:
- return c.r;
- case VAR_G:
- return c.g;
- case VAR_B:
- return c.b;
- case VAR_A:
- return c.a;
- case VAR_RGB:
- return min(c.r, min(c.g, c.b));
- case VAR_RGBA:
- return min(c.r, min(c.g, min(c.b, c.a)));
-
- case VAR_CI:
- return c.canCI? c.bufSize: 0;
-
- case VAR_ACCUM_R:
- return c.accR;
- case VAR_ACCUM_G:
- return c.accG;
- case VAR_ACCUM_B:
- return c.accB;
- case VAR_ACCUM_A:
- return c.accA;
- case VAR_ACCUM_RGB:
- return min(c.accR, min(c.accG, c.accB));
- case VAR_ACCUM_RGBA:
- return min(c.accR, min(c.accG, min(c.accB, c.accA)));
-
- case VAR_SAMPLES:
- return c.samples;
-
- case VAR_AUX:
- return c.aux;
-
- case VAR_DB:
- return c.db;
- case VAR_SB:
- return !c.db;
-
- case VAR_ID:
-# if defined(__X11__)
- return c.visID;
-# elif defined(__WIN__)
- return c.pfdID;
-# endif
- case VAR_FBCID:
-# if defined(GLX_VERSION_1_3)
- return c.fbcID;
-# else
- return 0;
-# endif
-
- case VAR_LEVEL:
- return c.level;
- case VAR_MAIN:
- return c.level == 0;
- case VAR_OVERLAY:
- return c.level > 0;
- case VAR_UNDERLAY:
- return c.level < 0;
-
- case VAR_MONO:
- return !c.stereo;
- break;
- case VAR_STEREO:
- return c.stereo;
-
- case VAR_MS:
- // XXX Can't support this at the moment; have no way to
- // compile or test.
- return 0;
-
- case VAR_S:
- return c.s;
-
- case VAR_Z:
- return c.z;
-
- case VAR_FAST:
- return c.fast;
- case VAR_CONFORMANT:
- return c.conformant;
-
- case VAR_TRANSPARENT:
- return c.transparent;
- case VAR_TRANS_R:
- return c.transR;
- case VAR_TRANS_G:
- return c.transG;
- case VAR_TRANS_B:
- return c.transB;
- case VAR_TRANS_A:
- return c.transA;
- case VAR_TRANS_CI:
- return c.transI;
-
- case VAR_WINDOW:
- return c.canWindow;
- case VAR_PBUFFER:
-# if defined(GLX_VERSION_1_3)
- return c.canPBuffer;
-# else
- return 0;
-# endif
- case VAR_PIXMAP:
-# if defined(__X11__)
- return c.canPixmap;
-# else
- return 0;
-# endif
-
- case VAR_GL_ONLY:
- return !c.canWinSysRender;
-
- default:
- throw InternalError();
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// GetSymbol - Fetch next symbol from the input string
-///////////////////////////////////////////////////////////////////////////////
-void
-DrawingSurfaceFilter::GetSymbol() {
- lex.next();
- switch(lex.token) {
- case Lex::ID:
- Symbol = varTable[lex.id];
- // Note: Because ERROR has value zero in the
- // Token enumeration, if the user provides a
- // variable that is not in varTable, then Symbol
- // will be set to ERROR.
- if (Symbol == ERROR)
- throw Syntax("unrecognized variable", lex.position());
- break;
- case Lex::ICONST:
- Value = lex.iValue;
- Symbol = CONSTANT;
- break;
- case Lex::OR_OR:
- Symbol = OR;
- break;
- case Lex::AND_AND:
- Symbol = AND;
- break;
- case Lex::LE:
- Symbol = LE;
- break;
- case Lex::LT:
- Symbol = LT;
- break;
- case Lex::GE:
- Symbol = GE;
- break;
- case Lex::GT:
- Symbol = GT;
- break;
- case Lex::EQ:
- Symbol = EQ;
- break;
- case Lex::NE:
- Symbol = NE;
- break;
- case Lex::BANG:
- Symbol = NOT;
- break;
- case Lex::PLUS:
- Symbol = ADD;
- break;
- case Lex::MINUS:
- Symbol = SUB;
- break;
- case Lex::STAR:
- Symbol = MUL;
- break;
- case Lex::SLASH:
- Symbol = DIV;
- break;
- case Lex::PERCENT:
- Symbol = MOD;
- break;
- case Lex::COMMA:
- Symbol = SEPARATOR;
- break;
- case Lex::LPAREN:
- Symbol = LPAREN;
- break;
- case Lex::RPAREN:
- Symbol = RPAREN;
- break;
- case Lex::END:
- Symbol = END;
- break;
- default:
- throw Syntax("unrecognized symbol", lex.position());
- }
-
- return;
-} // DrawingSurfaceFilter::GetSymbol
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseArithExpr
-// Syntax: arithExpr -> arithTerm {('+'|'-') arithTerm}
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseArithExpr() {
- if (!ParseArithTerm())
- return false;
-
- for (;;) {
- if (Symbol == ADD || Symbol == SUB) {
- Token op = Symbol;
- GetSymbol();
- if (!ParseArithTerm())
- throw Syntax("missing operand of + or -",
- lex.position());
- Emit(op);
- } else
- return true;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseArithFactor
-// Syntax: arithFactor -> ['+'|'-'|'!'] arithPrimary
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseArithFactor() {
- if (Symbol == ADD || Symbol == SUB || Symbol == NOT) {
- Token op = Symbol;
- GetSymbol();
- if (!ParseArithPrimary())
- throw Syntax("missing operand of unary +, -, or !",
- lex.position());
- if (op == SUB)
- Emit(NEGATE);
- else if (op == NOT)
- Emit(NOT);
- return true;
- }
-
- return ParseArithPrimary();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseArithPrimary
-// Syntax: arithPrimary -> variable | constant | '(' expression ')'
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseArithPrimary() {
- if (FIRST_VAR < Symbol && Symbol < LAST_VAR) {
- Emit(Symbol);
- GetSymbol();
- return true;
- }
-
- if (Symbol == CONSTANT) {
- Emit(CONSTANT);
- Emit(Value);
- GetSymbol();
- return true;
- }
-
- if (Symbol == LPAREN) {
- GetSymbol();
- if (!ParseExpression())
- throw Syntax("missing expression after (",
- lex.position());
- if (Symbol == RPAREN) {
- GetSymbol();
- return true;
- } else
- throw Syntax("missing )", lex.position());
- }
-
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseArithTerm
-// Syntax: arithTerm -> arithFactor {('*'|'/'|'%') arithFactor}
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseArithTerm() {
- if (!ParseArithFactor())
- return false;
-
- for (;;) {
- if (Symbol == MUL
- || Symbol == DIV
- || Symbol == MOD) {
- Token op = Symbol;
- GetSymbol();
- if (!ParseArithFactor())
- throw Syntax("missing operand of *, /, or %",
- lex.position());
- Emit(op);
- } else
- return true;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseBoolFactor
-// Syntax: boolFactor -> arithExpr [('<'|'>'|'<='|'>='|'=='|'!=') arithExpr]
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseBoolFactor() {
- if (!ParseArithExpr())
- return false;
-
- if (Symbol == LT
- || Symbol == GT
- || Symbol == LE
- || Symbol == GE
- || Symbol == EQ
- || Symbol == NE) {
- Token op = Symbol;
- GetSymbol();
- if (!ParseArithExpr())
- throw Syntax("missing operand of comparison",
- lex.position());
- Emit(op);
- }
-
- return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseBoolTerm
-// Syntax: boolTerm -> boolFactor {'&&' boolFactor}
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseBoolTerm() {
- if (!ParseBoolFactor())
- return false;
-
- for (;;) {
- if (Symbol == AND) {
- GetSymbol();
- if (!ParseBoolFactor())
- throw Syntax("missing operand of &&",
- lex.position());
- Emit(AND);
- } else
- return true;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseCriteria
-// Syntax: criteria -> criterion {',' criterion}
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseCriteria() {
- /* Process all the user-specified conditions and sort keys: */
- if (!ParseCriterion())
- return false;
-
- for (;;) {
- if (Symbol == SEPARATOR) {
- GetSymbol();
- if (!ParseCriterion())
- throw Syntax("missing criterion after comma",
- lex.position());
- Emit(AND);
- } else if (Symbol == END)
- return true;
- else
- throw Syntax("expected comma or end of criteria",
- lex.position());
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseCriterion
-// Syntax: criterion -> sortKey | expression
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseCriterion() {
- if (ParseSortKey())
- return true;
- return ParseExpression();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseExpression
-// Syntax: expression -> boolTerm {'||' boolTerm}
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseExpression() {
- if (!ParseBoolTerm())
- return false;
-
- for (;;) {
- if (Symbol == OR) {
- GetSymbol();
- if (!ParseBoolTerm())
- throw Syntax("missing operand of ||",
- lex.position());
- Emit(OR);
- } else
- return true;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ParseSortKey
-// Syntax: sortKey -> ('max'|'min') variable
-///////////////////////////////////////////////////////////////////////////////
-bool
-DrawingSurfaceFilter::ParseSortKey() {
- if (Symbol == MAX || Symbol == MIN) {
- EmitKey(Symbol);
- GetSymbol();
- if (FIRST_VAR < Symbol && Symbol < LAST_VAR) {
- EmitKey(Symbol);
- //
- // When sorting, eliminate visuals with a zero value
- // for the key. This is hard to justify on grounds
- // of orthogonality, but it seems to yield the right
- // behavior (especially for ``min'').
- //
- Emit(Symbol);
- GetSymbol();
- return true;
- } else
- throw Syntax("missing variable name after sort key",
- lex.position());
- }
-
- return false;
-} // DrawingSurfaceFilter::ParseSortKey
-
-
-} // namespace GLEAN
diff --git a/tests/glean/dsfilt.h b/tests/glean/dsfilt.h
deleted file mode 100644
index da9977a..0000000
--- a/tests/glean/dsfilt.h
+++ /dev/null
@@ -1,276 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin All Rights Reserved.
-//
-// multisample changes: Copyright (c) 2008 VMware, Inc. 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// dsfilt.h: Utilities for selecting (filtering) drawing surface configs
-
-// Given a string representing a Boolean expression involving
-// attributes of drawing surface configurations, construct an internal
-// representation of the expression which can be used to find matching
-// configurations. The string may also include sorting criteria that
-// will be used to select the order in which matching configurations
-// are returned.
-
-// This class accepts a superset of the criteria supported by the
-// visinfo package, originally released by SGI and used in the isfast
-// library (among other things). Apologies for inconsistent naming
-// conventions, capitalization, redundancy, etc.; they're due to an
-// incomplete translation of the old C code. Here's the original
-// copyright from visinfo, just in case the lawyers are interested:
-
-/*
- * Copyright (c) 1994 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee,
- * provided that (i) the above copyright notices and this permission
- * notice appear in all copies of the software and related documentation,
- * and (ii) the name of Silicon Graphics may not be used in any
- * advertising or publicity relating to the software without the specific,
- * prior written permission of Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
- * INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
- * OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-
-#ifndef __dsfilt_h__
-#define __dsfilt_h__
-
-#include <string>
-#include <vector>
-#include <map>
-#include "lex.h"
-
-using namespace std;
-
-namespace GLEAN {
-
-class DrawingSurfaceConfig; // forward reference
-
-class DrawingSurfaceFilter {
- public:
-
- // Constructors:
-
- DrawingSurfaceFilter(const string& s);
- // Creates a DrawingSurfaceFilter that implements the
- // filtering and sorting criteria in the given string.
-
- // Exceptions:
-
- struct Error { }; // Base class for errors.
- struct Syntax: public Error { // Syntax error in string.
- const char* err;
- int position;
- Syntax(const char* e, int p) {
- err = e;
- position = p;
- }
- };
- struct InternalError: public Error { // Shouldn't happen.
- };
-
- // Utilities:
-
- bool matches(DrawingSurfaceConfig& c);
- // Returns true if the given DrawingSurfaceConfig matches
- // the filter criteria.
-
- vector<DrawingSurfaceConfig*> filter(vector<DrawingSurfaceConfig*>& v);
- // Returns a vector of DrawingSurfaceConfig pointers that
- // match the filter criteria, sorted according to the sorting
- // criteria.
-
- vector<DrawingSurfaceConfig*> filter(vector<DrawingSurfaceConfig*>& v,
- unsigned int maxConfigs);
- // As above, but limit number of filter results to given count.
-
- protected:
-
- typedef enum {
- // These are items that may appear in the parsed
- // representations of the filter or sort keys.
-
- // First, some special cases:
- ERROR = 0, // erroneous token; must appear first
- END, // end of expression
-
- // Next, arithmetic and Boolean operators:
-
- ADD, // C integer +
- AND, // C integer &&
- DIV, // C integer /
- EQ, // C integer ==
- GE, // C integer >=
- GT, // C integer >
- LE, // C integer <=
- LT, // C integer <
- MOD, // C integer %
- MUL, // C integer *
- NE, // C integer !=
- NEGATE, // C integer unary -
- NOT, // C integer unary !
- OR, // C integer ||
- SUB, // C integer -
- SEPARATOR, // comma, separating exprs and sort keys
- LPAREN, // (
- RPAREN, // )
-
- // Sort keys:
-
- MAX, // sort largest value first
- MIN, // sort smallest value first
-
- // Finally, operands:
-
- CONSTANT, // integer constants
-
- FIRST_VAR, // marker; starts list of variables
-
- VAR_R, // red channel size
- VAR_G, // green channel size
- VAR_B, // blue channel size
- VAR_A, // alpha channel size
- VAR_RGB, // min(r, g, b)
- VAR_RGBA, // min(r, g, b, a)
-
- VAR_CI, // color index channel size
-
- VAR_ACCUM_R, // accum buf red channel size
- VAR_ACCUM_G, // accum buf green channel size
- VAR_ACCUM_B, // accum buf blue channel size
- VAR_ACCUM_A, // accum buf alpha channel size
- VAR_ACCUM_RGB, // min(accum r, accum g, accum b)
- VAR_ACCUM_RGBA, // min(accum r, accum g, accum b, accum a)
-
- VAR_SAMPLES, // number of samples per pixel
-
- VAR_AUX, // number of aux color buffers
-
- VAR_DB, // nonzero if double buffered
- VAR_SB, // nonzero if single buffered
-
- VAR_ID, // X11 Visual or Win32 PixelFormat ID
- VAR_FBCID, // GLXFBConfig ID
-
- VAR_LEVEL, // framebuffer level
- VAR_MAIN, // nonzero for main buffers
- VAR_OVERLAY, // nonzero for overlay buffers
- VAR_UNDERLAY, // nonzero for underlay buffers
-
- VAR_MONO, // nonzero for monoscopic buffers
- VAR_STEREO, // nonzero for stereoscopic buffers
-
- VAR_MS, // number of multisamples
-
- VAR_S, // stencil buffer depth
-
- VAR_Z, // depth (z) buffer depth
-
- VAR_FAST, // nonzero if accelerated (or not marked
- // ``slow'' in GLX)
-
- VAR_CONFORMANT, // nonzero if conforms to OpenGL spec
-
- VAR_TRANSPARENT, // nonzero if some pixel value is
- // transparent
- VAR_TRANS_R, // transparent value red component
- VAR_TRANS_G, // transparent value green component
- VAR_TRANS_B, // transparent value blue component
- VAR_TRANS_A, // transparent value alpha component
- VAR_TRANS_CI, // transparent value color index
-
- VAR_WINDOW, // nonzero if can be used to create a window
- VAR_PBUFFER, // nonzero if can be used to create a pbuffer
- VAR_PIXMAP, // nonzero if can be used to create a pixmap
- // XXXWIN need VAR_BITMAP, at least;
- // possibly others
-
- VAR_GL_ONLY, // nonzero if only OpenGL can render into
- // surfaces created with this config (i.e.,
- // the native window system *can't* render
- // into them).
-
- LAST_VAR // marker; ends list of variables
- } Token;
-
- vector<int> condition;
- inline void Emit(Token op) {condition.push_back(static_cast<int>(op));}
- inline void Emit(int v) {condition.push_back(v);}
- vector<Token> sortKeys;
- inline void EmitKey(Token key) {sortKeys.push_back(key);}
-
- // Expression-parsing state and utilities:
- Lex lex;
- Token Symbol;
- int Value;
- static map<string,Token> varTable;
- static bool varTableInitialized;
-
- static int FetchVariable(const DrawingSurfaceConfig& c, Token v);
- static void InitVarTable();
- bool ParseArithExpr();
- bool ParseArithFactor();
- bool ParseArithPrimary();
- bool ParseArithTerm();
- bool ParseBoolFactor();
- bool ParseBoolTerm();
- bool ParseCriteria();
- bool ParseCriterion();
- bool ParseExpression();
- bool ParseSortKey();
- void GetSymbol();
-
- class ConfigSort { // comparison function-object used for sorting
- protected:
- vector<Token>& keys;
- public:
- ConfigSort(vector<Token>& k): keys(k) { }
- bool operator() (const DrawingSurfaceConfig* c1,
- const DrawingSurfaceConfig* c2);
- };
- friend class ConfigSort;
-
-}; // class DrawingSurfaceFilter
-
-} // namespace GLEAN
-
-#endif // __dsfilt_h__
diff --git a/tests/glean/dsurf.cpp b/tests/glean/dsurf.cpp
deleted file mode 100644
index e371084..0000000
--- a/tests/glean/dsurf.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// dsurf.cpp: implementation of drawing surface utilities
-
-#include <iostream>
-#include <algorithm>
-#include "dsurf.h"
-#include "dsconfig.h"
-#include "winsys.h"
-
-namespace {
-
-#if defined(__X11__)
-
-Colormap
-ChooseColormap(Display* dpy, XVisualInfo* vi) {
- // We could be polite here and search for a standard colormap,
- // but the normal mode of operation should be that glean is
- // running alone, so there doesn't seem to be much point in sharing.
-
- return XCreateColormap(dpy, RootWindow(dpy, vi->screen),
- vi->visual, AllocNone);
-} // ChooseColormap
-
-#endif
-
-} // anonymous namespace
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructors
-///////////////////////////////////////////////////////////////////////////////
-DrawingSurface::DrawingSurface(WindowSystem& ws, DrawingSurfaceConfig& c) {
- // Link back to enclosing window system, so as to simplify bookkeeping:
- winSys = &ws;
- ws.surfaces.push_back(this);
-
- // Save pointer to configuration information:
- config = &c;
-} // DrawingSurface::DrawingSurface
-
-Window::Window(WindowSystem& ws, DrawingSurfaceConfig& c, int w, int h,
- int x, int y):
- DrawingSurface(ws, c) {
-
-#if defined(__X11__)
-
-#if defined(GLX_VERSION_1_3)
- if (ws.GLXVersMajor == 1 && ws.GLXVersMinor < 3)
- goto legacyMethod;
-// XXX Need GLX 1.3 window-creation code. For now, just fall through.
-#endif
-
-legacyMethod:
- // XXX There's basically no error-handling code here.
- // See XErrorHandler().
-
- // Create the window:
- XSetWindowAttributes xswa;
- XWMHints *wmHints;
- xswa.background_pixmap = None;
- xswa.border_pixel = 0;
- xswa.colormap = ChooseColormap(winSys->dpy, config->vi);
- xswa.event_mask = StructureNotifyMask;
- xWindow = XCreateWindow(winSys->dpy,
- RootWindow(winSys->dpy, config->vi->screen),
- x, y, w, h,
- 0,
- config->vi->depth,
- InputOutput,
- config->vi->visual,
- CWBackPixmap|CWBorderPixel|CWColormap|CWEventMask,
- &xswa);
-
- // Set attributes for the benefit of the window manager:
- XSizeHints sizeHints;
- sizeHints.width = w;
- sizeHints.height = h;
- sizeHints.x = x;
- sizeHints.y = y;
- sizeHints.flags = USSize | USPosition;
- XSetStandardProperties(winSys->dpy, xWindow, "glean", "glean",
- None, 0, 0, &sizeHints);
-
- // Try to prevent test window from stealing focus
- wmHints = XAllocWMHints();
- wmHints->flags |= InputHint;
- wmHints->input = False;
-
- XSetWMHints(winSys->dpy, xWindow, wmHints);
-
- XFree(wmHints);
-
- // Map the window and wait for it to appear:
- XMapWindow(winSys->dpy, xWindow);
- XEvent event;
- for (;;) {
- XNextEvent(winSys->dpy, &event);
- if (event.type == MapNotify && event.xmap.window == xWindow)
- break;
- }
-
-
-#elif defined(__WIN__)
- // XXX There's basically no error-handling code here.
- // create the window
- RECT r;
- int style = WS_POPUP | WS_CAPTION | WS_BORDER;
-
- r.left = x;
- r.top = y;
- r.right = r.left + w;
- r.bottom = r.top + h;
- AdjustWindowRect(&r,style,FALSE);
-
- hWindow = CreateWindow("glean","glean",
- style | WS_VISIBLE,
- r.left,r.top,r.right - r.left,r.bottom - r.top,
- NULL, NULL,
- GetModuleHandle(NULL),
- NULL);
-
- if (!hWindow)
- return;
-
- hDC = GetDC(hWindow);
-
- SetPixelFormat(hDC,config->pfdID,&config->pfd);
-
-#elif defined(__BEWIN__)
-
- tWindow = new GLTestWindow (BRect(x,y, x+w, y+h), "GL Test Window");
- tWindow->Show();
-
-#elif defined(__AGL__)
- Rect r ;
-
- //we need some extra room for the menu bar
- r.left = x+16;
- r.top = y+20;
- if (h < 20)
- r.bottom = r.top + 32;
- else
- r.bottom = r.top+w;
-
- if (w < 20)
- r.right = r.left + 32;
- else
- r.right = r.left + w;
-
- macWindow = NewCWindow(nil, &r, (unsigned char*)"glean", true, documentProc,
- (WindowPtr) -1, false, 0);
-
- SetPortWindowPort(macWindow);
-
-#endif
-} // Window::Window
-
-///////////////////////////////////////////////////////////////////////////////
-// Destructors
-///////////////////////////////////////////////////////////////////////////////
-
-void
-DrawingSurface::commonDestructorCode() {
- remove(winSys->surfaces.begin(), winSys->surfaces.end(), this);
-} // DrawingSurface::commonDestructorCode
-
-Window::~Window() {
-
-#if defined(__X11__)
- if (glXGetCurrentDrawable() == xWindow)
- glXMakeCurrent(winSys->dpy, None, NULL);
- XDestroyWindow(winSys->dpy, xWindow);
-#elif defined(__WIN__)
- if (wglGetCurrentDC() == hDC)
- wglMakeCurrent(NULL, NULL);
- ReleaseDC(hWindow,hDC);
- DestroyWindow(hWindow);
-
-#elif defined(__BEWIN__)
-
- tWindow->Lock();
- tWindow->Quit();
-
-#elif defined(__AGL__)
-// ::CloseWindow(macWindow);
-#endif
-
-} // Window::~Window
-
-///////////////////////////////////////////////////////////////////////////////
-// Utilities
-///////////////////////////////////////////////////////////////////////////////
-void
-Window::swap() {
-# if defined(__X11__)
- glXSwapBuffers(winSys->dpy, xWindow);
-# elif defined(__WIN__)
- SwapBuffers(hDC);
-# elif defined(__BEWIN__)
- tWindow->SwapBuffers();
-# elif defined(__AGL__)
- aglSwapBuffers(aglGetCurrentContext());
-# endif
-} // Window::swap
-
-#if defined(__WIN__)
-
-///////////////////////////////////////////////////////////////////////////////
-// Window procedure
-///////////////////////////////////////////////////////////////////////////////
-
-LRESULT CALLBACK
-Window::WindowProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
-{
- switch (message)
- {
- default :
- return DefWindowProc(hwnd, message, wParam, lParam);
-
- }
-
- return FALSE;
-}
-
-#endif
-
-
-#if defined(__BEWIN__)
-
-GLTestWindow::GLTestWindow(BRect frame, const char *title) :
- BWindow(frame, title, B_TITLED_WINDOW, B_NOT_RESIZABLE)
-{
- /* right now we just create all the buffers we can */
- tView = new BGLView(Bounds(), "glean_view", B_FOLLOW_ALL, B_WILL_DRAW,
- BGL_RGB | BGL_DOUBLE | BGL_DEPTH | BGL_ALPHA | BGL_STENCIL | BGL_ACCUM );
- AddChild(tView);
-}
-
-void
-GLTestWindow::SwapBuffers()
-{
- tView->SwapBuffers();
-}
-#endif
-} // namespace GLEAN
diff --git a/tests/glean/dsurf.h b/tests/glean/dsurf.h
deleted file mode 100644
index 9e81d96..0000000
--- a/tests/glean/dsurf.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// dsurf.h: utilities for manipulating drawing surfaces
-
-#ifndef __dsurf_h__
-#define __dsurf_h__
-
-#include "glwrap.h"
-
-namespace GLEAN {
-
-class WindowSystem; // Forward and mutually-recursive references
-class DrawingSurfaceConfig;
-
-class DrawingSurface {
- public:
- DrawingSurface(WindowSystem& ws, DrawingSurfaceConfig& c);
- virtual ~DrawingSurface() { }
-
- WindowSystem* winSys; // Window system that owns this surface.
- DrawingSurfaceConfig* config; // Configuration of this surface.
-
- protected:
- void commonDestructorCode();
-
-}; // class DrawingSurface
-
-/* we have to create a utility test window for BeOS */
-# if defined(__BEWIN__)
-class GLTestWindow : public BWindow {
-public:
- GLTestWindow(BRect frame, const char *title);
- void SwapBuffers();
-// void SwapBuffers( bool vSync );
-
-private:
- BGLView *tView;
-};
-# endif
-
-
-class Window: public DrawingSurface {
- public:
- Window(WindowSystem& ws, DrawingSurfaceConfig& c, int w, int h,
- int x = 10, int y = 10);
- ~Window();
-
- // Utilities:
-
- void swap();
-
- // XXX Add constructors for more specialized window creation --
- // for example, at a particular screen location, with a particular
- // parent window, etc. -- as needed by new tests.
-
-# if defined(__X11__)
- ::Window xWindow;
-# elif defined(__WIN__)
- ::HWND hWindow;
- ::HDC hDC;
-
- ::HDC get_dc() const {return hDC;}
- static LRESULT CALLBACK WindowProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
-
-# elif defined(__BEWIN__)
- GLTestWindow *tWindow;
-# elif defined(__AGL__)
- ::WindowRef macWindow;
-# endif
-}; // class Window
-
-} // namespace GLEAN
-
-#endif // __dsurf_h__
diff --git a/tests/glean/environ.cpp b/tests/glean/environ.cpp
deleted file mode 100644
index 824d24f..0000000
--- a/tests/glean/environ.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// environ.cpp: implementation of test environment class
-
-#include "environ.h"
-
-#if defined(__UNIX__)
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <cstdlib>
-#include <cstdio>
-#elif defined(__MS__)
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-
-#endif
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructor
-///////////////////////////////////////////////////////////////////////////////
-Environment::Environment(Options& opt):
- options(opt),
- log(cout),
- winSys(opt)
-{
-} // Environment::Environment()
-
-} // namespace GLEAN
diff --git a/tests/glean/environ.h b/tests/glean/environ.h
deleted file mode 100644
index 2970c7f..0000000
--- a/tests/glean/environ.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// environ.h: global test environment
-
-// This class provides a facade for all the operating-system and
-// window-system services that we need to run ``portable'' tests.
-// Examples include logging services, opening streams to read or write
-// database files, and gaining access to the window system.
-
-
-#ifndef __environ_h__
-#define __environ_h__
-
-#include <iostream>
-#include "options.h"
-#include "winsys.h"
-
-namespace GLEAN {
-
-class Image; // Forward and mutually-recursive references.
-
-class Environment {
- public:
- // Constructors:
- Environment(Options& opt);
-
- // Exceptions:
- struct Error { }; // Base class for all errors.
- struct DBExists: public Error { // Output DB already exists.
- };
- struct DBCantOpen: public Error { // Can't open a DB.
- const string* db;
- DBCantOpen(string& s) {db = &s;}
- };
-
- // Members:
- Options options; // Global testing options.
-
- ostream& log; // Output stream used for logging results.
-
- WindowSystem winSys; // The window system providing the OpenGL
- // implementation under test.
-}; // class Environment
-
-} // namespace GLEAN
-
-#endif // __environ_h__
diff --git a/tests/glean/geomrend.cpp b/tests/glean/geomrend.cpp
deleted file mode 100644
index dcd7f30..0000000
--- a/tests/glean/geomrend.cpp
+++ /dev/null
@@ -1,499 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999,2000 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-// geomrend.h: convenience object for rendering any geometry via
-// a host of OpenGL paths: immediate mode (glVertex), vertex
-// arrays with glDrawArrays, vertex arrays with glArrayElement,
-// vertex arrays with glDrawElements, and any of the preceding
-// methods stuffed in a display list.
-
-#include "geomrend.h"
-#include "glutils.h"
-#include <algorithm>
-#include <iostream>
-#include <cmath>
-#include <cassert>
-
-using namespace std;
-
-namespace GLEAN {
-
-
-// geomrend.h: convenience object for rendering any geometry via
-// a host of OpenGL paths: immediate mode (glVertex), vertex
-// arrays with glDrawArrays, vertex arrays with glArrayElement,
-// vertex arrays with glDrawElements, and any of the preceding
-// methods stuffed in a display list.
-
-// Functions for the helper class ArrayData, which stores the info about each parameter's data.
-ArrayData::ArrayData()
-{
- size = 0;
- type = GL_UNSIGNED_INT;
- stride = 0;
- pointer = 0;
-}
-
-void ArrayData::setData(GLint sizeIn, GLenum typeIn, GLsizei strideIn, const GLvoid* pointerIn)
-{
- size = sizeIn;
- type = typeIn;
- stride = strideIn;
- pointer = pointerIn;
- if (stride == 0)
- {
- stride = size;
- switch(type)
- {
- case GL_BYTE: stride *= sizeof(GLbyte); break;
- case GL_UNSIGNED_BYTE: stride *= sizeof(GLubyte); break;
- case GL_SHORT: stride *= sizeof(GLshort); break;
- case GL_UNSIGNED_SHORT: stride *= sizeof(GLushort); break;
- case GL_INT: stride *= sizeof(GLint); break;
- case GL_UNSIGNED_INT: stride *= sizeof(GLuint); break;
- case GL_FLOAT: stride *= sizeof(GLfloat); break;
- case GL_DOUBLE: stride *= sizeof(GLdouble); break;
- default: assert(false);
- }
- }
-}
-
-// Only a default constructor.
-GeomRenderer::GeomRenderer() : vertexData(), colorData(), texCoordData(), normalData()
-{
- drawMethod = GLVERTEX_MODE;
- parameterBits = 0;
- compileArrays = false;
-
- indicesCount = 0;
- indicesType = GL_UNSIGNED_INT;
- indices = 0;
-
- arrayLength = 0;
-}
-
-// Used to set the method by which this GeomRenderer will pass the primitive data to the GL.
-// Default is GLVERTEX_MODE.
-void GeomRenderer::setDrawMethod(GeomRenderer::DrawMethod method)
-{
- drawMethod = method;
-}
-
-GeomRenderer::DrawMethod GeomRenderer::getDrawMethod() const
-{
- return drawMethod;
-}
-
-// Used to set the various parameters that are either enabled or disabled. Example usage:
-// to tell the GeomRenderer to pass vertex, color, and texcoord data, but not normals,
-// call setParameterBits(COLOR_BIT | TEXTURE_COORD_BIT). (Vertex data is implicitly enabled
-// all the time.) The default is that only vertex data is enabled.
-void GeomRenderer::setParameterBits(GLuint bits)
-{
- parameterBits = bits;
-}
-
-GLuint GeomRenderer::getParameterBits() const
-{
- return parameterBits;
-}
-
-// Used to specify whether EXT_compiled_vertex_array should be used if present. Default is false.
-// If set to true, the arrays are kept unlocked and only locked just before rendering calls are issued.
-// If you call setArraysCompiled(true) and the extension is not present, the function returns false
-// and acts as though you had passed false in as the argument.
-bool GeomRenderer::setArraysCompiled(bool compile)
-{
- // Make sure we have the extension.
- if (!GLUtils::haveExtension("GL_EXT_compiled_vertex_array") && compile == true)
- {
- compileArrays = false;
- return false;
- }
-
- compileArrays = compile;
- return true;
-}
-
-bool GeomRenderer::getArraysCompiled() const
-{
- return compileArrays;
-}
-
-// If you're using GLDRAWELEMENTS_MODE, GLARRAYELEMENT_MODE, or GLVERTEX_MODE, you need to give
-// it the indices to pass into the GL.
-void GeomRenderer::setVArrayIndices(GLuint count, GLenum type, const GLvoid* indicesIn)
-{
- assert(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT);
-
- indicesCount = count;
- indicesType = type;
- indices = indicesIn;
-}
-
-// This hands the actual primitive data to the GeomRenderer. It holds onto these as pointers,
-// rather than copying them, so don't delete the data until you're done with the GeomRenderer.
-// These are prototypically equivalent to their respective GL calls, except that there's an extra
-// argument on the front of the vertex function for how many elements are in the array (this is
-// atomic; if you pass in 5, it means there are 5 vertices, not 5 floats or bytes or whatever).
-// The lengths of all other arrays are assumed to be >= the size passed in for the vertex array.
-void GeomRenderer::setVertexPointer(GLuint length, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
-{
- arrayLength = length;
- vertexData.setData(size, type, stride, pointer);
-}
-
-void GeomRenderer::setColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
-{
- colorData.setData(size, type, stride, pointer);
-}
-
-void GeomRenderer::setTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
-{
- texCoordData.setData(size, type, stride, pointer);
-}
-
-void GeomRenderer::setNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer)
-{
- normalData.setData(3, type, stride, pointer);
-}
-
-// Finally, the actual calls to do something with all this data. You can either choose to render
-// it given the configuration, or generate a display list of rendering it with the given
-// configuration (uses GL_COMPILE mode to build the list). Fails if insufficient data has
-// been given (i.e. if you don't give it an array for an enabled parameter, if you don't
-// give it an array of indices when it needs them).
-// Note that rendering with GLVERTEX_MODE currently involves a lot of CPU overhead to
-// unpack the data and pass it to the GL; while the results will be correct, it would be
-// unwise to use this method for rendering that is to be benchmarked, because it will
-// underestimate performance significantly on some machines.
-bool GeomRenderer::renderPrimitives(GLenum mode)
-{
- if (!isReadyToRender())
- {
- return false;
- }
-
- // Okay, different sections here depending on what we're doing.
- if (drawMethod == GLVERTEX_MODE)
- {
- glBegin(mode);
- for (unsigned int x=0; x<indicesCount; x++)
- {
- int directIndex = getIndex(x);
- if (parameterBits & COLOR_BIT) sendColor(directIndex);
- if (parameterBits & TEXTURE_COORD_BIT) sendTexCoord(directIndex);
- if (parameterBits & NORMAL_BIT) sendNormal(directIndex);
- sendVertex(directIndex);
- }
- glEnd();
- }
- // Otherwise it has something to do with arrays; set up the arrays.
- else
- {
- if (parameterBits & COLOR_BIT)
- {
- glEnableClientState(GL_COLOR_ARRAY);
- glColorPointer(colorData.size, colorData.type, colorData.stride, colorData.pointer);
-// std::cout << "Enabled color arrays, size [" << colorData.size << "], type [" << colorData.type
-// << "], stride [" << colorData.stride << "], pointer [" << colorData.pointer << "]" << std::endl;
- }
- if (parameterBits & TEXTURE_COORD_BIT)
- {
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glTexCoordPointer(texCoordData.size, texCoordData.type, texCoordData.stride, texCoordData.pointer);
-// std::cout << "Enabled texCoord arrays, size [" << texCoordData.size << "], type [" << texCoordData.type
-// << "], stride [" << texCoordData.stride << "], pointer [" << texCoordData.pointer << "]" << std::endl;
- }
- if (parameterBits & NORMAL_BIT)
- {
- glEnableClientState(GL_NORMAL_ARRAY);
- glNormalPointer(normalData.type, normalData.stride, normalData.pointer);
-// std::cout << "Enabled normal arrays, size [" << normalData.size << "], type [" << normalData.type
-// << "], stride [" << normalData.stride << "], pointer [" << normalData.pointer << "]" << std::endl;
- }
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(vertexData.size, vertexData.type, vertexData.stride, vertexData.pointer);
-// std::cout << "Enabled vertex arrays, size [" << vertexData.size << "], type [" << vertexData.type
-// << "], stride [" << vertexData.stride << "], pointer [" << vertexData.pointer << "]" << std::endl;
-
- // Should we lock?
- if (compileArrays)
- {
- assert(GLUtils::haveExtension("GL_EXT_compiled_vertex_array"));
- glLockArraysEXT(0, arrayLength);
- }
-
- // Okay, arrays configured; what exactly are we doing?
- if (drawMethod == GLARRAYELEMENT_MODE)
- {
- glBegin(mode);
- for (unsigned int x=0; x<indicesCount; x++)
- {
- glArrayElement(getIndex(x));
- }
- glEnd();
- }
- else if (drawMethod == GLDRAWARRAYS_MODE)
- {
- glDrawArrays(mode, 0, arrayLength);
- std::cout << "Called glDrawArrays, mode [" << mode << "], from 0 to " << arrayLength << std::endl;
- }
- else if (drawMethod == GLDRAWELEMENTS_MODE)
- {
- glDrawElements(mode, indicesCount, indicesType, indices);
- }
-
- // Done. If we locked, unlock.
- if (compileArrays)
- {
- assert(GLUtils::haveExtension("GL_EXT_compiled_vertex_array"));
- glUnlockArraysEXT();
- }
- }
-
- return true;
-}
-
-bool GeomRenderer::generateDisplayList(GLenum mode, GLint& listHandleOut)
-{
- bool result;
-
- if (!isReadyToRender())
- {
- return false;
- }
-
- listHandleOut = glGenLists(1);
- glNewList(listHandleOut, GL_COMPILE);
- result = renderPrimitives(mode);
- assert(result);
- glEndList();
-
- return true;
-}
-
-bool GeomRenderer::isReadyToRender()
-{
- // Make sure we have vertex data.
- if (vertexData.pointer == 0) return false;
-
- // For the enabled parameters, make sure we have them, too.
- if ((parameterBits & COLOR_BIT ) && (colorData.pointer == 0)) return false;
- if ((parameterBits & TEXTURE_COORD_BIT) && (texCoordData.pointer == 0)) return false;
- if ((parameterBits & NORMAL_BIT ) && (normalData.pointer == 0)) return false;
-
- // If we need indices, we'd better have them.
- if ((drawMethod == GLVERTEX_MODE ||
- drawMethod == GLARRAYELEMENT_MODE ||
- drawMethod == GLDRAWELEMENTS_MODE) && indices == 0)
- {
- return false;
- }
-
- // Otherwise we're good to go!
- return true;
-}
-
-// This unpacks the indices depending on their format and returns the specified one.
-GLuint GeomRenderer::getIndex(int indicesIndex)
-{
- assert(indicesIndex >= 0 && indicesIndex < static_cast<int>(indicesCount));
-
- switch (indicesType)
- {
- case GL_UNSIGNED_BYTE:
- return ((GLubyte*)indices)[indicesIndex];
- break;
-
- case GL_UNSIGNED_SHORT:
- return ((GLushort*)indices)[indicesIndex];
- break;
-
- case GL_UNSIGNED_INT:
- return ((GLuint*)indices)[indicesIndex];
- break;
-
- default:
- assert(false);
- break;
- }
-
- // It never gets here, but let's quell the compiler warning...
- return 0;
-}
-
-// I thought about making a lookup table for this, but it would involve an STL map of STL vectors
-// and some weird function casts, so I'm doing it the naive way instead.
-void GeomRenderer::sendVertex(GLuint vertexIndex)
-{
- assert(vertexData.size >= 2 && vertexData.size <= 4);
-
- switch(vertexData.type)
- {
- case GL_SHORT:
- if (vertexData.size == 2) glVertex2sv((const GLshort*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 3) glVertex3sv((const GLshort*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 4) glVertex4sv((const GLshort*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- break;
-
- case GL_INT:
- if (vertexData.size == 2) glVertex2iv((const GLint*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 3) glVertex3iv((const GLint*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 4) glVertex4iv((const GLint*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- break;
-
- case GL_FLOAT:
- if (vertexData.size == 2) glVertex2fv((const GLfloat*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 3) glVertex3fv((const GLfloat*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 4) glVertex4fv((const GLfloat*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- break;
-
- case GL_DOUBLE:
- if (vertexData.size == 2) glVertex2dv((const GLdouble*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 3) glVertex3dv((const GLdouble*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- if (vertexData.size == 4) glVertex4dv((const GLdouble*)((const char*)vertexData.pointer + vertexIndex*vertexData.stride));
- break;
- }
-}
-
-void GeomRenderer::sendColor(GLuint colorIndex)
-{
- assert(colorData.size == 3 || colorData.size == 4);
-
- switch(colorData.type)
- {
- case GL_BYTE:
- if (colorData.size == 3) glColor3bv((const GLbyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4bv((const GLbyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
-
- case GL_UNSIGNED_BYTE:
- if (colorData.size == 3) glColor3ubv((const GLubyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4ubv((const GLubyte*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
-
- case GL_SHORT:
- if (colorData.size == 3) glColor3sv((const GLshort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4sv((const GLshort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
-
- case GL_UNSIGNED_SHORT:
- if (colorData.size == 3) glColor3usv((const GLushort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4usv((const GLushort*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
-
- case GL_INT:
- if (colorData.size == 3) glColor3iv((const GLint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4iv((const GLint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
-
- case GL_UNSIGNED_INT:
- if (colorData.size == 3) glColor3uiv((const GLuint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4uiv((const GLuint*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
-
- case GL_FLOAT:
- if (colorData.size == 3) glColor3fv((const GLfloat*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4fv((const GLfloat*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
-
- case GL_DOUBLE:
- if (colorData.size == 3) glColor3dv((const GLdouble*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- if (colorData.size == 4) glColor4dv((const GLdouble*)((const char*)colorData.pointer + colorIndex*colorData.stride));
- break;
- }
-}
-
-void GeomRenderer::sendTexCoord(GLuint texCoordIndex)
-{
- assert(texCoordData.size >= 1 && texCoordData.size <= 4);
-
- switch(texCoordData.type)
- {
- case GL_SHORT:
- if (texCoordData.size == 1) glTexCoord1sv((const GLshort*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 2) glTexCoord2sv((const GLshort*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 3) glTexCoord3sv((const GLshort*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 4) glTexCoord4sv((const GLshort*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- break;
-
- case GL_INT:
- if (texCoordData.size == 1) glTexCoord1iv((const GLint*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 2) glTexCoord2iv((const GLint*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 3) glTexCoord3iv((const GLint*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 4) glTexCoord4iv((const GLint*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- break;
-
- case GL_FLOAT:
- if (texCoordData.size == 1) glTexCoord1fv((const GLfloat*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 2) glTexCoord2fv((const GLfloat*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 3) glTexCoord3fv((const GLfloat*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 4) glTexCoord4fv((const GLfloat*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- break;
-
- case GL_DOUBLE:
- if (texCoordData.size == 1) glTexCoord1dv((const GLdouble*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 2) glTexCoord2dv((const GLdouble*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 3) glTexCoord3dv((const GLdouble*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- if (texCoordData.size == 4) glTexCoord4dv((const GLdouble*)((const char*)texCoordData.pointer + texCoordIndex*texCoordData.stride));
- break;
- }
-}
-
-void GeomRenderer::sendNormal(GLuint normalIndex)
-{
- assert(normalData.size == 3);
-
- switch(normalData.type)
- {
- case GL_BYTE:
- glNormal3bv((const GLbyte*)((const char*)normalData.pointer + normalIndex*normalData.stride));
- break;
-
- case GL_SHORT:
- glNormal3sv((const GLshort*)((const char*)normalData.pointer + normalIndex*normalData.stride));
- break;
-
- case GL_INT:
- glNormal3iv((const GLint*)((const char*)normalData.pointer + normalIndex*normalData.stride));
- break;
-
- case GL_FLOAT:
- glNormal3fv((const GLfloat*)((const char*)normalData.pointer + normalIndex*normalData.stride));
- break;
-
- case GL_DOUBLE:
- glNormal3dv((const GLdouble*)((const char*)normalData.pointer + normalIndex*normalData.stride));
- break;
- }
-}
-
-} // namespace GLEAN
diff --git a/tests/glean/geomrend.h b/tests/glean/geomrend.h
deleted file mode 100644
index 31678b2..0000000
--- a/tests/glean/geomrend.h
+++ /dev/null
@@ -1,146 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999,2000 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// geomrend.h: convenience object for rendering any geometry via
-// a host of OpenGL paths: immediate mode (glVertex), vertex
-// arrays with glDrawArrays, vertex arrays with glArrayElement,
-// vertex arrays with glDrawElements, and any of the preceding
-// methods stuffed in a display list.
-
-#ifndef __geomrend_h__
-#define __geomrend_h__
-
-#include "glwrap.h"
-#include <cassert>
-
-namespace GLEAN {
-
-// A helper class to store parameter array data.
-class ArrayData {
-public:
- GLint size;
- GLenum type;
- GLsizei stride;
- const GLvoid* pointer;
-
- ArrayData();
- void setData(GLint sizeIn, GLenum typeIn, GLsizei strideIn, const GLvoid* pointerIn);
-};
-
-class GeomRenderer {
- public:
- // These indicate the methods of passing the primitive data to OpenGL. Note that whether
- // the arrays are locked or not is an independent variable, not part of the method. See
- // setArraysLocked and getArraysLocked.
- enum DrawMethod {GLVERTEX_MODE, GLARRAYELEMENT_MODE, GLDRAWARRAYS_MODE, GLDRAWELEMENTS_MODE};
-
- // Sorry, no indices, and especially no silly edge flags. There's no vertex bit because
- // vertex data always implicitly enabled (you can't draw anything without vertex data).
- enum ParameterBits {COLOR_BIT = 1, TEXTURE_COORD_BIT = 2, NORMAL_BIT = 4};
-
- // Only a default constructor.
- GeomRenderer();
-
- // Used to set the method by which this GeomRenderer will pass the primitive data to the GL.
- // Default is GLVERTEX_MODE.
- void setDrawMethod(DrawMethod);
- DrawMethod getDrawMethod() const;
-
- // Used to set the various parameters that are either enabled or disabled. Example usage:
- // to tell the GeomRenderer to pass vertex, color, and texcoord data, but not normals,
- // call setParameterBits(COLOR_BIT | TEXTURE_COORD_BIT). (Vertex data is implicitly enabled
- // all the time.) The default is that only vertex data is enabled.
- void setParameterBits(GLuint bits);
- GLuint getParameterBits() const;
-
- // Used to specify whether EXT_compiled_vertex_array should be used if present. Default is false.
- // If set to true, the arrays are kept unlocked and only locked just before rendering calls are issued.
- // If you call setArraysCompiled(true) and the extension is not present, the function returns false
- // and acts as though you had passed false in as the argument.
- bool setArraysCompiled(bool);
- bool getArraysCompiled() const;
-
- // If you're using GLDRAWELEMENTS_MODE, GLARRAYELEMENT_MODE, or GLVERTEX_MODE, you need to give
- // it the indices to pass into the GL.
- void setVArrayIndices(GLuint count, GLenum type, const GLvoid* indices);
-
- // This hands the actual primitive data to the GeomRenderer. It holds onto these as pointers,
- // rather than copying them, so don't delete the data until you're done with the GeomRenderer.
- // These are prototypically equivalent to their respective GL calls, except that there's an extra
- // argument on the front of the vertex function for how many elements are in the array (this is
- // atomic; if you pass in 5, it means there are 5 vertices, not 5 floats or bytes or whatever).
- // The lengths of all other arrays are assumed to be >= the size passed in for the vertex array.
- void setVertexPointer(GLuint arrayLength, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
- void setColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
- void setTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
- void setNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer);
-
- // Finally, the actual calls to do something with all this data. You can either choose to render
- // it given the configuration, or generate a display list of rendering it with the given
- // configuration (uses GL_COMPILE mode to build the list). Fails if insufficient data has
- // been given (i.e. if you don't give it an array for an enabled parameter, if you don't
- // give it an array of indices when it needs them).
- bool renderPrimitives(GLenum mode);
- bool generateDisplayList(GLenum mode, GLint& listHandleOut);
-
- private:
- bool isReadyToRender();
-
- // Helper functions for unpacking and translating the data from the indices, vertices, colors,
- // texcoords, and normals arrays.
- GLuint getIndex(int);
- void sendVertex(GLuint index);
- void sendColor(GLuint index);
- void sendTexCoord(GLuint index);
- void sendNormal(GLuint index);
-
- DrawMethod drawMethod;
- GLuint parameterBits;
- bool compileArrays;
-
- GLuint indicesCount;
- GLenum indicesType;
- const GLvoid* indices;
-
- GLuint arrayLength;
-
- ArrayData vertexData;
- ArrayData colorData;
- ArrayData texCoordData;
- ArrayData normalData;
-};
-
-} // namespace GLEAN
-
-#endif // __geomrend_h__
-
-
-
diff --git a/tests/glean/geomutil.cpp b/tests/glean/geomutil.cpp
deleted file mode 100644
index 1852332..0000000
--- a/tests/glean/geomutil.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999,2000 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-// geomutil.cpp: frequently-used geometric operations
-
-#include "geomutil.h"
-#include "rand.h"
-#include <cassert>
-#include <algorithm>
-#include <cmath>
-#include <float.h>
-#include <stdio.h>
-
-using namespace std;
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// RandomMesh2D: Generate 2D array with fixed boundaries but interior points
-// that have been perturbed randomly.
-///////////////////////////////////////////////////////////////////////////////
-RandomMesh2D::RandomMesh2D(float minX, float maxX, int xPoints,
- float minY, float maxY, int yPoints,
- RandomDouble& rand) {
- m = new float[xPoints * yPoints * 2];
- rowLength = xPoints;
-
- // Loop var; we declare it here and not in the for loop because
- // different compilers scope variables differently when
- // declared in a for loop.
- int iy;
-
- // Drop each point squarely into the center of its grid cell:
- for (iy = 0; iy < yPoints; ++iy)
- for (int ix = 0; ix < xPoints; ++ix) {
- float* v = (*this)(iy, ix);
- v[0] = minX + (ix * (maxX - minX)) / (xPoints - 1);
- v[1] = minY + (iy * (maxY - minY)) / (yPoints - 1);
- }
- // Now perturb each interior point, but only within its cell:
- double deltaX = 0.9 * (maxX - minX) / (xPoints - 1);
- double deltaY = 0.9 * (maxY - minY) / (yPoints - 1);
- for (iy = 1; iy < yPoints - 1; ++iy)
- for (int ix = 1; ix < xPoints - 1; ++ix) {
- float* v = (*this)(iy, ix);
- v[0] += deltaX * (rand.next() - 0.5);
- v[1] += deltaY * (rand.next() - 0.5);
- }
-} // RandomMesh2D::RandomMesh2D
-
-RandomMesh2D::~RandomMesh2D() {
- delete[] m;
-} // RandomMesh2D::~RandomMesh2D
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////
-// Sphere3D: Forms a stacks/slices sphere and can return the vertices and index list for drawing it.
-//////////////////////////////////////////////////////////////////////////////////////////////////////
-Sphere3D::Sphere3D(float radius, int slices, int stacks)
-{
- // Loop vars.
- int curStack, curSlice;
-
- // Can't have a sphere of less than 2 slices or stacks.
- assert(slices >= 2 && stacks >= 2);
-
- // We have 2 verts for the top and bottom point, and then slices*(stacks-1) more for the
- // middle rings (it's stacks-1 since the top and bottom points each count in the stack count).
- numVertices = 2 + (slices*(stacks-1));
- vertices.reserve(numVertices*3);
- normals.reserve(numVertices*3);
-
- // The top and bottom slices have <slices> tris in them, and the ones in the middle (since they're
- // made of quads) have 2*<slices> each.
- numIndices = 3*(2*slices + 2*(stacks-2)*slices);
- indices.reserve(numIndices);
-
-#define VX(i) vertices[3*(i)+0]
-#define VY(i) vertices[3*(i)+1]
-#define VZ(i) vertices[3*(i)+2]
-#define VINDEX(st,sl) (1 + (((st)-1)*slices) + (sl))
-#ifndef M_PI
-#define M_PI 3.14159
-#endif
-
- // Generate the verts. The bottom and top verts are kind of special cases (they
- // occupy the first and last vertex slots, respectively).
- vertices.push_back(0);
- vertices.push_back(0);
- vertices.push_back(-radius);
- normals.push_back(0);
- normals.push_back(0);
- normals.push_back(-1);
-
- // Now the inner rings; I can't decide whether it spreads the tri area out better to do this by
- // increments in the spherical coordinate phi or in the cartesian z, but I think phi is a better bet.
- for (curStack=1; curStack<stacks; curStack++)
- {
- float phi = M_PI - ((curStack / (float)stacks) * M_PI);
- float zVal = radius * cos(phi);
- float sliceRadius = sqrt(radius*radius - zVal*zVal);
- for (curSlice = 0; curSlice < slices; curSlice++)
- {
- float theta = 2*M_PI*((float)curSlice / slices);
-
- float xVal = sliceRadius*cos(theta);
- float yVal = sliceRadius*sin(theta);
-
- vertices.push_back(xVal);
- vertices.push_back(yVal);
- vertices.push_back(zVal);
- normals.push_back(xVal/radius);
- normals.push_back(yVal/radius);
- normals.push_back(zVal/radius);
- }
- }
-
- vertices.push_back(0);
- vertices.push_back(0);
- vertices.push_back(radius);
- normals.push_back(0);
- normals.push_back(0);
- normals.push_back(1);
-
- // Now to assemble them into triangles. Do the top and bottom slices first.
- for (curSlice=0; curSlice<slices; curSlice++)
- {
- indices.push_back(0);
- indices.push_back((curSlice+1)%slices + 1);
- indices.push_back(curSlice+1);
-
- indices.push_back(numVertices - 1);
- indices.push_back(numVertices - 2 - ((curSlice+1)%slices));
- indices.push_back(numVertices - 2 - curSlice);
- }
-
- // Now for the inner rings. We're already done with 2*slices triangles, so start after that.
- for (curStack=1; curStack<stacks-1; curStack++)
- {
- for (curSlice=0; curSlice<slices; curSlice++)
- {
- int nextStack = curStack+1;
- int nextSlice = (curSlice+1)%slices;
- indices.push_back(VINDEX(curStack, curSlice));
- indices.push_back(VINDEX(curStack, nextSlice));
- indices.push_back(VINDEX(nextStack, nextSlice));
-
- indices.push_back(VINDEX(curStack, curSlice));
- indices.push_back(VINDEX(nextStack, nextSlice));
- indices.push_back(VINDEX(nextStack, curSlice));
- }
- }
-
- assert(static_cast<int>(vertices.size()) == numVertices*3);
- assert(static_cast<int>(indices.size()) == numIndices);
-
-#undef VX
-#undef VY
-#undef VZ
-#undef VINDEX
-}
-
-// This returns the vertices: 3 floats per vertex in a tightly packed array (no padding between vertices).
-const float* Sphere3D::getVertices() const { return &(vertices[0]); }
-int Sphere3D::getNumVertices() const { return numVertices; }
-
-// This returns the normals; same data format as the vertices. And of course the number of normals is
-// the same as the number of vertices.
-const float* Sphere3D::getNormals() const { return &(normals[0]); }
-
-// This returns a series of vertices that form triangles from the vertices (the indices specify loose
-// triangles, not tristrips or fans or whatnot. So each triplet of indices is an individual triangle.)
-const unsigned int* Sphere3D::getIndices() const { return &(indices[0]); }
-int Sphere3D::getNumIndices() const { return numIndices; }
-
-
-} // namespace GLEAN
diff --git a/tests/glean/geomutil.h b/tests/glean/geomutil.h
deleted file mode 100644
index db899b1..0000000
--- a/tests/glean/geomutil.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999,2000 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// geomutil.h: frequently-used geometric operations
-
-#ifndef __geomutil_h__
-#define __geomutil_h__
-
-#include <vector>
-
-namespace GLEAN {
-
-class RandomDouble; // Forward reference.
-
-class RandomMesh2D {
- float* m;
- int rowLength;
- public:
- RandomMesh2D(float minX, float maxX, int xPoints,
- float minY, float maxY, int yPoints,
- RandomDouble& rand);
- ~RandomMesh2D();
- inline float* operator() (int y, int x)
- { return m + 2 * (y * rowLength + x); }
-}; // RandomMesh2D
-
-class Sphere3D {
- std::vector<float> vertices;
- std::vector<float> normals;
- int numVertices;
- std::vector<unsigned int> indices;
- int numIndices;
- public:
- Sphere3D(float radius, int slices, int stacks);
-
- // This returns the vertices: 3 floats per vertex in a tightly packed array (no padding between vertices).
- const float* getVertices() const;
- int getNumVertices() const;
-
- // This returns the normals; same data format as the vertices. And of course the number of normals is
- // the same as the number of vertices.
- const float* getNormals() const;
-
- // This returns a series of vertices that form triangles from the vertices (the indices specify loose
- // triangles, not tristrips or fans or whatnot. So each triplet of indices is an individual triangle.)
- const unsigned int* getIndices() const;
- int getNumIndices() const;
-};
-
-} // namespace GLEAN
-
-#endif // __geomutil_h__
diff --git a/tests/glean/gl.cpp b/tests/glean/gl.cpp
deleted file mode 100644
index 3191a04..0000000
--- a/tests/glean/gl.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// OpenGL utility routines for images
-
-#include "image.h"
-
-namespace GLEAN {
-
-
-///////////////////////////////////////////////////////////////////////////////
-// draw - draw image using glDrawPixels
-///////////////////////////////////////////////////////////////////////////////
-void
-Image::draw() {
- glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
- glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- glPixelStorei(GL_UNPACK_ALIGNMENT, alignment());
- glDrawPixels(width(), height(), format(), type(), pixels());
-} // Image::draw
-
-///////////////////////////////////////////////////////////////////////////////
-// read - read image using glReadPixels
-///////////////////////////////////////////////////////////////////////////////
-void
-Image::read(GLint x, GLint y) {
- glPixelStorei(GL_PACK_SWAP_BYTES, GL_FALSE);
- glPixelStorei(GL_PACK_LSB_FIRST, GL_FALSE);
- glPixelStorei(GL_PACK_ROW_LENGTH, 0);
- glPixelStorei(GL_PACK_SKIP_ROWS, 0);
- glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
- glPixelStorei(GL_PACK_ALIGNMENT, alignment());
- glReadPixels(x, y, width(), height(), format(), type(), pixels());
-} // Image::read
-
-}; // namespace GLEAN
diff --git a/tests/glean/glutils.cpp b/tests/glean/glutils.cpp
deleted file mode 100644
index a7d6bfa..0000000
--- a/tests/glean/glutils.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999, 2000 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// glutils.cpp: frequently-used OpenGL operations
-
-#define GLX_GLXEXT_PROTOTYPES
-#include <stdlib.h>
-#include "glwrap.h"
-#include "environ.h"
-#include "lex.h"
-#include "glutils.h"
-#if defined(__X11__) || defined(__AGL__)
-# include <dlfcn.h>
-#endif
-#if defined(__AGL__)
-# include <cstring>
-#endif
-#include "piglit-util-gl.h"
-
-namespace GLEAN {
-
-namespace GLUtils {
-
-///////////////////////////////////////////////////////////////////////////////
-// useScreenCoords: Map object coords directly to screen coords.
-///////////////////////////////////////////////////////////////////////////////
-void
-useScreenCoords(int windowW, int windowH) {
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, windowW, 0, windowH, -1, 1);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- glViewport(0, 0, windowW, windowH);
- glTranslatef(0.375, 0.375, 0.0);
-} // useScreenCoords
-
-///////////////////////////////////////////////////////////////////////////////
-// haveExtensions: See if the current rendering context supports a given
-// set of extensions.
-///////////////////////////////////////////////////////////////////////////////
-bool
-haveExtensions(const char* required) {
- const char* available = reinterpret_cast<const char*>
- (glGetString(GL_EXTENSIONS));
-
- if (!required)
- return true;
- if (!available)
- return false;
-
- bool haveAll = true;
- Lex lRequired(required);
- for (lRequired.next(); lRequired.token != Lex::END; lRequired.next()) {
- if (lRequired.token != Lex::ID)
- continue;
- bool haveOne = false;
- Lex lAvailable(available);
- for (lAvailable.next(); lAvailable.token != Lex::END;
- lAvailable.next())
- if (lAvailable.token == Lex::ID
- && lAvailable.id == lRequired.id) {
- haveOne = true;
- break;
- }
- haveAll &= haveOne;
- if (!haveAll)
- break;
- }
-
- return haveAll;
-} // haveExtensions
-
-
-float
-getVersion()
-{
- const GLubyte *version = glGetString(GL_VERSION);
- // we rely on atof() stopping parsing at whitespace
- return atof((const char *) version);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// logGLErrors: Check for OpenGL errors and log any that have occurred.
-///////////////////////////////////////////////////////////////////////////////
-void
-logGLErrors(Environment& env) {
- GLenum err;
- while ((err = glGetError()))
- env.log << "\tOpenGL error: " << piglit_get_gl_error_name(err) << '\n';
-} // logGLErrors
-
-} // namespace GLUtils
-
-} // namespace GLEAN
diff --git a/tests/glean/glutils.h b/tests/glean/glutils.h
deleted file mode 100644
index b943a21..0000000
--- a/tests/glean/glutils.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999, 2000 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// glutils.h: frequently-used OpenGL operations
-
-#ifndef __glutils_h__
-#define __glutils_h__
-
-namespace GLEAN {
-
-class Environment; // Forward reference.
-
-namespace GLUtils {
-
-// Set up projection and modelview matrices so that first-quadrant
-// object coordinates map directly to screen coordinates (using the
-// normal Cartesian convention, with (0,0) at lower left).
-void useScreenCoords(int windowW, int windowH);
-
-// Check to see if the current rendering context supports a given
-// extension or set of extensions. (This is here, rather than in
-// RenderingContext, because it can only be applied to the ``current''
-// context rather than to any arbitrary context.)
-bool haveExtensions(const char* required);
-inline bool haveExtension(const char* name) {
- return haveExtensions(name);
-}
-
-// Return GL renderer version as a float (1.1, 2.0, etc)
-float getVersion();
-
-// Check for OpenGL errors and log any that have occurred:
-void logGLErrors(Environment& env);
-
-} // namespace GLUtils
-
-} // namespace GLEAN
-
-#endif // __glutils_h__
diff --git a/tests/glean/glwrap.h b/tests/glean/glwrap.h
deleted file mode 100644
index 03aa274..0000000
--- a/tests/glean/glwrap.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// Microsoft's version of gl.h invokes macros that are defined in
-// windows.h. To avoid a conditional #include <windows.h> in
-// every file, we wrap gl.h with the proper conditions here, and
-// have our source files #include "glwrap.h" instead.
-
-// As a bonus we ensure that all declarations for GLU are included,
-// and on X11-based systems, we cover X11 and GLX as well. This
-// should cover nearly everything needed by a typical glean test.
-
-// It's unfortunate that both Windows and Xlib are so casual about
-// polluting the global namespace. The problem isn't easily resolved,
-// even with the use of C++ namespace directives, because (a) macros
-// in the include files refer to unqualified global variables, and (b)
-// preprocessor macros themselves aren't affected by namespaces.
-
-
-#ifndef __glwrap_h__
-#define __glwrap_h__
-
-#include "../util/piglit-dispatch.h"
-
-#if defined(__WIN__)
-# include <windows.h>
-#elif defined(__X11__)
-# include <GL/glx.h>
- // glx.h covers Xlib.h and gl.h, among others
-#elif defined(__AGL__)
-# include <Carbon/Carbon.h>
-# include <OpenGL/glext.h>
-# include <AGL/agl.h>
-# include <AGL/aglRenderers.h>
-# if !defined(sinf)
-# define sinf sin
-# define cosf cos
-# define sqrtf sqrt
-# endif
-#else
-# error "Improper window system configuration; must be __WIN__ or __X11__."
-#endif
-
-typedef unsigned short GLhalfARB;
-
-#endif // __glwrap_h__
diff --git a/tests/glean/image.h b/tests/glean/image.h
deleted file mode 100644
index ec1fd6f..0000000
--- a/tests/glean/image.h
+++ /dev/null
@@ -1,238 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// image.h: image data and attributes, image I/O
-
-// This class encapsulates OpenGL information related to images (size,
-// format, etc.) and provides utilities for transferring images to and
-// from files.
-
-
-#ifndef __image_h__
-#define __image_h__
-
-#include <string>
-#include "glwrap.h"
-#include "stats.h"
-
-namespace GLEAN {
-
-class Image {
-
- private:
-
- GLsizei _width;
- GLsizei _height;
- GLenum _format;
- GLenum _type;
- char* _pixels;
- GLsizei _alignment;
- GLsizei _rowSizeInBytes;
- GLsizei _pixelSizeInBytes;
-
- enum { // validation bits, for lazy validation
- vbRowSizeInBytes = 1,
- vbPixelSizeInBytes = 2,
- vbPacker = 4,
- vbUnpacker = 8,
- vbAll = ~0
- };
- int _invalid;
- inline bool invalid(int bit) const { return _invalid & bit; }
- inline bool valid(int bit) const { return !invalid(bit); }
- inline void invalidate(int bits) { _invalid |= bits; }
- inline void validate(int bits) { _invalid &= ~bits; }
-
- GLsizei validateRowSizeInBytes();
- GLsizei validatePixelSizeInBytes();
-
- typedef void Unpacker(GLsizei n, double* rgba, char* nextPixel);
- Unpacker* _unpacker;
- Unpacker* validateUnpacker();
- typedef void Packer(GLsizei n, char* nextPixel, double* rgba);
- Packer* _packer;
- Packer* validatePacker();
-
- // For now, we will require that:
- // 1. All images are in native byte order (so that byte swapping
- // at the OpenGL level is unnecessary).
- // 2. The image width and height above describe the entire image
- // (so that there is no need to specify row length
- // independently).
- // 3. We have no need to specify subimages at this level (so
- // there is no need for SKIP_ROWS and SKIP_PIXELS attributes).
-
- // Should construction fix the format and type for all time?
- // That would eliminate synchronization problems between data and
- // descriptive information that might arise when an Image is reused,
- // and might permit use of template functions instead of lots of
- // switches. Probably not; it would make dynamic type assignment
- // quite awkward.
-
- public:
-
- // Exceptions:
-
- struct Error { }; // Base class for all image errors.
- struct BadFormat: public Error { // Bad image format.
- GLenum format;
- BadFormat(GLenum f) {format = f;}
- };
- struct BadType: public Error { // Bad image type.
- GLenum type;
- BadType(GLenum t) {type = t;}
- };
- struct CantOpen: public Error { // Can't open file.
- const char* filename;
- CantOpen(const char* p) {filename = p;}
- };
- struct RefImageTooLarge: public Error { // Can't register ref image.
- };
-
- // Constructors/Destructor:
-
- Image();
- Image(int aWidth, int aHeight, GLenum aFormat, GLenum aType);
- Image(int aWidth, int aHeight, GLenum aFormat, GLenum aType,
- double r, double g, double b, double a);
- Image(Image& i);
- Image& operator= (Image& i);
- ~Image();
-
- // Reserve space for the pixel array:
-
- void reserve();
-
- // Get/Set attributes. These attributes are useful for calls
- // to glDrawPixels, glTexImage2D, etc. Note the alignment
- // value; passing it to glPixelStore is essential before using
- // one of the other OpenGL commands.
-
- inline GLsizei width() const // Image width, in pixels
- { return _width; }
- inline void width(GLsizei w)
- { _width = w; invalidate(vbRowSizeInBytes); }
-
- inline GLsizei height() const // Image height, in pixels.
- { return _height; }
- inline void height(GLsizei h)
- { _height = h; }
-
- inline GLenum format() const // Image format. Currently
- { return _format; } // these formats are supported:
- // GL_LUMINANCE,
- // GL_LUMINANCE_ALPHA,
- // GL_RGB, GL_RGBA.
- // It may be easiest to treat
- // stencil, depth, etc. images
- // as luminance images.
- inline void format(GLenum f) {
- _format = f;
- invalidate(
- vbRowSizeInBytes
- | vbPixelSizeInBytes
- | vbPacker
- | vbUnpacker);
- }
-
- inline GLenum type() const // Pixel data type. Currently
- { return _type; } // these types are supported:
- // GL_BYTE, GL_UNSIGNED_BYTE,
- // GL_SHORT, GL_UNSIGNED_SHORT,
- // GL_INT, GL_UNSIGNED_INT, GL_FLOAT.
- inline void type(GLenum t) {
- _type = t;
- invalidate(
- vbRowSizeInBytes
- | vbPixelSizeInBytes
- | vbPacker
- | vbUnpacker);
- }
-
- inline char* pixels() // The pixels.
- { return _pixels; }
- inline const char* pixels() const
- { return const_cast<const char*>(_pixels); }
- void pixels(char* p);
-
- inline GLsizei alignment() const // Alignment. See glPixelStore.
- { return _alignment; }
- inline void alignment(GLsizei a)
- { _alignment = a; invalidate(vbRowSizeInBytes); }
-
- inline GLsizei rowSizeInBytes() { // Size of scanline, in bytes
- return valid(vbRowSizeInBytes)?
- _rowSizeInBytes: validateRowSizeInBytes();
- }
-
- inline GLsizei pixelSizeInBytes() { // Size of pixel, in bytes
- return valid(vbPixelSizeInBytes)?
- _pixelSizeInBytes: validatePixelSizeInBytes();
- }
-
- // XXX Utilities to determine component size in bits/bytes?
- // XXX Component range (min neg, max neg, min pos, max pos, eps?)
-
- // Pixel packing/unpacking utilities:
-
- void unpack(GLsizei n, double* rgba, char* nextPixel);
- void pack(GLsizei n, char* nextPixel, double* rgba);
- // XXX get(x, y, double* rgba);
- // XXX put(x, y, double* rgba);
-
- // Image registration. The utility compares a reference image
- // to the current image (which must be at least as large as the
- // reference image in both dimensions), determines the offset at
- // which the reference image minus the current image has minimum
- // mean absolute error (summed over R, G, B, and A), and returns
- // an object specifying the offset and corresponding statistics.
-
- struct Registration {
- int wOffset; // offset in width (x)
- int hOffset; // offset in height (y)
- BasicStats stats[4]; // stats for absolute error in
- // R, G, B, and A
- };
- Registration reg(Image& img);
-
- // test if images are identical
- bool operator==(const Image &ref) const;
-
- // GL operation utilities:
-
- void draw(); // Invoke glDrawPixels.
- void read(GLint x, GLint y); // Invoke glReadPixels.
-
-}; // class Image
-
-} // namespace GLEAN
-
-#endif // __image_h__
diff --git a/tests/glean/image_misc.cpp b/tests/glean/image_misc.cpp
deleted file mode 100644
index f770d8f..0000000
--- a/tests/glean/image_misc.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// Implementation of image data, attribute, and I/O
-
-#include "image.h"
-#include <string.h>
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructors/Destructor
-///////////////////////////////////////////////////////////////////////////////
-// An empty image:
-Image::Image() {
- _width = _height = 0;
- _format = GL_RGB;
- _type = GL_UNSIGNED_BYTE;
- _pixels = 0;
- _alignment = 4;
- _packer = 0;
- _unpacker = 0;
- _invalid = vbAll;
-} // Image::Image
-
-// An unitialized image of the given type and size:
-Image::Image(int aWidth, int aHeight, GLenum aFormat, GLenum aType) {
- _width = aWidth;
- _height = aHeight;
- _format = aFormat;
- _type = aType;
- _pixels = 0;
- _alignment = 4;
- _packer = 0;
- _unpacker = 0;
- _invalid = vbAll;
- reserve();
-} // Image::Image(aWidth, aHeight, aFormat, aType)
-
-// An image of the given type and size, initialized to a solid color:
-Image::Image(int aWidth, int aHeight, GLenum aFormat, GLenum aType,
- double r, double g, double b, double a) {
- _width = aWidth;
- _height = aHeight;
- _format = aFormat;
- _type = aType;
- _pixels = 0;
- _alignment = 4;
- _packer = 0;
- _unpacker = 0;
- _invalid = vbAll;
- reserve();
- int i; // VC++ 6 doesn't handle the definition of variables in a
- // for-statement properly
-
- double* solidColor = new double[4 * width()];
- for (/*int */i = 0; i < 4 * width(); i += 4) {
- solidColor[i + 0] = r;
- solidColor[i + 1] = g;
- solidColor[i + 2] = b;
- solidColor[i + 3] = a;
- }
-
- char* row = pixels();
- for (/*int */i = 0; i < height(); ++i) {
- pack(width(), row, solidColor);
- row += rowSizeInBytes();
- }
-} // Image::Image(aWidth, aHeight, aFormat, aType)
-
-// Copy constructor:
-Image::Image(Image& i) {
- _width = i.width();
- _height = i.height();
- _format = i.format();
- _type = i.type();
- _alignment = i.alignment();
- _pixels = 0;
- _packer = 0;
- _unpacker = 0;
- _invalid = vbAll;
- reserve();
- memcpy(pixels(), i.pixels(), height() * rowSizeInBytes());
-} // Image::Image(Image&)
-
-/*Image::*/Image&
-Image::operator= (Image& i) {
- if (this == &i)
- return *this;
- width(i.width());
- height(i.height());
- format(i.format());
- type(i.type());
- alignment(i.alignment());
- _invalid = vbAll;
- reserve();
- memcpy(pixels(), i.pixels(), height() * rowSizeInBytes());
- return *this;
-} // Image::operator=
-
-Image::~Image() {
- if (_pixels)
- delete[] _pixels;
-}
-
-
-// Test if two images are identical
-bool Image::operator==(const Image &img) const
-{
- // cast away const because of rowSizeInBytes()
- Image &img1 = const_cast<Image&>(*this);
- Image &img2 = const_cast<Image&>(img);
-
- if (img1.width() != img2.width() ||
- img1.height() != img2.height() ||
- img1.format() != img2.format() ||
- img1.type() != img2.type() ||
- img1.alignment() != img2.alignment() ||
- img1.rowSizeInBytes() != img2.rowSizeInBytes())
- return false;
-
- const char *p1 = img1.pixels();
- const char *p2 = img2.pixels();
- const int n = img1.rowSizeInBytes() * img1.height();
- if (memcmp(p1, p2, n) != 0)
- return false;
-
- return true;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// pixels - set pointer to pixel array
-///////////////////////////////////////////////////////////////////////////////
-void
-Image::pixels(char* p) {
- // We always own our pixels, so delete the old ones (if any) before
- // installing new ones:
- if (_pixels)
- delete[] _pixels;
- _pixels = p;
-} // Image::pixels
-
-///////////////////////////////////////////////////////////////////////////////
-// reserve - reserve memory for image (assuming current type, format, and size)
-///////////////////////////////////////////////////////////////////////////////
-void
-Image::reserve() {
- pixels(0); // deallocate old pixel array
-
- const int size = height() * rowSizeInBytes();
- char * const p = new char[size];
- for (int i = 0; i < size; i++) {
- p[i] = 0;
- }
- pixels(p);
-} // Image::reserve
-
-///////////////////////////////////////////////////////////////////////////////
-// validateRowSizeInBytes - compute image row size, measured in bytes
-///////////////////////////////////////////////////////////////////////////////
-GLsizei
-Image::validateRowSizeInBytes() {
- _rowSizeInBytes =
- (width() * pixelSizeInBytes() + alignment() - 1)
- & ~(alignment() - 1);
- validate(vbRowSizeInBytes);
- return _rowSizeInBytes;
-} // Image::calcRowSizeInBytes
-
-///////////////////////////////////////////////////////////////////////////////
-// validatePixelSizeInBytes - compute pixel size, measured in bytes
-///////////////////////////////////////////////////////////////////////////////
-GLsizei
-Image::validatePixelSizeInBytes() {
- switch (format()) {
- case GL_LUMINANCE:
- _pixelSizeInBytes = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- _pixelSizeInBytes = 2;
- break;
- case GL_RGB:
- _pixelSizeInBytes = 3;
- break;
- case GL_RGBA:
- _pixelSizeInBytes = 4;
- break;
- default:
- throw BadFormat(format());
- }
-
- switch (type()) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- _pixelSizeInBytes <<= 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- _pixelSizeInBytes <<= 2;
- break;
- default:
- throw BadType(type());
- }
-
- validate(vbPixelSizeInBytes);
- return _pixelSizeInBytes;
-}
-
-}; // namespace GLEAN
diff --git a/tests/glean/lex.cpp b/tests/glean/lex.cpp
deleted file mode 100644
index d493910..0000000
--- a/tests/glean/lex.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// lex.cpp: Implementation of simple lexical analyzer
-
-#include <ctype.h>
-#include <stdlib.h>
-#include "lex.h"
-
-namespace GLEAN {
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructor:
-///////////////////////////////////////////////////////////////////////////////
-Lex::Lex(const char* s, bool ignoreCase/* = false */) {
- input = s;
- p = input;
- ignoringCase = ignoreCase;
- token = ERROR;
- iValue = 0;
-} // Lex::Lex
-
-///////////////////////////////////////////////////////////////////////////////
-// next - Fetch next token from the input string
-///////////////////////////////////////////////////////////////////////////////
-void
-Lex::next() {
- while (isspace(*p))
- ++p;
-
- if (isalpha(*p) || *p == '_') {
- id = "";
- if (ignoringCase)
- while (isalnum(*p) || *p == '_')
- id += tolower(*p++);
- else
- while (isalnum(*p) || *p == '_')
- id += *p++;
- token = ID;
- return;
- }
-
- if (isdigit(*p)) {
- iValue = strtol(p, const_cast<char**>(&p), 0);
- token = ICONST;
- return;
- }
-
- char nextC = 0;
- char c = *p++;
- if (c)
- nextC = *p;
- switch (c) {
- case '|':
- if (nextC == '|') {
- ++p;
- token = OR_OR;
- }
- else
- token = OR;
- break;
- case '&':
- if (nextC == '&') {
- ++p;
- token = AND_AND;
- }
- else
- token = AND;
- break;
- case '<':
- if (nextC == '=') {
- ++p;
- token = LE;
- }
- else
- token = LT;
- break;
- case '>':
- if (nextC == '=') {
- ++p;
- token = GE;
- }
- else
- token = GT;
- break;
- case '=':
- if (nextC == '=') {
- ++p;
- token = EQ;
- }
- else
- token = ASSIGN;
- break;
- case '!':
- if (nextC == '=') {
- ++p;
- token = NE;
- }
- else
- token = BANG;
- break;
- case '+':
- token = PLUS;
- break;
- case '-':
- token = MINUS;
- break;
- case '*':
- token = STAR;
- break;
- case '/':
- token = SLASH;
- break;
- case '%':
- token = PERCENT;
- break;
- case ',':
- token = COMMA;
- break;
- case '(':
- token = LPAREN;
- break;
- case ')':
- token = RPAREN;
- break;
- case '.':
- token = DOT;
- break;
- case '\0':
- token = END;
- --p; // push back '\0' so that token will always be END
- break;
- default:
- throw Lexical("unrecognized symbol", p - input);
- }
-
- return;
-} // Lex::next
-
-} // namespace GLEAN
diff --git a/tests/glean/lex.h b/tests/glean/lex.h
deleted file mode 100644
index 87e24df..0000000
--- a/tests/glean/lex.h
+++ /dev/null
@@ -1,128 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// lex.h: Simple lexical analysis utilities
-
-// Given a string containing C-style tokens, returns information about
-// successive tokens. Doesn't support all C tokens; just the few that
-// GLEAN needs.
-
-
-#ifndef __lex_h__
-#define __lex_h__
-
-#include <string>
-
-#ifdef __WIN__
-// ERROR is already defined in some windows header file
-#undef ERROR
-#endif
-
-namespace GLEAN {
-
-class Lex {
- protected:
-
- // State information:
- const char* input;
- const char* p;
- bool ignoringCase;
-
- public:
-
- // Constructors:
-
- Lex(const char* s, bool ignoreCase = false);
- // Creates a lexer which will draw input from the given string.
-
- // Exceptions:
-
- struct Error { }; // Base class for errors.
- struct Lexical: public Error { // Lexical error in string.
- const char* err;
- int position;
- Lexical(const char* e, int p) {
- err = e;
- position = p;
- }
- };
- struct InternalError: public Error { // Shouldn't happen.
- };
-
- // Tokens:
-
- typedef enum {
- ERROR = 0, // erroneous token; must be zero
- END, // end of input
-
- AND, // &
- AND_AND, // &&
- ASSIGN, // =
- BANG, // !
- COMMA, // ,
- DOT, // .
- EQ, // ==
- GE, // >=
- GT, // >
- LE, // <=
- LPAREN, // (
- LT, // <
- MINUS, // -
- NE, // !=
- OR, // |
- OR_OR, // ||
- PERCENT, // %
- PLUS, // +
- RPAREN, // )
- SLASH, // /
- STAR, // *
-
- ICONST, // signed integer constant
-
- ID // identifier
- } Token;
-
- // Utilities:
-
- void next(); // fetch next token
-
- Token token; // current token
- std::string id; // most recent identifier
- int iValue; // most recent signed integer value
-
- inline int position() { // current position in input string
- return p - input;
- }
-}; // class Lex
-
-} // namespace GLEAN
-
-#endif // __lex_h__
diff --git a/tests/glean/main.cpp b/tests/glean/main.cpp
deleted file mode 100644
index 8084d31..0000000
--- a/tests/glean/main.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// main.cpp: main program for Glean
-
-#include <cassert>
-#include <cstring>
-#include <iostream>
-#include <string>
-#include <vector>
-#include <cstring>
-#include <algorithm>
-#include "options.h"
-#include "environ.h"
-#include "test.h"
-#include "version.h"
-#include "lex.h"
-#include "dsfilt.h"
-
-using namespace std;
-
-using namespace GLEAN;
-
-char* mandatoryArg(int argc, char* argv[], int i);
-void selectTests(Options& o, vector<string>& allTestNames, int argc,
- char* argv[], int i);
-void usage(char* command);
-void listTests(const Test *tests, bool verbose);
-
-int
-main(int argc, char* argv[]) {
-
- // Until someone gets around to writing a fancy GUI front-end,
- // we'll set options the old-fashioned way.
- Options o;
- bool visFilter = false;
-
- vector<string> allTestNames;
- for (Test* t = Test::testList; t; t = t->nextTest)
- allTestNames.push_back(t->name);
- sort(allTestNames.begin(), allTestNames.end());
- o.selectedTests = allTestNames;
-
- bool listTestsMode = false;
-
- for (int i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "--help")) {
- usage(argv[0]);
- } else if (!strcmp(argv[i], "-v")
- || !strcmp(argv[i], "--verbose")) {
- ++o.verbosity;
- } else if (!strcmp(argv[i], "-o")
- || !strcmp(argv[i], "--overwrite")) {
- o.overwrite = true;
- } else if (!strcmp(argv[i], "--quick")) {
- o.quick = true;
- } else if (!strcmp(argv[i], "--visuals")) {
- visFilter = true;
- ++i;
- o.visFilter = mandatoryArg(argc, argv, i);
- } else if (!strcmp(argv[i], "-t")
- || !strcmp(argv[i], "--tests")) {
- ++i;
- selectTests(o, allTestNames, argc, argv, i);
- } else if (!strcmp(argv[i], "--listtests")) {
- listTestsMode = true;
-# if defined(__X11__)
- } else if (!strcmp(argv[i], "-display")
- || !strcmp(argv[i], "--display")) {
- ++i;
- o.dpyName = mandatoryArg(argc, argv, i);
-# endif
- } else {
- usage(argv[0]);
- }
- }
-
- if (listTestsMode) {
- listTests(Test::testList, o.verbosity);
- exit(0);
- }
-
- if (o.quick && !visFilter) {
- // If we have --quick but not --visuals then limit testing to
- // a single RGB, Z, Stencil visual.
- o.visFilter = "rgb && z>0 && s>0 && conformant";
- o.maxVisuals = 1;
- }
-
- // Create the test environment, then invoke each test to generate
- // results.
- try {
- Environment e(o);
- for (Test* t = Test::testList; t; t = t->nextTest)
- if (binary_search(o.selectedTests.begin(),
- o.selectedTests.end(), t->name))
- t->run(e);
- }
-#if defined(__X11__)
- catch (WindowSystem::CantOpenDisplay) {
- cerr << "can't open display " << o.dpyName << "\n";
- exit(1);
- }
-#endif
- catch (WindowSystem::NoOpenGL) {
- cerr << "display doesn't support OpenGL\n";
- exit(1);
- }
- catch (DrawingSurfaceFilter::Syntax e) {
- cerr << "Syntax error in visual selection criteria:\n"
- "'" << o.visFilter << "'\n";
- for (int i = 0; i < e.position; ++i)
- cerr << ' ';
- cerr << "^ " << e.err << '\n';
- exit(1);
- }
- catch (...) {
- cerr << "caught an unexpected error in main()\n";
- exit(1);
- }
-
- return 0;
-} // main
-
-
-char*
-mandatoryArg(int argc, char* argv[], int i) {
- if (i < argc && argv[i][0] != '-')
- return argv[i];
- usage(argv[0]);
- /*NOTREACHED*/
- return 0;
-} // mandatoryArg
-
-
-void
-selectTests(Options& o, vector<string>& allTestNames, int argc, char* argv[],
- int i) {
- if (i >= argc)
- usage(argv[0]);
-
- // At present, we deal with the following syntax:
- // [+] testname {(+|-) testname}
- // Assume we're running none of the tests, then include
- // those preceded by "+" and exclude those preceded by
- // "-".
- // - testname {(+|-) testname}
- // Assume we're running all of the tests, then exclude
- // those preceded by "-" and include those preceded by
- // "+".
- // XXX It would be nice to support the syntax "@filename" to mean
- // "the list of tests given in the named file." This could be
- // preceded by "+" or "-" just like an ordinary test name, or maybe
- // the +/- should be required in the file itself.
-
- struct SyntaxError {
- int position;
- SyntaxError(int pos): position(pos) { }
- };
-
- Lex lex(argv[i]);
- try {
- lex.next();
- if (lex.token == Lex::MINUS)
- o.selectedTests = allTestNames;
- else
- o.selectedTests.resize(0);
-
- while (lex.token != Lex::END) {
- bool inserting = true;
- if (lex.token == Lex::MINUS) {
- inserting = false;
- lex.next();
- } else if (lex.token == Lex::PLUS)
- lex.next();
-
- if (lex.token != Lex::ID)
- throw SyntaxError(lex.position());
-
- if (!binary_search(allTestNames.begin(),
- allTestNames.end(), lex.id))
- cerr << "Warning: " << lex.id << " ignored;"
- " not a valid test name.\n";
- else {
- vector<string>::iterator p =
- lower_bound(o.selectedTests.begin(),
- o.selectedTests.end(), lex.id);
- if (inserting) {
- if (p == o.selectedTests.end()
- || *p != lex.id)
- o.selectedTests.insert(p,
- lex.id);
- } else {
- // removing
- if (p != o.selectedTests.end()
- && *p == lex.id)
- o.selectedTests.erase(p);
- }
- }
- lex.next();
- }
- }
- catch (Lex::Lexical e) {
- cerr << "Lexical error in test inclusion/exclusion list:\n"
- "'" << argv[i] << "'\n";
- for (int i = 0; i < e.position; ++i)
- cerr << ' ';
- cerr << "^ " << e.err << "\n\n";
- usage(argv[0]);
- }
- catch (SyntaxError e) {
- cerr << "'" << argv[i] << "'\n";
- for (int i = 0; i < e.position; ++i)
- cerr << ' ';
- cerr << "^ Syntax error in test inclusion/exclusion list\n\n";
- usage(argv[0]);
- }
-} // selectTests
-
-
-void
-listTests(const Test *tests, bool verbose) {
- for (const Test *t = tests; t; t = t->nextTest) {
- cout << t->name << (verbose? ":" : "") << "\n";
- if (verbose) {
- cout << t->description;
- cout << '\n';
- }
- }
-}
-
-
-void
-usage(char* command) {
- cerr << GLEAN::versionString << '\n';
- cerr << "Usage: " << command << " [options]\n"
-"\n"
-"options:\n"
-" (-v|--verbose) # each occurrence increases\n"
-" # verbosity of output\n"
-" (-o|--overwrite) # overwrite existing results database\n"
-" --visuals 'filter-string' # select subset of visuals (FBConfigs,\n"
-" # pixel formats) to test\n"
-" (-t|--tests) {(+|-)test} # choose tests to include (+) or exclude (-)\n"
-" --quick # run fewer tests to reduce test time\n"
-" --listtests # list test names and exit\n"
-" --help # display usage information\n"
-#if defined(__X11__)
-" -display X11-display-name # select X11 display to use\n"
-" (or --display)\n"
-#elif defined(__WIN__)
-#endif
- ;
- exit(1);
-} // usage
diff --git a/tests/glean/misc.cpp b/tests/glean/misc.cpp
deleted file mode 100644
index 99f84d1..0000000
--- a/tests/glean/misc.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// misc.cpp: implementation of miscellaneous functions
-
-#include <cctype>
-#include <cmath>
-#ifdef __CYGWIN__
-#undef log2
-#endif
-#include "misc.h"
-
-namespace GLEAN {
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Utility routine to skip whitespace in streams
-// This is helpful when interleaving invocations of getline() and
-// operator>>. In particular, after operator>> at the end of a line,
-// there may be whitespace (especially a newline) remaining; this may
-// confuse a subsequent invocation of getline().
-///////////////////////////////////////////////////////////////////////////////
-void
-SkipWhitespace(istream& s) {
- char c;
- while (s.get(c)) {
- if (!isspace(c)) {
- s.putback(c);
- break;
- }
- }
-} // SkipWhitespace
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Utility routine to compute logarithm, base two
-///////////////////////////////////////////////////////////////////////////////
-double
-log2(double x) {
- return 1.4426950408889634 * log(x);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Utility routine to compute error, expressed in bits
-// Typically used to convert a floating-point error (in the range [0,1])
-// to the number of bits in the representation of a color.
-///////////////////////////////////////////////////////////////////////////////
-double
-ErrorBits(double absError, int repBits) {
- if (absError <= 0.0)
- return 0.0;
- double log2Error = log2(absError) + repBits;
- return (log2Error <= 0.0)? 0.0: log2Error;
-} // ErrorBits
-
-
-} // namespace GLEAN
diff --git a/tests/glean/misc.h b/tests/glean/misc.h
deleted file mode 100644
index 0590a5f..0000000
--- a/tests/glean/misc.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// misc.h: Miscellaneous functions
-
-
-#ifndef __misc_h__
-#define __misc_h__
-
-using namespace std;
-
-#include <iostream>
-
-namespace GLEAN {
-
-void SkipWhitespace(istream& s);
-double ErrorBits(double absError, int repBits);
-double log2(double x);
-
-} // namespace GLEAN
-
-#endif // __misc_h__
diff --git a/tests/glean/options.cpp b/tests/glean/options.cpp
deleted file mode 100644
index d77fbc5..0000000
--- a/tests/glean/options.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// options.cpp: implementation of global options class
-
-#include "options.h"
-#if defined(__X11__)
-# include <stdlib.h>
-#endif
-
-namespace GLEAN {
-
-
-
-Options::Options() {
- verbosity = 0;
- visFilter = "1";
- maxVisuals = ~0U;
- selectedTests.resize(0);
- overwrite = false;
- quick = false;
-# if defined(__X11__)
- {
- char* display = getenv("DISPLAY");
- if (display)
- dpyName = display;
- else
- dpyName = ":0";
- }
-# elif defined(__WIN__)
-# endif
-} // Options::Options()
-
-
-
-} // namespace GLEAN
diff --git a/tests/glean/options.h b/tests/glean/options.h
deleted file mode 100644
index 26fac81..0000000
--- a/tests/glean/options.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// options.h: global test options
-
-// This class encapsulates global options that apply to the entire
-// testing process -- things like the display name (for X11),
-// constraints on the drawing surface configurations to be tested,
-// locations of test results files, etc.
-
-// We collect this information for two reasons. First, it allows the
-// (relatively) large number of parameters needed for creating an
-// Environment to be passed cleanly to Environment's constructor.
-// Second, it allows the process of gathering parameters (by parsing a
-// command line, running a set of GUI dialogs, etc.) to be separated
-// from the creation of the Environment.
-
-
-
-#ifndef __options_h__
-#define __options_h__
-
-#include <string>
-#include <vector>
-
-using namespace std;
-
-namespace GLEAN {
-
-class Options {
- public:
- int verbosity; // Verbosity level. 0 == concise; larger
- // values imply more verbose output.
-
- string visFilter; // Filter constraining the set of visuals
- // (FBConfigs, pixel formats) that will be
- // available for test. See
- // DrawingSurfaceFilter for description of
- // contents.
-
- unsigned int maxVisuals;// Max number of visuals to test
-
- vector<string> selectedTests;
- // Sorted list of tests to be executed.
-
- bool overwrite; // overwrite old results database if exists
-
- bool quick; // run fewer/quicker tests when possible
-
-#if defined(__X11__)
- string dpyName; // Name of the X11 display providing the
- // OpenGL implementation to be tested.
-#elif defined(__WIN__)
-#endif
-
- Options();
-}; // class Options
-
-} // namespace GLEAN
-
-#endif // __options_h__
diff --git a/tests/glean/pack.cpp b/tests/glean/pack.cpp
deleted file mode 100644
index 11617ef..0000000
--- a/tests/glean/pack.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// Data packing utilities. Note that these map component values per
-// the usual OpenGL conversions. Also, see comments in unpack.cpp.
-
-#include "image.h"
-
-namespace {
-
-#define SCALE (static_cast<double>(num) / static_cast<double>(denom))
-#define BIAS (static_cast<double>(bias) / static_cast<double>(denom))
-
-// The original implementation of packing functions (using function
-// templates) wouldn't compile under VC6, but this slight variant
-// using static member functions in a class template will compile.
-
-template<class component, int num, unsigned int denom, int bias>
-class Pack
-{
-public :
- // pack_l
- static void pack_l(GLsizei n, char* dst, double* rgba)
- {
- component* out = reinterpret_cast<component*>(dst);
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias)
- out[0] = static_cast<component>(SCALE * rgba[0] - BIAS);
- else
- out[0] = static_cast<component>(SCALE * rgba[0]);
- out += 1;
- }
- }
-
- // pack_la
- static void pack_la(GLsizei n, char* dst, double* rgba)
- {
- component* out = reinterpret_cast<component*>(dst);
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias) {
- out[0] = static_cast<component>(SCALE * rgba[0] - BIAS);
- out[1] = static_cast<component>(SCALE * rgba[3] - BIAS);
- } else {
- out[0] = static_cast<component>(SCALE * rgba[0]);
- out[1] = static_cast<component>(SCALE * rgba[3]);
- }
- out += 2;
- }
- }
-
- // pack_rga
- static void pack_rgb(GLsizei n, char* dst, double* rgba)
- {
- component* out = reinterpret_cast<component*>(dst);
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias) {
- out[0] = static_cast<component>(SCALE * rgba[0] - BIAS);
- out[1] = static_cast<component>(SCALE * rgba[1] - BIAS);
- out[2] = static_cast<component>(SCALE * rgba[2] - BIAS);
- } else {
- out[0] = static_cast<component>(SCALE * rgba[0]);
- out[1] = static_cast<component>(SCALE * rgba[1]);
- out[2] = static_cast<component>(SCALE * rgba[2]);
- }
- out += 3;
- }
- }
-
- // pack_rgba
- static void pack_rgba(GLsizei n, char* dst, double* rgba)
- {
- component* out = reinterpret_cast<component*>(dst);
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias) {
- out[0] = static_cast<component>(SCALE * rgba[0] - BIAS);
- out[1] = static_cast<component>(SCALE * rgba[1] - BIAS);
- out[2] = static_cast<component>(SCALE * rgba[2] - BIAS);
- out[3] = static_cast<component>(SCALE * rgba[3] - BIAS);
- } else {
- out[0] = static_cast<component>(SCALE * rgba[0]);
- out[1] = static_cast<component>(SCALE * rgba[1]);
- out[2] = static_cast<component>(SCALE * rgba[2]);
- out[3] = static_cast<component>(SCALE * rgba[3]);
- }
- out += 4;
- }
- }
-
-}; // class Pack
-
-#undef SCALE
-#undef BIAS
-
-}; // anonymous namespace
-
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// Public interface
-///////////////////////////////////////////////////////////////////////////////
-void
-Image::pack(GLsizei n, char* nextPixel, double* rgba) {
- (*(valid(vbPacker)? _packer: validatePacker())) (n, nextPixel, rgba);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// validatePacker - select appropriate pixel-packing utility
-///////////////////////////////////////////////////////////////////////////////
-
-Image::Packer*
-Image::validatePacker() {
- switch (format()) {
- case GL_LUMINANCE:
- switch (type()) {
- case GL_BYTE:
- _packer = Pack<GLbyte, 255, 2, 1>::pack_l;
- break;
- case GL_UNSIGNED_BYTE:
- _packer = Pack<GLubyte, 255, 1, 0>::pack_l;
- break;
- case GL_SHORT:
- _packer = Pack<GLshort, 65535, 2, 1>::pack_l;
- break;
- case GL_UNSIGNED_SHORT:
- _packer = Pack<GLushort, 65535, 1, 0>::pack_l;
- break;
- case GL_INT:
- _packer = Pack<GLint, 4294967295U, 2, 1>::pack_l;
- break;
- case GL_UNSIGNED_INT:
- _packer = Pack<GLuint, 4294967295U, 1, 0>::pack_l;
- break;
- case GL_FLOAT:
- _packer = Pack<GLfloat, 1, 1, 0>::pack_l;
- break;
- default:
- throw BadType(type());
- }
- break;
- case GL_LUMINANCE_ALPHA:
- switch (type()) {
- case GL_BYTE:
- _packer = Pack<GLbyte, 255, 2, 1>::pack_la;
- break;
- case GL_UNSIGNED_BYTE:
- _packer = Pack<GLubyte, 255, 1, 0>::pack_la;
- break;
- case GL_SHORT:
- _packer = Pack<GLshort, 65535, 2, 1>::pack_la;
- break;
- case GL_UNSIGNED_SHORT:
- _packer = Pack<GLushort, 65535, 1, 0>::pack_la;
- break;
- case GL_INT:
- _packer = Pack<GLint, 4294967295U, 2, 1>::pack_la;
- break;
- case GL_UNSIGNED_INT:
- _packer = Pack<GLuint, 4294967295U, 1, 0>::pack_la;
- break;
- case GL_FLOAT:
- _packer = Pack<GLfloat, 1, 1, 0>::pack_la;
- break;
- default:
- throw BadType(type());
- }
- break;
- case GL_RGB:
- switch (type()) {
- case GL_BYTE:
- _packer = Pack<GLbyte, 255, 2, 1>::pack_rgb;
- break;
- case GL_UNSIGNED_BYTE:
- _packer = Pack<GLubyte, 255, 1, 0>::pack_rgb;
- break;
- case GL_SHORT:
- _packer = Pack<GLshort, 65535, 2, 1>::pack_rgb;
- break;
- case GL_UNSIGNED_SHORT:
- _packer = Pack<GLushort, 65535, 1, 0>::pack_rgb;
- break;
- case GL_INT:
- _packer = Pack<GLint, 4294967295U, 2, 1>::pack_rgb;
- break;
- case GL_UNSIGNED_INT:
- _packer = Pack<GLuint, 4294967295U, 1, 0>::pack_rgb;
- break;
- case GL_FLOAT:
- _packer = Pack<GLfloat, 1, 1, 0>::pack_rgb;
- break;
- default:
- throw BadType(type());
- }
- break;
- case GL_RGBA:
- switch (type()) {
- case GL_BYTE:
- _packer = Pack<GLbyte, 255, 2, 1>::pack_rgba;
- break;
- case GL_UNSIGNED_BYTE:
- _packer = Pack<GLubyte, 255, 1, 0>::pack_rgba;
- break;
- case GL_SHORT:
- _packer = Pack<GLshort, 65535, 2, 1>::pack_rgba;
- break;
- case GL_UNSIGNED_SHORT:
- _packer = Pack<GLushort, 65535, 1, 0>::pack_rgba;
- break;
- case GL_INT:
- _packer = Pack<GLint, 4294967295U, 2, 1>::pack_rgba;
- break;
- case GL_UNSIGNED_INT:
- _packer = Pack<GLuint, 4294967295U, 1, 0>::pack_rgba;
- break;
- case GL_FLOAT:
- _packer = Pack<GLfloat, 1, 1, 0>::pack_rgba;
- break;
- default:
- throw BadType(type());
- }
- break;
- default:
- throw BadFormat(format());
- }
-
- validate(vbPacker);
- return _packer;
-}
-
-}; // namespace GLEAN
diff --git a/tests/glean/rand.h b/tests/glean/rand.h
deleted file mode 100644
index b47684d..0000000
--- a/tests/glean/rand.h
+++ /dev/null
@@ -1,125 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// rand.h: Simple random sequence generation utilities.
-
-// We provide these to eliminate dependencies on the operating
-// system's random number generator. This makes it possible to
-// compare results for a given graphics device running under different
-// operating systems.
-
-// Based on Numerical Recipes, 2d ed., p. 284.
-
-
-#ifndef __rand_h__
-#define __rand_h__
-
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// RandomBase: Quick-and-dirty linear congruential generator that serves as
-// a base for other random-sequence classes.
-///////////////////////////////////////////////////////////////////////////////
-class RandomBase {
- unsigned int i;
- public:
- inline RandomBase(unsigned int seed): i(seed) { }
- inline RandomBase(): i(1) { }
- inline unsigned int next() {
- i = 1664525 * i + 1013904223;
- return i;
- }
-}; // class RandomBase
-
-///////////////////////////////////////////////////////////////////////////////
-// RandomBits: Returns a given number of random bits (expressed as an unsigned
-// int, so the maximum portable number of bits is 32).
-///////////////////////////////////////////////////////////////////////////////
-class RandomBits: public RandomBase {
- unsigned int shift;
- public:
- inline RandomBits(unsigned int bits, unsigned int seed):
- RandomBase(seed), shift(32 - bits) { }
- inline RandomBits(unsigned int bits):
- RandomBase(), shift(32 - bits) { }
- inline unsigned int next() { return RandomBase::next() >> shift; }
-}; // class RandomBits
-
-///////////////////////////////////////////////////////////////////////////////
-// RandomSignedBits: Returns a given number of random bits (expressed as a
-// signed int, so the maximum portable number of bits is 32 including sign).
-///////////////////////////////////////////////////////////////////////////////
-class RandomSignedBits: public RandomBase {
- unsigned int shift;
- public:
- inline RandomSignedBits(unsigned int bits, unsigned int seed):
- RandomBase(seed), shift(32 - bits) { }
- inline RandomSignedBits(unsigned int bits):
- RandomBase(), shift(32 - bits) { }
- inline int next() {
- return static_cast<int>(RandomBase::next()) >> shift;
- }
-}; // class RandomSignedBits
-
-///////////////////////////////////////////////////////////////////////////////
-// RandomDouble: Returns a random floating-point value in the closed
-// interval [0.0, 1.0].
-///////////////////////////////////////////////////////////////////////////////
-class RandomDouble: public RandomBase {
- public:
- inline RandomDouble(unsigned int seed): RandomBase(seed) { }
- inline RandomDouble(): RandomBase() { }
- inline double next() {
- return static_cast<double>(RandomBase::next()) / 4294967295.0;
- }
-}; // class RandomDouble
-
-///////////////////////////////////////////////////////////////////////////////
-// RandomBitsDouble: Returns a random floating-point value in the closed
-// interval [0.0, 1.0], but with possible values limited by a generator
-// returning a specific number of bits.
-///////////////////////////////////////////////////////////////////////////////
-class RandomBitsDouble: public RandomBits {
- double scale;
- public:
- inline RandomBitsDouble(unsigned int bits, unsigned int seed):
- RandomBits(bits, seed) { scale = (1 << bits) - 1.0; }
- inline RandomBitsDouble(unsigned int bits):
- RandomBits(bits) { scale = (1 << bits) - 1.0; }
- inline double next() {
- return static_cast<double>(RandomBits::next()) / scale;
- }
-}; // class RandomBitsDouble
-
-} // namespace GLEAN
-
-#endif // __rand_h__
diff --git a/tests/glean/rc.cpp b/tests/glean/rc.cpp
deleted file mode 100644
index e432d99..0000000
--- a/tests/glean/rc.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// rc.cpp: implementation of rendering context utilities
-
-#include <iostream>
-#include <algorithm>
-#include "rc.h"
-#include "dsconfig.h"
-#include "winsys.h"
-
-namespace {
-
-#if defined (__WIN__)
-
-// XXX
-// wglCreateContext requires a handle to a device context.
-// The ctor of RenderingContext doesn't know which window
-// it is creating a surface for, only what the pixelformat
-// of that window is. The hDC passed to wglCreateContext
-// doesn't have to be the same as the one use in SwapBuffers
-// or wglMakeCurrent, their pixelformats have to be the
-// same though. A limitation is that the pixelformat of
-// a window can only be set once. That is why a
-// temporary window is created.
-
-
-HGLRC create_context(GLEAN::DrawingSurfaceConfig &c)
-{
- HWND hwnd = CreateWindow("STATIC","temp",WS_POPUP,
- CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
- 0,0,GetModuleHandle(NULL),0);
-
- if (!hwnd)
- return 0;
-
- HDC hDC = GetDC(hwnd);
- if (!hDC)
- return 0;
-
- if (!SetPixelFormat(hDC,c.pfdID,&c.pfd))
- {
- ReleaseDC(hwnd,hDC);
- DestroyWindow(hwnd);
- return 0;
- }
-
- HGLRC rc = wglCreateContext(hDC);
- if (!rc)
- return 0;
-
- ReleaseDC(hwnd,hDC);
- DestroyWindow(hwnd);
-
- return rc;
-}
-
-#endif
-
-} // anonymous namespace
-
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructors
-///////////////////////////////////////////////////////////////////////////////
-RenderingContext::RenderingContext(WindowSystem& ws, DrawingSurfaceConfig& c,
- RenderingContext* share, bool direct) {
-
- // Link back to enclosing window system, so as to simplify bookkeeping:
- winSys = &ws;
- ws.contexts.push_back(this);
-
-# if defined(__X11__)
-
-# if defined(GLX_VERSION_1_3)
-
- if (ws.GLXVersMajor == 1 && ws.GLXVersMinor < 3)
- goto legacyMethod;
- // XXX Need GLX 1.3 rc constructor code
- // For now, just fall through.
-
-# endif
-
-legacyMethod:
- // Create the rendering context:
- rc = glXCreateContext(winSys->dpy, c.vi, (share? share->rc: 0),
- direct? True: False);
- if (!rc)
- throw Error();
- // XXX Ideally, we would deal with X11 and GLX errors here, too
- // (Badmatch, BadValue, GLXBadContext, BadAlloc)
-
-# elif defined(__WIN__)
-
- rc = create_context(c);
- if (!rc)
- throw Error();
-# elif defined(__AGL__)
- rc = aglCreateContext(c.pf, NULL);
- if(rc == NULL)
- throw Error();
-# endif
-
-} // RenderingContext::RenderingContext
-
-///////////////////////////////////////////////////////////////////////////////
-// Destructors
-///////////////////////////////////////////////////////////////////////////////
-
-RenderingContext::~RenderingContext() {
- remove(winSys->contexts.begin(), winSys->contexts.end(), this);
-# if defined(__X11__)
-# if defined(GLX_VERSION_1_3)
- if (winSys->GLXVersMajor == 1 && winSys->GLXVersMinor < 3)
- goto legacyMethod;
- // XXX Need to write GLX 1.3 rc destructor
- // For now, just fall through.
-# endif
-legacyMethod:
- glXDestroyContext(winSys->dpy, rc);
-# elif defined(__WIN__)
- wglDeleteContext(rc);
-# endif
-} // RenderingContext::~RenderingContext
-
-
-} // namespace GLEAN
diff --git a/tests/glean/rc.h b/tests/glean/rc.h
deleted file mode 100644
index eaea515..0000000
--- a/tests/glean/rc.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// rc.h: utilities for manipulating rendering contexts
-
-#ifndef __rc_h__
-#define __rc_h__
-
-#include "glwrap.h"
-
-namespace GLEAN {
-
-class WindowSystem; // Forward and mutually-recursive references
-class DrawingSurfaceConfig;
-
-class RenderingContext {
- public:
- RenderingContext(WindowSystem& ws, DrawingSurfaceConfig& c,
- RenderingContext* share = 0, bool direct = true);
- ~RenderingContext();
-
- // Exceptions:
- struct Error { }; // Base class for all errors.
-
- // Members:
- WindowSystem* winSys; // Window system that owns this context.
-
-# if defined(__X11__)
- GLXContext rc;
-# elif defined(__WIN__)
- ::HGLRC rc;
-# elif defined(__AGL__)
- ::AGLContext rc;
-# endif
-
-}; // class RenderingContext
-
-} // namespace GLEAN
-
-#endif // __rc_h__
diff --git a/tests/glean/reg.cpp b/tests/glean/reg.cpp
deleted file mode 100644
index 87c8c41..0000000
--- a/tests/glean/reg.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// Image registration.
-
-#include <cfloat>
-#include "image.h"
-
-#include <cmath> // for fabs
-
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// register: compare a reference image to the current (``test'') image.
-//
-// The reference image must be no larger than the current image, in
-// both dimensions. Type doesn't matter, as both images will be
-// converted to RGBA.
-//
-// The reference image will be slid into all possible positions over
-// the current image, and the sum of the mean absolute errors for all
-// four color channels computed at each position.
-//
-// Returns an Image::Registration struct that specifies the position at
-// which the sum of mean absolute errors was minimal, plus the statistics
-// at that position.
-///////////////////////////////////////////////////////////////////////////////
-Image::Registration
-Image::reg(Image& ref) {
- int wt = width(); // Width of test image, in pixels.
- int ht = height(); // Height of test image, in pixels.
- int wr = ref.width(); // Width of reference image, in pixels.
- int hr = ref.height(); // Height of test image, in pixels.
- int dh = ht - hr; // Difference in heights, in pixels.
- int dw = wt - wr; // Difference in widths, in pixels.
- int i;
-
- if (dh < 0 || dw < 0)
- throw RefImageTooLarge();
-
- int wt4 = 4 * wt; // Width of test image, in RGBA samples.
- int wr4 = 4 * wr; // Width of ref image, in RGBA samples.
- int dw4 = 4 * dw; // Difference in widths, in samples.
-
- double** testPix; // Buffers containing all the rows of
- // the test image that need to be
- // accessed concurrently.
- // XXX sure would be nice to use auto_ptr to allocate this stuff,
- // but it isn't supported in the STL that came with egcs 1.1.2.
-
- // XXX testPix = new (double*) [dh + 1];
- // VC 6 seems to misinterpret this as a c-style cast
- testPix = new double* [dh + 1];
-
-
- for (/*int */i = 0; i <= dh; ++i)
- testPix[i] = new double [wt4];
-
- double* refPix = new double [wr4];
- // Buffer containing the one row of
- // the reference image that's accessed
- // at any given time.
-
- BasicStats** stats; // Buffers containing a statistics-
- // gathering structure for each of
- // the possible reference image
- // positions.
- // XXX stats = new (BasicStats*) [dh + 1];
- // VC 6 seems to misinterpret this as a c-style cast
- stats = new BasicStats * [dh + 1];
-
- for (/*int*/ i = 0; i <= dh; ++i)
- stats[i] = new BasicStats [dw4 + 4];
-
- // Prime the pump by unpacking the first few rows of the test image:
- char* testRow = pixels();
- for (/*int*/ i = 0; i < dh; ++i) {
- unpack(wt, testPix[i], testRow);
- testRow += rowSizeInBytes();
- }
-
- // Now accumulate statistics for one row of the reference image
- // at a time, in all possible positions:
- char* refRow = ref.pixels();
- for (/*int*/ i = 0; i < hr; ++i) {
- // Get the next row of the reference image:
- ref.unpack(wr, refPix, refRow);
- refRow += ref.rowSizeInBytes();
-
- // Get the next row of the test image:
- unpack(wt, testPix[dh], testRow);
- testRow += rowSizeInBytes();
-
- // Accumulate absolute error for R,G,B,A in all positions:
- for (int j = 0; j <= dh; ++j)
- for (int k = 0; k <= dw4; k += 4)
- for (int m = 0; m < wr4; m += 4) {
- stats[j][k+0].sample( fabs(
- refPix[m+0]-testPix[j][m+k+0]));
- stats[j][k+1].sample( fabs(
- refPix[m+1]-testPix[j][m+k+1]));
- stats[j][k+2].sample( fabs(
- refPix[m+2]-testPix[j][m+k+2]));
- stats[j][k+3].sample( fabs(
- refPix[m+3]-testPix[j][m+k+3]));
- }
- }
-
- // Now find the position for which the sum of the mean absolute errors
- // is minimal:
- double minErrorSum = DBL_MAX;
- int minI = 0;
- int minJ = 0;
- for (/*int*/ i = 0; i <= dh; ++i)
- for (int j = 0; j <= dw4; j += 4) {
- double errorSum = stats[i][j+0].mean()
- + stats[i][j+1].mean()
- + stats[i][j+2].mean()
- + stats[i][j+3].mean();
- if (errorSum < minErrorSum) {
- minErrorSum = errorSum;
- minI = i;
- minJ = j;
- }
- }
-
- Registration r;
- r.wOffset = minJ / 4;
- r.hOffset = minI;
- r.stats[0] = stats[minI][minJ+0];
- r.stats[1] = stats[minI][minJ+1];
- r.stats[2] = stats[minI][minJ+2];
- r.stats[3] = stats[minI][minJ+3];
-
- // Clean up:
- for (/*int*/ i = 0; i <= dh; ++i)
- delete[] testPix[i];
- delete[] testPix;
- delete[] refPix;
- for (/*int*/ i = 0; i <= dh; ++i)
- delete[] stats[i];
- delete[] stats;
-
- return r;
-} // Image::register
-
-}; // namespace GLEAN
diff --git a/tests/glean/stats.h b/tests/glean/stats.h
deleted file mode 100644
index d9eb019..0000000
--- a/tests/glean/stats.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// stats.h: simple statistics-gathering utilities for glean
-
-// These are rather simplistic. For more robust implementations, consider
-// using Numerical Recipes.
-
-#ifndef __stats_h__
-#define __stats_h__
-
-#include <vector>
-
-#ifdef __WIN__
-using namespace std;
-#endif
-
-#if defined( __WIN__ )
-
-#undef min
-#undef max
-
-#endif
-
-namespace GLEAN {
-
-class BasicStats {
- int _n;
- double _min;
- double _max;
- double _sum;
- double _sum2;
- public:
- void init();
- inline int n() const {return _n;}
- inline double min() const {return _min;}
- inline double max() const {return _max;}
- inline double sum() const {return _sum;}
- inline double sum2() const {return _sum2;}
- double mean() const;
- double variance() const;
- double deviation() const;
- inline void sample(double d) {
- ++_n;
- if (d < _min)
- _min = d;
- if (d > _max)
- _max = d;
- _sum += d;
- _sum2 += d*d;
- }
-
- BasicStats() {init();}
- template<class T> BasicStats(std::vector<T>& v) {
- init();
- for (typename std::vector<T>::const_iterator p = v.begin(); p < v.end(); ++p)
- sample(*p);
- }
-}; // class BasicStats
-
-} // namespace GLEAN
-
-#endif // __stats_h__
diff --git a/tests/glean/tbase.h b/tests/glean/tbase.h
deleted file mode 100644
index b5fe2c5..0000000
--- a/tests/glean/tbase.h
+++ /dev/null
@@ -1,370 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999-2000 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-/*
-tbase.h: Base template class for (most) tests
-
-In general, a glean test is an instance of a class derived from the
-class Test. It produces a vector of results, which are instances of a
-class derived from the class Result. Most glean tests are "portable"
-in the sense that they don't contain OS- or window-system-specific
-code; those things are abstracted by the Environment and WindowSystem
-classes.
-
-This file contains a template class and result class that serve as
-bases for portable tests, and several macros that simplify test class
-declarations.
-
-The result class, BaseResult, includes utility functions that read and
-write test results. To use it, derive a new class from it, add
-whatever variables you need to store your test results, and override
-the getresults() and putresults() member functions to read and write
-those variables from and to a stream.
-
-The template class, BaseTest, is parameterized by the result class and
-declares member functions and variables that are common to all
-portable tests. This includes the member function run() which is
-invoked for each test by main(). BaseTest also provides several
-variables which you might want to use when constructing a test:
-
- A drawing surface filter string. The test can be run on all
- the drawing surface configurations that are selected by the
- filter, and one result structure will be generated for each
- such configuration.
-
- A flag indicating whether the test is to be run on *all*
- drawing surface configurations, or just one. For tests that
- take a long time to run, it is often sufficient to check just
- one drawing surface configuration rather than all of them.
-
- An extension filter string. The test will only be run on
- contexts that support all the listed extensions. Extension
- names in the string may be separated with non alphanumerics;
- whitespace and commas are used by convention.
-
- A description string. This will be printed in the test log to
- describe the test.
-
- Default width and height for any windows to be created by the
- test.
-
- A pointer to an array of other tests that must be run before
- running the current test. This makes the results of
- "prerequisite" tests available.
-
-To use BaseTest, declare a new class derived from BaseTest,
-parameterized by your result class. Then override the runOne()
-and logOne() member functions. runOne() runs a test and generates a
-result. logOne() generates a log message summarizing the result of
-the test.
-
-Your new test will need a few common declarations (such as
-constructors). To simplify writing them, this file provides a few
-helper macros. GLEAN_CLASS(TEST,RESULT) handles the declarations for
-a test class named TEST and a result class named RESULT, using the
-default values for window width and height and the run-once flag.
-GLEAN_CLASS_WH() and GLEAN_CLASS_WHO() allow you to specify the width,
-height, and run-once flag if you choose.
-
-Finally, declare an object using your new test class. This object
-must be global, so that its constructor will automatically add it to
-the list of all tests.
-
-You can find an example of this whole process in the files tbasic.h
-and tbasic.cpp.
-
-*/
-
-
-#ifndef __tbase_h__
-#define __tbase_h__
-
-#include "piglit-dispatch.h"
-
-#ifdef __UNIX__
-#include <unistd.h>
-#endif
-
-#ifdef __WIN32__
-#define sleep(__sec) Sleep((__sec)*1000)
-#define usleep(__usec) Sleep(((__usec) + 999)/1000)
-#endif
-
-#include <iostream>
-#include <fstream>
-#include "dsconfig.h"
-#include "dsfilt.h"
-#include "dsurf.h"
-#include "winsys.h"
-#include "environ.h"
-#include "rc.h"
-#include "glutils.h"
-#include "misc.h"
-
-#include "test.h"
-
-// Macro for constructor for Glean test taking width, height and one config flag
-#define GLEAN_CLASS_WHO(TEST, RESULT, WIDTH, HEIGHT, ONE) \
- TEST(const char* aName, const char* aFilter, \
- const char* aDescription): \
- BaseTest<RESULT>(aName, aFilter, aDescription) { \
- fWidth = WIDTH; \
- fHeight = HEIGHT; \
- testOne = ONE; \
- } \
- TEST(const char* aName, const char* aFilter, Test** thePrereqs, \
- const char* aDescription): \
- BaseTest<RESULT>(aName, aFilter, thePrereqs, aDescription) { \
- fWidth = WIDTH; \
- fHeight = HEIGHT; \
- testOne = ONE; \
- } \
- TEST(const char* aName, const char* aFilter, \
- const char* anExtensionList, \
- const char* aDescription): \
- BaseTest<RESULT>(aName, aFilter, anExtensionList, aDescription) { \
- fWidth = WIDTH; \
- fHeight = HEIGHT; \
- testOne = ONE; \
- } \
- virtual ~TEST() {} \
- \
- virtual void runOne(RESULT& r, Window& w); \
- virtual void logOne(RESULT& r)
-
-// Macro for constructor for Glean test taking width, height
-#define GLEAN_CLASS_WH(TEST, RESULT, WIDTH, HEIGHT) \
- GLEAN_CLASS_WHO(TEST, RESULT, WIDTH, HEIGHT, false)
-
-// Macro for constructor for Glean test taking only test class and result class
-#define GLEAN_CLASS(TEST, RESULT) \
- GLEAN_CLASS_WHO(TEST, RESULT, 258, 258, false)
-
-
-
-namespace GLEAN {
-
-class DrawingSurfaceConfig; // Forward reference.
-
-class BaseResult : public Result {
- // Class for a single test result. All basic tests have a
- // drawing surface configuration, plus other information
- // that's specific to the test.
-public:
- DrawingSurfaceConfig* config;
-
- virtual void putresults(ostream& s) const = 0;
- virtual bool getresults(istream& s) = 0;
-
- virtual void put(ostream& s) const {
- s << config->canonicalDescription() << '\n';
- putresults(s);
- }
-
- virtual bool get(istream& s) {
- SkipWhitespace(s);
- string configDesc;
- if (!getline(s, configDesc)) return false;
- config = new DrawingSurfaceConfig(configDesc);
- return getresults(s);
- }
-};
-
-
-// The BaseTest class is a templatized class taking a ResultType as a parameter
-template <class ResultType> class BaseTest: public Test {
-public:
- BaseTest(const char* aName, const char* aFilter,
- const char* aDescription): Test(aName, aDescription) {
- filter = aFilter;
- extensions = 0;
- description = aDescription;
- fWidth = 258;
- fHeight = 258;
- testOne = false;
- }
- BaseTest(const char* aName, const char* aFilter, Test** thePrereqs,
- const char* aDescription):
- Test(aName, aDescription, thePrereqs) {
- filter = aFilter;
- extensions = 0;
- description = aDescription;
- fWidth = 258;
- fHeight = 258;
- testOne = false;
- }
- BaseTest(const char* aName, const char* aFilter,
- const char* anExtensionList,
- const char* aDescription): Test(aName, aDescription) {
- filter = aFilter;
- extensions = anExtensionList;
- description = aDescription;
- fWidth = 258;
- fHeight = 258;
- testOne = false;
- }
-
- virtual ~BaseTest() {
- for (typename vector<ResultType*>::iterator result = results.begin();
- result != results.end();
- ++result)
- delete *result;
- }
-
- const char* filter; // Drawing surface config filter.
- const char* extensions; // Required extensions.
- int fWidth; // Drawing surface width.
- int fHeight; // Drawing surface height.
- bool testOne; // Test only one config?
- vector<ResultType*> results; // Test results.
-
- virtual void runOne(ResultType& r, Window& w) = 0;
- virtual void logOne(ResultType& r) = 0;
-
- virtual vector<ResultType*> getResults(istream& s) {
- vector<ResultType*> v;
- while (s.good()) {
- ResultType* r = new ResultType();
- if (r->get(s))
- v.push_back(r);
- else {
- delete r;
- break;
- }
- }
- return v;
- }
-
- virtual void logDescription() {
- if (env->options.verbosity)
- env->log <<
-"----------------------------------------------------------------------\n"
- << description
- << '\n';
- }
-
- // This method allows a test to indicate that it's not applicable.
- // For example, the GL version is too low.
- virtual bool isApplicable() const {
- return true;
- }
-
- virtual void run(Environment& environment) {
- if (hasRun)
- return; // no multiple invocations
-
- // Invoke the prerequisite tests, if any:
- for (Test** t = prereqs; t != 0 && *t != 0; ++t)
- (*t)->run(environment);
- env = &environment; // make environment available
- logDescription(); // log invocation
- WindowSystem& ws = env->winSys;
-
- try {
- // Select the drawing configurations for testing
- DrawingSurfaceFilter f(filter);
- vector<DrawingSurfaceConfig*>
- configs(f.filter(ws.surfConfigs, environment.options.maxVisuals));
-
- if (env->options.quick)
- testOne = true;
-
- // Test each config
- for (vector<DrawingSurfaceConfig*>::const_iterator
- p = configs.begin();
- p < configs.end();
- ++p) {
- // Many tests do not adjust their expectations
- // for multisampling and hence incorrectly
- // fail.
- if ((*p)->samples > 0)
- continue;
-
- Window w(ws, **p, fWidth, fHeight);
- RenderingContext rc(ws, **p);
- if (!ws.makeCurrent(rc, w)) {
- // XXX need to throw exception here
- }
-
- // Make sure glew is initialized so we can call
- // GL functions safely.
- piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
-
- // Check if test is applicable to this context
- if (!isApplicable())
- continue;
-
- // Check for all prerequisite extensions. Note
- // that this must be done after the rendering
- // context has been created and made current!
- if (!GLUtils::haveExtensions(extensions))
- continue;
-
- // Create a result object and run the test:
- ResultType* r = new ResultType();
- r->config = *p;
- runOne(*r, w);
- logOne(*r);
-
- // Save the result
- results.push_back(r);
-
- // if testOne, skip remaining surface configs
- if (testOne)
- break;
- }
- }
- catch (DrawingSurfaceFilter::Syntax e) {
- env->log << "Syntax error in test's drawing-surface"
- << " selection criteria:\n'"
- << filter
- << "'\n";
- for (int i = 0; i < e.position; ++i)
- env->log << ' ';
- env->log << "^ " << e.err << '\n';
- }
- catch (RenderingContext::Error) {
- env->log << "Could not create a rendering context\n";
- }
- env->log << '\n';
-
- hasRun = true; // Note that we've completed the run
- }
-
- virtual void logPassFail(ResultType& r) {
- env->log << name << (r.pass ? ": PASS ": ": FAIL ");
- }
-
- virtual void logConcise(ResultType& r) {
- env->log << r.config->conciseDescription() << '\n';
- }
-}; // class BaseTest
-
-} // namespace GLEAN
-
-#endif // __tbasic_h__
diff --git a/tests/glean/test.cpp b/tests/glean/test.cpp
deleted file mode 100644
index e67b33f..0000000
--- a/tests/glean/test.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// test.cpp: implementation of base class for tests
-#ifdef __UNIX__
-#include <unistd.h>
-#endif
-
-#include <iostream>
-#include "dsconfig.h"
-#include "dsurf.h"
-#include "winsys.h"
-#include "environ.h"
-#include "test.h"
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// Class variables for automatic construction of list of all tests
-///////////////////////////////////////////////////////////////////////////////
-Test* Test::testList; // Guaranteed initialized to zero at startup,
- // before any constructors are invoked.
- // (See discussion in section 10.4.9,
- // page 252, of ``C++ Programming Language''
- // (third edition).)
-
-int Test::testCount; // Also initialized to zero.
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructor/Destructor:
-///////////////////////////////////////////////////////////////////////////////
-Test::Test(const char* testName, const char *descrip):
- name(testName), description(descrip) {
- prereqs = 0;
- hasRun = false;
- env = NULL;
- nextTest = testList;
- testList = this;
- ++testCount;
-} // Test::Test()
-
-Test::Test(const char* testName, const char *descrip, Test** thePrereqs):
- name(testName), description(descrip) {
- prereqs = thePrereqs;
- hasRun = false;
- env = NULL;
- nextTest = testList;
- testList = this;
- ++testCount;
-} // Test::Test()
-
-Test::~Test() {
-} // Test::~Test
-
-} // namespace GLEAN
diff --git a/tests/glean/test.h b/tests/glean/test.h
deleted file mode 100644
index 540faac..0000000
--- a/tests/glean/test.h
+++ /dev/null
@@ -1,114 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// test.h: Base class for all tests
-
-// This class encapsulates base functionality used by all tests. Some
-// of this is fairly trivial (the test name, for example). One of the
-// most important nontrivial functions is the use of the constructor
-// to build a linked list of test objects; this eliminates the need to
-// maintain a separate table of tests. This class also provides a
-// flag for determining if a test has been run, which allows tests to
-// invoke one another and make use of previous results without forcing
-// tests to run multiple times. Finally, it provides a basic
-// framework for recording a vector of results (which typically will
-// vary depending on the drawing surface configuration or the
-// particular type of drawing surface used).
-
-// It is possible to derive test classes directly from this class.
-// Most people will find it more convenient to use the BaseTest
-// template class. See tbase.h for more information.
-
-
-
-#ifndef __test_h__
-#define __test_h__
-
-using namespace std;
-
-#include <string>
-#include <vector>
-#include <fstream>
-
-namespace GLEAN {
-
-class Environment; // Mutually-recursive and forward references.
-class DrawingSurfaceConfig;
-
-// Base class for a single test result. A test may have many results
-// (for example, one per drawing surface configuration), so in general
-// individual tests will have a vector of these objects.
-class Result {
-public:
- virtual void put(ostream& s) const = 0;
- virtual bool get(istream& s) = 0;
- Result() { }
- virtual ~Result() { }
-};
-
-class Test {
- public:
- Test(const char* testName, const char *descrip);
- Test(const char* testName, const char *descrip, Test** prereqs);
- virtual ~Test();
-
- string name; // Test name. Should avoid characters
- // that aren't universally available in
- // filenames, since it might be used to
- // construct such names.
-
- string description; // Verbose description of test.
-
- Test** prereqs; // Pointer to array of prerequisite tests.
- // These will always be run before the
- // current test.
-
- bool hasRun; // True if test has been run.
-
- Environment* env; // Environment in which runs or comparisons
- // will be performed.
-
- virtual void run(Environment& env) = 0; // Run test, save results.
-
- // Exceptions:
- struct Error { }; // Base class for all exceptions.
-
- static Test* testList; // List of all test objects. Built by
- // constructor Test::Test(...).
-
- Test* nextTest; // Link to next test object.
-
- static int testCount; // Count of elements in testList.
-}; // class Test
-
-} // namespace GLEAN
-
-#endif // __test_h__
diff --git a/tests/glean/tmultitest.cpp b/tests/glean/tmultitest.cpp
deleted file mode 100644
index 6e5f846..0000000
--- a/tests/glean/tmultitest.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-#include <cstring>
-#include "tmultitest.h"
-
-namespace GLEAN {
-
-
-MultiTestResult::MultiTestResult()
-{
- numPassed = numFailed = 0;
- pass = true;
-}
-
-
-void
-MultiTestResult::putresults(ostream &s) const
-{
- if (pass) {
- s << "PASS\n";
- }
- else {
- s << "FAIL\n";
- }
- s << numPassed << '\n';
- s << numFailed << '\n';
-}
-
-
-bool
-MultiTestResult::getresults(istream &s)
-{
- char result[1000];
- s >> result;
- if (strcmp(result, "FAIL") == 0) {
- pass = false;
- }
- else {
- pass = true;
- }
- s >> numPassed;
- s >> numFailed;
- return s.good();
-}
-
-
-// VERY IMPORTANT: this function _must_ be defined here, even though
-// it's never used. Otherwise, you'll get linker errors like this:
-// tmultitest.h:83: undefined reference to `vtable for GLEAN::MultiTest'
-void
-MultiTest::runOne(MultiTestResult &r, Window &)
-{
- r.numPassed = r.numFailed = 0;
- r.pass = true;
-}
-
-
-void
-MultiTest::logOne(MultiTestResult &r)
-{
- if (r.numPassed == 0 && r.numFailed == 0) {
- // non-applicable test
- env->log << name << ": NOTE ";
- logConcise(r);
- env->log << "\tTest skipped/non-applicable\n";
- }
- else {
- logPassFail(r);
- logConcise(r);
- env->log << "\t"
- << r.numPassed << " tests passed, "
- << r.numFailed << " tests failed.\n";
- }
-}
-
-
-#if 0
-MultiTest multiTest("multi", "window",
- "",
- "Base class for multi pass/fail tests\n"
- );
-#endif
-
-
-} // namespace GLEAN
diff --git a/tests/glean/tmultitest.h b/tests/glean/tmultitest.h
deleted file mode 100644
index 4ecad04..0000000
--- a/tests/glean/tmultitest.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// begin_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-// tmultitest.h - base class for Glean tests that produce a number of
-// sub-pass/fail results.
-// Brian Paul September 2006
-
-
-#ifndef __tmultitest_h__
-#define __tmultitest_h__
-
-#include "tbase.h"
-
-namespace GLEAN {
-
-#ifndef windowSize
-#define windowSize 100
-#endif
-
-#ifndef windowWidth
-#define windowWidth windowSize
-#endif
-
-#ifndef windowHeight
-#define windowHeight windowSize
-#endif
-
-
-class MultiTestResult: public BaseResult
-{
-public:
- MultiTestResult();
-
- bool pass;
- int numPassed, numFailed;
-
- virtual void putresults(ostream& s) const;
- virtual bool getresults(istream& s);
-};
-
-
-class MultiTest: public BaseTest<MultiTestResult>
-{
-public:
- GLEAN_CLASS_WH(MultiTest, MultiTestResult,
- windowWidth, windowHeight);
-};
-
-
-} // namespace GLEAN
-
-#endif // __tmultitest_h__
diff --git a/tests/glean/unpack.cpp b/tests/glean/unpack.cpp
deleted file mode 100644
index 5c0c9a6..0000000
--- a/tests/glean/unpack.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-// BEGIN_COPYRIGHT
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// Data unpacking utilities. Note that these map component values per
-// the usual OpenGL conventions.
-
-// XXX The construction of SCALE and BIAS is clumsy, and the need to
-// test bias is really unfortunate, but egcs 1.1.2 won't propagate
-// floating-point constant expressions from equivalent const
-// declarations.
-
-#include "image.h"
-
-namespace {
-
-#define SCALE (static_cast<double>(num) / static_cast<double>(denom))
-#define BIAS (static_cast<double>(bias) / static_cast<double>(denom))
-
-// See comments in pack.cpp concerning this workaround for a VC6 problem.
-
-template<class component, int num, unsigned int denom, int bias>
-class Unpack
-{
-public :
- // unpack_l
- static void unpack_l(GLsizei n, double* rgba, char* src)
- {
- component* in = reinterpret_cast<component*>(src);
- // XXX It seems to me that static_cast should be sufficient,
- // but egcs 1.1.2 thinks otherwise.
-
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias)
- rgba[0] = SCALE * in[0] + BIAS;
- else
- rgba[0] = SCALE * in[0];
- rgba[1] = rgba[2] = rgba[3] = 0.0;
- in += 1;
- }
- }
-
- // unpack_la
- static void unpack_la(GLsizei n, double* rgba, char* src)
- {
- component* in = reinterpret_cast<component*>(src);
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias) {
- rgba[0] = SCALE * in[0] + BIAS;
- rgba[3] = SCALE * in[1] + BIAS;
- } else {
- rgba[0] = SCALE * in[0];
- rgba[3] = SCALE * in[1];
- }
- rgba[1] = rgba[2] = 0.0;
- in += 2;
- }
- }
-
- // unpack_rgb
- static void unpack_rgb(GLsizei n, double* rgba, char* src)
- {
- component* in = reinterpret_cast<component*>(src);
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias) {
- rgba[0] = SCALE * in[0] + BIAS;
- rgba[1] = SCALE * in[1] + BIAS;
- rgba[2] = SCALE * in[2] + BIAS;
- } else {
- rgba[0] = SCALE * in[0];
- rgba[1] = SCALE * in[1];
- rgba[2] = SCALE * in[2];
- }
- rgba[3] = 0.0;
- in += 3;
- }
- }
-
- // unpack_rgba
- static void unpack_rgba(GLsizei n, double* rgba, char* src)
- {
- component* in = reinterpret_cast<component*>(src);
- double* end = rgba + 4 * n;
- for (; rgba != end; rgba += 4) {
- if (bias) {
- rgba[0] = SCALE * in[0] + BIAS;
- rgba[1] = SCALE * in[1] + BIAS;
- rgba[2] = SCALE * in[2] + BIAS;
- rgba[3] = SCALE * in[3] + BIAS;
- } else {
- rgba[0] = SCALE * in[0];
- rgba[1] = SCALE * in[1];
- rgba[2] = SCALE * in[2];
- rgba[3] = SCALE * in[3];
- }
- in += 4;
- }
- }
-
-}; // class Unpack
-
-#undef SCALE
-#undef BIAS
-
-}; // anonymous namespace
-
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// Public interface
-///////////////////////////////////////////////////////////////////////////////
-void
-Image::unpack(GLsizei n, double* rgba, char* nextPixel) {
- (*(valid(vbUnpacker)? _unpacker: validateUnpacker()))
- (n, rgba, nextPixel);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// validateUnpacker - select appropriate pixel-unpacking utility
-///////////////////////////////////////////////////////////////////////////////
-Image::Unpacker*
-Image::validateUnpacker() {
- switch (format()) {
- case GL_LUMINANCE:
- switch (type()) {
- case GL_BYTE:
- _unpacker = Unpack<GLbyte, 2, 255, 1>::unpack_l;
- break;
- case GL_UNSIGNED_BYTE:
- _unpacker = Unpack<GLubyte, 1, 255, 0>::unpack_l;
- break;
- case GL_SHORT:
- _unpacker = Unpack<GLshort, 2, 65535, 1>::unpack_l;
- break;
- case GL_UNSIGNED_SHORT:
- _unpacker = Unpack<GLushort, 1, 65535, 0>::unpack_l;
- break;
- case GL_INT:
- _unpacker = Unpack<GLint, 2, 4294967295U, 1>::unpack_l;
- break;
- case GL_UNSIGNED_INT:
- _unpacker = Unpack<GLuint, 1, 4294967295U, 0>::unpack_l;
- break;
- case GL_FLOAT:
- _unpacker = Unpack<GLfloat, 1, 1, 0>::unpack_l;
- break;
- default:
- throw BadType(type());
- }
- break;
- case GL_LUMINANCE_ALPHA:
- switch (type()) {
- case GL_BYTE:
- _unpacker = Unpack<GLbyte, 2, 255, 1>::unpack_la;
- break;
- case GL_UNSIGNED_BYTE:
- _unpacker = Unpack<GLubyte, 1, 255, 0>::unpack_la;
- break;
- case GL_SHORT:
- _unpacker = Unpack<GLshort, 2, 65535, 1>::unpack_la;
- break;
- case GL_UNSIGNED_SHORT:
- _unpacker = Unpack<GLushort, 1, 65535, 0>::unpack_la;
- break;
- case GL_INT:
- _unpacker = Unpack<GLint, 2, 4294967295U, 1>::unpack_la;
- break;
- case GL_UNSIGNED_INT:
- _unpacker = Unpack<GLuint, 2, 4294967295U, 0>::unpack_la;
- break;
- case GL_FLOAT:
- _unpacker = Unpack<GLfloat, 1, 1, 0>::unpack_la;
- break;
- default:
- throw BadType(type());
- }
- break;
- case GL_RGB:
- switch (type()) {
- case GL_BYTE:
- _unpacker = Unpack<GLbyte, 2, 255, 1>::unpack_rgb;
- break;
- case GL_UNSIGNED_BYTE:
- _unpacker = Unpack<GLubyte, 1, 255, 0>::unpack_rgb;
- break;
- case GL_SHORT:
- _unpacker = Unpack<GLshort, 2, 65535, 1>::unpack_rgb;
- break;
- case GL_UNSIGNED_SHORT:
- _unpacker = Unpack<GLushort, 1, 65535, 0>::unpack_rgb;
- break;
- case GL_INT:
- _unpacker = Unpack<GLint, 2, 4294967295U, 1>::unpack_rgb;
- break;
- case GL_UNSIGNED_INT:
- _unpacker = Unpack<GLuint, 1, 4294967295U, 0>::unpack_rgb;
- break;
- case GL_FLOAT:
- _unpacker = Unpack<GLfloat, 1, 1, 0>::unpack_rgb;
- break;
- default:
- throw BadType(type());
- }
- break;
- case GL_RGBA:
- switch (type()) {
- case GL_BYTE:
- _unpacker = Unpack<GLbyte, 2, 255, 1>::unpack_rgba;
- break;
- case GL_UNSIGNED_BYTE:
- _unpacker = Unpack<GLubyte, 1, 255, 0>::unpack_rgba;
- break;
- case GL_SHORT:
- _unpacker = Unpack<GLshort, 2, 65535, 1>::unpack_rgba;
- break;
- case GL_UNSIGNED_SHORT:
- _unpacker = Unpack<GLushort, 1, 65535, 0>::unpack_rgba;
- break;
- case GL_INT:
- _unpacker = Unpack<GLint, 2, 4294967295U, 1>::unpack_rgba;
- break;
- case GL_UNSIGNED_INT:
- _unpacker = Unpack<GLuint, 1, 4294967295U, 0>::unpack_rgba;
- break;
- case GL_FLOAT:
- _unpacker = Unpack<GLfloat, 1, 1, 0>::unpack_rgba;
- break;
- default:
- throw BadType(type());
- }
- break;
- default:
- throw BadFormat(format());
- }
-
- validate(vbUnpacker);
- return _unpacker;
-}
-
-}; // namespace GLEAN
diff --git a/tests/glean/version.h b/tests/glean/version.h
deleted file mode 100644
index c970689..0000000
--- a/tests/glean/version.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// GLEAN version information
-
-
-#ifndef __version_h__
-#define __version_h__
-
-#define GLEAN_MAJOR_VERSION 1
-#define GLEAN_MINOR_VERSION 1
-
-namespace GLEAN {
-
-const char* versionString = "glean v1.1 20 January 2000";
-
-} // namespace GLEAN
-
-#endif // __version_h__
diff --git a/tests/glean/winsys.cpp b/tests/glean/winsys.cpp
deleted file mode 100644
index 871dc87..0000000
--- a/tests/glean/winsys.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// winsys.cpp: implementation of window-system services class
-
-#include <iostream>
-#include "options.h"
-#include "winsys.h"
-#include "dsconfig.h"
-#include "dsfilt.h"
-#include "dsurf.h"
-#include "rc.h"
-
-using namespace std;
-
-namespace GLEAN {
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Constructors
-///////////////////////////////////////////////////////////////////////////////
-#if defined(__X11__)
-WindowSystem::WindowSystem(Options& o) {
- // Open the X11 display:
- dpy = XOpenDisplay(o.dpyName.c_str());
- if (!dpy)
- throw CantOpenDisplay();
-
- // Verify that GLX is supported:
- int error_base, event_base;
- if (glXQueryExtension(dpy, &error_base, &event_base) == False)
- throw NoOpenGL();
-
- // Record version numbers for later use:
- if (glXQueryVersion(dpy, &GLXVersMajor, &GLXVersMinor) == False)
- throw Error(); // this should never happen :-)
-
- // Get the list of raw XVisualInfo structures:
- XVisualInfo vit;
- vit.screen = DefaultScreen(dpy);
- int n;
- vip = XGetVisualInfo(dpy, VisualScreenMask, &vit, &n);
-
- // Construct a vector of DrawingSurfaceConfigs corresponding to the
- // XVisualInfo structures that indicate they support OpenGL:
- vector<DrawingSurfaceConfig*> glxv;
- for (int i = 0; i < n; ++i) {
- int supportsOpenGL;
- glXGetConfig(dpy, &vip[i], GLX_USE_GL, &supportsOpenGL);
- if (supportsOpenGL)
- glxv.push_back(new DrawingSurfaceConfig (dpy, &vip[i]));
- }
-
- // Filter the basic list of DrawingSurfaceConfigs according to
- // constraints provided by the user. (This makes it convenient
- // to run tests on just a subset of all available configs.)
- DrawingSurfaceFilter f(o.visFilter); // may throw an exception!
- surfConfigs = f.filter(glxv, o.maxVisuals);
-} // WindowSystem::WindowSystem
-
-#elif defined(__WIN__)
-WindowSystem::WindowSystem(Options& o) {
- // register an window class
- WNDCLASS wc;
-
- wc.style = CS_OWNDC;
- wc.lpfnWndProc = Window::WindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = GetModuleHandle(NULL);
- wc.hIcon = LoadIcon(wc.hInstance, "glean");
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "glean";
-
- if (!RegisterClass(&wc))
- throw Error();
-
-
- HDC hDC = GetDC(GetDesktopWindow());
-
- PIXELFORMATDESCRIPTOR pfd;
- int n = DescribePixelFormat(hDC,0,sizeof(pfd),0);
-
- vector<DrawingSurfaceConfig*> glpf;
-
- for (int i = 1;i <= n;++i) {
- DescribePixelFormat(hDC,i,sizeof(pfd),&pfd);
-
- glpf.push_back(new DrawingSurfaceConfig(i,&pfd));
- }
-
- ReleaseDC(GetDesktopWindow(),hDC);
-
- // Filter the basic list of DrawingSurfaceConfigs according to
- // constraints provided by the user. (This makes it convenient
- // to run tests on just a subset of all available configs.)
- DrawingSurfaceFilter f(o.visFilter); // may throw an exception!
- surfConfigs = f.filter(glpf, o.maxVisuals);
-}
-
-#elif defined(__BEWIN__)
-WindowSystem::WindowSystem(Options& o) {
- //cout << "Implement Me! WindowSystem::WindowSystem(Options& o)\n";
-
- theApp = new BApplication("application/x-AJH-glean");
-
- /* for BeOS, we just stack the current config onto the vector so */
- /* there is at least one thing to iterate over */
- vector<DrawingSurfaceConfig*> glconfigs;
- glconfigs.push_back(new DrawingSurfaceConfig());
-
- DrawingSurfaceFilter f(o.visFilter); // may throw an exception!
- surfConfigs = f.filter(glconfigs, o.maxVisuals);
-
-}
-
-#elif defined(__AGL__)
-WindowSystem::WindowSystem(Options& o) {
- GDHandle mainGD;
- //HW/SW Depth Reserved
- GLint testTypes[][3] = {
- {AGL_ACCELERATED, 16, 0 },
- {AGL_ACCELERATED, 16, 0 },
- {AGL_ACCELERATED, 16, 0 },
- {0, 16, 0 },
- {0, 16, 0 },
- {0, 0, 0 }
- };
- GLint testAttrib[][10]= {
- { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_ACCELERATED, 16, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE},
- { AGL_RGBA, AGL_ACCELERATED, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE},
- { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE},
- { AGL_RENDERER_ID, AGL_RENDERER_GENERIC_ID, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE},
- { AGL_RENDERER_ID, AGL_RENDERER_GENERIC_ID, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_DEPTH_SIZE, 16 , AGL_NONE, AGL_NONE, AGL_NONE, AGL_NONE}
- };
- AGLPixelFormat pf;
- GLint index = 0;
-
- mainGD = GetMainDevice();
- if (!mainGD)
- throw CantOpenDisplay();
-
- // Construct a vector of DrawingSurfaceConfigs corresponding to the
- // returned pixel formats
- vector<DrawingSurfaceConfig*> glpf;
-
- while (testTypes[index][1] != 0)
- {
- pf = aglChoosePixelFormat(&mainGD, 1, testAttrib[index]);
- if ( (pf == NULL) && ( testTypes[index][0] == 0) )
- {
- testAttrib[index][1] = 0x30300;
- pf = aglChoosePixelFormat(&mainGD, 1, testAttrib[index]);
- }
- if (pf != NULL) glpf.push_back(new DrawingSurfaceConfig (index+1, pf));
-
- index++;
- }
-
- // Filter the basic list of DrawingSurfaceConfigs according to
- // constraints provided by the user. (This makes it convenient
- // to run tests on just a subset of all available configs.)
- DrawingSurfaceFilter f(o.visFilter); // may throw an exception!
- surfConfigs = f.filter(glpf, o.maxVisuals);
-}
-
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-// Destructors
-///////////////////////////////////////////////////////////////////////////////
-#if defined(__X11__)
-WindowSystem::~WindowSystem() {
- XFree(vip);
-} // WindowSystem:: ~WindowSystem
-
-#elif defined(__WIN__)
-WindowSystem::~WindowSystem() {
-}
-#elif defined(__BEWIN__)
-WindowSystem::~WindowSystem() {
- delete theApp;
-} // WindowSystem:: ~WindowSystem
-#elif defined(__AGL__)
-WindowSystem::~WindowSystem() {
-}
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-// makeCurrent and friends - binding contexts and drawing surfaces
-///////////////////////////////////////////////////////////////////////////////
-
-bool
-WindowSystem::makeCurrent() {
-# if defined(__X11__)
-# if defined(GLX_VERSION_1_3)
- // XXX Need to write GLX 1.3 MakeCurrent code
-# endif
- return glXMakeCurrent(dpy, None, 0);
-# elif defined(__WIN__)
- return wglMakeCurrent(0,0);
-# elif defined(__AGL__)
- return aglSetCurrentContext(NULL);
-# endif
-} // WindowSystem::makeCurrent
-
-bool
-WindowSystem::makeCurrent(RenderingContext& r, Window& w) {
-# if defined(__X11__)
-# if defined(GLX_VERSION_1_3)
- // XXX Need to write GLX 1.3 MakeCurrent code
-# endif
- return glXMakeCurrent(dpy, w.xWindow, r.rc);
-# elif defined(__WIN__)
- return wglMakeCurrent(w.get_dc(),r.rc);
-# elif defined(__AGL__)
- if (GL_FALSE == aglSetDrawable(r.rc, (AGLDrawable) GetWindowPort (w.macWindow)))
- return GL_FALSE;
- if (GL_FALSE == aglSetCurrentContext(r.rc))
- return GL_FALSE;
- return true;
-# endif
-} // WindowSystem::makeCurrent
-
-} // namespace GLEAN
diff --git a/tests/glean/winsys.h b/tests/glean/winsys.h
deleted file mode 100644
index d045f20..0000000
--- a/tests/glean/winsys.h
+++ /dev/null
@@ -1,116 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999 Allen Akin 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 ALLEN AKIN 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.
-//
-// END_COPYRIGHT
-
-
-
-
-// winsys.h: facade for common window-system operations
-
-// This class and related classes provide window system operations
-// that are sufficient to support most basic rendering tests. These
-// operations include initializing the window system, creating and
-// destroying windows and rendering contexts, selecting pixel
-// configurations, etc.
-
-// Tests using this set of classes for all window system services are
-// ``portable'' in a useful sense. Not all tests are portable,
-// however; in particular, tests of window-system-specific
-// functionality must execute window system commands directly. Such
-// tests may require access to class members that would ideally be
-// private; for example, the X11 Display pointer. Thus most members
-// of this class are public.
-
-
-
-#ifndef __winsys_h__
-#define __winsys_h__
-
-using namespace std;
-
-#include <string>
-#include <vector>
-#include "glwrap.h"
-
-namespace GLEAN {
-
-class DrawingSurface; // Forward and mutually-recursive references.
-class Window;
-class DrawingSurfaceConfig;
-class RenderingContext;
-class Options;
-
-class WindowSystem {
- public:
- // Constructors/Destructor:
-
- WindowSystem(Options& o);
- ~WindowSystem();
-
- // Exceptions:
-
- struct Error { }; // Base class for window system errors.
- struct CantOpenDisplay: public Error { // Can't initialize display.
- };
- struct NoOpenGL: public Error { // Missing GLX, WGL, etc.
- };
-
- // Utilities:
-
- bool makeCurrent(); // Remove context/surface binding.
- bool makeCurrent(RenderingContext& r, Window& w);
- // Bind given context and surface.
-
- // State information:
-
- vector<DrawingSurfaceConfig*> surfConfigs;
- // All available drawing surface configurations.
- vector<DrawingSurface*> surfaces;
- // All currently-active surfaces.
- vector<RenderingContext*> contexts;
- // All currently-active rendering contexts.
-
-# if defined(__X11__)
- Display* dpy; // Pointer to X11 Display structure.
-
- int GLXVersMajor; // GLX major version number.
- int GLXVersMinor; // GLX minor version number.
-
- XVisualInfo* vip; // Array of raw XVisualInfo structures.
-
-# elif defined(__WIN__)
-
-# elif defined(__BEWIN__)
- BApplication *theApp;
-
-# endif
-
-}; // class WindowSystem
-
-} // namespace GLEAN
-
-#endif // __winsys_h__
--
2.7.4
More information about the Piglit
mailing list