mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-05-11 18:32:35 +08:00
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.
29 lines
1.6 KiB
Markdown
29 lines
1.6 KiB
Markdown
OCCT WebGL Viewer sample {#occt_samples_webgl}
|
|
==================
|
|
|
|
This sample demonstrates simple way of using OCCT libraries in Web application written in C++ and translated into WebAssembly module using Emscripten SDK (emsdk):
|
|
https://emscripten.org/
|
|
|
|
Sample consists of the Open CASCADE 3D Viewer with a button for opening a model in BREP format.
|
|
The sample requires a WebGL 2.0 capable browser supporting WebAssembly 1.0 (Wasm).
|
|
|
|
Installation and configuration:
|
|
1. Install Emscripten SDK and activate minimal configuration (Python, Java and CLang) following *emsdk* documentation. Activate also MinGW when building sample on Windows host.
|
|
2. Build (using *emsdk*) or download FreeType static library.
|
|
3. Configure CMake for building Open CASCADE Technology (OCCT) static libraries (BUILD_LIBRARY_TYPE="Static").
|
|
For this, activate *emsdk* command prompt, configure CMake for building OCCT using cross-compilation toolchain, disable *BUILD_MODULE_Draw*.
|
|
4. Perform building and installation steps.
|
|
~~~~~
|
|
> ${EMSDK}/fastcomp/emscripten/cmake/Modules/Platform/Emscripten.cmake
|
|
~~~~~
|
|
5. Configure CMake for building this WebGL sample using *emsdk* with paths to OCCT and FreeType. Perform building and installation steps.
|
|
6. Copy data/occ/Ball.brep from OCCT into "samples" folder within WebGL sample installation path.
|
|
7. Navigate to installation folder and start web server from it; Python coming with *emsdk* can be used for this purpose:
|
|
~~~~~
|
|
> python -m SimpleHTTPServer 8080
|
|
~~~~~
|
|
8. Open compatible browser and enter path taking into account your web server settings:
|
|
~~~~~
|
|
> http://localhost:8080/occt-webgl-sample.html
|
|
~~~~~
|