how does "screen" interact with "show_video_bitmap" ?
Geoman

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

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.

BAF

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

Geoman

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

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.

Geoman

Okay, that's clear now :)

Thread #585751. Printed from Allegro.cc