![]() |
|
Unsupported virtual resolution |
Danikaze
Member #8,889
August 2007
![]() |
Hello everybody! I'm coding in Linux, and testing my progress in Windows too. When I set up graphic modes, I use this: set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, w*2, h) It works perfectly on Linux, but I get an error on Windows: Is there any restriction on sizes for virtual resolution? I used w*2, h to make a double buffering (flipping with show_video_bitmap) and it works on Linux. If I try with set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, 0, 0) on Windows, it goes ok, but slow. Any suggestion? |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
You pretty much don't use the virtual screen nowadays.
|
Damian Yerrick
Member #186
April 2000
|
Are system bitmaps significantly slower than ordinary bitmaps? |
Danikaze
Member #8,889
August 2007
![]() |
Jonathan That's how I made double buffering: Initializing: if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, w*2, h)==0) {; pantalla_buffer[0] = create_video_bitmap(SCREEN_W, SCREEN_H); pantalla_buffer[1] = create_video_bitmap(SCREEN_W, SCREEN_H); pantalla_actual = 0; pantalla = pantalla_buffer[pantalla_actual]; fps_frame_time = (fps == 0)? 0 : 1000/fps; } else { allegro_message("Error: %s\n", allegro_error); } Flipping function: void flip() { show_video_bitmap(pantalla); pantalla_actual = (pantalla_actual+1)%2; pantalla = pantalla_buffer[pantalla_actual]; }
|
Milan Mimica
Member #3,877
September 2003
![]() |
Use this: #ifdef ALLEGRO_VRAM_SINGLE_SURFACE set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, w*2, h) #else set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, 0, 0) #endif
Quote:
f I try with set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, 0, 0) on Windows, it goes ok, but slow.
Keep in mind that reading from video bitmaps is very slow.
-- |
Danikaze
Member #8,889
August 2007
![]() |
Thanks! But then... how double buffering is made? |
Vanneto
Member #8,643
May 2007
|
You draw everything onto a sourface, the buffer, that is stored in memory. Then in the end you draw the buffer to the screen. Drawing: PlayerSprite --> Buffer Buffer --> Screen Easy! In capitalist America bank robs you. |
Milan Mimica
Member #3,877
September 2003
![]() |
In double buffering you draw something onto the buffer (in allegro, that's usually a memory bitmap) and then blit the contents of the buffer to the screen. This can be faster then page flipping if you are using transparency because reading from allegro's video bitmaps is slow. In page flipping you draw onto one page of video memory and then "flip" the pages to display the page you were previously drawing to. I can be faster then double buffering because no data copying occurs.
-- |
Danikaze
Member #8,889
August 2007
![]() |
So... If I have understood (I don't think so), double buffering is doing in this way:
That's all? Or is it needed 2 buffers to do it? Sorry for all those questions ^_^' |
Audric
Member #907
January 2001
|
You got it right. However the vsync() function does not have a precise timing, forces a wait, and is based on busy-waiting; so it's not all perfect. |
Danikaze
Member #8,889
August 2007
![]() |
After watching replies, I made this, to use page_flip or double buffering depending on PAGE_FLIP directive (sorry for variable names, I'm Spanish, just know "pantalla"="screen" global variables: #ifdef PAGE_FLIP static BITMAP* pantalla_buffer[2]; static int pantalla_actual; #endif function to init graphics:
Function to draw in screen: void flip() { #ifdef PAGE_FLIP show_video_bitmap(pantalla); pantalla_actual = (pantalla_actual+1)%2; pantalla = pantalla_buffer[pantalla_actual]; #else blit(pantalla, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); #endif }
|
Vanneto
Member #8,643
May 2007
|
I made a class some time ago with Mirans help. You can use it to have more buffers whitout changing a lot of code. For example:
Class(es) attached. P.S. The classes dont do error checking. In capitalist America bank robs you. |
Danikaze
Member #8,889
August 2007
![]() |
Thanks Vanneto! Even if I am using C (not C++) so I can't use your classes, and I have the code already implemented, it was very useful so I can check my code is ok now and I could see how the triple buffering is used. ^_^ PS: Thanks to everyone who replied here |
|