I've played other peoples examples using triple buffering in fullscreen mode, but I c an't seem to play mine in fullscreen mode. The exe will play, but once it get's to the function that uses triple buffering, it shuts down.
Here's the function (For those of you perfectionists out there: My code is a little messy and CAN be cleaned up, but I don't really do all of that until the function does what I want it to do. So please, don't waste my time telling me how I can clean it up or scolding me because it isn't clean. Thanks..)
BeginDrawing() function:
void BeginDrawing() { acquire_bitmap(buffer); }
EndDrawing() function:
Is there anything that I'm doing wrong in my forest_stage function that fullscreen doesn't like?
Search on the forums for Chris Barrys 'screen update' code. That lets you chose double buffering, page flipping, or triple buffering and returns error codes if it fails. Maybe that will help you.
Have you checked to see if triple buffering is working? what you might also find useful is trying to store your sprites as video memory too. Anyway, you didn't post your code for your graphics initialisation, but you should do something like this, what it does is determine what mode I want and tries fallbacks if it can't, e.g. if it can't get triple then it tries paging, etc. Note the triple buffering code first sees if it is available and if not it attempts to kick-start it.
| 1 | switch(GameConfiguration->CapsGraphics.GraphicsMode) |
| 2 | { |
| 3 | case MODE_TRIPLE: |
| 4 | if(gfx_capabilities & GFX_CAN_TRIPLE_BUFFER) CanDoIt=true; |
| 5 | else CanDoIt=(enable_triple_buffer()==0); |
| 6 | |
| 7 | if(CanDoIt) |
| 8 | { |
| 9 | Configuration::LogEntry("System Wanted and can do Triple buffering"); |
| 10 | BitmapPages[0]=create_video_bitmap(GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 11 | BitmapPages[1]=create_video_bitmap(GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 12 | BitmapPages[2]=create_video_bitmap(GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 13 | if(!BitmapPages[0] || !BitmapPages[1] || !BitmapPages[2]) |
| 14 | { |
| 15 | Configuration::LogEntry("Failed creating the 3 video bitmaps for Triple Buffering. Trying Paging"); |
| 16 | if(BitmapPages[0]) destroy_bitmap(BitmapPages[0]); |
| 17 | if(BitmapPages[1]) destroy_bitmap(BitmapPages[1]); |
| 18 | if(BitmapPages[2]) destroy_bitmap(BitmapPages[2]); |
| 19 | BitmapPages[0]=BitmapPages[1]=BitmapPages[2]=NULL; |
| 20 | //then fall through to paged |
| 21 | CanDoIt=false; |
| 22 | } |
| 23 | else |
| 24 | { |
| 25 | clear_to_color(BitmapPages[0],makecol(0,0,0)); |
| 26 | clear_to_color(BitmapPages[1],makecol(0,0,0)); |
| 27 | clear_to_color(BitmapPages[2],makecol(0,0,0)); |
| 28 | Configuration::LogEntry("Got Triple Buffering"); |
| 29 | GameConfiguration->CapsActualSystem.GraphicsMode=MODE_TRIPLE; |
| 30 | } |
| 31 | } |
| 32 | else |
| 33 | Configuration::LogEntry("Wanted Triple but System reported it cannot. Trying Paged"); |
| 34 | |
| 35 | if(CanDoIt) |
| 36 | break; |
| 37 | case MODE_PAGED: |
| 38 | BitmapPages[0]=create_video_bitmap(GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 39 | BitmapPages[1]=create_video_bitmap(GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 40 | BitmapPages[2]=NULL; |
| 41 | if(!BitmapPages[0] || !BitmapPages[1]) |
| 42 | { |
| 43 | Configuration::LogEntry("Failed creating the 2 video bitmaps for Paged Buffering. Trying Double"); |
| 44 | if(BitmapPages[0]) destroy_bitmap(BitmapPages[0]); |
| 45 | if(BitmapPages[1]) destroy_bitmap(BitmapPages[1]); |
| 46 | BitmapPages[0]=BitmapPages[1]=BitmapPages[2]=NULL; |
| 47 | //then fall through to system |
| 48 | CanDoIt=false; |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | clear_to_color(BitmapPages[0],makecol(0,0,0)); |
| 53 | clear_to_color(BitmapPages[1],makecol(0,0,0)); |
| 54 | Configuration::LogEntry("Got Paged Buffering"); |
| 55 | GameConfiguration->CapsActualSystem.GraphicsMode=MODE_PAGED; |
| 56 | CanDoIt=true; |
| 57 | } |
| 58 | if(CanDoIt) |
| 59 | break; |
| 60 | case MODE_SYSTEMDOUBLE: |
| 61 | BitmapPages[0]=create_system_bitmap(GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 62 | BitmapPages[1]=BitmapPages[2]=NULL; |
| 63 | //should always be a bitmap as system falls back to memory bitmap if not available |
| 64 | if(BitmapPages[0]) |
| 65 | { |
| 66 | if(is_system_bitmap(BitmapPages[0])) |
| 67 | { |
| 68 | GameConfiguration->CapsActualSystem.GraphicsMode=MODE_SYSTEMDOUBLE; |
| 69 | clear_to_color(BitmapPages[0],makecol(0,0,0)); |
| 70 | Configuration::LogEntry("Got System Double Buffering."); |
| 71 | CanDoIt=true; |
| 72 | break; |
| 73 | } |
| 74 | else |
| 75 | { |
| 76 | destroy_bitmap(BitmapPages[0]); |
| 77 | BitmapPages[0]=NULL; |
| 78 | Configuration::LogEntry("Failed creating System bitmap. Trying Double"); |
| 79 | CanDoIt=false; |
| 80 | } |
| 81 | } |
| 82 | else |
| 83 | Configuration::LogEntry("Failed to get a System, trying double"); |
| 84 | default: |
| 85 | //double - DR needs to be done by user |
| 86 | Configuration::LogEntry("Using double buffering"); |
| 87 | BitmapPages[0]=create_bitmap(GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 88 | if(BitmapPages[0]) |
| 89 | { |
| 90 | GameConfiguration->CapsActualSystem.GraphicsMode=MODE_DOUBLE; |
| 91 | Configuration::LogEntry("Got Double Buffering"); |
| 92 | CanDoIt=true; |
| 93 | } |
| 94 | else |
| 95 | Configuration::LogEntry("Failed to get a Double Buffer. Crikey!"); |
| 96 | } |
then in my drawing loop I do something like this:
| 1 | //set correct buffer |
| 2 | //double/system is always pointing at one and only page |
| 3 | //need to modify if using dirty. |
| 4 | if(this->GameConfiguration->CapsActualSystem.GraphicsMode<=MODE_SYSTEMDOUBLE) |
| 5 | { |
| 6 | //double buffering to either a memory or a system bitmap |
| 7 | if(GameConfiguration->CapsGraphics.VSync) vsync(); |
| 8 | blit(DrawingSurface, screen, 0, 0, 0, 0,GameConfiguration->CapsGraphics.ScrWidth,GameConfiguration->CapsGraphics.ScrHeight); |
| 9 | } |
| 10 | else |
| 11 | { |
| 12 | //release_bitmap(DrawingSurface); |
| 13 | if(this->GameConfiguration->CapsActualSystem.GraphicsMode==MODE_PAGED) |
| 14 | { |
| 15 | show_video_bitmap(BitmapPages[BitmapPagesActive]); |
| 16 | //show_video_bitmap(DrawingSurface); |
| 17 | BitmapPagesActive=1-BitmapPagesActive; |
| 18 | DrawingSurface=BitmapPages[BitmapPagesActive]; |
| 19 | } |
| 20 | else |
| 21 | { |
| 22 | //triple |
| 23 | do{}while(poll_scroll()); |
| 24 | request_video_bitmap(BitmapPages[BitmapPagesActive]); |
| 25 | //request_video_bitmap(DrawingSurface); |
| 26 | BitmapPagesActive=(BitmapPagesActive+1)%3; |
| 27 | DrawingSurface=BitmapPages[BitmapPagesActive]; |
| 28 | } |
| 29 | } |
So when I'm drawing my sprites and stuff before I call this code all I need worry about is blitting to 'DrawingSurface' and it does it, regardless of whether I'm using triple, paging, double, system double.
e.g. draw_sprite(DrawingSurface,somesprite,x,y);
The params may be the wrong way round, but you get the picture 
the 'BitmapPagesActive' is just an int that tells me which is the currently active drawing page. It is an index to the array of bitmaps created at top.