Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Graphical problems with video bitmaps

This thread is locked; no one can reply to it. rss feed Print
Graphical problems with video bitmaps
The Unknown
Member #8,441
March 2007

On a different computer to that which the game was compiled on, i get this lovely effect on my backgrounds. And as you can see from the screen shot, the test monkey is not happy.

{"name":"screenshotel7.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/3\/034e3f62570350aef1fc484ee8ccec2b.png","w":803,"h":481,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/3\/034e3f62570350aef1fc484ee8ccec2b"}screenshotel7.png

The reason you can see some rings, a small man, and an angry looking monkey. Is because i have a video bitmap for writing large bitmaps to, to save some RAM (by using the VRAM) so this includes backgrounds etc.

All other non-static objects are drawn to a memory bitmap. Once all the drawing is done, the memory bitmap is placed atop the video bitmap, and the video bitmap is displayed on the screen.

So, the backgrounds are video bitmaps, they are blitted to the video buffer, all should be good right? Well apparently it isn't. I put this code at the beggining to check that blitting VRAM to VRAM, was hardware accelerated:

if(!(gfx_capabilities & GFX_HW_VRAM_BLIT) || !(gfx_capabilities & GFX_HW_VRAM_BLIT_MASKED))
  allegro_message("Oh no...");

It said nothing so... i don't know whats going on :-\
And im not 100% on all things allegro

Paul whoknows
Member #5,081
September 2004
avatar

First, you should allways allow your game to work with a simple and nice double buffer system.
Once you have that, you can add page flipping and triple buffering.
About your problem I can't help you, sorry, perhaps if you show your code...

Quote:

to save some RAM (by using the VRAM)

I am not sure if that's a good idea, usually most systems have more RAM than VRAM.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

The Unknown
Member #8,441
March 2007

I'm only using about 20MB of the VRAM, so its not big deal. And it worked fine when i was only using memory bitmaps.

1int Tile = 800/BG0->w +2;
2for(i=0; i<Tile; i++) {
3 masked_blit(BG0, VideoBuffer[Page], 0,0,BG0offset+(i*BG0->w), 0, BG0->w, BG0->h);
4}
5 
6 
7Tile = 800/BG1->w +1;
8for(i=0; i<Tile; i++) {
9 masked_blit(BG1, VideoBuffer[Page], 0,0,BG0offset+(i*BG1->w), 0, BG1->w, BG1->h);
10}
11 
12
13Tile = 800/BG2->w +1;
14for(i=0; i<Tile; i++) {
15 masked_blit(BG2, VideoBuffer[Page], 0,0,BG0offset+(i*BG2->w), 0, BG0->w, BG2->h);
16}
17
18masked_blit(Foreground, VideoBuffer[Page],XOffset, YOffset,0,0, 800, 480);

Thats the background, thats what goes all crazy.
Everything else is just memory bitmap to memory bitmap, and then i put the memory bitmap over the video bitmap, and show it

masked_blit(Buffer, VideoBuffer[Page], 0,0,0,0,800,480);

show_video_bitmap(VideoBuffer[Page]);

And its not just random computers that do this, it seems to be any compy without allegro installed.

Kitty Cat
Member #2,815
October 2002
avatar

How are you loading them into VRAM?

Quote:

save some RAM (by using the VRAM)

Note that many systems will keep a copy of VRAM bitmaps in RAM as well in case the VRAM bitmaps get corrupted and need to be "refreshed".

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

The Unknown
Member #8,441
March 2007

Err...

BITMAP* Foreground = create_video_bitmap(RoomWidth, RoomHeight);
...
BITAMP* Temp = load_bitmap("Levels\\Jungle.tga");
blit(Temp, Foreground, 0,0,0,0, RoomWidth, RoomHeight);
...
destroy_bitmap(Temp);

Quote:

Note that many systems will keep a copy of VRAM bitmaps in RAM as well in case the VRAM bitmaps get corrupted and need to be "refreshed".

Even if that happens, i still get an extra 5FPS, ooh. Not that anybody will ever notice :-\

Kitty Cat
Member #2,815
October 2002
avatar

Should probably change that to:

BITAMP* Temp = load_bitmap("Levels/Jungle.tga");
BITMAP* Foreground = create_video_bitmap(Temp->w, Temp->h);
...
blit(Temp, Foreground, 0,0,0,0, Temp->w, Temp->h);
...
destroy_bitmap(Temp);

(with proper error checking) in case the bitmap you're loading is a different size than what RoomWidth and RoomHeight are.

Quote:

Even if that happens, i still get an extra 5FPS, ooh. Not that anybody will ever notice :-\

Not to dissuade you from using VRAM bitmaps, as it's a perfectly fine method. Just don't think you're saving RAM because of it.

Also, you're creating your video bitmap buffers first, before loading your images? Since the first video bitmaps created overlap the screen...

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

The Unknown
Member #8,441
March 2007

the RoomWidth and RoomHeight are the width and height of jungle.tga

Quote:

Also, you're creating your video bitmap buffers first, before loading your images? Since the first video bitmaps created overlap the screen...

Huh? All this stuff is done once when loading the level... after which the screen is cleared and drawn to.

Anyway, ive decided that it too much effort, and gone back to double buffering. I also imagine the performance boost given by using video bitmaps, would depend on the card so...

Go to: