Skip to content

Commit

Permalink
Fixed point size problem for iOS and Emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm4 committed Dec 12, 2023
1 parent 920bb35 commit 446d455
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 25 deletions.
1 change: 1 addition & 0 deletions data/shaders/ColorUniform.vert
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ out vec4 v_color; // Resulting color per vertex
//-----------------------------------------------------------------------------
void main(void)
{
gl_PointSize = 1.0;
v_color = u_matDiff;
gl_Position = u_pMatrix * u_vMatrix * u_mMatrix * a_position;
}
Expand Down
7 changes: 4 additions & 3 deletions modules/math/source/SLQuat4.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/*!Quaternion class for angle-axis rotation representation. For rotations
quaternions must have unit length. See http://en.wikipedia.org/wiki/Quaternion
Quaternions can be interpolated at low cost with the method lerp or slerp.
@todo Add more doxygen documentation.
*/
// clang-format off
template <class T>
Expand Down Expand Up @@ -737,11 +736,13 @@ inline void SLQuat4<T>::lerp(const SLQuat4<T>& q1,
}

//-----------------------------------------------------------------------------
//! Spherical linear interpolation
/*! Spherical linear interpolation
@todo clean up the code below and find a working algorithm or check the
original shoemake implementation for errors.
*/
template <class T>
inline SLQuat4<T> SLQuat4<T>::slerp(const SLQuat4<T>& q2, const T t) const
{
/// @todo clean up the code below and find a working algorithm (or check the original shoemake implementation for errors)
// Not 100% slerp, uses lerp in case of close angle! note the todo above this line!
SLfloat factor = t;
// calc cosine theta
Expand Down
1 change: 0 additions & 1 deletion modules/sl/source/gl/SLGLOculus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ void SLGLOculus::renderDistortion(SLint width,
*/
const SLVec3f& SLGLOculus::viewAdjust(SLEyeType eye)
{
//@todo find a nicer way to store this (SLEye has a -1 for left and +1 for right eye)
if (eye == ET_left)
return _viewAdjust[0];
else
Expand Down
2 changes: 1 addition & 1 deletion modules/sl/source/gl/SLGLTextureIBL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ SLGLTextureIBL::~SLGLTextureIBL()
Build the texture into a cube map, rendering the texture 6 times and capturing
each time one side of the cube (except for the BRDF LUT texture, which is
completely generated by calculations directly with the shader).
@todo: Priority 1: These frame buffer ops do not work properly on iOS & Android.
@todo Priority 1: These frame buffer ops do not work properly on iOS & Android.
This is probably the most difficult OpenGL code in the project.
*/
void SLGLTextureIBL::build(SLint texUnit)
Expand Down
17 changes: 9 additions & 8 deletions modules/sl/source/gl/SLGLVertexArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,12 @@ void SLGLVertexArray::generate(SLuint numVertices,
_numIndicesEdges * (SLuint)typeSize);

glGenBuffers(1, &_idVBOIndices);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _idVBOIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, tmBufSize, tmpBuf, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
_idVBOIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
tmBufSize,
tmpBuf,
GL_STATIC_DRAW);
SLGLVertexBuffer::totalBufferCount++;
SLGLVertexBuffer::totalBufferSize += tmBufSize;
delete[] tmpBuf;
Expand Down Expand Up @@ -434,9 +438,6 @@ void SLGLVertexArray::drawElementsAs(SLGLPrimitiveType primitiveType,
/*!
* Draws the vertex attributes as a specified primitive type as the vertices
* are defined in the attribute arrays.
* @param primitiveType
* @param firstVertex
* @param countVertices
*/
void SLGLVertexArray::drawArrayAs(SLGLPrimitiveType primitiveType,
SLint firstVertex,
Expand Down Expand Up @@ -555,7 +556,7 @@ void SLGLVertexArray::drawEdges(SLCol4f color,
// Set uniform color
glUniform4fv(sp->getUniformLocation("u_matDiff"), 1, (SLfloat*)&color);

#ifndef SL_GLES
#if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN)
if (lineWidth != 1.0f)
glLineWidth(lineWidth);
#endif
Expand All @@ -566,9 +567,9 @@ void SLGLVertexArray::drawEdges(SLCol4f color,
(SLuint)_numIndicesElements);
//////////////////////////////////////////////////////

#ifndef SL_GLES
#if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN)
if (lineWidth != 1.0f)
glPointSize(1.0f);
glLineWidth(1.0f);
#endif

GET_GL_ERROR;
Expand Down
8 changes: 4 additions & 4 deletions modules/sl/source/gl/SLGLVertexArrayExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void SLGLVertexArrayExt::drawArrayAsColored(SLGLPrimitiveType primitiveType,
// Set uniform color
glUniform4fv(sp->getUniformLocation("u_matDiff"), 1, (SLfloat*)&color);

#ifndef SL_GLES
#if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN)
if (pointSize != 1.0f)
if (primitiveType == PT_points)
glPointSize(pointSize);
Expand All @@ -79,7 +79,7 @@ void SLGLVertexArrayExt::drawArrayAsColored(SLGLPrimitiveType primitiveType,
(SLsizei)countVertices);
//////////////////////////////////////

#ifndef SL_GLES
#if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN)
if (pointSize != 1.0f)
if (primitiveType == PT_points)
glPointSize(1.0f);
Expand Down Expand Up @@ -114,7 +114,7 @@ void SLGLVertexArrayExt::drawElementAsColored(SLGLPrimitiveType primitiveType,
// Set uniform color
glUniform4fv(sp->getUniformLocation("u_matDiff"), 1, (SLfloat*)&color);

#ifndef SL_GLES
#if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN)
if (pointSize != 1.0f)
if (primitiveType == PT_points)
glPointSize(pointSize);
Expand All @@ -126,7 +126,7 @@ void SLGLVertexArrayExt::drawElementAsColored(SLGLPrimitiveType primitiveType,
countVertices);
////////////////////////////////

#ifndef SL_GLES
#if not defined(SL_GLES) && not defined(SL_EMSCRIPTEN)
if (pointSize != 1.0f)
if (primitiveType == PT_points)
glPointSize(1.0f);
Expand Down
12 changes: 9 additions & 3 deletions modules/sl/source/mesh/SLParticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ void SLParticleSystem::pauseOrResume()
* have been culled by the frustum culling or if they have been resumed by the
* user. After I update the particle in the update pass, then and finally I
* draw them.
@todo The assignment of TF buffer to a rendering buffer causes most probably
a warning on Emscripten-WebGL
*/
void SLParticleSystem::draw(SLSceneView* sv, SLNode* node, SLuint instances)
{
Expand Down Expand Up @@ -760,22 +762,26 @@ void SLParticleSystem::draw(SLSceneView* sv, SLNode* node, SLuint instances)
spTF->uniform1f("u_angularVelo",
_angularVelocityConst * DEG2RAD);

//////////////////////
// Draw call to update
//////////////////////
/////////////////////////
// Draw call to update //
/////////////////////////

if (_drawBuf == 0)
{
_vao1.beginTF(_vao2.tfoID());
_vao1.drawArrayAs(PT_points);
_vao1.endTF();

// @todo The assignment of TF buffer to a rendering buffer causes most probably a warning on Emscripten-WebGL
_vao = _doInstancedDrawing ? _instanceVao2 : _vao2;
}
else
{
_vao2.beginTF(_vao1.tfoID());
_vao2.drawArrayAs(PT_points);
_vao2.endTF();

// @todo The assignment of TF buffer to a rendering buffer causes most probably a warning on Emscripten-WebGL
_vao = _doInstancedDrawing ? _instanceVao1 : _vao1;
}
_updateTime.set(GlobalTimer::timeMS() - _startUpdateTimeMS);
Expand Down
5 changes: 2 additions & 3 deletions modules/sl/source/node/SLLightDirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ SLLightDirect::~SLLightDirect()
}
//-----------------------------------------------------------------------------
/*!
SLLightDirect::init sets the light id, the light states & creates an
emissive mat.
@todo properly remove this function and find a clean way to init lights in a scene
* SLLightDirect::init sets the light id, the light states & creates an emissive
* material.
*/
void SLLightDirect::init(SLScene* s)
{
Expand Down
1 change: 0 additions & 1 deletion modules/sl/source/node/SLLightRect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ SLLightRect::~SLLightRect()
/*!
SLLightRect::init sets the light id, the light states & creates an
emissive mat.
@todo properly remove this function and find a clean way to init lights in a scene
*/
void SLLightRect::init(SLScene* s)
{
Expand Down
1 change: 0 additions & 1 deletion modules/sl/source/node/SLLightSpot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ SLLightSpot::~SLLightSpot()
//-----------------------------------------------------------------------------
/*!
SLLightSpot::init sets the light id, the light states & creates an emissive mat.
@todo properly remove this function and find a clean way to init lights in a scene
*/
void SLLightSpot::init(SLScene* s)
{
Expand Down

0 comments on commit 446d455

Please sign in to comment.