lunixbochs / glshim

OpenGL 1.x driver shim for OpenGL ES devices.
https://boards.openpandora.org/topic/11506-glshim/
MIT License
160 stars 32 forks source link

Rendering problem with linthesia on RPi2 #85

Open shiona opened 9 years ago

shiona commented 9 years ago

I'm not sure if this is a problem with glshim, linthesia (https://github.com/linthesia/linthesia), something else or not an actual problem at all, but this seemed like the best place to start digging.

When running linthesia on RPi2 (arch) without glshim rendering works, but is unplayably slow. Running the game with glshim and LIBGL_FB=1 the rendering is fast, but there is no text rendering at all. All text shown in the photo are tga images. Also mouse cursor is not drawn and the UI element texture coordinates seem off.

This is what I see with glshim (I would've taken a screenshot, but scrot and fbgrab both refused to capture linthesia, rendering the xterm somewhere behind) img_20150513_135226

This is what I see without glshim

Looking at the UI button texture file interfacebuttons_1_ it seems the elements are taken one too much to the left, possibly a little up.

Sorry to bother you with this if it has nothing to do with your project, but my google-fu wouldn't take me any further.

lunixbochs commented 9 years ago

I probably need to implement a missing feature or something. Have you tried the unstable branch?

I'll check linthesia out tonight and see what's up.

shiona commented 9 years ago

Thanks.

Just tried the unstable branch and the result was the same. I'm not sure if this is helpful info, but I get the following print at launch with both master and unstable:

libGL:loaded: libGLESv1_CM.so
libGL: unknown attrib 3
libGL: build on [date]
libGL: framebuffer output enabled
libGL:loaded: libEGL.so
lunixbochs commented 9 years ago

Those prints pretty much just mean glshim is working. The unknown attrib is unique but it's not a problem as the app renders anything at all.

If there are any prints later in the execution they might be helpful, but I'll also see them when I try it myself. It's probably a texture related bug or missing feature in glshim.

lunixbochs commented 9 years ago

I can't reproduce the texture offset problem. it works fine on my only active reference system.

I'm looking into the text rendering.

lunixbochs commented 9 years ago

A basic problem here is the lack of support for glBitmap and glDrawPixels in display lists, which is a hard problem to fix - I need to copy the memory passed in, which requires me to add a bit of memory management to lists so they don't leak the bitmaps.

I worked around that, but it seems the glBitmap inside gdk is never called, so I don't get a chance to render:

lunixbochs commented 9 years ago

Oh, I need to implement glXUseXFont for this. Try ptitseb's fork in the meantime: https://github.com/ptitseb/glshim

shiona commented 9 years ago

ptitseb's fork doesn't seem to work at all. Game boots, but is as slow as without glshim and I get a ton of "libGL: warning, gles_glBlendFuncSeparate is NULL" lines.

Also are you able to repro the missing cursor, or am I just missing some package there?

lunixbochs commented 9 years ago

I didn't see a cursor either. Might also be X11 related. I haven't looked into how it draws the cursor yet. I might implement the font stuff tomorrow.

lunixbochs commented 9 years ago

I added glXUseXFont support using glshim's embedded monospace font, but I haven't tested it yet. It's in the unstable branch if you want to try it.

shiona commented 9 years ago

I'll take a look tonight. Any idea about the cursor? Or any example projects where the cursor works and whose code could be of use to compare to?

lunixbochs commented 9 years ago

They might be trying to set a cursor using X11. The solution could be to patch in an OpenGL cursor. I didn't find their cursor code when I skimmed the source so I don't know yet.

shiona commented 9 years ago

Now I actually get a crash. The DISPLAY is there so I could run the command over ssh on a machine which has a browser, the result is the same when run locally.

$ DISPLAY=:0 LD_LIBRARY_PATH=/home/pi/build/glshim-unstable/lib LIBGL_FB=1 linthesia
libGL:loaded: libGLESv1_CM.so
libGL: unknown attrib 3
libGL: built on May 18 2015 16:20:07
libGL: framebuffer output enabled
libGL:loaded: libEGL.so
*** Error in `linthesia': free(): invalid next size (fast): 0x0067cf60 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x67e3c)[0x75972e3c]
/usr/lib/libc.so.6(+0x6dad4)[0x75978ad4]
/usr/lib/libc.so.6(+0x6e44c)[0x7597944c]
/home/pi/build/glshim-unstable/lib/libGL.so.1(render_raster+0x2ec)[0x76d64290]
/home/pi/build/glshim-unstable/lib/libGL.so.1(glXSwapBuffers+0x1e4)[0x76d7e57c]
======= Memory map: ========
...
lunixbochs commented 9 years ago

Alright, I've made some progress. Linthesia actually triggered a few latent bugs :)

I fixed the first two and the last depends on #88

lunixbochs commented 9 years ago

It's now rendering text, but scaled weirdly and in the wrong spot.

shiona commented 9 years ago

For me it's not exporting mat4 functions:

$ DISPLAY=:0 LD_LIBRARY_PATH=/home/pi/build/glshim-unstable/lib LIBGL_FB=1 linthesia
libGL:loaded: libGLESv1_CM.so
libGL: unknown attrib 3
libGL: built on May 19 2015 06:28:24
libGL: framebuffer output enabled
libGL:loaded: libEGL.so
linthesia: symbol lookup error: /home/pi/build/glshim-unstable/lib/libGL.so.1: undefined symbol: mat4_identity

$ nm lib/libGL.so | grep mat4
     U mat4_frustum
     U mat4_identity
     U mat4_load
     U mat4_mul
     U mat4_mul_vec2
     U mat4_mul_vec3
     U mat4_mul_vec4
     U mat4_ortho
     U mat4_rotate
     U mat4_save
     U mat4_scale
     U mat4_translate
     U mat4_transpose
lunixbochs commented 9 years ago

You should run cmake again. I added c files.

shiona commented 9 years ago

That worked, but the scaling you mentioned causes the menu to end up in one corner as garbage. img_20150519_101632 img_20150519_101645

shiona commented 9 years ago

Any ideas or plans on investigating this issue?

lunixbochs commented 9 years ago

The initial matrix problem is fixed for me if I press enter (the subsequent screens and main screen work after that). I ordered a raspberry pi 2 so I can try to reproduce the rest.

lunixbochs commented 9 years ago

First part is fixed by 359f81b14caec63ba512a6f80f9004b56bf8068b.

The square in the bottom left is caused by Linthesia calling glViewport(0, 0, 200, 200). Pressing enter takes you to the next screen with no problem.

For some reason the text is extremely offset. Not sure why yet.

Also, glBitmap is extremely slow, so I'm probably going to modify glXUseXFont to generate a sprite sheet texture for the font.