Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Black screen of DOOM

This thread is locked; no one can reply to it. rss feed Print
Black screen of DOOM
SkaxCo
Member #8,323
February 2007

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?

gnolam
Member #2,030
March 2002
avatar

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.

[EDIT]
And don't double post.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

SkaxCo
Member #8,323
February 2007

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

gnolam
Member #2,030
March 2002
avatar

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

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

SkaxCo
Member #8,323
February 2007

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?

gnolam
Member #2,030
March 2002
avatar

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

DATAFILE *foo;

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

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

SkaxCo
Member #8,323
February 2007

Oh, like bitmaps.
Thanks!

Kris Asick
Member #1,424
July 2001

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)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Jonatan Hedborg
Member #4,886
July 2004
avatar

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

-------
Sweden: Free from the shackles of Democracy since 2008-06-18!

SkaxCo
Member #8,323
February 2007

Quote:

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

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

Go to: