lordmauve / wasabi2d

Cutting-edge 2D game framework for Python
https://wasabi2d.readthedocs.io/
GNU Lesser General Public License v3.0
156 stars 24 forks source link

Only 1 label per layer works #21

Closed dmoisset closed 4 years ago

dmoisset commented 4 years ago

I'm trying to add 2 labels into a layer, but the second one doesn't show (it seems to make the first one bolder. I.e., if I run:

from wasabi2d import Scene, run

scene = Scene()
text1 = scene.layers[0].add_label("Hello", pos=(100, 100))
text2 = scene.layers[0].add_label("World", pos=(200, 200))
run()

I expect to see both "hello" and "world", but I only see "hello". If I comment the assignment to text1, then "World" shows up. I think some GL object/array is being cached and reused too aggressively, but I couldn't understand how wasabi manages its caches....

dmoisset commented 4 years ago

Note: If I use different layers for each label, this works as expected

lordmauve commented 4 years ago

Thanks for the big report. That is very odd because there are multiple labels in both the Lander and Flappy Bird demos. Possibly this is an issue with use of BaseVertex?

What OpenGL version do you get? (I think this is scene.ctx.version_code?) And what OS/Version?

dmoisset commented 4 years ago

This is ubuntu 18.04.3. I'm using the proprietary NVIDIA drivers for the builtin nvidia card on my laptop. glxinfo reports:

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce MX150/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 390.116
OpenGL core profile shading language version string: 4.60 NVIDIA

I also see some issues (although different) in the Lander and flappy bird demos. The flappy bird label changed size and disappeared after a while; the lander hud labels sometimes are clipped, or some of the text disappears and appears later.

lordmauve commented 4 years ago

Ok, probably an index buffer allocation thing. This was something that was reworked hastily at PyCon UK to get it working under OpenGL 4.1. I'll investigate tomorrow.

lordmauve commented 4 years ago

Please can you try now with the master branch? Hoping it is fixed in a7c1d962584c17617e6e79bff12a0b7122ab97bd.

dmoisset commented 4 years ago

Works like a charm! thanks :)