gles2 C framework now with raspberry pi support! :o


37 posts   Page 1 of 2   1, 2
by chris_c » Fri Jun 29, 2012 12:55 am
I got my PI today - after giving RS spares an unauthorised interest free loan for more than a month.... finally! - me bitter..... nah :D

So I added support for the raspberry pi (previously it was xorg only)

I've included keyboard support but mouse support is missing for now....

it requires libpng-dev, pkg-config and build-essentials and possibly something else depending on your pi's setup (I use raspbian btw - kudos to the guy who did all the hard-float work!)


its the first time I've used GIT as well and it seem a thundering PITA so if there are files missing please be kind!

there are some weird inline warnings while compiling, from the broadcom libs, but it all links ok

the default makefile target builds a half finished 3d invaders type game (will eventually be a tutorial)
make simple will build simple.c which is the simplest example that uses most of the "api" to rotate a cube and display the current frame number with text

oh yeah you'll need this ;)
https://github.com/chriscamacho/gles2framework

Enjoy!
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by chris_c » Sat Jun 30, 2012 8:05 am
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by gregeric » Sat Jun 30, 2012 2:39 pm
Hi Chris.

Also on Raspbian here, but haven't been able to buld your sources.

Added dependencies as indicated, but fails here:
gcc o/obj.o o/support.o o/alien.o o/cube.o o/ship.o o/shot.o o/aabb.o o/mat3.o o/mat4.o o/plane.o o/quaternion.o o/ray2.o o/utility.o o/vec2.o o/vec3.o o/vec4.o o/main.o -o main -lGLESv2 -lEGL -lm -lbcm_host -L/opt/vc/lib `pkg-config libpng --libs`
/usr/bin/ld: warning: libvcos.so, needed by /opt/vc/lib/libGLESv2.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libvchiq_arm.so, needed by /opt/vc/lib/libGLESv2.so, not found (try using -rpath or -rpath-link)
/opt/vc/lib/libEGL.so: undefined reference to `vchiq_initialise'
/opt/vc/lib/libbcm_host.so: undefined reference to `vchi_service_close'
/opt/vc/lib/libbcm_host.so: undefined reference to `vcos_dummy_thread_create'
etc...

I checked with
find / -name libvcos.so
& see that both libvcos.so & libvcgiq_arm.so are sitting in /opt/vc/lib. So ???

I'm here to learn, any help appreciated. Thanks!
Posts: 137
Joined: Mon Nov 28, 2011 10:08 am
by chris_c » Sat Jun 30, 2012 7:11 pm
I'm using raspbian myself as well, I know at least one other person (on youtube) has got it compiling

are you using the version 2 image fully updated with the latest firmware?

I'm not quite sure what's causing the problem - sorry

Please do let me know how you get on !


you could try adding -lvcos to the LIBS variable in the Makefile but you shouldn't have to!

I'd see if updating fixes it, first if you're not updated
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by gregeric » Sat Jun 30, 2012 8:22 pm
Hi. I cloned again, but it looks like the new makefile doen't create the target "o" directory. After creating that manually, the compile fails at the same point. Will have another look later. Regards.
Posts: 137
Joined: Mon Nov 28, 2011 10:08 am
by gregeric » Sat Jun 30, 2012 10:02 pm
Got it to build at last, taking your advice I added both -lvcos -lvchiq_arm to the LIBS variable. Had to run it with

LD_LIBRARY_PATH=/opt/vc/lib ./main

And as per my previous experience viewtopic.php?p=109704#p109704 , I had to reduce the overclocking of the arm from 850MHz to 800 to avoid freezes when the GPU is also employed.

Nice!
Posts: 137
Joined: Mon Nov 28, 2011 10:08 am
by chris_c » Sun Jul 01, 2012 12:03 am
doh!

I forgot in the folder /etc/ld.so.conf.d

create a file called vc.conf or blah.conf if your that way inclined :o)

it should contain

/opt/vc/lib


I'd done this to compile Quake and forgot all about it, I'll add something in the readme

thanks!

edited readme - you shouldn't need the extra libs in the makefile or the LD_LIB_PATH mod when running....
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by gregeric » Mon Jul 02, 2012 9:08 pm
Hi Chris. I added the .conf file in /etc/ld.so.conf.d and the source then built without the previous mods.

Still need the LD_LIBRARY_PATH= mod when running, otherwise I get:
./main: symbol lookup error: /opt/vc/lib/libGLESv2.so: undefined symbol: client_tls

Must be some other environment tweak needed on Raspbian?

PS enjoyed the new physics demo!
Posts: 137
Joined: Mon Nov 28, 2011 10:08 am
by chris_c » Tue Jul 03, 2012 3:39 am
well...

I'm mystified! can you confirm that you are on the latest raspbian AND you have recently done rpi_update, please?

at least its working for you but I don't like untidy loose ends like this.... :(

I'm currently working on finding out how much "physics" I can throw at the pi and it still look "fluid" >:)
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by gregeric » Tue Jul 03, 2012 12:30 pm
Hi Chris.

I'm using Mike's original Pisces image with regular apt-get update, apt-get upgrade, & rpi-update. Hopefully someone will pitch in with a solution (to what is but a minor issue). Regards.
Posts: 137
Joined: Mon Nov 28, 2011 10:08 am
by chris_c » Tue Jul 03, 2012 1:55 pm
ah thats why!

time you moved to the r2 image ;)
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by gdgt » Sat Jul 07, 2012 8:04 am
did you try running 'sudo ldconfig' after adding your /etc/ld.conf.d file?
Posts: 1
Joined: Sat Jul 07, 2012 8:02 am
by kevs3d » Wed Sep 19, 2012 9:14 am
Hi,

I'm trying to compile the framework, I'm seeing this error after some successful bits:

m_host -L/opt/vc/lib `pkg-config libpng --libs`
o/input.o: In function `doEvents':
input.c:(.text+0x310): undefined reference to `__x_display'
input.c:(.text+0x320): undefined reference to `__eventWin'
o/support.o: In function `closeNativeWindow':
support.c:(.text+0x50): undefined reference to `restoreKbd'
o/support.o: In function `closeContext':
support.c:(.text+0x1bdc): undefined reference to `__mouse_fd'
collect2: ld returned 1 exit status
make: *** [invaders] Error 1

What am I missing (sorry I've got some way to learn on linux yet...)

Cheers,

Kev
--
http://www.kevs3d.co.uk/dev - HTML5 canvas games, demos and utils.
Posts: 23
Joined: Fri Sep 07, 2012 6:26 pm
by chris_c » Wed Sep 19, 2012 12:10 pm
kevs3d wrote:m_host -L/opt/vc/lib `pkg-config libpng --libs`

errm dunno what this is my supplied Makefile shouldn't be invoking it...

I assume you're running make actually on the PI ?
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by kevs3d » Wed Sep 19, 2012 5:49 pm
Sorry that's a duff copy/paste line - it's then end of the gcc that is building invaders. The rest of the error shown is pasted correctly, yes it's building on the pi (where else? :) )

I'm using the rpi_noX platform option if that makes any difference...
--
http://www.kevs3d.co.uk/dev - HTML5 canvas games, demos and utils.
Posts: 23
Joined: Fri Sep 07, 2012 6:26 pm
by chris_c » Wed Sep 19, 2012 7:53 pm
which target is failing?
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by chris_c » Sat Sep 22, 2012 2:22 pm
I assume you got it working?
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by mossman » Sun Sep 23, 2012 5:57 am
Hi Chris,

Thanks for posting this nice framework. I'm always happy to see examples of gles running on raspberry pi. I look forward to using this to have some fun.

Just a quick note in case it helps others. I'm running the latest wheezy debian and I was getting a segfault in all the executables until I modified /src/input.c @line 249

instead of:
if(n >= 0)

to:
if(n >= 0 && eps != 0 && eps[0] != 0)

I think somehow eps was null on my system. So just a little check there and everything was happy.

thanks again!
-moss

btw, this was with PLATFORM=rpi_noX
Posts: 2
Joined: Sun Sep 23, 2012 5:44 am
by chris_c » Sun Sep 23, 2012 12:31 pm
actually off the top of my head shouldn't it have been

if(n > 0)

!!!


Can you test this for me please?
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by mossman » Mon Sep 24, 2012 5:55 pm
Hi Chris,

I tried with if(n>0) and that worked fine for me.

moss
Posts: 2
Joined: Sun Sep 23, 2012 5:44 am
by chris_c » Mon Sep 24, 2012 6:24 pm
alas it didn't for me!

I'm not quite sure the best way to proceed I'll test your original fix and have a think...

thanks!
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by Theo Last » Wed Sep 26, 2012 9:46 am
Im Not following you on how you install this on my Pi
cheers

Theo
Posts: 17
Joined: Wed Sep 26, 2012 9:33 am
by chris_c » Wed Sep 26, 2012 11:44 am
meet me half way and give me some vague clue as to what you don't follow...

cloning a git repo ?
running make ?
Posts: 108
Joined: Sun May 06, 2012 10:23 am
by Theo Last » Thu Sep 27, 2012 9:27 am
I just dont get how you install openGL on the pi
Im sorry if im being stupid
please explain
Posts: 17
Joined: Wed Sep 26, 2012 9:33 am
by panik » Thu Sep 27, 2012 11:16 am
No need to install OpenGL. OpenGL ES is already installed on raspbian. In a terminal:
Code: Select all
git clone git://github.com/chriscamacho/gles2framework.git
cd gles2framework
make

Before 'make', you'll want to open the Makefile, and uncomment either 'PLATFORM=rpi' or 'PLATFORM=rpi_noX'

I had the same error as kevs3d. It's /src/input.c that fails. In /src/input.c, I just commented out (twice) the:
#ifndef __FOR_RPi_noX__
And #endif of course.
I don't think '__FOR_RPi_noX__' is defined somewhere (I expect it in the Makefile, but I didn't look really hard). Is that correct, chris_c?

Other that that: Nice!

Edit: same output (but more complete) as kevs3d:
Code: Select all
gcc o/input.o o/obj.o o/support.o o/invaders.o lib/libkazmath.a -o invaders -lX11 -lGLESv2 -lEGL -lm -lbcm_host -L/opt/vc/lib `pkg-config libpng --libs`
o/input.o: In function `doEvents':
/home/pi/code/gles2framework/src/input.c:200: undefined reference to `__x_display'
/home/pi/code/gles2framework/src/input.c:200: undefined reference to `__eventWin'
o/support.o: In function `closeNativeWindow':
support.c:(.text+0x50): undefined reference to `restoreKbd'
o/support.o: In function `closeContext':
support.c:(.text+0x1bdc): undefined reference to `__mouse_fd'
collect2: ld returned 1 exit status
make: *** [invaders] Error 1
User avatar
Posts: 273
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands