Skip to content

Commit d964227

Browse files
author
Will Usher
committed
Initial commit
0 parents  commit d964227

45 files changed

Lines changed: 89414 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlinesLeft: true
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: Empty
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: true
19+
AlwaysBreakTemplateDeclarations: true
20+
BinPackArguments: false
21+
BinPackParameters: false
22+
BraceWrapping:
23+
AfterClass: false
24+
AfterControlStatement: false
25+
AfterEnum: false
26+
AfterFunction: true
27+
AfterNamespace: false
28+
AfterStruct: false
29+
AfterUnion: false
30+
AfterExternBlock: false
31+
BeforeCatch: false
32+
BeforeElse: false
33+
IndentBraces: false
34+
BreakBeforeBinaryOperators: None
35+
BreakBeforeBraces: Custom
36+
BreakBeforeTernaryOperators: true
37+
BreakConstructorInitializersBeforeComma: false
38+
BreakStringLiterals: true
39+
ColumnLimit: 95
40+
CommentPragmas: '^ IWYU pragma:'
41+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
42+
Cpp11BracedListStyle: true
43+
DerivePointerAlignment: false
44+
DisableFormat: false
45+
ExperimentalAutoDetectBinPacking: false
46+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
47+
IncludeCategories:
48+
- Regex: '^<[^\.]*>'
49+
Priority: 1
50+
- Regex: '^<.*\.h>'
51+
Priority: 2
52+
- Regex: '.*'
53+
Priority: 3
54+
SortIncludes: true
55+
ConstructorInitializerIndentWidth: 4
56+
ContinuationIndentWidth: 4
57+
IndentCaseLabels: false
58+
IndentWidth: 4
59+
IndentWrappedFunctionNames: false
60+
KeepEmptyLinesAtTheStartOfBlocks: false
61+
MacroBlockBegin: ''
62+
MacroBlockEnd: ''
63+
MaxEmptyLinesToKeep: 1
64+
NamespaceIndentation: Inner
65+
PenaltyBreakBeforeFirstCallParameter: 1
66+
PenaltyBreakComment: 300
67+
PenaltyBreakFirstLessLess: 120
68+
PenaltyBreakString: 1000
69+
PenaltyExcessCharacter: 1000000
70+
PenaltyReturnTypeOnItsOwnLine: 200
71+
PointerAlignment: Right
72+
ReflowComments: true
73+
SpaceAfterCStyleCast: false
74+
SpaceAfterTemplateKeyword: true
75+
SpaceBeforeAssignmentOperators: true
76+
SpaceBeforeParens: ControlStatements
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: 2
79+
SpacesInAngles: false
80+
SpacesInContainerLiterals: false
81+
SpacesInCStyleCastParentheses: false
82+
SpacesInParentheses: false
83+
SpacesInSquareBrackets: false
84+
Standard: Cpp11
85+
TabWidth: 4
86+
FixNamespaceComments: false
87+
UseTab: Never
88+
...
89+
90+

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.swp
2+
*.raw
3+
build/
4+
cmake-build
5+
cmake-ninja
6+
.DS_Store
7+
compile_commands.json
8+
.cache/

CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_dependent_option(
2+
OSPRAY_MODULE_STARTER
3+
"Build the OSPRay Starter Example"
4+
OFF
5+
OSPRAY_MODULE_CPU
6+
OFF
7+
)
8+
9+
if (NOT OSPRAY_MODULE_STARTER)
10+
return()
11+
endif()
12+
13+
include(ExternalProject)
14+
15+
find_package(SDL2 REQUIRED)
16+
find_package(OpenGL REQUIRED)
17+
include(cmake/glm.cmake)
18+
19+
add_subdirectory(imgui)
20+
add_subdirectory(util)
21+
add_subdirectory(module)
22+
23+
add_executable(osp_starter
24+
main.cpp
25+
imgui_impl_opengl3.cpp
26+
imgui_impl_sdl.cpp)
27+
28+
set_target_properties(osp_starter PROPERTIES
29+
CXX_STANDARD 14
30+
CXX_STANDARD_REQUIRED ON)
31+
32+
target_link_libraries(osp_starter PUBLIC
33+
util)
34+
35+
target_compile_definitions(osp_starter PUBLIC
36+
-DNOMINMAX
37+
-DSDL_MAIN_HANDLED
38+
-DOSPRAY_CPP_RKCOMMON_TYPES
39+
-DOSPRAY_GLM_DEFINITIONS)
40+

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Will Usher
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# OSPRay Starter
2+
3+
Get started quickly with developing an OSPRay app or custom module.
4+
Clone this repo into OSPRay's `modules` directory and re-run CMake to build OSPRay
5+
with `-DOSPRAY_MODULE_STARTER=ON` to build the module and app.
6+
7+
## Dependencies:
8+
9+
The module requires that you're building OSPRay's CPU module, along with:
10+
11+
- SDL2
12+
- GLM (downloaded by CMake)
13+

cmake/glm.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ExternalProject_Add(glm_ext
2+
PREFIX glm
3+
DOWNLOAD_DIR glm
4+
STAMP_DIR glm/stamp
5+
SOURCE_DIR glm/src
6+
BINARY_DIR glm
7+
URL "https://github.com/g-truc/glm/releases/download/0.9.9.8/glm-0.9.9.8.zip"
8+
URL_HASH "SHA256=37e2a3d62ea3322e43593c34bae29f57e3e251ea89f4067506c94043769ade4c"
9+
CONFIGURE_COMMAND ""
10+
BUILD_COMMAND ""
11+
INSTALL_COMMAND ""
12+
BUILD_ALWAYS OFF
13+
)
14+
15+
set(GLM_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/glm/src)
16+
17+
add_library(glm INTERFACE)
18+
19+
add_dependencies(glm glm_ext)
20+
21+
target_include_directories(glm INTERFACE
22+
${GLM_INCLUDE_DIRS})
23+

imgui/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
add_library(imgui
2+
imgui.cpp
3+
imgui_demo.cpp
4+
imgui_draw.cpp
5+
imgui_tables.cpp
6+
imgui_widgets.cpp)
7+
8+
target_include_directories(imgui PUBLIC
9+
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
10+
11+
set_target_properties(imgui PROPERTIES
12+
CXX_STANDARD 14
13+
CXX_STANDARD_REQUIRED ON)
14+

imgui/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014-2021 Omar Cornut
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

imgui/imconfig.h

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
//-----------------------------------------------------------------------------
2+
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
3+
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
4+
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
5+
//-----------------------------------------------------------------------------
6+
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
7+
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
8+
//-----------------------------------------------------------------------------
9+
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
10+
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
11+
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
12+
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
13+
//-----------------------------------------------------------------------------
14+
15+
#pragma once
16+
17+
//---- Define assertion handler. Defaults to calling assert().
18+
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
19+
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
20+
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
21+
22+
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
23+
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
24+
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
25+
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
26+
//#define IMGUI_API __declspec( dllexport )
27+
//#define IMGUI_API __declspec( dllimport )
28+
29+
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
30+
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
31+
32+
//---- Disable all of Dear ImGui or don't implement standard windows.
33+
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
34+
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
35+
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
36+
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger and other debug tools: ShowMetricsWindow() and ShowStackToolWindow() will be empty.
37+
38+
//---- Don't implement some functions to reduce linkage requirements.
39+
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
40+
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
41+
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
42+
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
43+
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
44+
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
45+
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
46+
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
47+
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
48+
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
49+
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
50+
51+
//---- Include imgui_user.h at the end of imgui.h as a convenience
52+
//#define IMGUI_INCLUDE_IMGUI_USER_H
53+
54+
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
55+
//#define IMGUI_USE_BGRA_PACKED_COLOR
56+
57+
//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
58+
//#define IMGUI_USE_WCHAR32
59+
60+
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
61+
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
62+
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
63+
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
64+
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
65+
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
66+
67+
//---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
68+
// Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
69+
// #define IMGUI_USE_STB_SPRINTF
70+
71+
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
72+
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
73+
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
74+
//#define IMGUI_ENABLE_FREETYPE
75+
76+
//---- Use stb_truetype to build and rasterize the font atlas (default)
77+
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
78+
//#define IMGUI_ENABLE_STB_TRUETYPE
79+
80+
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
81+
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
82+
/*
83+
#define IM_VEC2_CLASS_EXTRA \
84+
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
85+
operator MyVec2() const { return MyVec2(x,y); }
86+
87+
#define IM_VEC4_CLASS_EXTRA \
88+
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
89+
operator MyVec4() const { return MyVec4(x,y,z,w); }
90+
*/
91+
92+
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
93+
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
94+
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
95+
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
96+
//#define ImDrawIdx unsigned int
97+
98+
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
99+
//struct ImDrawList;
100+
//struct ImDrawCmd;
101+
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
102+
//#define ImDrawCallback MyImDrawCallback
103+
104+
//---- Debug Tools: Macro to break in Debugger
105+
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
106+
//#define IM_DEBUG_BREAK IM_ASSERT(0)
107+
//#define IM_DEBUG_BREAK __debugbreak()
108+
109+
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
110+
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
111+
// This adds a small runtime cost which is why it is not enabled by default.
112+
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
113+
114+
//---- Debug Tools: Enable slower asserts
115+
//#define IMGUI_DEBUG_PARANOID
116+
117+
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
118+
/*
119+
namespace ImGui
120+
{
121+
void MyFunction(const char* name, const MyMatrix44& v);
122+
}
123+
*/

0 commit comments

Comments
 (0)