Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » how does "screen" interact with "show_video_bitmap" ?

This thread is locked; no one can reply to it. rss feed Print
how does "screen" interact with "show_video_bitmap" ?
Geoman
Member #6,873
February 2006

The following piece of code leads to unpredictable behaviour (due to recasting the screen pointer).

video_screen = create_video_bitmap(width, height);
show_video_bitmap(video_screen);
screen = video_screen;

I wonder why the screen pointer leads to a crash (on exit) if you let it point to the displayed screen. Also, I wonder if the "screen" pointer becomes obsolete after you use the show_video_bitmap function.

miran
Member #2,407
June 2002

You should not use the screen pointer if you use show_video_bitmap. Why would you want to do that anyway?

the allmighty Manual said:

Warning: video memory bitmaps are usually allocated from the same space as the screen bitmap, so they may overlap with it; it is therefore not a good idea to use the global screen at the same time as any surfaces returned by this function.

This is from the documentation of the create_video_bitmap() function.

--
sig used to be here

BAF
Member #2,981
December 2002
avatar

screen points to a special bitmap for the screen, you cant just change what bitmap is used for the screen by changing screen...

Geoman
Member #6,873
February 2006

I guess I'm nitpicky, but I'd like to know why the old "screen" pointer is still important, even if I only draw to something that was explicitly allocated. By using show_video_bitmap, I would expect that the old pointer becomes irrelevant, because what's its use after the graphics operations are routed elsewhere ?

Also, if I'm not allowed to change it (it seems like it), then why is its name something as general as "screen", instead of something more explicit like "screen_raw" or "screen_memory" or something like that (assuming here that "screen" is used as an entry value to the video memory as a whole) ?

(imo what's mentioned sofar is a bit vague -- and it's a problem in my case, cause I thought there wouldn't be a problem if I changed "screen").

Kitty Cat
Member #2,815
October 2002
avatar

The screen bitmap is like the main bitmap. In certain system, it holds all the available VRAM for Allegro to use. There, it's the entirety of the screen. And creating video bitmaps is basically making sub-bitmaps of the screen. On all systems, it holds extra info pertaining to the display. So when you exit the video mode, Allegro will also get bogus data about the display and crash.

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

Geoman
Member #6,873
February 2006

Okay, that's clear now :)

Go to: