Skip to content

Commit

Permalink
Improved Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm4 committed Dec 12, 2023
1 parent 85e20d8 commit 9a36b27
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 292 deletions.
4 changes: 2 additions & 2 deletions apps/app_demo_slproject/source/AppDemoGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3705,10 +3705,10 @@ void AppDemoGui::buildProperties(SLScene* s, SLSceneView* sv)

if (SLGLState::instance()->glHasGeometryShaders())
{
bool drawInstanced = ps->drawInstanced();
bool drawInstanced = ps->doInstancedDrawing();
if (ImGui::Checkbox("Instanced draw", &drawInstanced))
{
ps->drawInstanced(drawInstanced);
ps->doInstancedDrawing(drawInstanced);
ps->isGenerated(false);
}
}
Expand Down
23 changes: 23 additions & 0 deletions docs/pages/ExampleParticles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
\page example-particles Particle Systems
The SLParticleSystem is the most complex derivative of the SLMesh class and allows the creation of highly
configurable particle systems (PS). All its parameters can be modified in the _Properties_ tab (see menu Info > Properties).
The implementation uses for rendering geometry shaders on systems that have OpenGL >= 4.1 or OpenGLES >= 3.2. All other
systems (mainly iOS and Emscripten with WebGL) use instanced rendering. The consecutive motion update is done with OpenGL
feedback buffers. For the torch fires in the following example scene we use one PS for the glow effect and one
for the flames. The center fire uses one PS for the glow, one for the flames, one for the sparks, one for the black,
and one for the white smoke.

\htmlonly
<iframe src="https://pallas.ti.bfh.ch/slproject?scene=77" width="100%" height="640" tabindex="0" style="border: 1px solid gray"></iframe>
\endhtmlonly

General help:
<ul>
<li>Click and drag the left mouse button to rotate the scene.</li>
<li>Click and drag the middle mouse button to move sidewards/up-down.</li>
<li>Roll the mouse-wheel to move forward/backward.</li>
<li>Double click with the left mouse button to select an object.</li>
<li>Click the right mouse button to open the context menu.</li>
<li>Open and dock additional windows from the menu <em>Infos</em>.</li>
<li>See more example scenes over the menu <em>File > Load Test Scene</em></li>
</ul>
3 changes: 2 additions & 1 deletion docs/pages/ExampleScenes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ See also \ref emscripten for more background information.
- \subpage example-node-animations
- \subpage example-skinned-animations
- \subpage example-raytracing
- \subpage example-pathtracing
- \subpage example-pathtracing
- \subpage example-particles
37 changes: 19 additions & 18 deletions modules/sl/source/gl/SLGLState.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ class SLGLState
SLbool glIsES3() const { return _glIsES3; }
SLint glMaxTexUnits() const { return _glMaxTexUnits; }
SLint glMaxTexSize() const { return _glMaxTexSize; }
SLbool glHasGeometryShaders() const { return (_glIsES3 && _glVersionNOf > 3.1f) || (!glIsES() && _glVersionNOf >= 4.1f); }
SLbool glHasGeometryShaders() const { return (_glIsES3 && _glVersionNOf >= 3.2f) ||
(!glIsES() && _glVersionNOf >= 4.1f); }
SLbool hasExtension(const SLstring& e) { return _glExtensions.find(e) != string::npos; }
SLVec4i viewport() { return _viewport; }
SLMat4f viewportMatrix()
Expand All @@ -157,25 +158,25 @@ class SLGLState
SLstring getSLVersionNO();

private:
SLGLState(); //!< private onetime constructor
~SLGLState(); //!< destruction in ~SLScene
SLGLState(); //!< private onetime constructor
~SLGLState(); //!< destruction in ~SLScene

static SLGLState* _instance; //!< global singleton object

SLbool _isInitialized; //!< flag for first init

SLstring _glVersion; //!< OpenGL Version string
SLstring _glVersionNO; //!< OpenGL Version number string
SLfloat _glVersionNOf; //!< OpenGL Version number as float
SLstring _glVendor; //!< OpenGL Vendor string
SLstring _glRenderer; //!< OpenGL Renderer string
SLstring _glSLVersion; //!< GLSL Version string
SLstring _glSLVersionNO; //!< GLSL Version number string
SLstring _glExtensions; //!< OpenGL extensions string
SLbool _glIsES2; //!< Flag if OpenGL ES2
SLbool _glIsES3; //!< Flag if OpenGL ES3
SLint _glMaxTexUnits; //!< glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_glMaxTexUnits);
SLint _glMaxTexSize; //!< glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_glMaxTexSize);
SLbool _isInitialized; //!< flag for first init

SLstring _glVersion; //!< OpenGL Version string
SLstring _glVersionNO; //!< OpenGL Version number string
SLfloat _glVersionNOf; //!< OpenGL Version number as float
SLstring _glVendor; //!< OpenGL Vendor string
SLstring _glRenderer; //!< OpenGL Renderer string
SLstring _glSLVersion; //!< GLSL Version string
SLstring _glSLVersionNO; //!< GLSL Version number string
SLstring _glExtensions; //!< OpenGL extensions string
SLbool _glIsES2; //!< Flag if OpenGL ES2
SLbool _glIsES3; //!< Flag if OpenGL ES3
SLint _glMaxTexUnits; //!< glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_glMaxTexUnits);
SLint _glMaxTexSize; //!< glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_glMaxTexSize);

// read/write states
SLbool _blend; //!< blending default false;
Expand Down Expand Up @@ -204,7 +205,7 @@ class SLGLState
GLboolean _colorMaskB; //!< current color mask for B
GLboolean _colorMaskA; //!< current color mask for A

SLVstring errors; //!< vector for errors collected in getGLError
SLVstring errors; //!< vector for errors collected in getGLError

SLMaterial* _currentMaterial;
};
Expand Down
34 changes: 18 additions & 16 deletions modules/sl/source/gl/SLGLVertexArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SLGLVertexArray::SLGLVertexArray()
_numVertices = 0;
_indexDataElements = nullptr;
_indexDataEdges = nullptr;
_externalVbo = nullptr;
_instanceVbo = nullptr;
}
//-----------------------------------------------------------------------------
/*! Deletes the OpenGL objects for the vertex array and the vertex buffer.
Expand Down Expand Up @@ -89,10 +89,15 @@ void SLGLVertexArray::setAttrib(SLGLAttributeType type,
_vbo.attribs().push_back(va);
}
//-----------------------------------------------------------------------------
void SLGLVertexArray::setExternalVBO(SLGLVertexBuffer* vbo, SLuint divisor)
/*! Assignment of the additional VBO for instanced drawing. The passed vbo
* contains the positions for the instanced drawing done in
* drawElementsInstanced. This used e.g. for SLParticleSystems on systems
* without geometry shaders.
*/
void SLGLVertexArray::setInstanceVBO(SLGLVertexBuffer* vbo, SLuint divisor)
{
_externalVbo = vbo;
_externalDivisor = divisor;
_instanceVbo = vbo;
_instanceDivisor = divisor;
}
//-----------------------------------------------------------------------------
/*! Defines the vertex indices for the element drawing. Without indices vertex
Expand Down Expand Up @@ -208,9 +213,9 @@ void SLGLVertexArray::generate(SLuint numVertices,
_vbo.bindAndEnableAttrib(divisor);
}

if (_externalVbo != nullptr)
if (_instanceVbo != nullptr)
{
_externalVbo->bindAndEnableAttrib(_externalDivisor);
_instanceVbo->bindAndEnableAttrib(_instanceDivisor);
}

/////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -289,9 +294,9 @@ void SLGLVertexArray::generateTF(SLuint numVertices,
}

// ???
if (_externalVbo != nullptr)
if (_instanceVbo != nullptr)
{
_externalVbo->bindAndEnableAttrib(_externalDivisor);
_instanceVbo->bindAndEnableAttrib(_instanceDivisor);
}

///////////////////////////////
Expand Down Expand Up @@ -472,15 +477,12 @@ void SLGLVertexArray::drawArrayAs(SLGLPrimitiveType primitiveType,
GET_GL_ERROR;
}
//-----------------------------------------------------------------------------
/*! ???
*
* @param primitiveType
* @param countInstance
* @param numIndexes
* @param indexOffset
/*! Wrapper around glDrawElementsInstanced using a second VBO (_instanceVbo)
* that contains all positions for the instances. This used e.g. for
* SLParticleSystems on systems without geometry shaders.
*/
void SLGLVertexArray::drawElementsInstanced(SLGLPrimitiveType primitiveType,
SLuint countInstance,
SLuint countInstances,
SLuint numIndexes,
SLuint indexOffset)
{
Expand All @@ -504,7 +506,7 @@ void SLGLVertexArray::drawElementsInstanced(SLGLPrimitiveType primitiveType,
(GLsizei)numIndexes,
_indexDataType,
(void*)(size_t)(indexOffset * (SLuint)indexTypeSize),
(GLsizei)countInstance);
(GLsizei)countInstances);
////////////////////////////////////////////////////////

GET_GL_ERROR;
Expand Down
6 changes: 3 additions & 3 deletions modules/sl/source/gl/SLGLVertexArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class SLGLVertexArray
}

//! Attach a VBO that has been created outside of this VAO
void setExternalVBO(SLGLVertexBuffer* vbo, SLuint divisor = 0);
void setInstanceVBO(SLGLVertexBuffer* vbo, SLuint divisor = 0);

//! Updates a specific vertex attribute in the VBO
void updateAttrib(SLGLAttributeType type,
Expand Down Expand Up @@ -216,14 +216,14 @@ class SLGLVertexArray
SLuint _tfoID; //! OpenGL id of transform feedback object
SLuint _numVertices; //! NO. of vertices in array
SLGLVertexBuffer _vbo; //! Vertex buffer object for float attributes
SLGLVertexBuffer* _externalVbo; //! Vertex buffer object that has been created outside of this VAO
SLuint _externalDivisor; //! VBO attrib divisor for the external VBO
SLuint _idVBOIndices; //! OpenGL id of index vbo
size_t _numIndicesElements; //! NO. of vertex indices in array for triangles, lines or points
void* _indexDataElements; //! Pointer to index data for elements
size_t _numIndicesEdges; //! NO. of vertex indices in array for hard edges
void* _indexDataEdges; //! Pointer to index data for hard edges
SLGLBufferType _indexDataType; //! index data type (ubyte, ushort, uint)
SLGLVertexBuffer* _instanceVbo; //! Vertex buffer object containing the positions for instanced drawing
SLuint _instanceDivisor; //! instanceVBO divisor number
};
//-----------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 9a36b27

Please sign in to comment.