|
Drawing Issue |
Morshock
Member #16,875
July 2018
|
Hello, Regards. 1#include <allegro5/allegro.h>
2#include <allegro5/allegro_image.h>
3
4using namespace std ;
5
6const char ChessBoardPath [] = "./Media/Images/ChessBoard.png" ;
7const int Dimensions = 512 ;
8
9int main ()
10{
11 al_init () ;
12 al_init_image_addon () ;
13
14 ALLEGRO_MONITOR_INFO Monitor ;
15 al_get_monitor_info (0, &Monitor) ;
16 al_set_new_window_title ("Test") ;
17 al_set_new_window_position (Monitor.x2 / 2 - Dimensions / 2, Monitor.y2 / 2 - Dimensions / 2) ;
18
19
20 ALLEGRO_DISPLAY * Display = al_create_display (Dimensions, Dimensions) ;
21
22 ALLEGRO_BITMAP * Frame = al_load_bitmap (ChessBoardPath) ;
23
24 al_draw_bitmap (Frame, 0, 0, 0) ;
25 al_flip_display() ;
26
27 sleep (10.0) ;
28
29 al_clear_to_color (al_map_rgb (255, 255, 255)) ;
30 al_flip_display () ;
31
32 sleep (10.0) ;
33
34 al_draw_bitmap (Frame, 0, 0, 0) ;
35 al_flip_display() ;
36 al_flip_display() ;
37
38 sleep (10.0) ;
39
40 al_clear_to_color (al_map_rgb (255, 255, 255)) ;
41 al_flip_display () ;
42 al_flip_display () ;
43
44 sleep (10.0) ;
45
46 al_destroy_bitmap (Frame) ;
47 al_destroy_display (Display) ;
48
49 return 0 ;
50}
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
I think it's a bug in Allegro. I seem to recall encountering this before. It takes two flips to render the first image. It may have something to do with the buffering method in use by the allegro linux driver. All subsequent flips should work properly. However, if you have to flip twice every time you draw something, that's a more serious bug. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Morshock
Member #16,875
July 2018
|
Hello, |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You mentioned you're using a VM. Which one? VBox? VMWare? What's your host OS? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
It would be good if you could file a bug for this: I tried your program on macos; I saw the image for 10s and then 30s of white. So, the double flip isn't a solution for all platforms. Also you would be better to use al_rest rather than sleep Pete
|
Morshock
Member #16,875
July 2018
|
@Edgar Reynaldo @Peter Hull |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Are you running 64 bit or 32 bit Ubuntu? Where did you get your Ubuntu image from? I can install it and try it myself, since I'm on Windows 10 with VirtualBox installed. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Morshock
Member #16,875
July 2018
|
64 bit version download from Ubuntu.com Update : Even in the 18.04 version the problem seems to persist. |
Niunio
Member #1,975
March 2002
|
I never had problems with al_flip_display(), using Xubuntu 16.04. I must say that I'm using the Allegro that is in the Ubuntu repository, not compiled by myself, and that I use Object Pascal instead of C++. ----------------- |
dthompson
Member #5,749
April 2005
|
If you're running Ubuntu from VirtualBox, it might be worth checking your VM's graphics settings. Most aren't initialised with too much video memory and with 3D acceleration turned off: {"name":"611648","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/a\/0a4a47aa38b9a88125f8ba87b363147a.png","w":713,"h":436,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/a\/0a4a47aa38b9a88125f8ba87b363147a"} In any case, I'm running Allegro on Ubuntu 18.04 (but on bare metal) without this issue. ______________________________________________________ |
Morshock
Member #16,875
July 2018
|
@dthompson |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I've almost finished downloading Ubuntu 18.04, but then I have to burn it to a DVD (Does 1.8GB fit on a DVD???) before I can install it in VBox and try this. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
I tried it on VirtualBox 5.2.12, macos host, running 64-bit Lubuntu 18.04 and the allegro that I got from 'apt install' I saw image-white-image-white i.e. single or double flip updated the screen. For my previous test on macos, I saw image-white-white-white. The single flips updated the screen, the double did something else (not sure what!) Edgar: you can load the downloaded .iso straight into VB without making a DVD (apologies if you know this already) Pete
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Peter Hull said: Edgar: you can load the downloaded .iso straight into VB without making a DVD (apologies if you know this already)
Who knows how long it will take to install though... EDIT EDIT2 Quote:
marc@VBOXUBUNTU:~$ sudo apt-get install allegro5 [sudo] password for marc: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? marc@VBOXUBUNTU:~$ sudo apt-get install allegro5 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package allegro5 marc@VBOXUBUNTU:~$ sudo apt-get install allegro Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package allegro marc@VBOXUBUNTU:~$
EDIT4 https://wiki.allegro.cc/index.php?title=Ubuntu_and_Allegro_5 My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
Edgar Reynaldo said: What does this mean? In my experience this happens when it's checking for updates (which it does in the background on a schedule) Also: I often find it says something about the updates not being valid - this happens if you save the VM state and restore it later. It takes a while for the system clock to catch up and during this time, the updates appear to be 'from the future' and are therefore not accepted. edit: it's liballegro5-dev
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Peter Hull said:
edit: it's liballegro5-dev OMG THAT WAS WAY TOO EASY!!!!11111 R0F1MA0 101 VBOXUBUNTU said:
marc@VBOXUBUNTU:>sudo apt-get install liballegro5-dev
EDIT 1
2#include "allegro5/allegro.h"
3
4
5enum COL {
6 R = 0,
7 G = 1,
8 B = 2
9};
10
11void Clear(COL c) {
12 static const ALLEGRO_COLOR cols[3] = {
13 al_map_rgb(255,0,0),
14 al_map_rgb(0,255,0),
15 al_map_rgb(0,0,255)
16 };
17 al_clear_to_color(cols[c]);
18}
19
20COL color = B;
21
22void SingleFlip() {
23 Clear(color = (COL)((int)((color + 1))%3));
24 al_flip_display();
25}
26
27void DoubleFlip() {
28 Clear(color = (COL)((int)((color + 1))%3));
29 al_flip_display();
30 al_flip_display();
31}
32
33int main(int argc , char** argv) {
34
35
36 if (!al_init()) {return 1;}
37
38 ALLEGRO_DISPLAY* d = al_create_display(800,600);
39
40 SingleFlip();
41 al_rest(3.0);
42
43 SingleFlip();
44 al_rest(3.0);
45
46 SingleFlip();
47 al_rest(3.0);
48
49 DoubleFlip();
50 al_rest(3.0);
51
52 DoubleFlip();
53 al_rest(3.0);
54
55 DoubleFlip();
56 al_rest(3.0);
57
58 return 0;
59}
It shows red, green, blue, red, green, blue for me. Perhaps it's different for images but I don't know. It would seem allegro is using a double buffer. That can be queried from allegro. EDIT2 {"name":"611655","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/6\/3648e51c667ebe7e3111e431aedd822c.png","w":799,"h":621,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/6\/3648e51c667ebe7e3111e431aedd822c"} My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
Edgar Reynaldo said: It works with an image as well. My brother!
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
We really need to make Elias's GIF addon to allegro an offical addon. So that way I could make a program that played a video of your gif blinking. Your avatar reminds me of oh what is it, Scream? {"name":"%22The_scream%22._Wellcome_L0011212.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/2\/02c6cfbe1acfa6dce84c0a0cfc44f68c.jpg","w":1164,"h":1666,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/2\/02c6cfbe1acfa6dce84c0a0cfc44f68c"} My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|