OneLoneCoder / olcPixelGameEngine

The official distribution of olcPixelGameEngine, a tool used in javidx9's YouTube videos and projects
Other
3.87k stars 914 forks source link

olcExampleProgram draws white screen on Linux #108

Closed gurkanctn closed 4 years ago

gurkanctn commented 4 years ago

I was just able to compile and run the example program.

(My second program on Linux, right after Hello World of course.)

The example program draws white pixels, instead of random colors, resulting in a white blank screen.

When I debug with a breakpoint at the Draw command line (line 24 as of now) I see that the rand() returns random values, and rand() %255 returns meaningful (and seemingly random values, 110, 56, 156, etc.).

Therefore I suppose either the olc:: pixel() function or the Draw function, or a library of my setup is to blame for the issue.

Any help would be appreciated.

OneLoneCoder commented 4 years ago

Hi gurkan,

Im reasonably confident many people have had the example program running, so I'm going to suggest there is a setup issue - and given the program compiles, it could well be a driver issue on your system.

It would be useful to know the following information. Your linux setup, your compiler setup, the compile command you used, and what graphics drivers you may be using. Also, even though it displays white, do you see the frame rate in the titlebar? If you dont, then chances are its simply not able to interact with your graphics driver, and simply locks up.

gurkanctn commented 4 years ago

Hello Javidx9, thanks for the reply.

I'm using Lubuntu (lightweight Ubuntu) on a quite old computer, from 2005 I guess, for a challenge :)

I've installed gcc, g++, x11, g++-8, libpng, glew, glfw, and freeglut.

Details of my compile command (and quick history of my Linux setup) is here: https://github.com/OneLoneCoder/olcPixelGameEngine/issues/99#issuecomment-622107252

The compile command was: g++-8 olcExampleProgram.cpp -o ExampleProgram -lX11 -lGL -lpthread -lpng -lstdc++fs -std=c++17

The title bar shows the frame rate correctly (28 in release and a few in debug mode). The computer is quite an old one, as you may guess :) I normally use a modern PC for daily stuff, running Win 10, without problems.

I have not tried running any other drawing routines (rectangle, text etc.), yet, on Linux.

Unfortunately I don't know the graphics driver, but I'll check that. Could the problem be a consequence of installing several (3) GL libraries? I'll try uninstalling some :)

Thanks for any advice, suggestions or possible solutions.

gurkanctn commented 4 years ago

I've tried a few more configuration changes but still cannot display any non-white pixel/graph on the screen: e.g.

Clear(olc::BLACK);
FillCircle(100, 100, 30, olc::RED);

do not work, even after uninstalling the Glew and Glfw packages, recompiling the code, and updating my Lubuntu packages, then recompiling the code again.

I've also tried updating the video driver, using the following commands, still no progress:

sudo add-apt-repository ppa:oibaf/graphics-drivers
sudo apt update
sudo apt dist-upgrade
OneLoneCoder commented 4 years ago

Could you try resizing the screen once its launched? Do you see anything interesting happen. This is all pointing at your GPU simply being incompatible or bad drivers. What is it? Can you run any OpenGL applications, glxgears for example?

gurkanctn commented 4 years ago

Could you try resizing the screen once its launched? Do you see anything interesting happen. This is all pointing at your GPU simply being incompatible or bad drivers. What is it?

Tried resizing, depending on the form factor of the window, the non-drawable region is black. Other than that, no progress at all.

I think you're right that it's most probably a graphics card or driver issue. I will try to find&update drivers once again.

gurkanctn commented 4 years ago

Small progress regarding the detail of the problem: I've set MESA_DEBUG=1 (to report any OpenGL problems on the screen), and this is what the error seems to be: Mesa: User error: GL_INVALID_VALUE in glTexImage2D(invalid width=128 or height=48 or depth=1)

OneLoneCoder commented 4 years ago

Ahh! That's very useful! You will be restricted to sprites/resolutions with sizes that are powers of two. This was a common design on (really) old graphics hardware XD

OneLoneCoder commented 4 years ago

Try setting a screen size of 128 by 128, it may just work then

gurkanctn commented 4 years ago

haha. Actually, I read somewhere the opposite so I intentionally tried non powers of two all the time. :)))

you just made my day! Will try and report.

Thanks a lot.

gurkanctn commented 4 years ago

Conclusion: the problem was the driver incompatibility. And the solution: is to use powers of two for the screen and sprites.

Tested and verified. Thanks.

aaarbk commented 7 months ago

I'm running Windows 11 ARM Edition in a VM running on Mac Silicon, and encountered the same issue (white screen) while trying to run olcExampleProgram - the solution posted in this thread worked for me. I'm just curious to know why this might be happening? I do realise that my compilation/runtime environment isn't the most conventional, but I'm certainly not on "old" hardware!

OneLoneCoder commented 7 months ago

Your VM will to some extent be emulating a GPU interface. The "fake drivers" for this may not be cutting edge in the slightest. Certainly however, people manage to get PGE working in a VM, thats how I test the linux builds - so it smells a bit like your VM graphics drivers may be a little out of date?

aaarbk commented 7 months ago

@OneLoneCoder I appreciate the super-fast response! I tried digging around for graphics driver related stuff, but haven't turned up anything useful yet. I might try a different virtualisation program (currently using the latest version of VMware Fusion) but it's no biggie - just messing around with the library, really, so powers-of-two sizes will do fine.