Merge remote-tracking branch 'upstream/master' into MDI7
This commit is contained in:
@@ -773,7 +773,7 @@ void ComputeNode::initComputingSetup()
|
||||
_dataArray->setBufferObject(_ssbo.get());
|
||||
|
||||
|
||||
_ssbb = new osg::ShaderStorageBufferBinding(0, _ssbo.get(), 0, blockSize);
|
||||
_ssbb = new osg::ShaderStorageBufferBinding(0, _dataArray, 0, blockSize);
|
||||
statesetComputation->setAttributeAndModes(_ssbb.get(), osg::StateAttribute::ON);
|
||||
|
||||
|
||||
|
||||
@@ -108,10 +108,10 @@ class ResetAtomicCounter : public osg::StateAttributeCallback
|
||||
osg::AtomicCounterBufferBinding * acbb = dynamic_cast<osg::AtomicCounterBufferBinding *>(sa);
|
||||
if (acbb)
|
||||
{
|
||||
osg::AtomicCounterBufferObject * acbo = dynamic_cast<osg::AtomicCounterBufferObject*>(acbb->getBufferObject());
|
||||
if (acbo && acbo->getBufferData(0))
|
||||
osg::BufferData * acbd = acbb->getBufferData();
|
||||
if (acbd)
|
||||
{
|
||||
acbo->getBufferData(0)->dirty();
|
||||
acbd->dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,10 +207,10 @@ int main(int argc, char** argv)
|
||||
acboBlue->setUsage(GL_STREAM_COPY);
|
||||
atomicCounterArrayBlue->setBufferObject(acboBlue.get());
|
||||
|
||||
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbRedAndGreen = new osg::AtomicCounterBufferBinding(0, acboRedAndGreen.get(), 0, sizeof(GLuint)*3);
|
||||
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbRedAndGreen = new osg::AtomicCounterBufferBinding(0, atomicCounterArrayRedAndGreen.get(), 0, sizeof(GLuint)*3);
|
||||
ss->setAttributeAndModes(acbbRedAndGreen.get());
|
||||
|
||||
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbBlue = new osg::AtomicCounterBufferBinding(2, acboBlue.get(), 0, sizeof(GLuint));
|
||||
osg::ref_ptr<osg::AtomicCounterBufferBinding> acbbBlue = new osg::AtomicCounterBufferBinding(2, atomicCounterArrayBlue.get(), 0, sizeof(GLuint));
|
||||
ss->setAttributeAndModes(acbbBlue.get());
|
||||
|
||||
acbbRedAndGreen->setUpdateCallback(new ResetAtomicCounter);
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
/// with a different texture. Generally speaking in broad terms
|
||||
/// driver overhead tends to be a huge bottle neck on modern
|
||||
/// hardware (as of late 2016). By using bindless textures
|
||||
/// we can remove alot of calls to the driver to switch active
|
||||
/// we can remove a lot of calls to the driver to switch active
|
||||
/// textures while rendering. What this also allows us to do
|
||||
/// is to consolidate more objects + draw states as we do
|
||||
/// not need to change textures, this save us alot of calls to
|
||||
/// not need to change textures, this save us a lot of calls to
|
||||
/// the driver.
|
||||
///
|
||||
/// This example combines instancing with bindless textures
|
||||
@@ -43,7 +43,7 @@
|
||||
/// a pretty simplified example, where each instance ID is
|
||||
/// used as a index into the array of textures.
|
||||
///
|
||||
/// One of the powerfull things about bindless textures is it allows
|
||||
/// One of the powerful things about bindless textures is it allows
|
||||
/// many more objects to be combined into a single drawable.
|
||||
/// However to do this you may need to add an attribute to
|
||||
/// use an index into the array of texture handles, and not
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
val->_handles = new osg::UInt64Array();
|
||||
val->_handles->resize(count*2,0);
|
||||
val->_handles->setBufferObject(val->_sbbo.get());
|
||||
val->_ssbb = new osg::UniformBufferBinding(0, val->_sbbo.get(), 0, sizeof(GLuint64)*count);
|
||||
val->_ssbb = new osg::UniformBufferBinding(0, val->_handles.get(), 0, sizeof(GLuint64)*count);
|
||||
return val;
|
||||
}
|
||||
BindlessBuffer& operator = (const BindlessBuffer& rhs){
|
||||
@@ -261,7 +261,7 @@ void BindlessTexture::setBidlessIndex(unsigned int index){
|
||||
_bindlessIndex = index;
|
||||
}
|
||||
/// Just as the name suggest this should be called once per
|
||||
/// context, durring its lifetime. This basically
|
||||
/// context, during its lifetime. This basically
|
||||
/// just sets up our texture handles, and loads them
|
||||
/// into our UBO. A good portion of this was copied from
|
||||
/// Texture2D::apply, this is in no ways a general solution.
|
||||
@@ -326,7 +326,7 @@ void BindlessTexture::apply(osg::State& state) const
|
||||
applyOnce(state);
|
||||
_isBound[contextID] = true;
|
||||
}else{
|
||||
//we should mostly hit this durring the lifetime of this object,
|
||||
//we should mostly hit this during the lifetime of this object,
|
||||
//note we basically do nothing......
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class Receiver
|
||||
// Define what port to listen and bind to
|
||||
void setPort( const short port );
|
||||
|
||||
// Sync does a blocking wait to recieve next message
|
||||
// Sync does a blocking wait to receive next message
|
||||
unsigned int sync( void );
|
||||
|
||||
private :
|
||||
|
||||
60
examples/osgemscripten/CMakeLists.txt
Normal file
60
examples/osgemscripten/CMakeLists.txt
Normal file
@@ -0,0 +1,60 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
|
||||
|
||||
# Path to OpenSceneGraph
|
||||
SET(OSG_DIR "${CMAKE_SOURCE_DIR}/../..")
|
||||
|
||||
# Specify critical OpenSceneGraph build variables.
|
||||
SET(BUILD_OSG_APPLICATIONS NO CACHE BOOL "Do not build applications")
|
||||
SET(EGL_LIBRARY "GL" CACHE STRING "Suppress linkage error")
|
||||
SET(OSG_GL1_AVAILABLE OFF CACHE BOOL "Unavailable under Emscripten")
|
||||
SET(OSG_GL2_AVAILABLE OFF CACHE BOOL "Unavailable under Emscripten")
|
||||
SET(OSG_GLES2_AVAILABLE ON CACHE BOOL "GLES2 is what Emscripten uses")
|
||||
SET(DYNAMIC_OPENTHREADS OFF CACHE BOOL "Link OpenThreads statically")
|
||||
SET(DYNAMIC_OPENSCENEGRAPH OFF CACHE BOOL "Link OpenSceneGraph statically")
|
||||
# Reference SDL2 during build process.
|
||||
# We use SDL2 to do the following:
|
||||
# * OpenGL functions' address retrieval
|
||||
# * OpenGL graphics context creation
|
||||
SET(USE_SDL2 "-s USE_SDL=2")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${USE_SDL2}" CACHE STRING "Use SDL2" FORCE)
|
||||
|
||||
# Reference OpenSceneGraph includes and libraries.
|
||||
SET(OSG_SOURCE_DIR "${OSG_DIR}")
|
||||
SET(OSG_BUILD_DIR "${OSG_DIR}/build/Emscripten")
|
||||
INCLUDE_DIRECTORIES(${OSG_SOURCE_DIR}/include)
|
||||
INCLUDE_DIRECTORIES(${OSG_BUILD_DIR}/include)
|
||||
LINK_DIRECTORIES(${OSG_BUILD_DIR}/lib)
|
||||
|
||||
# Build OpenSceneGraph if osgViewer library is missing.
|
||||
IF(EXISTS "${OSG_BUILD_DIR}/lib/libosgViewer.a")
|
||||
MESSAGE("Skip building OpenSceneGraph")
|
||||
ELSE()
|
||||
MESSAGE("Build OpenSceneGraph")
|
||||
FILE(MAKE_DIRECTORY ${OSG_BUILD_DIR})
|
||||
ADD_SUBDIRECTORY(${OSG_SOURCE_DIR} ${OSG_BUILD_DIR})
|
||||
ENDIF()
|
||||
|
||||
# Build example.
|
||||
ADD_EXECUTABLE(osgemscripten osgemscripten.cpp)
|
||||
# Make Emscripten generate ready-to-open HTML page.
|
||||
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
# Make Emscripten preload the resource.
|
||||
SET_TARGET_PROPERTIES(osgemscripten PROPERTIES LINK_FLAGS "--preload-file box.osgt")
|
||||
# Copy the resource to the build directory.
|
||||
CONFIGURE_FILE(box.osgt box.osgt COPYONLY)
|
||||
# Libraries must be linked in the specified order.
|
||||
# Otherwise you may get unsatisified linker errors.
|
||||
TARGET_LINK_LIBRARIES(
|
||||
osgemscripten
|
||||
osgViewer
|
||||
osgDB
|
||||
# osgDB plugins start.
|
||||
osgdb_osg
|
||||
osgdb_serializers_osg
|
||||
# osgDB plugins end.
|
||||
osgGA
|
||||
osgText
|
||||
osgUtil
|
||||
osg
|
||||
OpenThreads
|
||||
)
|
||||
43
examples/osgemscripten/README.md
Normal file
43
examples/osgemscripten/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
How to build osgemscripten example
|
||||
==================================
|
||||
|
||||
### 1. Install Emscripten
|
||||
|
||||
Download and install [Emscripten portable SDK](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html)
|
||||
|
||||
### 2. Create build directory
|
||||
|
||||
Run the following commands:
|
||||
|
||||
`mkdir /path/to/build/dir`
|
||||
|
||||
`cd /path/to/build/dir`
|
||||
|
||||
### 3. Configure example
|
||||
|
||||
Run the following command:
|
||||
|
||||
`cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/emsdk-portable/emscripten/<version>/cmake/Modules/Platform/Emscripten.cmake /path/to/OpenSceneGraph/examples/osgemscripten`
|
||||
|
||||
This also configures OpenSceneGraph as a dependency
|
||||
|
||||
### 3. Build example
|
||||
|
||||
Run the following command:
|
||||
|
||||
`make`
|
||||
|
||||
This also builds OpenSceneGraph under `/path/to/OpenSceneGraph/build/Emscripten`
|
||||
if it has not yet been built.
|
||||
|
||||
### 4. Launch example
|
||||
|
||||
Firefox only: locate and open `osgemscripten.html` file.
|
||||
|
||||
All browsers:
|
||||
* go to the directory with `osgemscripten.html`
|
||||
* run `python -m SimpleHTTPServer 8080` from there
|
||||
* open `http://localhost:8080/osgemscripten.html` in any browser
|
||||
|
||||
You should now see red cube in your web browser.
|
||||
|
||||
857
examples/osgemscripten/box.osgt
Normal file
857
examples/osgemscripten/box.osgt
Normal file
@@ -0,0 +1,857 @@
|
||||
#Ascii Scene
|
||||
#Version 92
|
||||
#Generator osgexport 0.13.0
|
||||
|
||||
osg::Group {
|
||||
UniqueID 4
|
||||
Name "Root"
|
||||
Children 1 {
|
||||
osg::MatrixTransform {
|
||||
UniqueID 0
|
||||
Name "Cube"
|
||||
Children 1 {
|
||||
osg::Geode {
|
||||
UniqueID 3
|
||||
Name "GeodeCube.001"
|
||||
Drawables 1 {
|
||||
osg::Geometry {
|
||||
UniqueID 2
|
||||
Name "Cube"
|
||||
PrimitiveSetList 1 {
|
||||
DrawElementsUInt GL_TRIANGLES 576 {
|
||||
0 1 2
|
||||
3 4 5
|
||||
6 7 8
|
||||
9 10 11
|
||||
12 13 14
|
||||
15 16 17
|
||||
18 19 20
|
||||
21 22 23
|
||||
24 25 26
|
||||
27 28 29
|
||||
30 31 32
|
||||
33 34 35
|
||||
36 37 38
|
||||
39 40 41
|
||||
42 43 44
|
||||
45 46 47
|
||||
48 49 50
|
||||
51 52 53
|
||||
54 55 56
|
||||
57 58 59
|
||||
60 61 62
|
||||
63 64 65
|
||||
66 67 68
|
||||
69 70 71
|
||||
72 71 67
|
||||
73 72 66
|
||||
74 69 72
|
||||
75 76 68
|
||||
77 76 75
|
||||
78 66 76
|
||||
79 65 80
|
||||
68 79 81
|
||||
67 63 79
|
||||
82 83 58
|
||||
84 82 57
|
||||
85 86 87
|
||||
88 59 89
|
||||
90 88 91
|
||||
92 57 88
|
||||
93 56 94
|
||||
95 96 97
|
||||
98 99 96
|
||||
100 53 49
|
||||
101 102 103
|
||||
101 104 105
|
||||
106 107 108
|
||||
109 110 111
|
||||
112 103 113
|
||||
114 115 47
|
||||
116 117 118
|
||||
119 120 117
|
||||
121 44 40
|
||||
122 123 124
|
||||
125 126 123
|
||||
127 41 128
|
||||
129 130 131
|
||||
132 124 130
|
||||
133 38 134
|
||||
135 136 133
|
||||
137 36 133
|
||||
138 35 31
|
||||
139 138 30
|
||||
140 33 138
|
||||
141 32 142
|
||||
143 141 144
|
||||
145 30 141
|
||||
146 29 147
|
||||
32 146 148
|
||||
31 27 146
|
||||
149 26 22
|
||||
150 149 21
|
||||
151 24 149
|
||||
152 23 153
|
||||
154 152 155
|
||||
156 21 152
|
||||
157 20 158
|
||||
23 157 159
|
||||
22 18 157
|
||||
160 17 19
|
||||
26 160 18
|
||||
25 15 160
|
||||
12 161 28
|
||||
35 12 27
|
||||
34 13 12
|
||||
162 11 37
|
||||
163 162 36
|
||||
164 9 162
|
||||
165 8 46
|
||||
166 167 120
|
||||
168 169 167
|
||||
170 171 55
|
||||
172 173 99
|
||||
174 175 173
|
||||
176 2 64
|
||||
71 176 63
|
||||
71 70 0
|
||||
176 0 2
|
||||
177 178 179
|
||||
165 6 8
|
||||
162 9 11
|
||||
161 12 14
|
||||
160 15 17
|
||||
157 18 20
|
||||
152 21 23
|
||||
149 24 26
|
||||
146 27 29
|
||||
141 30 32
|
||||
138 33 35
|
||||
133 36 38
|
||||
127 39 41
|
||||
121 42 44
|
||||
115 45 47
|
||||
180 48 50
|
||||
100 51 53
|
||||
93 54 56
|
||||
88 57 59
|
||||
83 82 181
|
||||
79 63 65
|
||||
76 66 68
|
||||
72 69 71
|
||||
66 72 67
|
||||
78 73 66
|
||||
73 74 72
|
||||
182 75 68
|
||||
183 77 75
|
||||
77 78 76
|
||||
81 79 80
|
||||
182 68 81
|
||||
68 67 79
|
||||
57 82 58
|
||||
92 84 57
|
||||
184 85 87
|
||||
91 88 89
|
||||
185 90 91
|
||||
90 92 88
|
||||
186 93 94
|
||||
187 95 97
|
||||
95 98 96
|
||||
48 100 49
|
||||
112 101 103
|
||||
102 101 105
|
||||
188 189 190
|
||||
191 109 111
|
||||
192 112 113
|
||||
193 194 195
|
||||
196 116 118
|
||||
116 119 117
|
||||
39 121 40
|
||||
132 122 124
|
||||
122 125 123
|
||||
197 127 128
|
||||
198 129 131
|
||||
129 132 130
|
||||
199 133 134
|
||||
199 135 133
|
||||
136 137 133
|
||||
30 138 31
|
||||
145 139 30
|
||||
139 140 138
|
||||
144 141 142
|
||||
200 143 144
|
||||
143 145 141
|
||||
148 146 147
|
||||
142 32 148
|
||||
32 31 146
|
||||
21 149 22
|
||||
156 150 21
|
||||
150 151 149
|
||||
155 152 153
|
||||
201 154 155
|
||||
154 156 152
|
||||
159 157 158
|
||||
153 23 159
|
||||
23 22 157
|
||||
18 160 19
|
||||
22 26 18
|
||||
26 25 160
|
||||
27 12 28
|
||||
31 35 27
|
||||
35 34 12
|
||||
36 162 37
|
||||
137 163 36
|
||||
163 164 162
|
||||
45 165 46
|
||||
119 166 120
|
||||
166 168 167
|
||||
54 170 55
|
||||
98 172 99
|
||||
172 174 173
|
||||
63 176 64
|
||||
67 71 63
|
||||
176 71 0
|
||||
}
|
||||
}
|
||||
VertexData {
|
||||
Array TRUE ArrayID 0 Vec3fArray 202 {
|
||||
-1.00000 0.71786 -0.50000
|
||||
-1.00000 1.00000 -1.00000
|
||||
-1.00000 0.50000 -1.00000
|
||||
0.50000 0.71786 -0.50000
|
||||
1.00000 0.71786 -0.50000
|
||||
0.80513 0.86344 -1.00000
|
||||
1.00000 -1.00000 -0.50000
|
||||
1.00000 -1.00000 -1.00000
|
||||
1.00000 -0.50000 -1.00000
|
||||
-1.00000 -1.00000 -0.50000
|
||||
-1.00000 -1.00000 -1.00000
|
||||
-0.50000 -1.00000 -1.00000
|
||||
0.50000 0.50000 -1.00000
|
||||
0.50000 1.00000 -1.00000
|
||||
0.80513 0.86344 -1.00000
|
||||
-0.50000 1.00000 1.00000
|
||||
-1.00000 1.00000 1.00000
|
||||
-1.00000 0.50000 1.00000
|
||||
-0.50000 0.00000 1.00000
|
||||
-1.00000 0.00000 1.00000
|
||||
-1.00000 -0.50000 1.00000
|
||||
0.50000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 -0.50000 1.00000
|
||||
0.50000 1.00000 1.00000
|
||||
0.00000 1.00000 1.00000
|
||||
0.00000 0.50000 1.00000
|
||||
0.50000 0.00000 -1.00000
|
||||
1.00000 0.00000 -1.00000
|
||||
1.00000 -0.50000 -1.00000
|
||||
-0.50000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 -0.50000 -1.00000
|
||||
-0.50000 1.00000 -1.00000
|
||||
0.00000 1.00000 -1.00000
|
||||
0.00000 0.50000 -1.00000
|
||||
0.00000 -1.00000 -0.50000
|
||||
0.00000 -1.00000 -1.00000
|
||||
0.50000 -1.00000 -1.00000
|
||||
0.00000 -0.69802 0.50000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.50000 -1.00000 0.00000
|
||||
-1.00000 -0.69802 0.50000
|
||||
-1.00000 -1.00000 0.00000
|
||||
-0.50000 -1.00000 0.00000
|
||||
1.00000 0.00000 -0.50000
|
||||
1.00000 0.00000 -1.00000
|
||||
1.00000 0.50000 -1.00000
|
||||
1.00000 0.00000 0.50000
|
||||
0.74690 0.00000 0.00000
|
||||
0.74690 0.50000 0.00000
|
||||
1.00000 -0.69802 0.50000
|
||||
0.74690 -1.00000 0.00000
|
||||
0.74690 -0.50000 0.00000
|
||||
0.00000 0.71786 -0.50000
|
||||
0.00000 1.00000 -1.00000
|
||||
-0.50000 1.00000 -1.00000
|
||||
0.00000 1.00000 0.50000
|
||||
0.00000 1.00000 0.00000
|
||||
-0.50000 1.00000 0.00000
|
||||
0.50000 1.00000 0.50000
|
||||
0.80513 0.86344 0.50000
|
||||
0.74690 1.00000 0.00000
|
||||
-1.00000 0.00000 -0.50000
|
||||
-1.00000 0.00000 -1.00000
|
||||
-1.00000 -0.50000 -1.00000
|
||||
-1.00000 0.00000 0.50000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 -0.50000 0.00000
|
||||
-1.00000 1.00000 0.50000
|
||||
-1.00000 1.00000 0.00000
|
||||
-1.00000 0.50000 0.00000
|
||||
-1.00000 0.50000 0.50000
|
||||
-1.00000 0.50000 1.00000
|
||||
-1.00000 1.00000 1.00000
|
||||
-1.00000 -0.69802 0.50000
|
||||
-1.00000 -0.50000 0.50000
|
||||
-1.00000 -0.50000 1.00000
|
||||
-1.00000 0.00000 1.00000
|
||||
-1.00000 -0.50000 -0.50000
|
||||
-1.00000 -1.00000 -1.00000
|
||||
-1.00000 -1.00000 -0.50000
|
||||
0.50000 1.00000 0.50000
|
||||
0.50000 1.00000 0.00000
|
||||
0.50000 1.00000 1.00000
|
||||
0.80513 0.86344 1.00000
|
||||
0.80513 0.86344 0.50000
|
||||
0.50000 1.00000 0.50000
|
||||
-0.50000 1.00000 0.50000
|
||||
-1.00000 1.00000 0.00000
|
||||
-0.50000 1.00000 1.00000
|
||||
-1.00000 1.00000 0.50000
|
||||
0.00000 1.00000 1.00000
|
||||
-0.50000 0.71786 -0.50000
|
||||
-1.00000 1.00000 -1.00000
|
||||
-0.50000 1.00000 0.00000
|
||||
-0.50000 0.71786 -0.50000
|
||||
-1.00000 0.71786 -0.50000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 0.71786 -0.50000
|
||||
1.00000 -0.50000 0.50000
|
||||
1.00000 -0.50000 1.00000
|
||||
1.00000 -0.50000 0.50000
|
||||
1.00000 0.00000 0.50000
|
||||
1.00000 -1.00000 1.00000
|
||||
1.00000 -0.69802 0.50000
|
||||
0.80513 0.86344 0.50000
|
||||
1.00000 0.50000 0.50000
|
||||
0.74690 0.50000 0.00000
|
||||
1.00000 0.50000 1.00000
|
||||
1.00000 0.50000 0.50000
|
||||
0.80513 0.86344 0.50000
|
||||
1.00000 0.00000 1.00000
|
||||
1.00000 0.50000 0.50000
|
||||
1.00000 0.71786 -0.50000
|
||||
1.00000 0.50000 -0.50000
|
||||
0.74690 0.50000 0.00000
|
||||
1.00000 0.50000 -0.50000
|
||||
1.00000 0.71786 -0.50000
|
||||
0.74690 0.00000 0.00000
|
||||
1.00000 0.00000 -0.50000
|
||||
-0.50000 -0.69802 0.50000
|
||||
-0.50000 -1.00000 1.00000
|
||||
-0.50000 -0.69802 0.50000
|
||||
0.00000 -0.69802 0.50000
|
||||
-1.00000 -1.00000 1.00000
|
||||
-1.00000 -0.69802 0.50000
|
||||
0.50000 -0.69802 0.50000
|
||||
0.74690 -1.00000 0.00000
|
||||
0.50000 -1.00000 1.00000
|
||||
0.50000 -0.69802 0.50000
|
||||
1.00000 -0.69802 0.50000
|
||||
0.00000 -1.00000 1.00000
|
||||
0.50000 -1.00000 -0.50000
|
||||
1.00000 -1.00000 -1.00000
|
||||
0.74690 -1.00000 0.00000
|
||||
0.50000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
-0.50000 0.50000 -1.00000
|
||||
-1.00000 0.50000 -1.00000
|
||||
-1.00000 1.00000 -1.00000
|
||||
-0.50000 -0.50000 -1.00000
|
||||
0.00000 -1.00000 -1.00000
|
||||
-1.00000 -0.50000 -1.00000
|
||||
-0.50000 -1.00000 -1.00000
|
||||
-1.00000 0.00000 -1.00000
|
||||
0.50000 -0.50000 -1.00000
|
||||
1.00000 -1.00000 -1.00000
|
||||
0.50000 -1.00000 -1.00000
|
||||
0.50000 0.50000 1.00000
|
||||
1.00000 0.50000 1.00000
|
||||
0.80513 0.86344 1.00000
|
||||
0.50000 -0.50000 1.00000
|
||||
0.00000 -1.00000 1.00000
|
||||
1.00000 -0.50000 1.00000
|
||||
0.50000 -1.00000 1.00000
|
||||
1.00000 0.00000 1.00000
|
||||
-0.50000 -0.50000 1.00000
|
||||
-1.00000 -1.00000 1.00000
|
||||
-0.50000 -1.00000 1.00000
|
||||
-0.50000 0.50000 1.00000
|
||||
1.00000 0.50000 -1.00000
|
||||
-0.50000 -1.00000 -0.50000
|
||||
-0.50000 -1.00000 0.00000
|
||||
-1.00000 -1.00000 0.00000
|
||||
1.00000 -0.50000 -0.50000
|
||||
0.74690 -0.50000 0.00000
|
||||
1.00000 -0.50000 -0.50000
|
||||
0.74690 -1.00000 0.00000
|
||||
1.00000 -1.00000 -0.50000
|
||||
0.50000 0.71786 -0.50000
|
||||
0.50000 1.00000 -1.00000
|
||||
0.50000 1.00000 0.00000
|
||||
0.50000 0.71786 -0.50000
|
||||
0.74690 1.00000 0.00000
|
||||
1.00000 0.71786 -0.50000
|
||||
-1.00000 0.50000 -0.50000
|
||||
0.50000 1.00000 -1.00000
|
||||
0.50000 0.71786 -0.50000
|
||||
0.80513 0.86344 -1.00000
|
||||
1.00000 0.50000 0.50000
|
||||
0.74690 1.00000 0.00000
|
||||
-1.00000 -1.00000 0.00000
|
||||
-1.00000 -1.00000 1.00000
|
||||
0.50000 1.00000 1.00000
|
||||
-1.00000 1.00000 1.00000
|
||||
-1.00000 0.71786 -0.50000
|
||||
-1.00000 1.00000 0.00000
|
||||
0.74690 1.00000 0.00000
|
||||
0.80513 0.86344 0.50000
|
||||
0.74690 0.50000 0.00000
|
||||
0.80513 0.86344 1.00000
|
||||
1.00000 0.50000 1.00000
|
||||
0.80513 0.86344 -1.00000
|
||||
1.00000 0.71786 -0.50000
|
||||
1.00000 0.50000 -1.00000
|
||||
0.74690 1.00000 0.00000
|
||||
1.00000 -0.69802 0.50000
|
||||
1.00000 -1.00000 1.00000
|
||||
1.00000 -1.00000 -0.50000
|
||||
-1.00000 -1.00000 -1.00000
|
||||
1.00000 -1.00000 1.00000
|
||||
}
|
||||
Indices FALSE
|
||||
Binding BIND_PER_VERTEX
|
||||
Normalize 0
|
||||
}
|
||||
NormalData {
|
||||
Array TRUE ArrayID 1 Vec3fArray 202 {
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
0.00000 0.96013 0.27955
|
||||
0.00000 0.96013 0.27955
|
||||
0.00000 0.96013 0.27955
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
-0.00000 -0.00000 -1.00000
|
||||
-0.00000 -0.00000 -1.00000
|
||||
-0.00000 -0.00000 -1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -0.85599 0.51699
|
||||
0.00000 -0.85599 0.51699
|
||||
0.00000 -0.85599 0.51699
|
||||
0.00000 -0.85599 0.51699
|
||||
0.00000 -0.85599 0.51699
|
||||
0.00000 -0.85599 0.51699
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
0.89220 0.00000 -0.45164
|
||||
0.89220 0.00000 -0.45164
|
||||
0.89220 0.00000 -0.45164
|
||||
0.89220 0.00000 -0.45164
|
||||
0.89220 0.00000 -0.45164
|
||||
0.89220 0.00000 -0.45164
|
||||
-0.00000 0.87091 0.49144
|
||||
-0.00000 0.87091 0.49144
|
||||
-0.00000 0.87091 0.49144
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.40044 0.89473 0.19774
|
||||
0.40044 0.89473 0.19774
|
||||
0.40044 0.89473 0.19774
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.40851 0.91275 -0.00000
|
||||
0.40851 0.91275 -0.00000
|
||||
0.40851 0.91275 -0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
0.00000 1.00000 0.00000
|
||||
-0.00000 0.87091 0.49144
|
||||
-0.00000 0.87091 0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.89220 0.00000 -0.45164
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
0.80484 0.43155 -0.40742
|
||||
0.80484 0.43155 -0.40742
|
||||
0.80484 0.43155 -0.40742
|
||||
0.88130 0.47255 -0.00000
|
||||
0.88130 0.47255 -0.00000
|
||||
0.88130 0.47255 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
1.00000 0.00000 0.00000
|
||||
1.00000 0.00000 0.00000
|
||||
0.89220 0.00000 0.45164
|
||||
0.89220 0.00000 0.45164
|
||||
0.89220 0.00000 0.45164
|
||||
0.89220 0.00000 0.45164
|
||||
0.89220 0.00000 0.45164
|
||||
0.00000 -0.85599 0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
0.00000 -0.85599 0.51699
|
||||
0.00000 -0.85599 0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
-0.00000 -0.85599 -0.51699
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
-0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 1.00000
|
||||
0.00000 0.00000 -1.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
0.00000 -1.00000 0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
0.89220 0.00000 0.45164
|
||||
0.89220 0.00000 0.45164
|
||||
0.89220 0.00000 0.45164
|
||||
0.89220 0.00000 0.45164
|
||||
-0.00000 0.87091 0.49144
|
||||
-0.00000 0.87091 0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
-1.00000 0.00000 0.00000
|
||||
0.36317 0.81145 0.45789
|
||||
0.36317 0.81145 0.45789
|
||||
0.36317 0.81145 0.45789
|
||||
0.89220 0.00000 -0.45164
|
||||
0.00000 1.00000 0.00000
|
||||
-1.00000 -0.00000 0.00000
|
||||
-1.00000 0.00000 0.00000
|
||||
0.40851 0.91275 0.00000
|
||||
0.00000 1.00000 -0.00000
|
||||
0.00000 0.87091 0.49144
|
||||
0.00000 0.87091 -0.49144
|
||||
0.99329 0.00000 -0.11568
|
||||
0.99329 0.00000 -0.11568
|
||||
0.99329 0.00000 -0.11568
|
||||
0.88130 0.47255 0.00000
|
||||
1.00000 0.00000 -0.00000
|
||||
0.86320 0.46284 -0.20167
|
||||
0.86320 0.46284 -0.20167
|
||||
0.86320 0.46284 -0.20167
|
||||
0.89220 -0.00000 0.45164
|
||||
0.00000 -0.85599 0.51699
|
||||
0.00000 -0.85599 -0.51699
|
||||
0.00000 -1.00000 0.00000
|
||||
-0.00000 -0.00000 -1.00000
|
||||
-0.00000 0.00000 1.00000
|
||||
}
|
||||
Indices FALSE
|
||||
Binding BIND_PER_VERTEX
|
||||
Normalize 0
|
||||
}
|
||||
TexCoordData 1 {
|
||||
Data {
|
||||
Array TRUE ArrayID 2 Vec2fArray 202 {
|
||||
0.24987 0.57156
|
||||
0.33316 0.50121
|
||||
0.33316 0.62589
|
||||
0.58434 0.12457
|
||||
0.58427 0.00000
|
||||
0.66715 0.05008
|
||||
0.08352 0.50121
|
||||
0.00024 0.50121
|
||||
0.00016 0.37667
|
||||
0.74911 0.49874
|
||||
0.66715 0.49874
|
||||
0.66715 0.37405
|
||||
0.75013 0.62595
|
||||
0.66684 0.62595
|
||||
0.68959 0.54986
|
||||
0.66684 0.87532
|
||||
0.66684 1.00000
|
||||
0.58355 1.00000
|
||||
0.50026 0.87532
|
||||
0.50026 1.00000
|
||||
0.41697 1.00000
|
||||
0.50026 0.62595
|
||||
0.50026 0.75063
|
||||
0.41697 0.75063
|
||||
0.66684 0.62595
|
||||
0.66684 0.75063
|
||||
0.58355 0.75063
|
||||
0.83342 0.62595
|
||||
0.83342 0.50126
|
||||
0.91671 0.50126
|
||||
0.83342 0.87532
|
||||
0.83342 0.75063
|
||||
0.91671 0.75063
|
||||
0.66684 0.87532
|
||||
0.66684 0.75063
|
||||
0.75013 0.75063
|
||||
0.74911 0.24937
|
||||
0.66715 0.24937
|
||||
0.66715 0.12468
|
||||
0.92198 0.24937
|
||||
0.83107 0.24937
|
||||
0.83107 0.12468
|
||||
0.92198 0.49874
|
||||
0.83107 0.49874
|
||||
0.83107 0.37405
|
||||
0.08335 0.25213
|
||||
0.00008 0.25213
|
||||
0.00000 0.12759
|
||||
0.24990 0.25213
|
||||
0.16747 0.24908
|
||||
0.16739 0.12454
|
||||
0.25001 0.42599
|
||||
0.16763 0.49816
|
||||
0.16755 0.37362
|
||||
0.58440 0.24915
|
||||
0.66685 0.25211
|
||||
0.66691 0.37669
|
||||
0.41702 0.25211
|
||||
0.50030 0.25211
|
||||
0.50036 0.37669
|
||||
0.41696 0.12754
|
||||
0.41732 0.05008
|
||||
0.50021 0.06602
|
||||
0.24987 0.75058
|
||||
0.33316 0.75058
|
||||
0.33316 0.87526
|
||||
0.08329 0.75058
|
||||
0.16658 0.75058
|
||||
0.16658 0.87526
|
||||
0.08329 0.50121
|
||||
0.16658 0.50121
|
||||
0.16658 0.62589
|
||||
0.08329 0.62589
|
||||
0.00000 0.62589
|
||||
0.00000 0.50121
|
||||
0.08329 0.92464
|
||||
0.08329 0.87526
|
||||
0.00000 0.87526
|
||||
0.00000 0.75058
|
||||
0.24987 0.87526
|
||||
0.33316 0.99995
|
||||
0.24987 0.99995
|
||||
0.41696 0.12754
|
||||
0.50024 0.12754
|
||||
0.33368 0.12754
|
||||
0.33404 0.05008
|
||||
0.41732 0.05008
|
||||
0.41696 0.12754
|
||||
0.41708 0.37669
|
||||
0.50042 0.50126
|
||||
0.33381 0.37669
|
||||
0.41714 0.50126
|
||||
0.33375 0.25211
|
||||
0.58446 0.37372
|
||||
0.66698 0.50126
|
||||
0.50036 0.37669
|
||||
0.58446 0.37372
|
||||
0.58452 0.49830
|
||||
0.50030 0.25211
|
||||
0.58440 0.24915
|
||||
0.24998 0.37667
|
||||
0.33325 0.37667
|
||||
0.24998 0.37667
|
||||
0.24990 0.25213
|
||||
0.33333 0.50121
|
||||
0.25001 0.42599
|
||||
0.25041 0.03472
|
||||
0.24982 0.12759
|
||||
0.16739 0.12454
|
||||
0.33309 0.12759
|
||||
0.24982 0.12759
|
||||
0.25041 0.03472
|
||||
0.33317 0.25213
|
||||
0.24982 0.12759
|
||||
0.08324 0.07332
|
||||
0.08327 0.12759
|
||||
0.16739 0.12454
|
||||
0.08327 0.12759
|
||||
0.08324 0.07332
|
||||
0.16747 0.24908
|
||||
0.08335 0.25213
|
||||
0.92198 0.37405
|
||||
0.99498 0.37405
|
||||
0.92198 0.37405
|
||||
0.92198 0.24937
|
||||
0.99498 0.49874
|
||||
0.92198 0.49874
|
||||
0.92198 0.12468
|
||||
0.83107 0.06312
|
||||
0.99498 0.12468
|
||||
0.92198 0.12468
|
||||
0.92198 0.00000
|
||||
0.99498 0.24937
|
||||
0.74911 0.12468
|
||||
0.66715 0.00000
|
||||
0.83107 0.06312
|
||||
0.83107 0.12468
|
||||
0.83107 0.24937
|
||||
0.75013 0.87532
|
||||
0.75013 1.00000
|
||||
0.66684 1.00000
|
||||
0.91671 0.87532
|
||||
1.00000 0.75063
|
||||
0.91671 1.00000
|
||||
1.00000 0.87532
|
||||
0.83342 1.00000
|
||||
0.91671 0.62595
|
||||
1.00000 0.50126
|
||||
1.00000 0.62595
|
||||
0.58355 0.62595
|
||||
0.58355 0.50126
|
||||
0.64409 0.54986
|
||||
0.41697 0.62595
|
||||
0.33368 0.75063
|
||||
0.41697 0.50126
|
||||
0.33368 0.62595
|
||||
0.50026 0.50126
|
||||
0.41697 0.87532
|
||||
0.33368 1.00000
|
||||
0.33368 0.87532
|
||||
0.58355 0.87532
|
||||
0.75013 0.50126
|
||||
0.74911 0.37405
|
||||
0.83107 0.37405
|
||||
0.83107 0.49874
|
||||
0.08343 0.37667
|
||||
0.16755 0.37362
|
||||
0.08343 0.37667
|
||||
0.16763 0.49816
|
||||
0.08352 0.50121
|
||||
0.58434 0.12457
|
||||
0.66679 0.12754
|
||||
0.50024 0.12754
|
||||
0.58434 0.12457
|
||||
0.50021 0.06602
|
||||
0.58427 0.00000
|
||||
0.24987 0.62589
|
||||
0.66679 0.12754
|
||||
0.58434 0.12457
|
||||
0.66715 0.05008
|
||||
0.24982 0.12759
|
||||
0.50021 0.06602
|
||||
0.16658 0.99995
|
||||
0.00000 0.99995
|
||||
0.33368 0.12754
|
||||
0.33387 0.50126
|
||||
0.58452 0.49830
|
||||
0.50042 0.50126
|
||||
0.16731 0.00000
|
||||
0.25041 0.03472
|
||||
0.16739 0.12454
|
||||
0.33368 0.03472
|
||||
0.33309 0.12759
|
||||
0.00059 0.03472
|
||||
0.08324 0.07332
|
||||
0.00000 0.12759
|
||||
0.16731 0.00000
|
||||
0.92198 0.00000
|
||||
0.99498 0.00000
|
||||
0.74911 0.00000
|
||||
1.00000 1.00000
|
||||
0.33368 0.50126
|
||||
}
|
||||
Indices FALSE
|
||||
Binding BIND_PER_VERTEX
|
||||
Normalize 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Matrix {
|
||||
1.00000 0.00000 0.00000 0.00000
|
||||
0.00000 1.00000 0.00000 0.00000
|
||||
0.00000 0.00000 1.00000 0.00000
|
||||
0.00000 0.00000 0.00000 1.00000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
examples/osgemscripten/functions.h
Normal file
76
examples/osgemscripten/functions.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* OpenSceneGraph example, osgemscripten.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef OSGEMSCRIPTEN_FUNCTIONS_H
|
||||
#define OSGEMSCRIPTEN_FUNCTIONS_H
|
||||
|
||||
#include <osg/Notify>
|
||||
|
||||
// Convert NotifySeverity enum value to string.
|
||||
std::string logLevelToString(osg::NotifySeverity severity)
|
||||
{
|
||||
switch (severity)
|
||||
{
|
||||
case osg::DEBUG_FP:
|
||||
// Verbose.
|
||||
return "V";
|
||||
case osg::DEBUG_INFO:
|
||||
// Debug.
|
||||
return "D";
|
||||
case osg::NOTICE:
|
||||
case osg::INFO:
|
||||
// Info.
|
||||
return "I";
|
||||
case osg::WARN:
|
||||
// Warning.
|
||||
return "W";
|
||||
case osg::FATAL:
|
||||
case osg::ALWAYS:
|
||||
// Error.
|
||||
return "E";
|
||||
}
|
||||
}
|
||||
|
||||
#include <osg/Program>
|
||||
|
||||
// Fragment shader to display everything in red colour.
|
||||
static const char shaderFragment[] =
|
||||
"void main() { \n"
|
||||
" gl_FragColor = vec4(0.5, 0.3, 0.3, 1.0);\n"
|
||||
"} \n";
|
||||
// Geometry shader to pass geometry vertices to fragment shader.
|
||||
static const char shaderVertex[] =
|
||||
"void main() { \n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
|
||||
"} \n";
|
||||
|
||||
osg::Program *createShaderProgram(
|
||||
const std::string &vertexShader,
|
||||
const std::string &fragmentShader)
|
||||
{
|
||||
// Load shaders.
|
||||
osg::Shader *vs = new osg::Shader(osg::Shader::VERTEX, vertexShader);
|
||||
osg::Shader *fs = new osg::Shader(osg::Shader::FRAGMENT, fragmentShader);
|
||||
// Compile shaders and compose shader program.
|
||||
osg::Program *prog = new osg::Program;
|
||||
prog->addShader(vs);
|
||||
prog->addShader(fs);
|
||||
return prog;
|
||||
}
|
||||
|
||||
#endif // OSGEMSCRIPTEN_FUNCTIONS_H
|
||||
84
examples/osgemscripten/osgemscripten.cpp
Normal file
84
examples/osgemscripten/osgemscripten.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/* OpenSceneGraph example, emscripten.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <emscripten.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include "osgemscripten.h"
|
||||
|
||||
// We use app global variable in loop() function.
|
||||
Application *app = 0;
|
||||
|
||||
// Stand alone function that is called by Emscripten to run the app.
|
||||
void loop()
|
||||
{
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e))
|
||||
{
|
||||
if (app)
|
||||
{
|
||||
app->handleEvent(e);
|
||||
}
|
||||
}
|
||||
if (app)
|
||||
{
|
||||
app->frame();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Make sure SDL is working.
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
printf("OSGWeb. Could not init SDL: '%s'\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
// Clean SDL up at exit.
|
||||
atexit(SDL_Quit);
|
||||
// Configure rendering context.
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
// Create rendering window.
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
SDL_Window* window =
|
||||
SDL_CreateWindow(
|
||||
"OSGWeb",
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
width,
|
||||
height,
|
||||
SDL_WINDOW_OPENGL);
|
||||
if (!window)
|
||||
{
|
||||
printf("OSGWeb. Could not create window: '%s'\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
SDL_GL_CreateContext(window);
|
||||
// Create application.
|
||||
app = new Application;
|
||||
app->setupWindow(width, height);
|
||||
app->loadScene("box.osgt");
|
||||
// Render asynchronously.
|
||||
emscripten_set_main_loop(loop, -1, 0);
|
||||
return 0;
|
||||
}
|
||||
180
examples/osgemscripten/osgemscripten.h
Normal file
180
examples/osgemscripten/osgemscripten.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/* OpenSceneGraph example, osgemscripten.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef OSGEMSCRIPTEN_OSGEMSCRIPTEN_H
|
||||
#define OSGEMSCRIPTEN_OSGEMSCRIPTEN_H
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
|
||||
// VBO setup visitor.
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/NodeVisitor>
|
||||
|
||||
// Initialize OSG plugins statically.
|
||||
USE_OSGPLUGIN(osg2)
|
||||
USE_SERIALIZER_WRAPPER_LIBRARY(osg)
|
||||
|
||||
// This class prints OpenSceneGraph notifications to console.
|
||||
class Logger : public osg::NotifyHandler
|
||||
{
|
||||
public:
|
||||
Logger() { }
|
||||
virtual ~Logger() { }
|
||||
|
||||
// Override NotifyHandler::notify() to receive OpenSceneGraph notifications.
|
||||
void notify(osg::NotifySeverity severity, const char *message)
|
||||
{
|
||||
printf("OSG/%s %s", logLevelToString(severity).c_str(), message);
|
||||
}
|
||||
};
|
||||
|
||||
// This class forces the use of VBO.
|
||||
class VBOSetupVisitor : public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
VBOSetupVisitor() :
|
||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { }
|
||||
virtual void apply(osg::Geode &geode)
|
||||
{
|
||||
for (unsigned int i = 0; i < geode.getNumDrawables(); ++i)
|
||||
{
|
||||
osg::Geometry *geom =
|
||||
dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
|
||||
if (geom)
|
||||
{
|
||||
geom->setUseVertexBufferObjects(true);
|
||||
}
|
||||
}
|
||||
NodeVisitor::apply(geode);
|
||||
}
|
||||
};
|
||||
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
Application()
|
||||
{
|
||||
setupLogging();
|
||||
setupRendering();
|
||||
}
|
||||
~Application()
|
||||
{
|
||||
tearDownLogging();
|
||||
tearDownRendering();
|
||||
}
|
||||
|
||||
bool handleEvent(SDL_Event &e)
|
||||
{
|
||||
osgViewer::GraphicsWindow *gw =
|
||||
dynamic_cast<osgViewer::GraphicsWindow *>(
|
||||
mViewer->getCamera()->getGraphicsContext());
|
||||
if (!gw)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
osgGA::EventQueue &queue = *(gw->getEventQueue());
|
||||
switch (e.type)
|
||||
{
|
||||
case SDL_MOUSEMOTION:
|
||||
queue.mouseMotion(e.motion.x, e.motion.y);
|
||||
return true;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
queue.mouseButtonPress(e.button.x, e.button.y, e.button.button);
|
||||
printf("OSGWeb. Application. Mouse button down\n");
|
||||
return true;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
queue.mouseButtonRelease(e.button.x, e.button.y, e.button.button);
|
||||
printf("OSGWeb. Application. Mouse button up\n");
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void loadScene(const std::string &fileName)
|
||||
{
|
||||
// Load scene.
|
||||
osg::Node *scene = osgDB::readNodeFile(fileName);
|
||||
if (!scene)
|
||||
{
|
||||
printf("Could not load scene\n");
|
||||
return;
|
||||
}
|
||||
// Use VBO and EBO instead of display lists. CRITICAL for Emscripten
|
||||
// to skip FULL_ES2 emulation flag.
|
||||
VBOSetupVisitor vbo;
|
||||
scene->accept(vbo);
|
||||
// Load shaders.
|
||||
osg::Program *prog = createShaderProgram(shaderVertex, shaderFragment);
|
||||
// Apply shaders.
|
||||
scene->getOrCreateStateSet()->setAttribute(prog);
|
||||
// Set scene.
|
||||
mViewer->setSceneData(scene);
|
||||
}
|
||||
void setupWindow(int width, int height)
|
||||
{
|
||||
mViewer->setUpViewerAsEmbeddedInWindow(0, 0, width, height);
|
||||
}
|
||||
void frame()
|
||||
{
|
||||
mViewer->frame();
|
||||
}
|
||||
|
||||
private:
|
||||
void setupLogging()
|
||||
{
|
||||
// Create custom logger.
|
||||
mLogger = new Logger;
|
||||
// Provide the logger to OpenSceneGraph.
|
||||
osg::setNotifyHandler(mLogger);
|
||||
// Only accept notifications of Info level or higher
|
||||
// like warnings and errors.
|
||||
osg::setNotifyLevel(osg::INFO);
|
||||
}
|
||||
void setupRendering()
|
||||
{
|
||||
// Create OpenSceneGraph viewer.
|
||||
mViewer = new osgViewer::Viewer;
|
||||
// Use single thread: CRITICAL for Emscripten.
|
||||
mViewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
|
||||
// Create manipulator: CRITICAL for Emscripten.
|
||||
mViewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
}
|
||||
void tearDownLogging()
|
||||
{
|
||||
// Remove the logger from OpenSceneGraph.
|
||||
// This also destroys the logger: no need to deallocate it manually.
|
||||
osg::setNotifyHandler(0);
|
||||
}
|
||||
void tearDownRendering()
|
||||
{
|
||||
delete mViewer;
|
||||
}
|
||||
|
||||
private:
|
||||
Logger *mLogger;
|
||||
osgViewer::Viewer *mViewer;
|
||||
};
|
||||
|
||||
#endif // OSGEMSCRIPTEN_OSGEMSCRIPTEN_H
|
||||
@@ -36,17 +36,13 @@
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
#include <osg/BufferTemplate>
|
||||
#include <osg/PrimitiveSetIndirect>
|
||||
#include "ShapeToGeometry.h"
|
||||
#include "AggregateGeometryVisitor.h"
|
||||
#if 0
|
||||
#include "DrawIndirectPrimitiveSet.h"
|
||||
#else
|
||||
#include <osg/PrimitiveSetIndirect>
|
||||
#endif
|
||||
#include "GpuCullShaders.h"
|
||||
|
||||
|
||||
|
||||
// each instance type may have max 8 LODs ( if you change
|
||||
// this value, don't forget to change it in vertex shaders accordingly )
|
||||
const unsigned int OSGGPUCULL_MAXIMUM_LOD_NUMBER = 8;
|
||||
@@ -180,17 +176,20 @@ struct IndirectTarget
|
||||
IndirectTarget()
|
||||
: maxTargetQuantity(0)
|
||||
{
|
||||
indirectCommands = new osg::DefaultIndirectCommandDrawArrays;
|
||||
indirectCommands->getBufferObject()->setUsage(GL_DYNAMIC_DRAW);
|
||||
indirectCommands = new osg::DrawArraysIndirectCommandArray ;
|
||||
}
|
||||
IndirectTarget( AggregateGeometryVisitor* agv, osg::Program* program )
|
||||
: geometryAggregator(agv), drawProgram(program), maxTargetQuantity(0)
|
||||
{
|
||||
indirectCommands = new osg::DefaultIndirectCommandDrawArrays;
|
||||
indirectCommands->getBufferObject()->setUsage(GL_DYNAMIC_DRAW);
|
||||
indirectCommands = new osg::DrawArraysIndirectCommandArray;
|
||||
}
|
||||
void endRegister(unsigned int index, unsigned int rowsPerInstance, GLenum pixelFormat, GLenum type, GLint internalFormat, bool useMultiDrawArraysIndirect )
|
||||
{
|
||||
|
||||
osg::DrawIndirectBufferObject * indirectCommandbuffer=new osg::DrawIndirectBufferObject();
|
||||
indirectCommandbuffer->setUsage(GL_DYNAMIC_DRAW);
|
||||
indirectCommands->setBufferObject(indirectCommandbuffer);
|
||||
|
||||
indirectCommandTextureBuffer = new osg::TextureBuffer(indirectCommands);
|
||||
indirectCommandTextureBuffer->setInternalFormat( GL_R32I );
|
||||
indirectCommandTextureBuffer->bindToImageUnit(index, osg::Texture::READ_WRITE);
|
||||
@@ -200,27 +199,28 @@ struct IndirectTarget
|
||||
// add proper primitivesets to geometryAggregators
|
||||
if( !useMultiDrawArraysIndirect ) // use glDrawArraysIndirect()
|
||||
{
|
||||
std::vector<osg::DrawArraysIndirect*> newPrimitiveSets;
|
||||
std::vector<DrawArraysIndirect*> newPrimitiveSets;
|
||||
|
||||
for(unsigned int j=0;j<indirectCommands->size(); ++j){
|
||||
osg::DrawArraysIndirect *ipr=new osg::DrawArraysIndirect( GL_TRIANGLES, j );
|
||||
ipr->setIndirectCommandArray( indirectCommands);
|
||||
newPrimitiveSets.push_back(ipr);
|
||||
}
|
||||
for(unsigned int j=0;j<indirectCommands->size(); ++j)
|
||||
newPrimitiveSets.push_back( new DrawArraysIndirect( GL_TRIANGLES, j*sizeof( osg::DrawArraysIndirectCommand ), indirectCommands ) );
|
||||
|
||||
geometryAggregator->getAggregatedGeometry()->removePrimitiveSet(0,geometryAggregator->getAggregatedGeometry()->getNumPrimitiveSets() );
|
||||
|
||||
for(unsigned int j=0;j<indirectCommands->size(); ++j)
|
||||
geometryAggregator->getAggregatedGeometry()->addPrimitiveSet( newPrimitiveSets[j] );
|
||||
|
||||
|
||||
/*DrawIndirectBufferBinding should be deprecated
|
||||
///attach a DrawIndirect buffer binding to the stateset for non builtin primset DrawArraysIndirect
|
||||
osg::ref_ptr<osg::DrawIndirectBufferBinding> bb=new osg::DrawIndirectBufferBinding();
|
||||
bb->setBufferObject(indirectCommandbuffer );
|
||||
geometryAggregator->getAggregatedGeometry()->getOrCreateStateSet()->setAttribute(bb );*/
|
||||
}
|
||||
else // use glMultiDrawArraysIndirect()
|
||||
{
|
||||
osg::MultiDrawArraysIndirect *ipr=new osg::MultiDrawArraysIndirect( GL_TRIANGLES );
|
||||
ipr->setIndirectCommandArray( indirectCommands );
|
||||
osg::MultiDrawArraysIndirect * mdi=new osg::MultiDrawArraysIndirect(GL_TRIANGLES);
|
||||
mdi->setIndirectCommandArray(indirectCommands);
|
||||
geometryAggregator->getAggregatedGeometry()->removePrimitiveSet(0,geometryAggregator->getAggregatedGeometry()->getNumPrimitiveSets() );
|
||||
geometryAggregator->getAggregatedGeometry()->addPrimitiveSet( ipr );
|
||||
geometryAggregator->getAggregatedGeometry()->addPrimitiveSet(mdi );
|
||||
|
||||
}
|
||||
|
||||
geometryAggregator->getAggregatedGeometry()->setUseDisplayList(false);
|
||||
@@ -266,7 +266,7 @@ struct IndirectTarget
|
||||
stateset->setAttributeAndModes( drawProgram.get(), osg::StateAttribute::ON );
|
||||
}
|
||||
|
||||
osg::ref_ptr< osg::DefaultIndirectCommandDrawArrays > indirectCommands;
|
||||
osg::ref_ptr< osg::DrawArraysIndirectCommandArray > indirectCommands;
|
||||
osg::ref_ptr<osg::TextureBuffer> indirectCommandTextureBuffer;
|
||||
osg::ref_ptr< AggregateGeometryVisitor > geometryAggregator;
|
||||
osg::ref_ptr<osg::Program> drawProgram;
|
||||
@@ -286,7 +286,7 @@ struct GPUCullData
|
||||
instanceTypesUBO = new osg::UniformBufferObject;
|
||||
// instanceTypesUBO->setUsage( GL_STREAM_DRAW );
|
||||
instanceTypes->setBufferObject( instanceTypesUBO.get() );
|
||||
instanceTypesUBB = new osg::UniformBufferBinding(1, instanceTypesUBO.get(), 0, 0);
|
||||
instanceTypesUBB = new osg::UniformBufferBinding(1, instanceTypes.get(), 0, 0);
|
||||
|
||||
}
|
||||
void setUseMultiDrawArraysIndirect( bool value )
|
||||
@@ -316,7 +316,7 @@ struct GPUCullData
|
||||
// AggregateGeometryVisitor creates single osg::Geometry from all objects used by specific indirect target
|
||||
AggregateGeometryVisitor::AddObjectResult aoResult = target->second.geometryAggregator->addObject( node , typeID, lodNumber );
|
||||
// Information about first vertex and a number of vertices is stored for later primitiveset creation
|
||||
target->second.indirectCommands->push_back( osg::DrawArraysIndirectCommand( aoResult.count,1, aoResult.first ) );
|
||||
target->second.indirectCommands->push_back( osg::DrawArraysIndirectCommand( aoResult.count,1,aoResult.first ) );
|
||||
|
||||
osg::ComputeBoundsVisitor cbv;
|
||||
node->accept(cbv);
|
||||
@@ -725,9 +725,9 @@ struct ResetTexturesCallback : public osg::StateSet::Callback
|
||||
osg::TextureBuffer* tex = dynamic_cast<osg::TextureBuffer*>( stateset->getTextureAttribute(*it,osg::StateAttribute::TEXTURE) );
|
||||
if(tex==NULL)
|
||||
continue;
|
||||
osg::BufferData* img =const_cast<osg::BufferData*>(tex->getBufferData());
|
||||
if(img!=NULL)
|
||||
img->dirty();
|
||||
osg::BufferData* drawcmds = tex->getBufferData();
|
||||
if(drawcmds!=NULL)
|
||||
drawcmds->dirty();
|
||||
}
|
||||
for(it=texUnitsDirtyParams.begin(), eit=texUnitsDirtyParams.end(); it!=eit; ++it)
|
||||
{
|
||||
|
||||
@@ -124,7 +124,7 @@ int main( int argc, char **argv )
|
||||
impostor->setRange(0,0.0f,1e7f);
|
||||
impostor->setCenter(bs.center());
|
||||
|
||||
// impostor specfic settings.
|
||||
// impostor specific settings.
|
||||
impostor->setImpostorThresholdToBound(5.0f);
|
||||
|
||||
model = impostor;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
|
||||
{
|
||||
if (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP)
|
||||
{
|
||||
@@ -238,10 +238,22 @@ int main(int argc, char** argv)
|
||||
geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3(0.0f,characterSize*thickness,0.0f),osg::Vec3(characterSize,0.0,0.0),osg::Vec3(0.0f,0.0,characterSize), 0.0, 0.0, 1.0, 1.0) );
|
||||
}
|
||||
|
||||
if (arguments.read("--add-axes"))
|
||||
group->addChild(osgDB::readNodeFile("axes.osgt"));
|
||||
|
||||
std::string mode;
|
||||
if (arguments.read("--character-size-mode", mode))
|
||||
{
|
||||
if (mode == "screen_coords")
|
||||
{
|
||||
text3D->setCharacterSizeMode(osgText::TextBase::SCREEN_COORDS);
|
||||
text3D->setCharacterSize(1080/4);
|
||||
}
|
||||
}
|
||||
|
||||
viewer.addEventHandler(new Text3DAttributeHandler(text3D));
|
||||
}
|
||||
|
||||
|
||||
viewer.setSceneData(group);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -613,7 +613,7 @@ public:
|
||||
// to be deleted and re-recreated.
|
||||
//
|
||||
// The load/subload happens during the draw traversal so doesn't happen on
|
||||
// the setImage which just updates internal pointers and modifed flags.
|
||||
// the setImage which just updates internal pointers and modified flags.
|
||||
|
||||
_texture->setImage(_imageList[_currPos].get());
|
||||
|
||||
|
||||
@@ -104,9 +104,7 @@ public:
|
||||
void operator() (StateAttribute* attr, NodeVisitor* nv)
|
||||
{
|
||||
UniformBufferBinding* ubb = static_cast<UniformBufferBinding*>(attr);
|
||||
UniformBufferObject* ubo
|
||||
= static_cast<UniformBufferObject*>(ubb->getBufferObject());
|
||||
FloatArray* array = static_cast<FloatArray*>(ubo->getBufferData(0));
|
||||
FloatArray* array = static_cast<FloatArray*>(ubb->getBufferData());
|
||||
double time = nv->getFrameStamp()->getSimulationTime();
|
||||
double frac = fmod(time, 1.0);
|
||||
Vec4f warmColor = (Vec4f(0.0, 0.0, 1.0 ,1) * frac
|
||||
@@ -165,7 +163,7 @@ int main(int argc, char** argv)
|
||||
group1->addChild(loadedModel.get());
|
||||
scene->addChild(group1);
|
||||
ref_ptr<UniformBufferBinding> ubb1
|
||||
= new UniformBufferBinding(0, ubo.get(), 0, blockSize);
|
||||
= new UniformBufferBinding(0, colorArray.get(), 0, blockSize);
|
||||
ss1->setAttributeAndModes(ubb1.get(), StateAttribute::ON);
|
||||
|
||||
ref_ptr<FloatArray> colorArray2
|
||||
@@ -180,7 +178,7 @@ int main(int argc, char** argv)
|
||||
group2->addChild(loadedModel.get());
|
||||
scene->addChild(group2);
|
||||
ref_ptr<UniformBufferBinding> ubb2
|
||||
= new UniformBufferBinding(0, ubo2.get(), 0, blockSize);
|
||||
= new UniformBufferBinding(0, colorArray2.get(), 0, blockSize);
|
||||
ss2->setAttributeAndModes(ubb2.get(), StateAttribute::ON);
|
||||
|
||||
ref_ptr<FloatArray> colorArray3
|
||||
@@ -195,7 +193,7 @@ int main(int argc, char** argv)
|
||||
group3->addChild(loadedModel.get());
|
||||
scene->addChild(group3);
|
||||
ref_ptr<UniformBufferBinding> ubb3
|
||||
= new UniformBufferBinding(0, ubo3.get(), 0, blockSize);
|
||||
= new UniformBufferBinding(0, colorArray3.get(), 0, blockSize);
|
||||
ubb3->setUpdateCallback(new UniformBufferCallback);
|
||||
ubb3->setDataVariance(Object::DYNAMIC);
|
||||
ss3->setAttributeAndModes(ubb3.get(), StateAttribute::ON);
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
* This class packs a lot of functionality that you might not expect from a "Viewer".
|
||||
* The reason is that Mac users have high expectations of their applications, so things
|
||||
* that might not even be considered on other platforms (like drag-and-drop), are almost
|
||||
* a requirment on Mac OS X.
|
||||
* a requirement on Mac OS X.
|
||||
* The good news is that this class can almost be used as a template for other purposes.
|
||||
* If you are looking for the bare minimum code needed, focus your attention on
|
||||
* the init* routines and drawRect.
|
||||
@@ -782,7 +782,7 @@ A -respondsToSelector: check has been used to provide compatibility with previou
|
||||
}
|
||||
|
||||
// This is a job for Mighty Mouse!
|
||||
// For the most fluid experience turn on 360 degree mode availble in 10.4.8+.
|
||||
// For the most fluid experience turn on 360 degree mode available in 10.4.8+.
|
||||
// With your Mighty Mouse plugged in,
|
||||
// open 'Keyboard & Mouse' in 'System Preferences'.
|
||||
// Select the 'Mouse' tab.
|
||||
@@ -796,7 +796,7 @@ A -respondsToSelector: check has been used to provide compatibility with previou
|
||||
// This this call does nothing.
|
||||
// theViewer->getEventQueue()->mouseScroll2D([the_event deltaX], [the_event deltaY]);
|
||||
|
||||
// With the absense of a useful mouseScroll2D API, we can manually simulate the desired effect.
|
||||
// With the absence of a useful mouseScroll2D API, we can manually simulate the desired effect.
|
||||
NSPoint the_point = [the_event locationInWindow];
|
||||
NSPoint converted_point = [self convertPoint:the_point fromView:nil];
|
||||
theViewer->getEventQueue()->mouseButtonPress(converted_point.x, converted_point.y, 1);
|
||||
|
||||
Reference in New Issue
Block a user