Which modules to import?

BlitzMax Forums/BlitzMax Programming/Which modules to import?

Diordna(Posted 2004) [#1]
I see a whole bunch and I have no clue what they do. I want to cut down on the file size but I don't know what to cut out.

Here's my approximate list of what I use:
-Drawing circles/lines/boxes (basic OpenGL)
-Pixmaps
-Keyboard
-Mouse
-File I/O
-Bit shifting
-Ogg and Wav sounds
-BASIC commands occasionally
-PNG's
-Randomizer
-Trig
-Font loading/drawing

Which modules should I import?


Diordna(Posted 2004) [#2]
Here is my list which seems to work well enough, though it hasn't been tested. Can I take any of these out?

Framework BRL.glMax2D

Import BRL.AppStub
Import BRL.Audio
Import BRL.AudioSample
Import BRL.BASIC
Import BRL.Blitz
Import BRL.BlitzGL
Import BRL.EndianStream
Import BRL.FileSystem
Import BRL.Font
Import BRL.FreeAudioAudio
Import BRL.FreeTypeFont
Import BRL.Keycodes
Import BRL.Math
Import BRL.Max2D
Import BRL.OggLoader
Import BRL.Pixmap
Import BRL.PNGLoader
Import BRL.Random
Import BRL.Retro
Import BRL.StandardIO
Import BRL.Stream
Import BRL.System
Import BRL.WavLoader
Import pub.FreeAudio
Import pub.FreeType
Import pub.glew
Import pub.LibPNG
Import pub.OggVorbis
Import pub.OpenGL


Diordna(Posted 2004) [#3]
What a help you guys are :)

What I've found is that the pub modules don't need to be imported. Revised list:

Framework BRL.glMax2D

Import BRL.AppStub
Import BRL.Audio
Import BRL.BASIC
Import BRL.Blitz
Import BRL.BlitzGL
Import BRL.EndianStream
Import BRL.FileSystem
Import BRL.Font
Import BRL.FreeAudioAudio
Import BRL.FreeTypeFont
Import BRL.Keycodes
Import BRL.Math
Import BRL.Max2D
Import BRL.OggLoader
Import BRL.Pixmap
Import BRL.PNGLoader
Import BRL.Random
Import BRL.Retro
Import BRL.StandardIO
Import BRL.Stream
Import BRL.System
Import BRL.WavLoader

Which of these are imported automatically?


Hotcakes(Posted 2004) [#4]
You know, generally you can get away with only Importing modules that your main program uses directly (you can check which module each command can be found in by looking at the bottom of the command's reference in the docs)... with exception of the gfx and sound loader modules (png, wav, ogg, tga, etc) - altho the docs don't mention anything about the sound modules.


Diordna(Posted 2004) [#5]
Yeah, but I didn't know if some modules sometimes rely on other modules to function. For example, I would have expected the BRL.Font module to rely on the pub.FreeTypeFont module, but apparently it doesn't. Or imports it itself.

In other news, I've shaved off 400k from my executable.


Dreamora(Posted 2004) [#6]
You can check this "who relies on who " out by checking the source ( or owning protean which shows it on its own in the modules window )


Hotcakes(Posted 2004) [#7]
Yeah, but I didn't know if some modules sometimes rely on other modules to function.

Constantly. But those that do will import the modules they need themselves. You don't need to worry about it. That's the beauty of the Import command.

I would have expected the BRL.Font module to rely on the pub.FreeTypeFont module, but apparently it doesn't.

I would have expected that too, but you're right, there's no sign of it. <checks> That's because there's a sepereate brl.freetypefont module, which relies on brl.font, brl.pixmap and pub.freetype. Which makes me wonder if/how brl.font works if you only import that and try to use it... <checks> Ahh, it doesn't. You are supposed to import the entire brl.max2d module for font support.


Diordna(Posted 2004) [#8]
Wow, so I don't even need to import BRL.font...


Hotcakes(Posted 2004) [#9]
-Usually- I've found that basically whatever module the command is documented in (the font things are all in the brl.max2d documentation) is the module you would want to import. However, the sound modules are a little messy. For them to work properly, I think you're supposed to import brl.freeaudioaudio, rather than brl.audio or brl.audiosample...

I should clarify that when I say 'work properly' or whatever, I mean the documented commands when used as is, or as documented. Naturally if you're willing to go 'behind the scenes' and mess around with a particular module, then so long as you know what you're doing everything will go smoothly for you =]