User Tools

Site Tools


proton:win_3dapp

RT3DApp - Enter Irrlicht

This app combines the features of the previous apps with the powerful 3D engine Irrlicht.

It's based on the Irrlicht GLES 1.7.1 beta branch.

Key points about how I integrated it:

  • I don't use any of Irrlicht's GL init/window code, Proton handles that
  • I added a custom texture type so it could read my .rttex format, including pvrct. (PowerVR compressed textures that iOS stuff uses)
  • It supports only two renderers, GL and GLES V1.X. (GLES or GL can work on windows, mobiles can only use GLES)
  • It is able to load texture formats that Proton can't, including .jpg and .png directly
  • You can use Proton's entity/components along side of Irrlicht, in this example Proton handles the GUI controls
  • I statically link everything just by including .cpp files. It's a lot of files, woe is the person that has to setup a new project without copying an existing one.
  • There are enough changes to make it slightly tricky to update to later versions of Irrlicht, just be careful around the driver and texture code

There is a lot of overlap between Irrlicht and Proton, for instance, they both have file systems where you can mount a zip, font systems and Rect classes.

However, I don't mind too much, because it means for games that don't require 3D, Irrlicht doesn't have to be included at all. (RTBareBones and RTSimpleApp examples don't include a single Irrlicht file)

You built RTBareBones and RTSimpleAPP, right?

This tutorial assumes you already did this one, and this one. At least skim them or you won't know about building resources!

Compiling RT3DApp on Windows

Should be a breeze, exactly the same as RTSimpleApp.

You do have to build resources first, by running RT3DApp/media/update_media.bat. It converts all jpg/png to .rttex files.

This cryptic line in the batch file does most of the compressing:

for /r %%f in (*.bmp *.png *.jpg *.tga) do ..\%PACK_EXE% -flipv -mipmaps -stretch -pvrt4444 %%f

It's saying turn everything into 4444 raw files, stretch them to be power of two, and flip them vertically. It also compresses the final product with zlib, the filesizes of an .rttex are comparable to .png.

These textures will load on anything.

But let's say you are doing an iOS build, you should really use PowerVR's pvrtc format instead, it will save texture memory and might give you a few extra fps in performance.

In that case, you should comment out the above line and uncomment this one:

for /r %%f in (*.bmp *.png *.jpg *.tga) do ..\%PACK_EXE% -flipv -mipmaps -stretch -4444_if_not_square_or_too_big -pvrtc4 %%f

(a : in front of a .bat file line makes it comment btw, sort of like REM but won't display it while running)

Note that along with -pvrtc4 it adds the hilariously long flag -4444_if_not_square_or_too_big. This is because iOS HW cannot display non-square pvrtc4 files. Yeah, wow, huh?

Btw, if you run /shared/win/rtpack.exe without parms it will let you know all the parameters possible.

RTPack V1.1 by Seth A. Robinson.  /h for help

Help and examples

RTPack.exe <any file> (Compresses it as an rtpack without changing the name)
RTPack.exe -make_font <filename.txt> (Create a .rtfont)
RTPack.exe -pvrtc4 <image file> (Makes pvrtc .rttex)

More options/flags for making textures:

RTPack.exe -pvrt4444 <image file> (Makes raw 16 bit 4444 or 565 if no alpha)
RTPack.exe -pvrt8888 <image file> (Creates raw 32 bit .rttex
RTPack.exe -pvrt4444 -o pvr <image file> (Writes a .pvr format output)
Extra flags you can use with texture generation:
-mipmaps (Causes mipmaps to be generated)
-stretch (Stretches instead of pads to reach power of 2)
-force_square (forces textures to be square in addition to being power of 2)
-4444_if_not_square_or_too_big (1024 width or height and non square will use -pvrt4444)
-8888_if_not_square_or_too_big (1024 width or height and non square will use -pvrt8888)
-flipv (vertical flip, applies to textures only)

Running it

The main menu has multiple tests, the one above is a quake like map, it's loading a .bsp. It's all in

Check source/GUI/MapMenu.cpp for the code.

Landscape. Code in source/GUI/TerrainMenu.cpp.

Loads and animates a simple model. Code is in source/GUI/Mesh3DMenu.cpp - if you look, you can uncomment some stuff to load a .md2 model and some others as well.

Akiko modeled that chipmunk for TeenageLawnmower waaaay back when.

This is a .max file of a ground and house exported from 3DSMax as Blitz3D. (.b3d) The light mapping channel was applied in max and correctly exports with the mesh. Don't you love lightmapping?!

It also loads a separate .b3d file for the collision data, this lets you simplify it and make it so trees and things are smoother to navigate around.

Hmm, I probably should put up the .max file of the house scene as an example for 3DSMax users, bug me if you need it. :)

Does this mean I can pop out a 3d game now?

Uh… well, not really, these examples are just showing the technology works. You would really have to hit the Irrlicht Forums and understand what is going on to make a 3D game with this, there are no shortcuts.

Oh, they have nice tutorials as well. You can either use them with the vanilla Irrlicht distribution or with Proton SDK's version proving you use some common sense to ignore irrelevant pieces such as setting display modes.

If you're already familiar with 3D engine code in general, you'll like Irrlicht's design, it's clean and makes sense for the most part.

proton/win_3dapp.txt · Last modified: 2010/12/22 03:35 by seth