mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0031070: Configuration - fix building issues when using Emscripten toolchain
Handled __EMSCRIPTEN__ macros to: - Workaround atomics (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is undefined, but GCC atomics are provided). - Suppress non-standard header <sys/signal.h> warning. - Return OSD_LinuxREDHAT. - Avoid inclusion of XLib headers. - Skip fontconfig library. - Enable EGL+GLES path (translated by Emscripten into WebGL). - Skip eglCreatePbufferSurface() not implemented by Emscripten EGL. Fixed Graphic3d_Vec4.hxx usage within Quantity_ColorRGBA.hxx. OpenGl_ShaderManager::defaultGlslVersion() now prefers GLSL 300 es when WebGL 2.0 is available, as there no any OpenGL ES greater than 3.0 emulation so far. Shaders_Declarations.glsl - added workaround for GLSL compilation on WebGL 1.0 by defining Light properties accessors as macros instead of functions ('[]' : Index expression must be constant). OpenGl_FrameBuffer::Init() - added workaround for initialization of GL_DEPTH24_STENCIL8 depth-stencil attachment on WebGL 1.0 + GL_WEBGL_depth_texture extension. OpenGl_Context::Vec4FromQuantityColor() now considers myIsSRgbActive flag to handle use case, when Immediate Layer is drawn directly into window buffer, which is not sRGB-ready. Added new sample - OCCT WebGL viewer.
This commit is contained in:
@@ -102,7 +102,7 @@ uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse
|
||||
uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix
|
||||
uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix
|
||||
|
||||
// light type enumeration
|
||||
// light type enumeration (same as Graphic3d_TypeOfLightSource)
|
||||
const int OccLightType_Direct = 1; //!< directional light source
|
||||
const int OccLightType_Point = 2; //!< isotropic point light source
|
||||
const int OccLightType_Spot = 3; //!< spot light source
|
||||
@@ -111,16 +111,36 @@ const int OccLightType_Spot = 3; //!< spot light source
|
||||
uniform vec4 occLightAmbient; //!< Cumulative ambient color
|
||||
#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)
|
||||
uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources
|
||||
int occLight_Type (in int theId); //!< Type of light source
|
||||
int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
|
||||
vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
|
||||
vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity)
|
||||
vec4 occLight_Position (in int theId); //!< Position of specified light source
|
||||
vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source
|
||||
float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source
|
||||
float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source
|
||||
float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)
|
||||
float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)
|
||||
|
||||
//! Type of light source, int (see OccLightType enum).
|
||||
#define occLight_Type(theId) occLightSourcesTypes[theId].x
|
||||
|
||||
//! Is light a headlight, int?
|
||||
#define occLight_IsHeadlight(theId) occLightSourcesTypes[theId].y
|
||||
|
||||
//! Specular intensity (equals to diffuse), vec4.
|
||||
#define occLight_Specular(theId) occLightSources[theId * 4 + 0]
|
||||
|
||||
//! Position of specified light source, vec4.
|
||||
#define occLight_Position(theId) occLightSources[theId * 4 + 1]
|
||||
|
||||
//! Direction of specified spot light source, vec4.
|
||||
#define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2]
|
||||
|
||||
//! Maximum spread angle of the spot light (in radians), float.
|
||||
#define occLight_SpotCutOff(theId) occLightSources[theId * 4 + 3].z
|
||||
|
||||
//! Attenuation of the spot light intensity (from 0 to 1), float.
|
||||
#define occLight_SpotExponent(theId) occLightSources[theId * 4 + 3].w
|
||||
|
||||
//! Diffuse intensity (equals to Specular), vec4.
|
||||
#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0]
|
||||
|
||||
//! Const attenuation factor of positional light source, float.
|
||||
#define occLight_ConstAttenuation(theId) occLightSources[theId * 4 + 3].x
|
||||
|
||||
//! Linear attenuation factor of positional light source, float.
|
||||
#define occLight_LinearAttenuation(theId) occLightSources[theId * 4 + 3].y
|
||||
#endif
|
||||
|
||||
// Front material properties accessors
|
||||
|
@@ -21,18 +21,6 @@ void occSetFragColor (in vec4 theColor)
|
||||
// arrays of light sources
|
||||
uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types
|
||||
uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters
|
||||
|
||||
// light source properties accessors
|
||||
int occLight_Type (in int theId) { return occLightSourcesTypes[theId].x; }
|
||||
int occLight_IsHeadlight (in int theId) { return occLightSourcesTypes[theId].y; }
|
||||
vec4 occLight_Diffuse (in int theId) { return occLightSources[theId * 4 + 0]; }
|
||||
vec4 occLight_Specular (in int theId) { return occLightSources[theId * 4 + 0]; }
|
||||
vec4 occLight_Position (in int theId) { return occLightSources[theId * 4 + 1]; }
|
||||
vec4 occLight_SpotDirection (in int theId) { return occLightSources[theId * 4 + 2]; }
|
||||
float occLight_ConstAttenuation (in int theId) { return occLightSources[theId * 4 + 3].x; }
|
||||
float occLight_LinearAttenuation (in int theId) { return occLightSources[theId * 4 + 3].y; }
|
||||
float occLight_SpotCutOff (in int theId) { return occLightSources[theId * 4 + 3].z; }
|
||||
float occLight_SpotExponent (in int theId) { return occLightSources[theId * 4 + 3].w; }
|
||||
#endif
|
||||
|
||||
// material state
|
||||
|
@@ -24,18 +24,6 @@ static const char Shaders_DeclarationsImpl_glsl[] =
|
||||
"// arrays of light sources\n"
|
||||
"uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types\n"
|
||||
"uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters\n"
|
||||
"\n"
|
||||
"// light source properties accessors\n"
|
||||
"int occLight_Type (in int theId) { return occLightSourcesTypes[theId].x; }\n"
|
||||
"int occLight_IsHeadlight (in int theId) { return occLightSourcesTypes[theId].y; }\n"
|
||||
"vec4 occLight_Diffuse (in int theId) { return occLightSources[theId * 4 + 0]; }\n"
|
||||
"vec4 occLight_Specular (in int theId) { return occLightSources[theId * 4 + 0]; }\n"
|
||||
"vec4 occLight_Position (in int theId) { return occLightSources[theId * 4 + 1]; }\n"
|
||||
"vec4 occLight_SpotDirection (in int theId) { return occLightSources[theId * 4 + 2]; }\n"
|
||||
"float occLight_ConstAttenuation (in int theId) { return occLightSources[theId * 4 + 3].x; }\n"
|
||||
"float occLight_LinearAttenuation (in int theId) { return occLightSources[theId * 4 + 3].y; }\n"
|
||||
"float occLight_SpotCutOff (in int theId) { return occLightSources[theId * 4 + 3].z; }\n"
|
||||
"float occLight_SpotExponent (in int theId) { return occLightSources[theId * 4 + 3].w; }\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"// material state\n"
|
||||
|
@@ -105,7 +105,7 @@ static const char Shaders_Declarations_glsl[] =
|
||||
"uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix\n"
|
||||
"uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix\n"
|
||||
"\n"
|
||||
"// light type enumeration\n"
|
||||
"// light type enumeration (same as Graphic3d_TypeOfLightSource)\n"
|
||||
"const int OccLightType_Direct = 1; //!< directional light source\n"
|
||||
"const int OccLightType_Point = 2; //!< isotropic point light source\n"
|
||||
"const int OccLightType_Spot = 3; //!< spot light source\n"
|
||||
@@ -114,16 +114,36 @@ static const char Shaders_Declarations_glsl[] =
|
||||
"uniform vec4 occLightAmbient; //!< Cumulative ambient color\n"
|
||||
"#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n"
|
||||
"uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources\n"
|
||||
"int occLight_Type (in int theId); //!< Type of light source\n"
|
||||
"int occLight_IsHeadlight (in int theId); //!< Is light a headlight?\n"
|
||||
"vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source\n"
|
||||
"vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity)\n"
|
||||
"vec4 occLight_Position (in int theId); //!< Position of specified light source\n"
|
||||
"vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source\n"
|
||||
"float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source\n"
|
||||
"float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source\n"
|
||||
"float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)\n"
|
||||
"float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)\n"
|
||||
"\n"
|
||||
"//! Type of light source, int (see OccLightType enum).\n"
|
||||
"#define occLight_Type(theId) occLightSourcesTypes[theId].x\n"
|
||||
"\n"
|
||||
"//! Is light a headlight, int?\n"
|
||||
"#define occLight_IsHeadlight(theId) occLightSourcesTypes[theId].y\n"
|
||||
"\n"
|
||||
"//! Specular intensity (equals to diffuse), vec4.\n"
|
||||
"#define occLight_Specular(theId) occLightSources[theId * 4 + 0]\n"
|
||||
"\n"
|
||||
"//! Position of specified light source, vec4.\n"
|
||||
"#define occLight_Position(theId) occLightSources[theId * 4 + 1]\n"
|
||||
"\n"
|
||||
"//! Direction of specified spot light source, vec4.\n"
|
||||
"#define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2]\n"
|
||||
"\n"
|
||||
"//! Maximum spread angle of the spot light (in radians), float.\n"
|
||||
"#define occLight_SpotCutOff(theId) occLightSources[theId * 4 + 3].z\n"
|
||||
"\n"
|
||||
"//! Attenuation of the spot light intensity (from 0 to 1), float.\n"
|
||||
"#define occLight_SpotExponent(theId) occLightSources[theId * 4 + 3].w\n"
|
||||
"\n"
|
||||
"//! Diffuse intensity (equals to Specular), vec4.\n"
|
||||
"#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0]\n"
|
||||
"\n"
|
||||
"//! Const attenuation factor of positional light source, float.\n"
|
||||
"#define occLight_ConstAttenuation(theId) occLightSources[theId * 4 + 3].x\n"
|
||||
"\n"
|
||||
"//! Linear attenuation factor of positional light source, float.\n"
|
||||
"#define occLight_LinearAttenuation(theId) occLightSources[theId * 4 + 3].y\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"// Front material properties accessors\n"
|
||||
|
Reference in New Issue
Block a user