Commit 5bb098d2 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Merge branch 'deprecations'

parents c6166712 4a81a05b
......@@ -5,7 +5,7 @@
## This source code is released under the New BSD License.
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# Turn off policy 0017, which makes modules packaged with CMake find
# any module rather than just others packaged with CMake. This is
......@@ -22,6 +22,12 @@ SET(ICET_MINOR_VERSION 1)
SET(ICET_PATCH_VERSION 0)
SET(ICET_VERSION "${ICET_MAJOR_VERSION}.${ICET_MINOR_VERSION}.${ICET_PATCH_VERSION}")
# CMake 2.8.12 and later supports an rpath mechanism on Mac OSX that allows
# build and install targets to point to dependent libraries that are not
# dependent on DYLD_LIBRARY_PATH. This variable turns that behavior on by
# default and also suppresses CMake policy warning 0042.
SET(CMAKE_MACOSX_RPATH ON)
# Set output paths.
SET(LIBRARY_OUTPUT_PATH ${ICET_BINARY_DIR}/lib CACHE PATH
"Output directory for building all libraries.")
......@@ -248,8 +254,8 @@ MACRO(ICET_ADD_LIBRARY library_name)
)
IF (NOT ICET_INSTALL_NO_DEVELOPMENT)
INSTALL(EXPORT ${ICET_INSTALL_EXPORT_NAME}
DESTINATION ${ICET_INSTALL_LIB_DIR}
)
DESTINATION ${ICET_INSTALL_LIB_DIR}
)
ENDIF (NOT ICET_INSTALL_NO_DEVELOPMENT)
ENDIF(NOT ICET_INSTALL_NO_LIBRARIES)
ENDMACRO(ICET_ADD_LIBRARY)
......
......@@ -227,9 +227,15 @@ IceTCommunicator icetCreateMPICommunicator(MPI_Comm mpi_comm)
MPI_Comm_dup(mpi_comm, (MPI_Comm *)comm->data);
#ifdef BREAK_ON_MPI_ERROR
#if MPI_VERSION < 2
MPI_Errhandler_create(ErrorHandler, &eh);
MPI_Errhandler_set(*((MPI_Comm *)comm->data), eh);
MPI_Errhandler_free(&eh);
#else // MPI_VERSION >= 2
MPI_Comm_create_errhandler(ErrorHandler, &eh);
MPI_Comm_set_errhandler(*((MPI_Comm *)comm->data), eh);
MPI_Errhandler_free(&eh);
#endif // MPI_VERSION >= 2
#endif
return comm;
......
......@@ -6,14 +6,40 @@
#
IF (ICET_USE_OPENGL)
FIND_PACKAGE(GLUT)
IF (GLUT_FOUND)
SET(ICET_TESTS_USE_OPENGL 1)
ENDIF (GLUT_FOUND)
SET(ICET_OPENGL_WINDOW_LIBRARY GLUT
CACHE STRING
"The name of the library the IceT tests will use to create windows for
OpenGL contexts. Supported values are GLUT and GLFW."
)
SET_PROPERTY(CACHE ICET_OPENGL_WINDOW_LIBRARY
PROPERTY STRINGS GLUT GLFW
)
MARK_AS_ADVANCED(ICET_OPENGL_WINDOW_LIBRARY)
IF (ICET_OPENGL_WINDOW_LIBRARY STREQUAL GLUT)
FIND_PACKAGE(GLUT)
IF (GLUT_FOUND)
INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})
SET(ICET_TESTS_USE_OPENGL 1)
SET(ICET_TESTS_USE_GLUT 1)
ELSE (GLUT_FOUND)
MESSAGE(WARNING "Cannot find GLUT library. OpenGL tests disabled.")
ENDIF (GLUT_FOUND)
ELSEIF (ICET_OPENGL_WINDOW_LIBRARY STREQUAL GLFW)
FIND_PACKAGE(GLFW)
IF (GLFW_FOUND)
INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIR})
SET(ICET_TESTS_USE_OPENGL 1)
SET(ICET_TESTS_USE_GLFW 1)
ELSE (GLFW_FOUND)
MESSAGE(WARNING "Cannot find GLFW library. OpenGL tests disabled.")
ENDIF (GLFW_FOUND)
ELSE ()
MESSAGE(SEND_ERROR "Invalid value for ICET_OPENGL_WINDOW_LIBRARY: ${ICET_OPENGL_WINDOW_LIBRARY}")
ENDIF ()
ENDIF (ICET_USE_OPENGL)
IF (NOT ICET_TESTS_USE_OPENGL)
MESSAGE(STATUS "Most tests require ICET_USE_OPENGL and Glut. Those tests are disabled.")
MESSAGE(STATUS "Most tests require ICET_USE_OPENGL and GLUT or GLFW. Those tests are disabled.")
ENDIF (NOT ICET_TESTS_USE_OPENGL)
SET(MyTests
......@@ -61,11 +87,13 @@ TARGET_LINK_LIBRARIES(icetTests_mpi
IceTMPI
)
IF (ICET_TESTS_USE_OPENGL)
TARGET_LINK_LIBRARIES(icetTests_mpi
IceTGL
${OPENGL_glu_LIBRARY}
${GLUT_LIBRARIES}
)
TARGET_LINK_LIBRARIES(icetTests_mpi IceTGL)
IF (ICET_TESTS_USE_GLUT)
TARGET_LINK_LIBRARIES(icetTests_mpi ${GLUT_LIBRARIES})
ENDIF (ICET_TESTS_USE_GLUT)
IF (ICET_TESTS_USE_GLFW)
TARGET_LINK_LIBRARIES(icetTests_mpi ${GLFW_LIBRARY})
ENDIF (ICET_TESTS_USE_GLFW)
ENDIF (ICET_TESTS_USE_OPENGL)
IF (ICET_MPIRUN_EXE)
......
......@@ -13,29 +13,80 @@
#include "test-util.h"
#include "test_codes.h"
#ifdef __APPLE__
# include <OpenGL/gl.h>
# include <OpenGL/glu.h>
#else
# include <GL/gl.h>
# include <GL/glu.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288 /* pi */
#endif
IceTInt rank;
IceTInt num_proc;
#define SPHERE_RESOLUTION 20
#define SPHERE_RADIUS 0.5f
#define SPHERE_NUM_QUADS (SPHERE_RESOLUTION*SPHERE_RESOLUTION/2)
#define SPHERE_NUM_VERTICES (SPHERE_NUM_QUADS*4)
static void GetSphereArrays(GLfloat **vertex_array_p, GLfloat **normal_array_p)
{
static GLfloat vertex_array[SPHERE_NUM_VERTICES*3];
static GLfloat normal_array[SPHERE_NUM_VERTICES*3];
static GLboolean arrays_initialized = 0;
if (!arrays_initialized)
{
GLfloat cos_table[SPHERE_RESOLUTION+1];
GLfloat sin_table[SPHERE_RESOLUTION+1];
int theta_index, phi_index;
// Fill out tables.
for (theta_index = 0; theta_index <= SPHERE_RESOLUTION; theta_index++)
{
cos_table[theta_index]=cosf((2*M_PI/SPHERE_RESOLUTION)*theta_index);
sin_table[theta_index]=sinf((2*M_PI/SPHERE_RESOLUTION)*theta_index);
}
// Compute the vertices and normals.
GLfloat *vertex_p = vertex_array;
GLfloat *normal_p = normal_array;
for (phi_index = 0; phi_index < SPHERE_RESOLUTION/2; phi_index++)
{
for (theta_index = 0; theta_index<SPHERE_RESOLUTION; theta_index++)
{
#define SET_VERT(t_index, p_index) \
normal_p[0] = cos_table[t_index]*sin_table[p_index]; \
normal_p[1] = sin_table[t_index]*sin_table[p_index]; \
normal_p[2] = cos_table[p_index]; \
vertex_p[0] = normal_p[0]*SPHERE_RADIUS; \
vertex_p[1] = normal_p[1]*SPHERE_RADIUS; \
vertex_p[2] = normal_p[2]*SPHERE_RADIUS; \
normal_p += 3; vertex_p += 3;
SET_VERT(theta_index, phi_index);
SET_VERT(theta_index, phi_index+1);
SET_VERT(theta_index+1, phi_index+1);
SET_VERT(theta_index+1, phi_index);
}
}
arrays_initialized = 1;
}
*vertex_array_p = vertex_array;
*normal_array_p = normal_array;
}
static void draw(void)
{
static GLUquadricObj *sphere = NULL;
GLfloat *vertex_array;
GLfloat *normal_array;
if (sphere == NULL) {
sphere = gluNewQuadric();
gluQuadricDrawStyle(sphere, GLU_FILL);
gluQuadricNormals(sphere, GLU_SMOOTH);
}
GetSphereArrays(&vertex_array, &normal_array);
glVertexPointer(3, GL_FLOAT, 0, vertex_array);
glNormalPointer(GL_FLOAT, 0, vertex_array);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
......@@ -50,7 +101,7 @@ static void draw(void)
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glTranslatef((float)rank, 0, 0);
gluSphere(sphere, 0.5, 10, 30);
glDrawArrays(GL_QUADS, 0, SPHERE_NUM_VERTICES);
glPopMatrix();
}
......
......@@ -29,16 +29,18 @@
#include <sys/stat.h>
#include <fcntl.h>
#ifdef ICET_TESTS_USE_OPENGL
#ifdef ICET_TESTS_USE_GLUT
#ifndef __APPLE__
#include <GL/glut.h>
#include <GL/gl.h>
#else
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#endif
#endif
#ifdef ICET_TESTS_USE_GLFW
#include <GLFW/glfw3.h>
#endif
#ifndef WIN32
#include <unistd.h>
#else
......@@ -58,11 +60,13 @@ int SINGLE_IMAGE_STRATEGY_LIST_SIZE = 4;
IceTSizeType SCREEN_WIDTH;
IceTSizeType SCREEN_HEIGHT;
#ifdef ICET_TESTS_USE_OPENGL
#ifdef ICET_TESTS_USE_GLUT
static int windowId;
#endif
static int (*test_function)(void);
#endif /* ICET_TESTS_USE_OPENGL */
#ifdef ICET_TESTS_USE_GLFW
static GLFWwindow *window;
#endif
#ifdef ICET_TESTS_USE_OPENGL
static void checkOglError(void)
......@@ -200,11 +204,15 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
/* while (i == 0) sleep(1); */
/* } */
#ifdef ICET_TESTS_USE_OPENGL
#ifdef ICET_TESTS_USE_GLUT
/* Let Glut have first pass at the arguments to grab any that it can use. */
glutInit(argcp, *argvp);
#endif
#ifdef ICET_TESTS_USE_GLFW
if (!glfwInit()) { exit(1); }
#endif
/* Parse my arguments. */
for (arg = 1; arg < argc; arg++) {
if (strcmp(argv[arg], "-width") == 0) {
......@@ -250,8 +258,8 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
exit(1);
}
#ifdef ICET_TESTS_USE_OPENGL
/* Create a renderable window. */
#ifdef ICET_TESTS_USE_GLUT
/* Create a renderable window. */
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA);
glutInitWindowPosition(0, 0);
glutInitWindowSize(width, height);
......@@ -261,7 +269,25 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
sprintf(title, "IceT Test %d of %d", rank, num_proc);
windowId = glutCreateWindow(title);
}
#endif /* ICET_TESTS_USE_OPENGL */
#endif /* ICET_TESTS_USE_GLUT */
#ifdef ICET_TESTS_USE_GLFW
/* Create a renderable window. */
glfwWindowHint(GLFW_RED_BITS, 8);
glfwWindowHint(GLFW_GREEN_BITS, 8);
glfwWindowHint(GLFW_BLUE_BITS, 8);
glfwWindowHint(GLFW_ALPHA_BITS, 8);
glfwWindowHint(GLFW_DEPTH_BITS, 24);
glfwWindowHint(GLFW_SAMPLES, 0);
{
char title[256];
sprintf(title, "IceT Test %d of %d", rank, num_proc);
window = glfwCreateWindow(width, height, title, NULL, NULL);
}
glfwMakeContextCurrent(window);
#endif /* ICET_TESTS_USE_GLFW */
SCREEN_WIDTH = width;
SCREEN_HEIGHT = height;
......@@ -319,7 +345,8 @@ IceTBoolean strategy_uses_single_image_strategy(IceTEnum strategy)
}
}
#ifdef ICET_TESTS_USE_OPENGL
#if defined(ICET_TESTS_USE_GLUT)
static int (*test_function)(void);
static void no_op()
{
......@@ -338,6 +365,8 @@ static void glut_draw()
finalize_test(result);
glutDestroyWindow(windowId);
exit(result);
}
......@@ -360,6 +389,31 @@ int run_test(int (*tf)(void))
return TEST_NOT_PASSED;
}
#elif defined(ICET_TESTS_USE_GLFW)
int run_test(int (*tf)(void))
{
int result;
glEnable(GL_DEPTH_TEST);
glViewport(0, 0, (GLsizei)SCREEN_WIDTH, (GLsizei)SCREEN_HEIGHT);
glClear(GL_COLOR_BUFFER_BIT);
swap_buffers();
result = tf();
finalize_test(result);
glfwDestroyWindow(window);
glfwTerminate();
return result;
}
#elif defined(ICET_TESTS_USE_OPENGL)
#error "ICET_TESTS_USE_OPENGL defined but no window library is defined."
#else /* ICET_TESTS_USE_OPENGL */
int run_test(int (*tf)(void))
......@@ -373,15 +427,23 @@ int run_test(int (*tf)(void))
return result;
}
#endif /* ICET_TESTS_USE_OPENGL */
#endif /* !ICET_TESTS_USE_OPENGL */
#ifdef ICET_TESTS_USE_OPENGL
#ifdef ICET_TESTS_USE_GLUT
void swap_buffers(void)
{
glutSwapBuffers();
}
#endif
#ifdef ICET_TESTS_USE_GLFW
void swap_buffers(void)
{
glfwSwapBuffers(window);
glfwPollEvents();
}
#endif
#define TEST_RESULT_TAG 3492
extern void finalize_communication(void);
void finalize_test(IceTInt result)
......@@ -428,7 +490,4 @@ void finalize_test(IceTInt result)
icetDestroyContext(context);
finalize_communication();
#ifdef ICET_TESTS_USE_OPENGL
glutDestroyWindow(windowId);
#endif
}
......@@ -8,3 +8,7 @@
*/
#cmakedefine ICET_TESTS_USE_OPENGL
#cmakedefine ICET_TESTS_USE_GLUT
#cmakedefine ICET_TESTS_USE_GLFW
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment