glshim icon indicating copy to clipboard operation
glshim copied to clipboard

Rendering problem with linthesia on RPi2

Open shiona opened this issue 9 years ago • 20 comments

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.

shiona avatar May 13 '15 11:05 shiona

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.

lunixbochs avatar May 13 '15 16:05 lunixbochs

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

shiona avatar May 13 '15 18:05 shiona

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 avatar May 13 '15 18:05 lunixbochs

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 avatar May 15 '15 01:05 lunixbochs

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:

  • https://github.com/linthesia/linthesia/blob/master/src/TextWriter.cpp#L63
  • https://github.com/DX-MON/gtkGLExt2/blob/master/gdk/x11/gdkglfont-x11.c#L169

lunixbochs avatar May 15 '15 02:05 lunixbochs

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

lunixbochs avatar May 15 '15 02:05 lunixbochs

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?

shiona avatar May 15 '15 06:05 shiona

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 avatar May 15 '15 06:05 lunixbochs

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.

lunixbochs avatar May 18 '15 07:05 lunixbochs

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?

shiona avatar May 18 '15 08:05 shiona

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.

lunixbochs avatar May 18 '15 15:05 lunixbochs

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: ========
...

shiona avatar May 18 '15 16:05 shiona

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

  • Display lists outright ignored some GL functions which aren't found in GLES (including glBitmap)
  • A free() crash which happened if an app never called glViewport
  • glRasterPos is inaccurate (I suspected this, and it's the reason I haven't merged unstable to master in a while)

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

lunixbochs avatar May 19 '15 04:05 lunixbochs

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

lunixbochs avatar May 19 '15 06:05 lunixbochs

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

shiona avatar May 19 '15 07:05 shiona

You should run cmake again. I added c files.

lunixbochs avatar May 19 '15 07:05 lunixbochs

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 avatar May 19 '15 07:05 shiona

Any ideas or plans on investigating this issue?

shiona avatar May 26 '15 14:05 shiona

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 avatar May 26 '15 19:05 lunixbochs

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.

lunixbochs avatar Aug 03 '15 01:08 lunixbochs