![]() |
|
Screen Flicker in Linux |
AceBlkwell
Member #13,038
July 2011
![]() |
All, I’ll try to be to the point while still giving enough info to understand the issue I finished my game for grandkids. It works as intended in Windows. I can run from Windows or the compiler. When I go to Linux I run into issues. The program won’t run from the terminal. The Allegro alligator window opens but nothing happens. I can’t get the window to close. When I run from the compiler, the game works fine. The options on the title screen works fine. The issue is with the “setup” option. When chosen, the screen flickers as you move the mouse. I mean the title screen keeps popping up. The setup screen is a simple black screen with colored text. The text highlight as the mouse hovers. If you stop moving the mouse you will have the correct black screen and text or the colors texts on a transparent silver background allowing the title screen to bleed through. Occasionally it will just show the title screen. If you guesstimate where the screen sizes are located, they function as expected. I haven’t had a chance to dive into it yet. When running from the compiler in Linux I noticed this error on the exit of the game. I don't get in Windows. free(): double free detected in tcache 2 I looked this up online but the explanations seem to address specific coding without telling what the cause is. I read a lot of <i>“You shouldn’t put this there”<i> or <i>“You really don’t need this or that”<i> I didn’t see anything saying <i>“This error is due to array over run or lack of memory allocated?<i> In short, I’m hoping this type of screen result isn’t unheard of. Also that someone here knows what the free(): error is all about. Thanks. |
DanielH
Member #934
January 2001
![]() |
Linux is stricter than Windows on invalid memory access. There is probably the same issue in Windows, just you don't get an error. Could be many things and without seeing code, I don't know how to help. If you zip your entire game with assets and attach, I can compile it and look into it. |
AceBlkwell
Member #13,038
July 2011
![]() |
Daniel, Thanks. I'm attaching the code files. The site isn't allowing ZIP files, picture files or ttf files. You can use any picture files. Mine are 640x480. On the start up since yo won't have button locations, you can use P for play, S for setup, and Q for quit. Works with mouse or keyboard. Let me know what you find out. UPDATE. I believe the reason pictures and ZIPs wont upload is the lapse in time. The 11 files at 37K total bytes I uploaded took 20 min or better. |
DanielH
Member #934
January 2001
![]() |
I forgot this site doesn't allow zip files anymore. Some thoughts. Linux is strict in filename case as opposed to lazy Windows. Make sure filenames are case correct. You don't do any error checking on the settings.txt file open. It froze at that point. Had to fix it. The display's backbuffer should not be directly destroyed. It get destroyed whey you destroy the display. You destroying the target bitmap is giving you the double free error. Also, you should get target every instance not at the start. Didn't see anything else out of the ordinary. Don't know why it would be flickering in Linux. Be wary of set_window_position. I reported it, but in Windows it moves the window so the client area is at the set position. A bit annoying because that puts the outer frame and title bar outside the display. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
I need to correct you on something. The compiler compiles and links but in no way does it ever run the program. That's the terminal you're running that runs the program. I think I know what you meant, but terminology needs to be clear. 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 |
AceBlkwell
Member #13,038
July 2011
![]() |
Edgar, I’m sure you are right. To clarify, when I’m in Eclipse, I hit Ctrl+Shift+S to save everything. Then Ctrl+B to build. Finally, Ctrl-F11 to run. Eclipse probably does activate a terminal. But other than the flicker I mentioned in setup, the game works well. Well, I do get the free() error on exit. So, I close Eclipse out, go to my executable file to run directly, and the only thing that pops up is a blank window with the Allegro alligator in the title bar. I don’t have any error or trouble running in Windows, only Linux, which usually is the other way around. Thanks Daniel, Thanks for the info. I'm looking into it. Quick question, can you define instance? The only instance I'm familiar with is in declaring variables of a class. Granted my understanding is limited. In any case, if I have multiple instances but one default destroy, wouldn't the instances start stacking up the longer the game plays? Thanks |
DanielH
Member #934
January 2001
![]() |
The display has 2 internal bitmaps (the front buffer which is what you see, and the back buffer which you should draw to). When you flip_buffer, they switch positions. The front becomes the back and vice-versa. If you only grab the back buffer once then you risk having target point to the front buffer after a flip. And you do not want to draw to the front buffer. Only the back buffer. Drawing to the front buffer will have graphical glitches, screen tearing, etc. Not instance referring to object instances. I mean instance as in each instance of a set of code. I said to grab the buffer every instance. Meaning, you have multiple sections where you draw to display. You need to get the current target each time. That way you insure you are only drawing to the correct buffer. 1. get current target bitmap // Another option is just to get display's backbuffer. al_set_target_bitmap(al_get_display_backbuffer(display));
1. set target to your bitmap |
AceBlkwell
Member #13,038
July 2011
![]() |
Thanks for the break down Daniel. This should clear up a few issues I've had in the past. Thanks Again. |
DanielH
Member #934
January 2001
![]() |
There is a display option to request that the display is created with only a single buffer. That would then make it acceptable to only grab target at the beginning. Just remember, the buffers belong to the display and will get destroyed internally when you destroy the display. Never destroy yourself or you will get the double free error. Also, if you go the single buffer route make sure you vsync before drawing to the target. Never want to draw mid-refresh or you will have graphical glitches. Nothing major. |
AceBlkwell
Member #13,038
July 2011
![]() |
Daniel, I'm not sure how buffers are linked to the display. I use "target" & "buffer" because I copied code seen on the net. Are those two names designated for the display? I mean I could have call them anything. Plus I load multiple bitmaps. How does the display know those two are for buffering? *UPDATE* I commented out the window locator when I notice my window starts in the center in Linux regardless of the command. I figure it might be causing problem at the prompt. No change. The window still comes up with alligator title bar and black background. I'm getting an error in terminal that I didn't previously notice. I was running from the terminal in Dolphin. The error starts with One last observation, when I run ls at the prompt, the stars.bmp and still.bmp are listed but the S_L Title Screen.bmp has quotes around it. I wonder is there is something weird with this file. In any case, I'll keep you posted. |
DanielH
Member #934
January 2001
![]() |
In computer science, a buffer is a temporary storage area in memory that holds data while it's being moved from one place to another It is common to call the bitmap, you draw to, the buffer (double buffer, triple buffer etc). It's a hidden bitmap (storage area) for the drawing until flipped. Flpping "moves" it to the front. You can consider the front bitmap the display as that it what is viewed and the back bitmap a buffer until a flip. as for quotes around file name: it will do that if spaces in the filename. Windows does it to. You cannot have spaces in a command. for example: Say you had a text file called "This is my text file.txt" and tried to open it ">type This is my text file.txt". It will look for a a file called "This" with arguments "is my text file.txt". As for the x error: Do you have nvidia? Are the drivers updated? Just googled the error brought a few suggestions. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Ace, it's time you started debugging things yourself. I have a small guide to using gdb on the wiki here : https://github.com/liballeg/allegro_wiki/wiki/Debugging-and-logging-with-A5#debugging-with-gdb Run your program through gdb and it will stop when it crashes. It is still crashing on Linux. Type bt to get a backtrace and see where it is crashing in your code. 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 |
AceBlkwell
Member #13,038
July 2011
![]() |
Edgar, You are right, I should debug on my own. What once was meant as a joke, has become evident. If I didn't ask silly questions that I could research my self, no one would be on this site unfortunately. I often reply back and forth just to keep the site engaged. Daniel, I think you are right. I looked up the error yesterday afternoon and seen it was a potential NVIDIA issue. I even found a work around that I haven't tried yet for fear of causing other stuff not to run. Something I've had happen before. I was going to respond last night but couldn't find the time. Example, logging on and finally getting to a response screen today has taken me over 16 mins. That's a long time to wait if you are just trying to get out a quick blurb. Thanks again all. |
DanielH
Member #934
January 2001
![]() |
I don't mind your questions. I'll help you out, if I can. This site is barely hanging on. We started meeting on Discord and IRC has been active for years. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Ace, I was in no way suggesting you don't need help or you should do it all on your own. Some things (like debugging) are best done on the original computer that is having the problem. Oftentimes a program will crash or stop without an obvious cause, and that is when you want to run it through the debugger. This site is just about dead. ML has shown no interest in maintaining it for quite a few years now, and everyone has moved to Discord. In its day allegro.cc was the bomb. But now it's gone kablooey. It takes forever to load and most people are fed up with the problems this site has now. That said, I'll be glad to continue to help you with your programs here if you must or on Discord where you can get a much faster and more useful response. DanielH and I are about the only other people who still put up with this site, and it takes a while to reply, but I'll help if I can. Edgar aka Modulo5k aka Bugsquasher 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 |
|