├── .gitattributes
├── .gitignore
├── LICENSE
├── OSG.Cpp.CLI
├── OSG.Cpp.CLI.vcxproj
├── OSG.Cpp.CLI.vcxproj.filters
├── Wrapper.cpp
└── Wrapper.h
├── OSG.Cpp
├── Core.cpp
├── Core.h
├── OSG.Cpp.vcxproj
└── OSG.Cpp.vcxproj.filters
├── OSG.WPF
├── App.config
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── OSG.WPF.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── osg.ico
├── README.md
└── osg-wpf.sln
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | # DNX
42 | project.lock.json
43 | artifacts/
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | *.pch
52 | *.pdb
53 | *.pgc
54 | *.pgd
55 | *.rsp
56 | *.sbr
57 | *.tlb
58 | *.tli
59 | *.tlh
60 | *.tmp
61 | *.tmp_proj
62 | *.log
63 | *.vspscc
64 | *.vssscc
65 | .builds
66 | *.pidb
67 | *.svclog
68 | *.scc
69 |
70 | # Chutzpah Test files
71 | _Chutzpah*
72 |
73 | # Visual C++ cache files
74 | ipch/
75 | *.aps
76 | *.ncb
77 | *.opensdf
78 | *.sdf
79 | *.cachefile
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 | *.vspx
85 |
86 | # TFS 2012 Local Workspace
87 | $tf/
88 |
89 | # Guidance Automation Toolkit
90 | *.gpState
91 |
92 | # ReSharper is a .NET coding add-in
93 | _ReSharper*/
94 | *.[Rr]e[Ss]harper
95 | *.DotSettings.user
96 |
97 | # JustCode is a .NET coding add-in
98 | .JustCode
99 |
100 | # TeamCity is a build add-in
101 | _TeamCity*
102 |
103 | # DotCover is a Code Coverage Tool
104 | *.dotCover
105 |
106 | # NCrunch
107 | _NCrunch_*
108 | .*crunch*.local.xml
109 |
110 | # MightyMoose
111 | *.mm.*
112 | AutoTest.Net/
113 |
114 | # Web workbench (sass)
115 | .sass-cache/
116 |
117 | # Installshield output folder
118 | [Ee]xpress/
119 |
120 | # DocProject is a documentation generator add-in
121 | DocProject/buildhelp/
122 | DocProject/Help/*.HxT
123 | DocProject/Help/*.HxC
124 | DocProject/Help/*.hhc
125 | DocProject/Help/*.hhk
126 | DocProject/Help/*.hhp
127 | DocProject/Help/Html2
128 | DocProject/Help/html
129 |
130 | # Click-Once directory
131 | publish/
132 |
133 | # Publish Web Output
134 | *.[Pp]ublish.xml
135 | *.azurePubxml
136 | ## TODO: Comment the next line if you want to checkin your
137 | ## web deploy settings but do note that will include unencrypted
138 | ## passwords
139 | #*.pubxml
140 |
141 | *.publishproj
142 |
143 | # NuGet Packages
144 | *.nupkg
145 | # The packages folder can be ignored because of Package Restore
146 | **/packages/*
147 | # except build/, which is used as an MSBuild target.
148 | !**/packages/build/
149 | # Uncomment if necessary however generally it will be regenerated when needed
150 | #!**/packages/repositories.config
151 |
152 | # Windows Azure Build Output
153 | csx/
154 | *.build.csdef
155 |
156 | # Windows Store app package directory
157 | AppPackages/
158 |
159 | # Visual Studio cache files
160 | # files ending in .cache can be ignored
161 | *.[Cc]ache
162 | # but keep track of directories ending in .cache
163 | !*.[Cc]ache/
164 |
165 | # Others
166 | ClientBin/
167 | [Ss]tyle[Cc]op.*
168 | ~$*
169 | *~
170 | *.dbmdl
171 | *.dbproj.schemaview
172 | *.pfx
173 | *.publishsettings
174 | node_modules/
175 | orleans.codegen.cs
176 |
177 | # RIA/Silverlight projects
178 | Generated_Code/
179 |
180 | # Backup & report files from converting an old project file
181 | # to a newer Visual Studio version. Backup files are not needed,
182 | # because we have git ;-)
183 | _UpgradeReport_Files/
184 | Backup*/
185 | UpgradeLog*.XML
186 | UpgradeLog*.htm
187 |
188 | # SQL Server files
189 | *.mdf
190 | *.ldf
191 |
192 | # Business Intelligence projects
193 | *.rdl.data
194 | *.bim.layout
195 | *.bim_*.settings
196 |
197 | # Microsoft Fakes
198 | FakesAssemblies/
199 |
200 | # Node.js Tools for Visual Studio
201 | .ntvs_analysis.dat
202 |
203 | # Visual Studio 6 build log
204 | *.plg
205 |
206 | # Visual Studio 6 workspace options file
207 | *.opt
208 |
209 | # LightSwitch generated files
210 | GeneratedArtifacts/
211 | _Pvt_Extensions/
212 | ModelManifest.xml
213 |
214 | # VS 2015 bug? http://stackoverflow.com/questions/34319008/git-issue-with-visual-studio-2015-update-1
215 | *.VC.opendb
216 | *.VC.db
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 haruelrovix
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.
22 |
--------------------------------------------------------------------------------
/OSG.Cpp.CLI/OSG.Cpp.CLI.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}
23 | OSGCppCLI
24 | 8.1
25 |
26 |
27 |
28 | DynamicLibrary
29 | true
30 | v140
31 | MultiByte
32 | true
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | MultiByte
40 |
41 |
42 | Application
43 | true
44 | v140
45 | MultiByte
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | MultiByte
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | Level3
76 | Disabled
77 | true
78 | $(OSG_INCLUDE_PATH)
79 |
80 |
81 | ..\Debug\OSG.Cpp.lib;OpenThreadsd.lib;osgd.lib;osgDBd.lib;osgGAd.lib;osgViewerd.lib;%(AdditionalDependencies)
82 | $(OSG_LIB_PATH)
83 |
84 |
85 |
86 |
87 | Level3
88 | Disabled
89 | true
90 |
91 |
92 |
93 |
94 | Level3
95 | MaxSpeed
96 | true
97 | true
98 | true
99 |
100 |
101 | true
102 | true
103 |
104 |
105 |
106 |
107 | Level3
108 | MaxSpeed
109 | true
110 | true
111 | true
112 |
113 |
114 | true
115 | true
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/OSG.Cpp.CLI/OSG.Cpp.CLI.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/OSG.Cpp.CLI/Wrapper.cpp:
--------------------------------------------------------------------------------
1 | // OSG.Cpp.CLI/Wrapper.cpp
2 |
3 | #include "Wrapper.h"
4 | #include "../OSG.Cpp/Core.h"
5 |
6 | ///
7 | /// Renders the OSG Viewer into the specified Window handler.
8 | ///
9 | /// The Window handler.
10 | void OSG::Cpp::CLI::Wrapper::Render(IntPtr hwnd)
11 | {
12 | // Get the pointer as window handler
13 | HWND nativeHWND = (HWND)hwnd.ToPointer();
14 |
15 | // Call the native Render method
16 | _impl->Render(nativeHWND);
17 | }
18 |
19 | ///
20 | /// Destroys this instance.
21 | ///
22 | void OSG::Cpp::CLI::Wrapper::Destroy()
23 | {
24 | // Call the native Destroy method
25 | _impl->Destroy();
26 | }
27 |
--------------------------------------------------------------------------------
/OSG.Cpp.CLI/Wrapper.h:
--------------------------------------------------------------------------------
1 | // OSG.Cpp.CLI/Wrapper.h
2 | #pragma once
3 |
4 | #include
5 |
6 | using namespace System;
7 |
8 | namespace OSG
9 | {
10 | namespace Cpp
11 | {
12 | class Core;
13 |
14 | namespace CLI
15 | {
16 | public ref class Wrapper
17 | {
18 | public:
19 | ///
20 | /// Renders the OSG Viewer into the specified Window handler.
21 | ///
22 | /// The Window handler.
23 | void Render(IntPtr hwnd);
24 |
25 | ///
26 | /// Destroys this instance.
27 | ///
28 | void Destroy();
29 |
30 | private:
31 | ///
32 | /// The pointer for this Wrapper class.
33 | ///
34 | Cpp::Core* _impl;
35 | };
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/OSG.Cpp/Core.cpp:
--------------------------------------------------------------------------------
1 | // OSG.Cpp/Core.cpp
2 | #include "Core.h"
3 |
4 | #pragma region Global Variables
5 |
6 | ///
7 | /// Holds the OSG Viewer
8 | ///
9 | osg::ref_ptr g_viewer;
10 |
11 | ///
12 | /// Rendering status
13 | ///
14 | bool g_finished;
15 |
16 | #pragma endregion
17 |
18 | #pragma region Private Methods
19 |
20 | ///
21 | /// Renders the frame.
22 | ///
23 | void render(void*)
24 | {
25 | // Keep the rendering as long as the viewer's work isn't done
26 | while (!g_viewer->done())
27 | {
28 | g_viewer->frame();
29 | }
30 |
31 | // The rendering is done, set the status to Finished
32 | g_finished = true;
33 | }
34 |
35 | ///
36 | /// Creates the viewer.
37 | ///
38 | /// The Window handler.
39 | /// True if there is no error during the creating process.
40 | bool createViewer(HWND hwnd)
41 | {
42 | // Get the dimensions of the window handle
43 | RECT rect;
44 | GetWindowRect(hwnd, &rect);
45 |
46 | // WindowData is used to pass in the Win32 window handle attached the GraphicsContext::Traits structure
47 | osg::ref_ptr windata = new osgViewer::GraphicsWindowWin32::WindowData(hwnd);
48 |
49 | // Create osg's graphics context traits
50 | osg::ref_ptr traits = new osg::GraphicsContext::Traits;
51 |
52 | // Set location and size of the window
53 | traits->x = 0;
54 | traits->y = 0;
55 | traits->width = rect.right - rect.left;
56 | traits->height = rect.bottom - rect.top;
57 | traits->windowDecoration = false;
58 | traits->doubleBuffer = true;
59 | traits->sharedContext = 0;
60 | traits->inheritedWindowData = windata;
61 | traits->pbuffer = false;
62 |
63 | // We must set the pixelformat before we can create the OSG Rendering Surface
64 | PIXELFORMATDESCRIPTOR pixelFormat =
65 | {
66 | sizeof(PIXELFORMATDESCRIPTOR), // Specifies the size of this data structure. This value should be set to sizeof(PIXELFORMATDESCRIPTOR).
67 | 1, // Specifies the version of this data structure. This value should be set to 1.
68 | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, // A set of bit flags that specify properties of the pixel buffer
69 | PFD_TYPE_RGBA, // Specifies the type of pixel data. PFD_TYPE_RGBA or PFD_TYPE_COLORINDEX
70 | 24, // Specifies the number of color bitplanes in each color buffer. For RGBA pixel types, it is the size of the color buffer, excluding the alpha bitplanes
71 | 0, // cRedBits Specifies the number of red bitplanes in each RGBA color buffer.
72 | 0, // cRedShift Specifies the shift count for red bitplanes in each RGBA color buffer.
73 | 0,0,// cGreenBits, cGreenShift
74 | 0,0,// cBlueBits , cBlueShift
75 | 0,0,// cAlphaBits, cAlphaShift
76 | 0, // cAccumBits Specifies the total number of bitplanes in the accumulation buffer.
77 | 0, // cAccumRedBits Specifies the number of red bitplanes in the accumulation buffer.
78 | 0,0,0,// cAccumGreenBits, cAccumBlueBits, cAccumAlphaBits
79 | 24,// cDepthBits Specifies the depth of the depth (z-axis) buffer.
80 | 0, // cStencilBits Specifies the depth of the stencil buffer.
81 | 0, // cAuxBuffers Specifies the number of auxiliary buffers. Auxiliary buffers are not supported.
82 | PFD_MAIN_PLANE, // iLayerType Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
83 | 0, // bReserved Specifies the number of overlay and underlay planes. Bits 0 through 3 specify up to 15 overlay planes and bits 4 through 7 specify up to 15 underlay planes
84 | 0, // dwLayerMask Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
85 | 0, // dwVisibleMask Specifies the transparent color or index of an underlay plane. When the pixel type is RGBA, dwVisibleMask is a transparent RGB color value
86 | 0 // dwDamageMask Ignored. Earlier implementations of OpenGL used this member, but it is no longer used.
87 | };
88 |
89 | // Retrieves a device context for the client area. (ATL)
90 | HDC hdc = ::GetDC(hwnd);
91 | if (hdc == 0)
92 | {
93 | // Destroys the window associated with the CWindow object and sets m_hWnd to NULL.
94 | ::DestroyWindow(hwnd);
95 | return false;
96 | }
97 |
98 | // The ChoosePixelFormat OpenGL function attempts to match an appropriate pixel format supported by a device context to a given pixel format specification.
99 | int pixelFormatIndex = ::ChoosePixelFormat(hdc, &pixelFormat);
100 | if (pixelFormatIndex == 0)
101 | {
102 | // (MFC)Releases the display device context of a container of a windowless control, freeing the device context for use by other applications
103 | ::ReleaseDC(hwnd, hdc);
104 | ::DestroyWindow(hwnd);
105 | return false;
106 | }
107 |
108 | // The SetPixelFormat OpenGL function sets the pixel format of the specified device context to the format specified by the iPixelFormat index.
109 | if (!::SetPixelFormat(hdc, pixelFormatIndex, &pixelFormat))
110 | {
111 | ::ReleaseDC(hwnd, hdc);
112 | ::DestroyWindow(hwnd);
113 | return false;
114 | }
115 |
116 | // Create graphics context
117 | osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get());
118 | osg::ref_ptr camera = new osg::Camera;
119 | camera->setGraphicsContext(gc.get());
120 | camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
121 |
122 | camera->setDrawBuffer(GL_BACK);
123 | camera->setReadBuffer(GL_BACK);
124 |
125 | // Create the viewer and attach the camera to it
126 | g_viewer = new osgViewer::Viewer;
127 | g_viewer->addSlave(camera.get());
128 |
129 | g_viewer->setCamera(camera.get());
130 | g_viewer->setSceneData(osgDB::readNodeFile("cessna.osg"));
131 | g_viewer->setKeyEventSetsDone(0);
132 | g_viewer->setCameraManipulator(new osgGA::TrackballManipulator);
133 |
134 | // The viewer isn't rendering yet, set the status to False
135 | g_finished = false;
136 |
137 | return true;
138 | }
139 |
140 | #pragma endregion
141 |
142 | #pragma region Public Methods
143 |
144 | ///
145 | /// Renders the OSG Viewer into the specified Window handler.
146 | ///
147 | /// The Window handler.
148 | void OSG::Cpp::Core::Render(HWND hwnd)
149 | {
150 | if (createViewer(hwnd))
151 | {
152 | // Create a rendering thread
153 | _beginthread(render, 0, NULL);
154 | }
155 | }
156 |
157 | ///
158 | /// Destroys this instance.
159 | ///
160 | void OSG::Cpp::Core::Destroy()
161 | {
162 | // Set viewer's work to Done
163 | g_viewer->setDone(true);
164 |
165 | // Get the rendering status
166 | while (!g_finished) Sleep(10);
167 |
168 | // Release the memory
169 | g_viewer = NULL;
170 | g_finished = NULL;
171 | }
172 |
173 | #pragma endregion
--------------------------------------------------------------------------------
/OSG.Cpp/Core.h:
--------------------------------------------------------------------------------
1 | // OSG.Cpp/Core.h
2 | #pragma once
3 |
4 | #include
5 | #include
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | namespace OSG
14 | {
15 | namespace Cpp
16 | {
17 | class __declspec(dllexport) Core
18 | {
19 | public:
20 | ///
21 | /// Renders the OSG Viewer into the specified Window handler.
22 | ///
23 | /// The Window handler.
24 | void Render(HWND hwnd);
25 |
26 | ///
27 | /// Destroys this instance.
28 | ///
29 | void Destroy();
30 | };
31 | }
32 | }
--------------------------------------------------------------------------------
/OSG.Cpp/OSG.Cpp.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}
23 | OSGCpp
24 | 8.1
25 |
26 |
27 |
28 | DynamicLibrary
29 | true
30 | v140
31 | MultiByte
32 |
33 |
34 | Application
35 | false
36 | v140
37 | true
38 | MultiByte
39 |
40 |
41 | Application
42 | true
43 | v140
44 | MultiByte
45 |
46 |
47 | Application
48 | false
49 | v140
50 | true
51 | MultiByte
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Level3
75 | Disabled
76 | true
77 | $(OSG_INCLUDE_PATH)
78 |
79 |
80 | $(OSG_LIB_PATH)
81 | osgd.lib;osgDBd.lib;osgGAd.lib;osgViewerd.lib;%(AdditionalDependencies)
82 |
83 |
84 |
85 |
86 | Level3
87 | Disabled
88 | true
89 |
90 |
91 |
92 |
93 | Level3
94 | MaxSpeed
95 | true
96 | true
97 | true
98 |
99 |
100 | true
101 | true
102 |
103 |
104 |
105 |
106 | Level3
107 | MaxSpeed
108 | true
109 | true
110 | true
111 |
112 |
113 | true
114 | true
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/OSG.Cpp/OSG.Cpp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/OSG.WPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/OSG.WPF/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/OSG.WPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace OSG.WPF
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/OSG.WPF/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/OSG.WPF/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using OSG.Cpp.CLI;
2 | using System.Windows;
3 | using System.Windows.Forms;
4 |
5 | namespace OSG.WPF
6 | {
7 | ///
8 | /// Interaction logic for MainWindow.xaml
9 | ///
10 | public partial class MainWindow : Window
11 | {
12 | ///
13 | /// The drawing area for OSG Viewer.
14 | ///
15 | private PictureBox _drawingArea;
16 |
17 | ///
18 | /// The wrapper to the managed C++/CLI
19 | ///
20 | private Wrapper wrapper;
21 |
22 | ///
23 | /// Initializes a new instance of the class.
24 | ///
25 | public MainWindow()
26 | {
27 | InitializeComponent();
28 |
29 | // Initializes the wrapper and the drawing area
30 | wrapper = new Wrapper();
31 | _drawingArea = new PictureBox();
32 |
33 | // Construct the drawing area
34 | windowsFormHost.Child = _drawingArea;
35 | _drawingArea.Paint += new PaintEventHandler(_drawingArea_Paint);
36 | }
37 |
38 | ///
39 | /// Handles the Paint event of the _drawingArea control.
40 | ///
41 | /// The source of the event.
42 | /// The instance containing the event data.
43 | private void _drawingArea_Paint(object sender, PaintEventArgs e)
44 | {
45 | // Renders the OSG Viewer into the drawing area
46 | wrapper.Render(_drawingArea.Handle);
47 | }
48 |
49 | ///
50 | /// Handles the Closed event of the Window control.
51 | ///
52 | /// The source of the event.
53 | /// The instance containing the event data.
54 | private void Window_Closed(object sender, System.EventArgs e)
55 | {
56 | // Release everything we tied
57 | wrapper.Destroy();
58 | _drawingArea.Paint -= _drawingArea_Paint;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/OSG.WPF/OSG.WPF.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x86
7 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}
8 | WinExe
9 | Properties
10 | OSG.WPF
11 | OSG.WPF
12 | v4.5
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 |
17 |
18 | x86
19 | ..\Debug\
20 |
21 |
22 | x86
23 | ..\Release\
24 |
25 |
26 | x64
27 | bin\x64\Debug\
28 |
29 |
30 | x64
31 | bin\x64\Release\
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | MSBuild:Compile
46 | Designer
47 |
48 |
49 | MSBuild:Compile
50 | Designer
51 |
52 |
53 | App.xaml
54 | Code
55 |
56 |
57 | MainWindow.xaml
58 | Code
59 |
60 |
61 |
62 |
63 | Code
64 |
65 |
66 | True
67 | True
68 | Resources.resx
69 |
70 |
71 | True
72 | Settings.settings
73 | True
74 |
75 |
76 | PublicResXFileCodeGenerator
77 | Resources.Designer.cs
78 |
79 |
80 | SettingsSingleFileGenerator
81 | Settings.Designer.cs
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | {af8af7df-34f8-48c3-a2e3-b48da8bbae61}
94 | OSG.Cpp.CLI
95 |
96 |
97 |
98 |
105 |
--------------------------------------------------------------------------------
/OSG.WPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("OSG.WPF")]
11 | [assembly: AssemblyDescription("Integrate OpenSceneGraph in WPF")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("OSG.WPF")]
15 | [assembly: AssemblyCopyright("Copyright © 2016")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/OSG.WPF/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace OSG.WPF.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | public static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OSG.WPF.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | public static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to OpenSceneGraph in WPF.
65 | ///
66 | public static string WindowTitle {
67 | get {
68 | return ResourceManager.GetString("WindowTitle", resourceCulture);
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/OSG.WPF/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | OpenSceneGraph in WPF
122 |
123 |
--------------------------------------------------------------------------------
/OSG.WPF/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace OSG.WPF.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/OSG.WPF/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/OSG.WPF/osg.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haruelrovix/osg-wpf/9e4c333a280f1b7b5346ee31882c97a17394483d/OSG.WPF/osg.ico
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # osg-wpf
2 | Integrate OpenSceneGraph in WPF
3 |
4 | 
5 |
6 | The running application as follow:
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/osg-wpf.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OSG.Cpp", "OSG.Cpp\OSG.Cpp.vcxproj", "{D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OSG.Cpp.CLI", "OSG.Cpp.CLI\OSG.Cpp.CLI.vcxproj", "{AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25} = {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}
11 | EndProjectSection
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSG.WPF", "OSG.WPF\OSG.WPF.csproj", "{B9348559-493B-4CA8-A6B3-A10B6D8CC93B}"
14 | ProjectSection(ProjectDependencies) = postProject
15 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61} = {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}
16 | EndProjectSection
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|x64 = Debug|x64
21 | Debug|x86 = Debug|x86
22 | Release|x64 = Release|x64
23 | Release|x86 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Debug|x64.ActiveCfg = Debug|x64
27 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Debug|x64.Build.0 = Debug|x64
28 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Debug|x86.ActiveCfg = Debug|Win32
29 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Debug|x86.Build.0 = Debug|Win32
30 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Release|x64.ActiveCfg = Release|x64
31 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Release|x64.Build.0 = Release|x64
32 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Release|x86.ActiveCfg = Release|Win32
33 | {D7274A67-1EA2-4D01-A63C-27D2EB3F7A25}.Release|x86.Build.0 = Release|Win32
34 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Debug|x64.ActiveCfg = Debug|x64
35 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Debug|x64.Build.0 = Debug|x64
36 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Debug|x86.ActiveCfg = Debug|Win32
37 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Debug|x86.Build.0 = Debug|Win32
38 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Release|x64.ActiveCfg = Release|x64
39 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Release|x64.Build.0 = Release|x64
40 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Release|x86.ActiveCfg = Release|Win32
41 | {AF8AF7DF-34F8-48C3-A2E3-B48DA8BBAE61}.Release|x86.Build.0 = Release|Win32
42 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Debug|x64.ActiveCfg = Debug|x64
43 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Debug|x64.Build.0 = Debug|x64
44 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Debug|x86.ActiveCfg = Debug|x86
45 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Debug|x86.Build.0 = Debug|x86
46 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Release|x64.ActiveCfg = Release|x64
47 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Release|x64.Build.0 = Release|x64
48 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Release|x86.ActiveCfg = Release|x86
49 | {B9348559-493B-4CA8-A6B3-A10B6D8CC93B}.Release|x86.Build.0 = Release|x86
50 | EndGlobalSection
51 | GlobalSection(SolutionProperties) = preSolution
52 | HideSolutionNode = FALSE
53 | EndGlobalSection
54 | EndGlobal
55 |
--------------------------------------------------------------------------------