mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Add GLFW unittest.
This commit is contained in:
parent
4d43c1c8ab
commit
be643811d6
102
CMake/FindGLFW.cmake
Normal file
102
CMake/FindGLFW.cmake
Normal file
@ -0,0 +1,102 @@
|
||||
##=============================================================================
|
||||
##
|
||||
## Copyright (c) Kitware, Inc.
|
||||
## All rights reserved.
|
||||
## See LICENSE.txt for details.
|
||||
##
|
||||
## This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
## PURPOSE. See the above copyright notice for more information.
|
||||
##
|
||||
## Copyright 2016 Sandia Corporation.
|
||||
## Copyright 2016 UT-Battelle, LLC.
|
||||
## Copyright 2016 Los Alamos National Security.
|
||||
##
|
||||
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
## the U.S. Government retains certain rights in this software.
|
||||
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
## Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
## this software.
|
||||
##
|
||||
##=============================================================================
|
||||
# Try to find EGL library and include dir.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLFW_FOUND
|
||||
# GLFW_INCLUDE_DIR
|
||||
# GLFW_LIBRARY
|
||||
#
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if (WIN32)
|
||||
find_path( GLFW_INCLUDE_DIR
|
||||
NAMES
|
||||
GLFW/glfw3.h
|
||||
PATHS
|
||||
${PROJECT_SOURCE_DIR}/shared_external/glfw/include
|
||||
${PROJECT_SOURCE_DIR}/../shared_external/glfw/include
|
||||
${GLFW_LOCATION}/include
|
||||
$ENV{GLFW_LOCATION}/include
|
||||
$ENV{PROGRAMFILES}/GLFW/include
|
||||
${GLFW_LOCATION}
|
||||
$ENV{GLFW_LOCATION}
|
||||
DOC "The directory where GLFW/glfw3.h resides" )
|
||||
if(ARCH STREQUAL "x86")
|
||||
find_library( GLFW_LIBRARY
|
||||
NAMES
|
||||
glfw3
|
||||
PATHS
|
||||
${GLFW_LOCATION}/lib
|
||||
$ENV{GLFW_LOCATION}/lib
|
||||
$ENV{PROGRAMFILES}/GLFW/lib
|
||||
DOC "The GLFW library")
|
||||
else()
|
||||
find_library( GLFW_LIBRARY
|
||||
NAMES
|
||||
glfw3
|
||||
PATHS
|
||||
${GLFW_LOCATION}/lib
|
||||
$ENV{GLFW_LOCATION}/lib
|
||||
$ENV{PROGRAMFILES}/GLFW/lib
|
||||
DOC "The GLFW library")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (${CMAKE_HOST_UNIX})
|
||||
find_path( GLFW_INCLUDE_DIR
|
||||
NAMES
|
||||
GLFW/glfw3.h
|
||||
PATHS
|
||||
${GLFW_LOCATION}/include
|
||||
$ENV{GLFW_LOCATION}/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
NO_DEFAULT_PATH
|
||||
DOC "The directory where GLFW/glfw3.h resides"
|
||||
)
|
||||
find_library( GLFW_LIBRARY
|
||||
NAMES
|
||||
glfw3 glfw
|
||||
PATHS
|
||||
${GLFW_LOCATION}/lib
|
||||
$ENV{GLFW_LOCATION}/lib
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib64
|
||||
/usr/local/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/usr/lib/x86_64-linux-gnu
|
||||
NO_DEFAULT_PATH
|
||||
DOC "The GLFW library")
|
||||
endif ()
|
||||
|
||||
find_package_handle_standard_args(GLFW DEFAULT_MSG
|
||||
GLFW_INCLUDE_DIR
|
||||
GLFW_LIBRARY
|
||||
)
|
||||
|
||||
mark_as_advanced( GLFW_FOUND )
|
@ -186,6 +186,7 @@ include(CMakeDependentOption)
|
||||
find_package(OpenGL)
|
||||
find_package(GLEW)
|
||||
find_package(GLUT)
|
||||
find_package(GLFW)
|
||||
find_package(EGL)
|
||||
|
||||
#dependent option reads, value to set, if condition is true, otherwise
|
||||
|
@ -45,6 +45,11 @@ public:
|
||||
: Canvas(0,0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
CanvasGL(vtkm::Id width, vtkm::Id height) : Canvas(width,height)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
virtual void Initialize()
|
||||
|
@ -36,8 +36,15 @@ if (OPENGL_FOUND)
|
||||
)
|
||||
list(APPEND libs ${EGL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
if (GLFW_FOUND)
|
||||
set(unit_tests ${unit_tests}
|
||||
UnitTestMapperGLFW.cxx
|
||||
)
|
||||
list(APPEND libs ${GLFW_LIBRARY})
|
||||
list(APPEND includes ${GLFW_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if (OSMESA_FOUND)
|
||||
set(unit_tests ${unit_tests}
|
||||
UnitTestMapperOSMesa.cxx
|
||||
|
92
vtkm/rendering/testing/UnitTestMapperGLFW.cxx
Normal file
92
vtkm/rendering/testing/UnitTestMapperGLFW.cxx
Normal file
@ -0,0 +1,92 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2015 Sandia Corporation.
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#include <vtkm/Bounds.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <vtkm/rendering/Actor.h>
|
||||
#include <vtkm/rendering/CanvasGL.h>
|
||||
#include <vtkm/rendering/MapperGL.h>
|
||||
#include <vtkm/rendering/Scene.h>
|
||||
#include <vtkm/rendering/View.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/rendering/testing/RenderTest.h>
|
||||
|
||||
namespace {
|
||||
static const vtkm::Id WIDTH = 512, HEIGHT = 512;
|
||||
static vtkm::Id which = 0, NUM_DATASETS = 4;
|
||||
static bool done = false;
|
||||
|
||||
static void
|
||||
keyCallback(GLFWwindow* vtkmNotUsed(window), int key,
|
||||
int vtkmNotUsed(scancode), int action, int vtkmNotUsed(mods))
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE)
|
||||
done = true;
|
||||
if (action == 1)
|
||||
which = (which+1) % NUM_DATASETS;
|
||||
}
|
||||
|
||||
void RenderTests()
|
||||
{
|
||||
std::cout<<"Press any key to cycle through datasets. ESC to quit."<<std::endl;
|
||||
|
||||
typedef vtkm::rendering::MapperGL<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> M;
|
||||
typedef vtkm::rendering::CanvasGL C;
|
||||
typedef vtkm::rendering::View3D V3;
|
||||
typedef vtkm::rendering::View2D V2;
|
||||
|
||||
vtkm::cont::testing::MakeTestDataSet maker;
|
||||
vtkm::rendering::ColorTable colorTable("thermal");
|
||||
|
||||
glfwInit();
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "GLFW Test", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSetKeyCallback(window, keyCallback);
|
||||
glewInit();
|
||||
|
||||
while (!glfwWindowShouldClose(window) && !done)
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
||||
if (which == 0)
|
||||
vtkm::rendering::testing::Render<M,C,V3>(maker.Make3DRegularDataSet0(),
|
||||
"pointvar", colorTable, "reg3D.pnm");
|
||||
else if (which == 1)
|
||||
vtkm::rendering::testing::Render<M,C,V3>(maker.Make3DRectilinearDataSet0(),
|
||||
"pointvar", colorTable, "rect3D.pnm");
|
||||
else if (which == 2)
|
||||
vtkm::rendering::testing::Render<M,C,V3>(maker.Make3DExplicitDataSet4(),
|
||||
"pointvar", colorTable, "expl3D.pnm");
|
||||
else if (which == 3)
|
||||
vtkm::rendering::testing::Render<M,C,V2>(maker.Make2DRectilinearDataSet0(),
|
||||
"pointvar", colorTable, "rect2D.pnm");
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
}
|
||||
} //namespace
|
||||
|
||||
int UnitTestMapperGLFW(int, char *[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(RenderTests);
|
||||
}
|
Loading…
Reference in New Issue
Block a user