Allegro - can you open more than one window?

Started by
4 comments, last by Fiddler 18 years, 10 months ago
Does anyone know if you can open more than one window in Allegro? It would be great to have the game window and an output window for error messages.
Advertisement
Allegro doesn't have provisions for opening more than one window as far as I know. You might consider outputting your error messages to a text file. Another common way to output messages while the game is running is to draw your text messages in the upper or lower part of the screen so you can read them there.

I hope that helps :)
You cannot open up multiple graphics windows with Allegro 4. However, all it sounds like you need is a console window. By default MinGW will open up a console window that you can print to. I would assume that MSVC could be configured to do so as well. That console window can be printed to via standard output functions like printf().

Also, you can use the TRACE() macro that Allegro provides to send output to a text log file. (Note that it only works when you are using the debug version.)
This feature has been planned and will probably be included in the 4.3 and later versions. However, as has already been mentioned you do not really need a second window to display error messages. You can try to do one of the following:

- If you want on-screen feedback you can open a console window (mingw does this by default, for msvc there is a compiler switch - I think it is called subsystem and you can select between window or console). You can use the regular printf and cout to output messages. However, this is mostly useless in fullscreen apps.

- As has already been mentioned, you can output messages in the app window itself (the textout_ex, textprintf_ex and allegro_message functions can be very useful).

- You can use the TRACE() macro that is provided by allegro. To use it, you must "#define DEBUGMODE" in any sourcefile you need it (this will work whether you've built the debug or the release library). If you wish you use this define only in debug modes to get a small speed boost in the release. To do this you could pass the parameter to the compiler invocation, so you don't have to write #define DEBUGMODE in every sourcefile. I think the syntax for mingw is -DDEBUGMODE=1, while for msvc there is a field in the project properties where you can write DEBUGMODE=1.

- You can roll your own error logger, which is a rather trivial task, but a good exercise nonetheless. If you use c++, you could use the following minimalistic approach:

#include "fstream"std::ofstream& log() {    static std::ofstream logfile("whatisthenameofmyapplication.log");    return logfile;}

You can then write log() << "Blah" << std::flush;

If you wish you can wrap it up in an inline function that calls the log() if you are in debug mode or does nothing if you are in release.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Fiddler (or anyone else?), I wonder if you could explain how to open the console window? Call me dumb but I don't know what mingw is, and I'm not using Visual C, I'm using DevC. Maybe you just can't do it in DevC(until version 4.3 or whatever)?
The Dev-cpp is an IDE (Integrated Development Environment) that uses MingW as its compiler. Basically it lets you write and compile code without using the command line or writing your own makefile (it creates its own based on the project settings). So, in fact you are using MingW.

Dev-Cpp will, by default, create a console window, unless you set the "Do not create a console window" option under Tools->Compiler->Settings->Linker to yes.

If you have created a project (new->project instead of new->source file), you can override the default setting (mentioned above) in the Project Options.

Keep in mind that a console window automatically shuts down when you exit your program, so if your program crashes you might not be able to read the error message.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

This topic is closed to new replies.

Advertisement