OpenB3DMax Framework

Tweet blitzmax opengl frameworks toolbox openb3d rated
(Posted 2 months ago) RonTek

I started this Framework in miniB3D for my Extrasolar game project and ported it now to OpenB3D as it is more superior than miniB3D. This framework is still under construction but it has already many features to help creating a 3D game or demo using the OpenB3D wrapper in Blitzmax. I'm using this now in my current Legend of Faerghail game project and I think it will be the base of all other projects in future. It's free so feel free to use/alter it for you own needs or just learn from it.

Author: Krischan


The demo has some basic movement code, use WASD and R/F to move around.

Download [5.1MB]:

The main features are:

Associative Media management with TMaps capable of unloading

Instead of loading and assigning Media objects the "classic" way you just load the Media in a TMedia Object and retrieve it from everywhere, assign it and even delete it again to save VRAM (for example loading a different level with other textures):

Global MEDIA:TMedia = New TMedia
MEDIA.Load("TEX", "NOTEX", "notex.png", 1 + 8)
EntityTexture mesh, MEDIA.GetTexture("NOTEX")

The TMedia Object supports many different types like Textures, Pixmaps, Sounds, Images, Fonts and so on. Check out the TMedia.bmx in the includes/Types folder or look at the demo source. In the compiled .debug EXE or if you set the PROJECT_DEBUG variable in the Variables.bmx to True there is an example how to fill VRAM with created Textures and unload them. I've checked this with the nVidia Gpu Utilization tool and it worked.

Instant screen resolution switch (ingame)

If you want to switch the resolution ingame a common method is to use EndGraphics and rebuild the whole scene again. Rubbish. Using a MAXGUI window with canvas can switch the resolution ingame with just a new function: SetResolution(x,y). I had to rewrite BeginMax2D/EndMax2D (now called: Begin2D/End2D) for this and use a global "Scaler" variable but it works, try it yourself. In Windows it is even possible to create either a fullscreen window or a window maximized including the Windows Taskbar.

Pre-Load resolution selector

Using MAXGUI has another advantage: Gadgets. When you start the game/demo you can now select a resolution first from a list which contains common resolutions retrieved from the available client resolution list.

Framesafe movement

The framework includes FPS management, so the game always runs at a fixed speed, if there a 30 or 300 FPS, Vsync, Delay or not. Just multiply all movement with the FPS.Multi variable and it'll be fine.


The framework has a simple localization system using Brucey's bah.DBSQLite module and a single SQL file containing ALL localized text. So your application can be multilingual now. It is very easy to use it. In the SQL Table you define a Category, a Key and one row per supported language. So the table looks like:

If you want to retrieve the english text for the "CREATECANVAS" key in your application you just use it this way:

Global LOCALE:TLocale = New TLocale
LOCALE.path = PATH_Locale
LOCALE.language = "EN"
Result: Create Canvas Window

The key to retrieve is using this Syntax: CATEGORY_KEY, that's why it is "LOG_CREATECANVAS" instead of "CREATECANVAS". In the Framework demo I'm using this in the GUI.bmx file to display information. You can even store an array of text in a cell and decode it later like "on/off" and so on. It's all shown in the demo how to use it.


OpenB3D can load shaders and the demo shows a single bumpmapping shader with a diffusemap and a normalmap applied to it. With the TMedia Object it is possible to "cache" a shader - you load it once and apply it to many objects by creating the shader when you need it. This is much faster than loading the files again and again. This is shown in the demo too. You can even load a different texture resolution in the demo and apply it to the shader again, in runtime. The demo basically shows a level with walls and two lights, one blue pointlight above the sphere and a second spotlight attached to the camera pointing forward. You can alter the light intensity with the mouswheel and see how the tiled surface is affected by the two lightsources when you look around. You can turn the lightsources on and off with the two mouse buttons.


I've included TONS OF FUNCTIONS in the include/Functions folder ready to use. You'll find many useful functions for Math, Text, Mesh, Primitives, Noise and so on. I've documented everything and most of them shoudl be easy to understand and how they are used. If not feel free to ask me about them. There are other cool features like the "Blip Text" which displays a text like a SciFi Computer with a "blip" for each character. I've made this using the TBeat Type to initiate an event every x milliseconds. Don't miss the two mouselook codes, one uses Euler rotation like in a FPS shooter and the other complex Quaternion rotation like in a 3D space game or flight simulator. Another addition is the Fraps-like FPS counter in the upper right corner, I've even created an extra font for this. So there is no need to have Fraps running in the background anymore :-p Turn it on/off with F12 like in the original.

BLIde additions

I've included the whole BLIde project and my color settings. I've even added a feature that you can edit GLSL shaders in BLIde as GLSL is using a C Syntax and highlighting is very important as there are only limited ways to debug a shader. It's not perfect but I only use BLIde for editing GLSL now. I've tweaked the color settings for my own needs and I'm using the "Lucida Console" Font in 11pt. This is perfect for my 2560x1440 iMac resolution.

And now - what do you think or what can you create using this framework or contribute to it? Like I said I had to rewrite the BeginMax2D/EndMax2D functions to make the ingame resolution switch work and I'm not sure if I did this correct. At least it is working but you never know which sideeffects can occur.

Reply To Topic (minimum 10 characters)

Please log in to reply