as far as I can see, if we want to switch between a windowed mode and into a full screen (by which I don't mean fullscreen windowed), and back, a new display has to be created. If this is so, then does this mean we have to reload all the graphics ?

*nods* Fortunately, loading and sending textures to a graphics card is lightning fast, even if you've got a ton of them, and on an OS like Windows they'll all be buffered anyways from recent access.

This is why I group all of my graphics loading and unloading into their own routines which I can call whenever I need to. For specialized graphics that you only need loaded for certain sections of code, or if you're using a dynamic loading/unloading system, you'll need to track what's already loaded and reload them if you switch the display mode.

I don't know how Direct X does it, but when I was using raw OpenGL, I'd load the pixels for an image into system memory using fstream functions, then tell OpenGL to upload it as a texture. If I didn't free() this image in system memory, I could have uploaded it as many times as I wanted.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

I'm working on a 2D game. For the PNG images I use, I created a library that will load them only when requested, will only create a bitmap once for all objects to share (to prevent loading multiple copies of the same bitmap into RAM), and will prevent needing to constantly open and close a file on the drive (slow).

What do you mean by "we have to reload all the graphics"? Do bitmaps need to be reloaded from PNG image files when switching to fullscreen? Is my library still necessary?

You don't have to reload from disk, you just have to reupload the bitmap data to the gpu. That is, all of the textures need to be re-created.

With Allegro 5.0 I believe you have to take all of your existing normal (non-memory) bitmaps and call new_bitmap =al_clone_bitmap(old_bitmap); on each one. With Allegro 5.1 I believe you can use al_convert_bitmap(bitmap); or possibly (I'm not sure on this) al_convert_bitmaps(); which should take all bitmaps that were lost (assuming you didn't turn on the ALLEGRO_NO_PRESERVE_TEXTURE flag) and reupload them to the gpu. This is assuming that the current bitmap flags have ALLEGRO_VIDEO_BITMAP set, which is the default (you actually have to set ALLEGRO_MEMORY_BITMAP to turn ALLEGRO_VIDEO_BITMAP off iirc).

DX is fun in that, if your window is hidden for some reason, it will loose the contents of video memory, so you have to re-upload. Android is a bit worse in that if android sees fit, it will decide to destroy the EGL context, thus losing all video memory contents as well as the entire EGL and GLES state. Allegro has to bend over backwards to hide that from the user as much as possible.

As for the case of manually destroying and re-creating a display, I belive allegro will convert bitmaps to memory bitmaps. Once you have a new display, you can do the clone or convert trick mentioned above.

In most (all) of my engine designs I can handle having to redraw the screen when the state is destroyed. Would there be any speed benefit to disabling Allegro's magic on that part and handling it at the game level?

It's not just about the screen needing redrawn, you also need to get your bitmaps re-uploaded to the gpu. Which which is what happens when you either re-al_load_bitmap, or use al_clone_bitmap or al_convert_bitmap[s].

But there can be a speed advantage to disabling Allegro's magic ability to preserve your bitmaps automagically. Note though that the automagicall bitmap preservation only happens with D3D and GLES (android for sure, not sure about iOS) so far as far as I know. Regular OpenGL makes sure your textures aren't lost.