Black screen of DOOM

Whenever I try to draw from a datafile, nothing happens. Just nothing- the screen stays black. However, it worked in a test file. This is the relevant code:

#include "ZomOn.h"
DATAFILE *zombo = load_datafile("ZomOn.dat");

int main(){
  //init stuff here
  blit((BITMAP*)zombo[hud_back].dat, screen, 0, 0, 0, 480, 480, 60);

This doesn't work. It just stays black (the screen). Why?


You can't load datafiles in the global scope. You don't error check. Oh, and your example omits a hell of a lot of code of interest, making it impossible to say for certain what your problem is.

In the future, please show actual problem code, instead of made-up or completely gutted examples.

And don't double post.


The rest is ALL game logic. All of it. I pretty much cut the program down to those few lines.


No, it's not.
There's no initialization. Whatsoever. Meaning you could be doing about a thousand things wrong before even touching the datafile.


The init stuff is fine. The game worked fine until I started using the datafile. I started out using all bmps, I just added the dat and replaced all of the blit stuff. But here:

//there was the code here but I took it out.

EDIT: Thanks for the datafile info, its now locally made. Now I just need to work out a few kinks.

EDIT2: If you can't have a global datafile, what is the best way to draw a bmp from the file in a function?


You can have a global datafile. You just can't load it in the global scope.


void bar(void)
 foo = load_datafile("fnord.dat");
 if (!foo)


Oh, like bitmaps.

Kris Asick

You can have a global datafile, you just can't initialize globally.

The reason why you can't is because when load_datafile() is processed at program startup, you still have yet to call allegro_init(), thus load_datafile() doesn't work properly.

Before you use ANY Allegro commands, you should always call allegro_init() first, which means any global pointers to Allegro objects cannot be initialized at global scope.

--- Kris Asick (Gemini)

Jonatan Hedborg

You should probably brush up on your C/C++ a bit :/


You should probably brush up on your C/C++ a bit :/

Yeah, I do...I started C++ like...5 months ago?

Thread #590708. Printed from