Commit ccc8ed32 authored by Kenneth Moreland's avatar Kenneth Moreland

Converted tests to use Glut.

Previously the tests used some hack-ish code for creating windows
on X and Win32.  Unfortunately, this meant that I could not run
the tests on Mac, where I now do most of my development.  Rather
that make my own knock off again, I am using a well-established
portable library.
parent 58fa5890
# Id
#
## Copyright 2003 Sandia Coporation
## Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
## license for use of this work by or on behalf of the U.S. Government.
......@@ -147,11 +145,12 @@ INCLUDE_DIRECTORIES(${ICET_BINARY_DIR}/src/include)
ADD_SUBDIRECTORY(src)
IF (BUILD_TESTING AND ICET_BUILD_TESTING)
IF (NOT APPLE)
FIND_PACKAGE(Glut)
IF (GLUT_FOUND)
ADD_SUBDIRECTORY(tests)
ELSE (NOT APPLE)
MESSAGE(STATUS "Tests not supported on Mac. Disabling.")
ENDIF (NOT APPLE)
ELSE (GLUT_FOUND)
MESSAGE(STATUS "Tests require Glut, which is not found. Disabling tests.")
ENDIF (GLUT_FOUND)
ENDIF (BUILD_TESTING AND ICET_BUILD_TESTING)
ADD_SUBDIRECTORY(doc)
......
/* -*- c -*- *****************************************************************
** Id
**
** Copyright (C) 2003 Sandia Corporation
** Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
** license for use of this work by or on behalf of the U.S. Government.
......@@ -14,7 +12,6 @@
#include <GL/ice-t.h>
#include "test-util.h"
#include "test_codes.h"
#include "glwin.h"
#include <stdlib.h>
#include <stdio.h>
......@@ -33,17 +30,13 @@ static void draw(void)
printf("Leaving draw\n");
}
int BlankTiles(int argc, char *argv[])
static int BlankTilesRun()
{
int i, j, x, y;
GLubyte *cb;
int result = TEST_PASSED;
GLint rank, num_proc;
/* To remove warning */
(void)argc;
(void)argv;
icetGetIntegerv(ICET_RANK, &rank);
icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc);
......@@ -95,8 +88,14 @@ int BlankTiles(int argc, char *argv[])
}
}
printf("Cleaning up.\n");
finalize_test(result);
return result;
}
int BlankTiles(int argc, char *argv[])
{
/* To remove warning */
(void)argc;
(void)argv;
return run_test(BlankTilesRun);
}
/* -*- c -*- *****************************************************************
** Id
**
** Copyright (C) 2005 Sandia Corporation
** Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
** license for use of this work by or on behalf of the U.S. Government.
......@@ -15,7 +13,6 @@
#include <GL/ice-t.h>
#include "test-util.h"
#include "test_codes.h"
#include "glwin.h"
#include <stdlib.h>
#include <stdio.h>
......@@ -43,14 +40,10 @@ static void PrintMatrix(float *mat)
}
}
int BoundsBehindViewer(int argc, char *argv[])
static int BoundsBehindViewerRun()
{
float mat[16];
/* To remove warning */
(void)argc;
(void)argv;
GLint rank;
icetGetIntegerv(ICET_RANK, &rank);
......@@ -101,11 +94,18 @@ int BoundsBehindViewer(int argc, char *argv[])
GLuint *cb = (GLuint *)icetGetColorBuffer();
if (cb[0] != 0xFFFFFFFF) {
printf("First pixel in color buffer wrong: 0x%x\n", cb[0]);
finalize_test(TEST_FAILED);
return TEST_FAILED;
}
}
finalize_test(TEST_PASSED);
return TEST_PASSED;
}
int BoundsBehindViewer(int argc, char *argv[])
{
/* To remove warning */
(void)argc;
(void)argv;
run_test(BoundsBehindViewerRun);
}
# Id
#
## Copyright 2003 Sandia Coporation
## Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
## license for use of this work by or on behalf of the U.S. Government.
......@@ -19,12 +17,6 @@ SET(MyTests
SET(UTIL_SRCS init.c ppm.c)
IF (WIN32)
SET(UTIL_SRCS ${UTIL_SRCS} glwin_wgl.c)
ELSE (WIN32)
SET(UTIL_SRCS ${UTIL_SRCS} glwin_glx.c)
ENDIF (WIN32)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
CREATE_TEST_SOURCELIST(Tests icetTests_mpi.c ${MyTests}
......@@ -37,6 +29,7 @@ TARGET_LINK_LIBRARIES(icetTests_mpi
icet_strategies
icet_mpi
${OPENGL_glu_LIBRARY}
${GLUT_LIBRARIES}
)
IF (ICET_MPIRUN_EXE)
......
/* -*- c -*- *****************************************************************
** Id
**
** Copyright (C) 2003 Sandia Corporation
** Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
** license for use of this work by or on behalf of the U.S. Government.
......@@ -161,14 +159,10 @@ static int DoCompressionTest(int num_buffers)
return result;
}
int CompressionSize(int argc, char *argv[])
static int CompressionSizeRun()
{
int result;
/* To remove warning */
(void)argc;
(void)argv;
icetStrategy(ICET_STRATEGY_REDUCE);
printf("Compress depth only.\n");
......@@ -190,6 +184,14 @@ int CompressionSize(int argc, char *argv[])
DoCompressionTest(2);
}
finalize_test(result);
return result;
}
int CompressionSize(int argc, char *argv[])
{
/* To remove warning */
(void)argc;
(void)argv;
run_test(CompressionSizeRun);
}
/* -*- c -*- *****************************************************************
** Id
**
** Copyright (C) 2003 Sandia Corporation
** Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
** license for use of this work by or on behalf of the U.S. Government.
......@@ -20,7 +18,6 @@
#include <GL/ice-t.h>
#include "test_codes.h"
#include "test-util.h"
#include "glwin.h"
#include <stdlib.h>
#include <stdio.h>
......@@ -43,16 +40,12 @@ static void draw(void)
printf("Leaving draw\n");
}
int DisplayNoDraw(int argc, char *argv[])
static DisplayNoDrawRun()
{
int result = TEST_PASSED;
int i;
GLint rank, num_proc;
/* To remove warning */
(void)argc;
(void)argv;
icetGetIntegerv(ICET_RANK, &rank);
icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc);
......@@ -124,6 +117,14 @@ int DisplayNoDraw(int argc, char *argv[])
}
}
finalize_test(result);
return result;
}
int DisplayNoDraw(int argc, char *argv[])
{
/* To remove warning */
(void)argc;
(void)argv;
return run_test(DisplayNoDrawRun);
}
/* -*- c -*- *****************************************************************
** Id
**
** Copyright (C) 2003 Sandia Corporation
** Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
** license for use of this work by or on behalf of the U.S. Government.
......@@ -16,7 +14,6 @@
#include <context.h>
#include "test_codes.h"
#include "test-util.h"
#include "glwin.h"
#include <stdlib.h>
#include <stdio.h>
......@@ -228,7 +225,7 @@ static void check_results(int result)
}
}
int RandomTransform()
static int RandomTransformRun()
{
int i, x, y;
GLubyte *cb;
......@@ -524,6 +521,14 @@ int RandomTransform()
icetInputOutputBuffers(ICET_COLOR_BUFFER_BIT | ICET_DEPTH_BUFFER_BIT,
ICET_COLOR_BUFFER_BIT);
finalize_test(result);
return result;
}
int RandomTransform(int argc, char *argv[])
{
/* To remove warning */
(void)argc;
(void)argv;
return run_test(RandomTransformRun);
}
/* -*- c -*- *****************************************************************
** Id
**
** Copyright (C) 2003 Sandia Corporation
** Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
** license for use of this work by or on behalf of the U.S. Government.
......@@ -15,7 +13,6 @@
#include <GL/ice-t.h>
#include "test-util.h"
#include "test_codes.h"
#include "glwin.h"
#ifdef __APPLE__
# include <OpenGL/gl.h>
......@@ -58,14 +55,10 @@ static void draw(void)
glPopMatrix();
}
int SimpleExample(int argc, char * argv[])
static int SimpleExampleRun()
{
float angle;
/* To remove warning */
(void)argc;
(void)argv;
/* Normally, the first thing that you do is set up your communication and
* then create at least one ICE-T context. This has already been done in
* the calling function (i.e. icetTests_mpi.c). See the init_mpi_comm in
......@@ -174,6 +167,14 @@ int SimpleExample(int argc, char * argv[])
swap_buffers();
}
finalize_test(TEST_PASSED);
return TEST_PASSED;
}
int SimpleExample(int argc, char * argv[])
{
/* To remove warning */
(void)argc;
(void)argv;
return run_test(SimpleExampleRun);
}
/*
* Copyright (C) 2003 Sandia Corporation
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that this Notice and any statement
* of authorship are reproduced on all copies.
*/
#ifdef __cplusplus
extern "C" {
#endif
int wincreat( int x, int y, int width, int height, char *title);
void swap_buffers(void);
#ifdef __cplusplus
}
#endif
/*
* Copyright (C) 2003 Sandia Corporation
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that this Notice and any statement
* of authorship are reproduced on all copies.
*/
#ifndef _WIN32
/*
* This code opens up a GL window in X
* Id
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xutil.h> /* XVisualInfo */
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
static Bool WaitForMapNotify( Display *d, XEvent *e, char *arg );
static Window glwin;
static Display *dpy;
int wincreat( int x, int y, int width, int height, char *title)
{
XSetWindowAttributes swa;
Colormap cmap;
XVisualInfo *vi;
int dummy;
GLXContext glcx;
XEvent event;
int attributes[] = { GLX_RGBA,
GLX_DEPTH_SIZE, 16,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DOUBLEBUFFER,
None };
if( !(dpy = XOpenDisplay( NULL )) ) /* defaults to $DISPLAY */
{
fprintf( stderr, "Unable to open display.\n" );
exit( 1 );
} else {
/*printf( "Connected to display... %s (%s).\n", dpy->display_name, dpy->vendor );*/
} /* end if( ) */
if( !glXQueryExtension( dpy, &dummy, &dummy ) )
{
fprintf( stderr, "Unable to query GLX extensions.\n" );
exit( 1 );
} /* end if( ) */
if( !(vi = glXChooseVisual( dpy, DefaultScreen( dpy ), attributes )) )
{
fprintf( stderr, "Unable get a visual.\n" );
exit( 1 );
} /* end if( ) */
if( vi->class != TrueColor )
{
fprintf( stderr, "Need TrueColor class.\n" );
exit( 1 );
}
if( !(glcx = glXCreateContext( dpy, vi, None, GL_TRUE )) )
{
fprintf( stderr, "Unable create a GL context.\n" );
exit( 1 );
} /* end if( ) */
cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ),
vi->visual, AllocNone );
swa.colormap = cmap;
swa.border_pixel = 0;
swa.event_mask = ExposureMask
| KeyPressMask
| StructureNotifyMask;
glwin = XCreateWindow( dpy,
RootWindow( dpy, vi->screen ),
x,
y,
width,
height,
0,
vi->depth,
InputOutput,
vi->visual,
CWBorderPixel |
CWColormap |
CWEventMask,
&swa
);
/* Make a clear cursor so it looks like we have none. */
{
Pixmap pixmap;
Cursor cursor;
XColor color;
char clear_bits[32];
memset(clear_bits, 0, sizeof(clear_bits));
pixmap = XCreatePixmapFromBitmapData(dpy, glwin, clear_bits,
16, 16, 1, 0, 1);
cursor = XCreatePixmapCursor(dpy, pixmap, pixmap, &color, &color, 8, 8);
XDefineCursor(dpy, glwin, cursor);
XFreePixmap(dpy, pixmap);
}
XSetStandardProperties( dpy, glwin, title, title, None, NULL, 0, NULL );
if( !glXMakeCurrent( dpy, glwin, glcx ) )
{
fprintf( stderr, "Failed to make the GL context current.\n" );
exit( 1 );
}
XMapWindow( dpy, glwin );
XIfEvent( dpy, &event, WaitForMapNotify, (char *)glwin );
return( 1 );
} /* end int APIENTRY pglc_wincreat( ) */
void resize( GLsizei width, GLsizei height )
{
GLfloat aspect = (GLfloat) width / height;
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 45.0, aspect, .1, 10000 );
glMatrixMode( GL_MODELVIEW );
} /* end void resize( ) */
static Bool WaitForMapNotify(Display *foo, XEvent *e, char *arg)
{
/* To remove warning */
(void)foo;
if( (e->type == MapNotify) && (e->xmap.window == (Window)arg) )
{
return( GL_TRUE );
} else {
return( GL_FALSE );
}
} /* end static Bool WaitForMapNotify( ) */
void swap_buffers(void)
{
glXSwapBuffers(dpy, glwin);
}
#endif /* WIN32 */
/*
* Copyright (C) 2003 Sandia Corporation
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that this Notice and any statement
* of authorship are reproduced on all copies.
*/
/*
* This code opens up a GL window on Windows
* Author: Various
* Id
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#include <stdio.h>
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
void APIENTRY pglcErr( void );
long APIENTRY MainWndProc( HWND, UINT, WPARAM, LPARAM );
BOOL APIENTRY bSetupPixelFormat(HDC);
BOOL createRGBPalette(HDC hDC);
void printVisualInfo(HDC hdc);
HDC ghDC;
HGLRC ghRC;
int wincreat( int x, int y, int width, int height, char *title)
{
MSG msg;
HWND ghWnd;
WNDCLASS wndclass;
HINSTANCE hInstance = GetModuleHandle(NULL);
/* Register the frame class */
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC)MainWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = title;
if (!RegisterClass (&wndclass) )
{
printf( "register class\n" );
fflush( stdout );
pglcErr( );
return FALSE;
}
/* Create the frame */
ghWnd = CreateWindow (title, title,
/*WS_POPUP | WS_MAXIMIZE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, */
WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
x, y,
width, height,
NULL,
NULL,
hInstance,
NULL);
/* make sure window was created */
if (!ghWnd)
{
printf( "create window\n" ); fflush( stdout );
return FALSE;
}
/* show, enable, update main window */
EnableWindow( ghWnd, TRUE );
ShowWindow( ghWnd, SW_SHOWDEFAULT );
UpdateWindow( ghWnd );
/* Hide the mouse cursor. It looks bad showing in the middle of every
tile.*/
ShowCursor(FALSE);
/*
* Process all pending messages
*/
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE)
{
if (GetMessage(&msg, NULL, 0, 0) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
return TRUE;
}
}
return TRUE;
} /* end int APIENTRY pglc_wincreat( ) */
/* main window procedure */
long APIENTRY
MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
LONG lRet = 1;
switch (uMsg) {
case WM_CREATE:
ghDC = GetDC(hWnd);
if (!bSetupPixelFormat(ghDC))
{
printf( "bSetupPixelFormat( ) failed\n" );
PostQuitMessage (0);
}
ghRC = wglCreateContext(ghDC);
wglMakeCurrent(ghDC, ghRC);
break;
case WM_PAINT:
ValidateRect(hWnd,NULL);
break;
case WM_SIZE:
break;
case WM_CLOSE:
if (ghRC)
wglDeleteContext(ghRC);
if (ghDC)
ReleaseDC(hWnd, ghDC);
ghRC = 0;
ghDC = 0;
DestroyWindow (hWnd);
break;
case WM_DESTROY:
if (ghRC)
wglDeleteContext(ghRC);
if (ghDC)
ReleaseDC(hWnd, ghDC);
PostQuitMessage (0);
break;
default:
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
}
return lRet;
} /* end long APIENTRY MainWndProc( ) */
BOOL APIENTRY
bSetupPixelFormat(HDC hdc)
{
PIXELFORMATDESCRIPTOR pfd, *ppfd;
int pixelformat;
ppfd = &pfd;
ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
ppfd->nVersion = 1;
ppfd->dwFlags = PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER;
ppfd->iPixelType = PFD_TYPE_RGBA;
ppfd->cRedBits = 4;
ppfd->cGreenBits = 4;
ppfd->cBlueBits = 4;
ppfd->cAlphaBits = 4;