Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VTK-m
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Sudhanshu Sane
VTK-m
Commits
59a24105
Commit
59a24105
authored
Oct 06, 2016
by
Robert Maynard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor the Interop tests to work with OSMesa and GLUT.
parent
750b261f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
246 deletions
+121
-246
vtkm/interop/testing/CMakeLists.txt
vtkm/interop/testing/CMakeLists.txt
+29
-11
vtkm/interop/testing/TestingOpenGLInterop.h
vtkm/interop/testing/TestingOpenGLInterop.h
+3
-5
vtkm/interop/testing/UnitTestTransferEGL.cxx
vtkm/interop/testing/UnitTestTransferEGL.cxx
+11
-1
vtkm/interop/testing/UnitTestTransferGLUT.cxx
vtkm/interop/testing/UnitTestTransferGLUT.cxx
+37
-58
vtkm/interop/testing/UnitTestTransferOSMesa.cxx
vtkm/interop/testing/UnitTestTransferOSMesa.cxx
+41
-0
vtkm/interop/testing/WindowBase.h
vtkm/interop/testing/WindowBase.h
+0
-171
No files found.
vtkm/interop/testing/CMakeLists.txt
View file @
59a24105
...
...
@@ -20,20 +20,38 @@
set
(
headers
TestingOpenGLInterop.h
TestingWindow.h
WindowBase.h
)
set
(
unit_tests
UnitTestTransferToOpenGL.cxx
set
(
unit_tests
)
# So because we are using GLEW to do our
# GL binding we can only expect one
# of these transfer tests to work
#
#
set
(
needs_rendering FALSE
)
if
(
VTKm_OSMesa_FOUND AND TARGET vtkm_rendering
)
list
(
APPEND unit_tests
UnitTestTransferOSMesa.cxx
)
set
(
needs_rendering TRUE
)
elseif
(
VTKm_EGL_FOUND AND TARGET vtkm_rendering
)
list
(
APPEND unit_tests
UnitTestTransferEGL.cxx
)
set
(
needs_rendering TRUE
)
else
()
vtkm_configure_component_GLUT
()
if
(
VTKm_GLUT_FOUND
)
list
(
APPEND unit_tests
UnitTestTransferGLUT.cxx
)
endif
()
endif
()
# Need glut for these tests
vtkm_configure_component_GLUT
()
if
(
VTKm_GLUT_FOUND
)
vtkm_declare_headers
(
${
headers
}
)
vtkm_unit_tests
(
SOURCES
${
unit_tests
}
)
else
()
message
(
STATUS
"Interop tests disabled. They need GLUT."
)
vtkm_declare_headers
(
${
headers
}
)
vtkm_unit_tests
(
SOURCES
${
unit_tests
}
)
if
(
needs_rendering
)
target_link_libraries
(
UnitTests_vtkm_interop_testing vtkm_rendering
)
endif
()
vtkm/interop/testing/TestingOpenGLInterop.h
View file @
59a24105
...
...
@@ -25,7 +25,6 @@
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/Magnitude.h>
#include <vtkm/interop/testing/TestingWindow.h>
#include <vtkm/interop/TransferToOpenGL.h>
#include <vtkm/cont/testing/Testing.h>
...
...
@@ -148,6 +147,7 @@ private:
template
<
typename
T
>
void
operator
()(
const
T
t
)
const
{
std
::
cout
<<
"TransferFunctor"
<<
std
::
endl
;
const
std
::
size_t
Size
=
10
;
GLuint
GLHandle
;
//verify that T is able to be transfer to openGL.
...
...
@@ -281,10 +281,8 @@ private:
public:
VTKM_CONT_EXPORT
static
int
Run
()
{
//create a valid openGL context that we can test transfer of data
vtkm
::
interop
::
testing
::
TestingWindow
window
;
window
.
Init
(
"Testing Window"
,
300
,
300
);
std
::
cout
<<
"TestingOpenGLInterop Run() "
<<
std
::
endl
;
//verify that we can transfer basic arrays and constant value arrays to opengl
vtkm
::
testing
::
Testing
::
TryTypes
(
TransferFunctor
());
...
...
vtkm/interop/testing/UnitTestTransfer
ToOpen
GL.cxx
→
vtkm/interop/testing/UnitTestTransfer
E
GL.cxx
View file @
59a24105
...
...
@@ -20,11 +20,21 @@
//This sets up testing with the default device adapter and array container
#include <vtkm/rendering/CanvasEGL.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/interop/testing/TestingOpenGLInterop.h>
int
UnitTestTransfer
ToOpen
GL
(
int
,
char
*
[])
int
UnitTestTransfer
E
GL
(
int
,
char
*
[])
{
//get egl canvas to construct a context for us
vtkm
::
rendering
::
CanvasEGL
canvas
(
1024
,
1024
);
canvas
.
Initialize
();
canvas
.
Activate
();
//get glew to bind all the opengl functions
glewInit
();
return
vtkm
::
interop
::
testing
::
TestingOpenGLInterop
<
vtkm
::
cont
::
DeviceAdapterTagSerial
>::
Run
();
}
vtkm/interop/testing/
TestingWindow.h
→
vtkm/interop/testing/
UnitTestTransferGLUT.cxx
View file @
59a24105
...
...
@@ -17,11 +17,27 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_interop_testing_TestingWindow_h
#define vtk_m_interop_testing_TestingWindow_h
#include <vtkm/internal/ExportMacros.h>
#include <vtkm/interop/testing/WindowBase.h>
//This sets up testing with the default device adapter and array container
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/interop/testing/TestingOpenGLInterop.h>
#include <vtkm/internal/Configure.h>
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
// OpenGL Graphics includes
//glew needs to go before glut
#include <vtkm/interop/internal/OpenGLHeaders.h>
#if defined (__APPLE__)
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#endif
#if defined(VTKM_GCC) && defined(VTKM_POSIX) && !defined(__APPLE__)
//
...
...
@@ -75,65 +91,28 @@ static int vtkm_force_linking_to_pthread_to_fix_nvidia_libgl_bug()
{
return
static_cast
<
int
>
(
pthread_self
());
}
#endif
namespace
vtkm
{
namespace
interop
{
namespace
testing
{
/// \brief Basic Render Window that only makes sure opengl has a valid context
///
/// Bare-bones class that fulfullis the requirements of WindowBase but
/// has no ability to interact with opengl other than to close down the window
///
///
class
TestingWindow
:
public
vtkm
::
interop
::
testing
::
WindowBase
<
TestingWindow
>
int
UnitTestTransferGLUT
(
int
argc
,
char
**
argv
)
{
public:
VTKM_CONT_EXPORT
TestingWindow
(){};
//called after opengl is inited
VTKM_CONT_EXPORT
void
PostInit
()
{}
VTKM_CONT_EXPORT
void
Display
()
{}
VTKM_CONT_EXPORT
void
Idle
()
{}
//get glut to construct a context for us
glutInit
(
&
argc
,
argv
);
glutInitDisplayMode
(
GLUT_RGB
|
GLUT_DOUBLE
|
GLUT_DEPTH
);
glutInitWindowSize
(
1024
,
1024
);
glutCreateWindow
(
"GLUT test"
);
VTKM_CONT_EXPORT
void
ChangeSize
(
int
vtkmNotUsed
(
w
),
int
vtkmNotUsed
(
h
)
)
{}
//get glew to bind all the opengl functions
glewInit
();
VTKM_CONT_EXPORT
void
Key
(
unsigned
char
key
,
int
vtkmNotUsed
(
x
),
int
vtkmNotUsed
(
y
)
)
{
if
(
key
==
27
)
//escape pressed
if
(
!
glewIsSupported
(
"GL_VERSION_2_1"
))
{
#if defined(VTKM_NVIDIA_PTHREAD_WORKAROUND)
std
::
cout
<<
::
vtkm_force_linking_to_pthread_to_fix_nvidia_libgl_bug
();
#endif
exit
(
0
);
std
::
cerr
<<
glGetString
(
GL_RENDERER
)
<<
std
::
endl
;
std
::
cerr
<<
glGetString
(
GL_VERSION
)
<<
std
::
endl
;
return
1
;
}
}
VTKM_CONT_EXPORT
void
SpecialKey
(
int
vtkmNotUsed
(
key
),
int
vtkmNotUsed
(
x
),
int
vtkmNotUsed
(
y
)
)
{}
VTKM_CONT_EXPORT
void
Mouse
(
int
vtkmNotUsed
(
button
),
int
vtkmNotUsed
(
state
),
int
vtkmNotUsed
(
x
),
int
vtkmNotUsed
(
y
)
)
{}
VTKM_CONT_EXPORT
void
MouseMove
(
int
vtkmNotUsed
(
x
),
int
vtkmNotUsed
(
y
)
)
{}
VTKM_CONT_EXPORT
void
PassiveMouseMove
(
int
vtkmNotUsed
(
x
),
int
vtkmNotUsed
(
y
)
)
{}
};
#if defined(VTKM_NVIDIA_PTHREAD_WORKAROUND)
std
::
cout
<<
::
vtkm_force_linking_to_pthread_to_fix_nvidia_libgl_bug
();
#endif
return
vtkm
::
interop
::
testing
::
TestingOpenGLInterop
<
vtkm
::
cont
::
DeviceAdapterTagSerial
>::
Run
();
}
}
}
#endif //vtk_m_interop_testing_TestingWindow_h
vtkm/interop/testing/UnitTestTransferOSMesa.cxx
0 → 100644
View file @
59a24105
//============================================================================
// 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 2014 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//o
// 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.
//============================================================================
//This sets up testing with the default device adapter and array container
#include <vtkm/rendering/CanvasOSMesa.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/interop/testing/TestingOpenGLInterop.h>
int
UnitTestTransferOSMesa
(
int
,
char
*
[])
{
//get osmesa canvas to construct a context for us
vtkm
::
rendering
::
CanvasOSMesa
canvas
(
1024
,
1024
);
canvas
.
Initialize
();
canvas
.
Activate
();
//get glew to bind all the opengl functions
glewInit
();
return
vtkm
::
interop
::
testing
::
TestingOpenGLInterop
<
vtkm
::
cont
::
DeviceAdapterTagSerial
>::
Run
();
}
vtkm/interop/testing/WindowBase.h
deleted
100644 → 0
View file @
750b261f
//============================================================================
// 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 2014 Sandia Corporation.
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 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.
//============================================================================
#ifndef vtkm_m_interop_testing_WindowBase_h
#define vtkm_m_interop_testing_WindowBase_h
//constructs a valid openGL context so that we can verify
//that vtkm to open gl bindings work
#include <string>
#include <vtkm/internal/Configure.h>
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
// OpenGL Graphics includes
//glew needs to go before glut
#include <vtkm/interop/internal/OpenGLHeaders.h>
#if defined (__APPLE__)
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#endif
#include <vtkm/cont/ErrorControlBadValue.h>
#ifdef VTKM_CUDA
# include <vtkm/cont/cuda/ChooseCudaDevice.h>
# include <vtkm/interop/cuda/SetOpenGLDevice.h>
#endif
#include <iostream>
namespace
vtkm
{
namespace
interop
{
namespace
testing
{
namespace
internal
{
template
<
typename
T
>
struct
GLUTStaticCallbackHolder
{
static
T
*
StaticGLUTResource
;
};
template
<
typename
T
>
T
*
GLUTStaticCallbackHolder
<
T
>::
StaticGLUTResource
;
}
/// \brief Basic GLUT Wrapper class
///
/// This class gives the ability to wrap the glut function callbacks into
/// a single class so that you can use c++ objects. The only downside
/// is that you can only have a single window created
///
template
<
class
Derived
>
class
WindowBase
:
private
internal
::
GLUTStaticCallbackHolder
<
Derived
>
{
public:
void
Init
(
std
::
string
title
,
int
width
,
int
height
,
int
argc
,
char
**
argv
)
{
//set our selves as the static instance to call
WindowBase
<
Derived
>::
StaticGLUTResource
=
static_cast
<
Derived
*>
(
this
);
glutInit
(
&
argc
,
argv
);
glutInitDisplayMode
(
GLUT_RGBA
|
GLUT_DOUBLE
|
GLUT_DEPTH
);
glutInitWindowPosition
(
0
,
0
);
glutInitWindowSize
(
width
,
height
);
glutCreateWindow
(
title
.
c_str
());
// glewExperimental = GL_TRUE;
glewInit
();
if
(
!
glewIsSupported
(
"GL_VERSION_2_1"
))
{
std
::
cerr
<<
glGetString
(
GL_RENDERER
)
<<
std
::
endl
;
std
::
cerr
<<
glGetString
(
GL_VERSION
)
<<
std
::
endl
;
throw
vtkm
::
cont
::
ErrorControlBadValue
(
"Unable to create an OpenGL 2.1 Context"
);
}
#ifdef VTKM_CUDA
int
id
=
vtkm
::
cont
::
cuda
::
FindFastestDeviceId
();
vtkm
::
interop
::
cuda
::
SetCudaGLDevice
(
id
);
#endif
//attach all the glut call backs
glutDisplayFunc
(
WindowBase
<
Derived
>::
GLUTDisplayCallback
);
glutIdleFunc
(
WindowBase
<
Derived
>::
GLUTIdleCallback
);
glutReshapeFunc
(
WindowBase
<
Derived
>::
GLUTChangeSizeCallback
);
glutKeyboardFunc
(
WindowBase
<
Derived
>::
GLUTKeyCallback
);
glutSpecialFunc
(
WindowBase
<
Derived
>::
GLUTSpecialKeyCallback
);
glutMouseFunc
(
WindowBase
<
Derived
>::
GLUTMouseCallback
);
glutMotionFunc
(
WindowBase
<
Derived
>::
GLUTMouseMoveCallback
);
glutPassiveMotionFunc
(
WindowBase
<
Derived
>::
GLUTPassiveMouseMoveCallback
);
//call any custom init code you want to have
WindowBase
<
Derived
>::
StaticGLUTResource
->
PostInit
();
}
void
Init
(
std
::
string
title
,
int
width
,
int
height
)
{
int
argc
=
0
;
char
**
argv
=
0
;
Init
(
title
,
width
,
height
,
argc
,
argv
);
}
//Init must be called before you call Start so that we have a valid
//opengl context
void
Start
()
{
glutMainLoop
();
}
static
void
GLUTDisplayCallback
()
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
Display
();
}
static
void
GLUTIdleCallback
()
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
Idle
();
}
static
void
GLUTChangeSizeCallback
(
int
width
,
int
height
)
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
ChangeSize
(
width
,
height
);
}
static
void
GLUTKeyCallback
(
unsigned
char
key
,
int
x
,
int
y
)
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
Key
(
key
,
x
,
y
);
}
static
void
GLUTSpecialKeyCallback
(
int
key
,
int
x
,
int
y
)
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
SpecialKey
(
key
,
x
,
y
);
}
static
void
GLUTMouseCallback
(
int
button
,
int
state
,
int
x
,
int
y
)
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
Mouse
(
button
,
state
,
x
,
y
);
}
static
void
GLUTMouseMoveCallback
(
int
x
,
int
y
)
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
MouseMove
(
x
,
y
);
}
static
void
GLUTPassiveMouseMoveCallback
(
int
x
,
int
y
)
{
WindowBase
<
Derived
>::
StaticGLUTResource
->
PassiveMouseMove
(
x
,
y
);
}
};
}
}
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
# pragma GCC diagnostic pop
#endif
#endif //vtkm_m_interop_testing_WindowBase_h
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment