SyntaxBoom

General Category => Worklogs => Topic started by: Krischan on Oct 07, 2025, 02:23 PM

Title: Blitzmax GLB Loader
Post by: Krischan on Oct 07, 2025, 02:23 PM
I've always missed a GLB/GLTF Loader in Blitzmax to switch to a more modern 3D file format. So I've written a wrapper in C for the CGLTF (https://github.com/jkuhlmann/cgltf) project, and a GLB Demo loading application in BlitzmaxNG+OpenB3D. Works so far with exported GLBs/GLTFs from Blender, sketchfab.com or also meshy.ai

It currently does only load the Basecolor texture - not the PBR textures - but this will be added in a future version with Shader support, merging it with my latest PBR Shader Demo (not released yet). It may also not be fully optimized yet as I've got a lot of help from my friend ChatGPT here, but I'm happy that it works at all :o

Works with BlitzmaxNG (BCC 0.146, BMK 3.58, GCC 120200) + OpenB3D (https://github.com/markcwm/openb3d.mod)

Demo Viewer download including all sources and some GLB models:
LoadGLB.zip (https://www.extrasolar.de/blitzbasic/2025/Projects/LoadGLB.zip)

Demo controls:
- LMB Load new Model
- RMB Save Screenshot
- WHEEL Zoom
- TAB Wireframe
- ENTER Autorotation on/off
- ESC End

I've also included a little Python script in the Models/ folder which "compresses" a GLB to a smaller size. It simply rescales all Textures to a maximum size of 1024 pixels and saves Textures with an Alpha channel as PNG and all others als JPEG with quality 90. Needs pygltflib and PIL.
Title: Re: Blitzmax GLB Loader
Post by: Amon on Oct 07, 2025, 09:01 PM
Very nice. Can you link me to OpenB3D for BlitzMax please?
Title: Re: Blitzmax GLB Loader
Post by: Krischan on Oct 07, 2025, 09:43 PM
Quote from: Amon on Oct 07, 2025, 09:01 PMVery nice. Can you link me to OpenB3D for BlitzMax please?

It's already linked in the initial post. You can also browse my Blitzmax Archive - see signature - 2025 Folder. There you'll also find a complete BlitzmaxNG environment, I usually run it from C:\BlitzmaxNG - including all precompiled Mods.
Title: Re: Blitzmax GLB Loader
Post by: Amon on Oct 07, 2025, 10:08 PM
Thanks! :)