quitequick
Posts: 33
Joined: Tue Jan 31, 2012 5:10 pm

Re: 3d opengl hello_triangle

Fri May 11, 2012 4:01 pm

As per the 'Quick start guide', I'm having a stab at getting an OpenGL demo working - /opt/vc/src/hello_pi/hello_triangle.

I have compiled it (make) and run it... but it hangs. I gdb'ed it with -g and it is hanging on a swapbuffers...> gdb ./hello_triangle.bin
...Starting program: /home/me/opengltest/hello_pi/hello_triangle/hello_triangle.bin
[Thread debugging using libthread_db enabled]
[New Thread 0x40af2470 (LWP 8331)]
[New Thread 0x412f2470 (LWP 8332)]
[New Thread 0x41af2470 (LWP 8333)]
[New Thread 0x422f2470 (LWP 8334)]
^C
Program received signal SIGINT, Interrupt.
0x4021efc0 in sem_wait@@GLIBC_2.4 () from /lib/libpthread.so.0
(gdb) where
#0 0x4021efc0 in sem_wait@@GLIBC_2.4 () from /lib/libpthread.so.0
#1 0x40059254 in eglSwapBuffers () from /opt/vc/lib/libEGL.so
#2 0x00024ad8 in redraw_scene (state=0x31384) at triangle.c:381
#3 0x000252e0 in main () at triangle.c:539
(gdb) I'm running it through a VNC client with the pi running a tightvncserver, if that matters. Any ideas?

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5502
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: 3d opengl hello_triangle

Fri May 11, 2012 4:12 pm

You won't see anything though VNC. OpenGL ES does not interact with X. My guess is there is a 3D image being output from the Pi, and it is not hanging, just eglSwapBuffer is where it blocks withing for VSYNC.

quitequick
Posts: 33
Joined: Tue Jan 31, 2012 5:10 pm

Re: 3d opengl hello_triangle

Fri May 11, 2012 4:17 pm

The X 3d looking screensavers work with VNC - are they not OpenGL?

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5502
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: 3d opengl hello_triangle

Fri May 11, 2012 4:19 pm

No. Software rendered.

quitequick
Posts: 33
Joined: Tue Jan 31, 2012 5:10 pm

Re: 3d opengl hello_triangle

Fri May 11, 2012 5:29 pm

I just rebooted and plugged it in to my TV - still no luck but with different error...

> ./hello_triangle.bin
hello_triangle.bin: triangle.c:167: init_ogl: Assertion `state->surface != ((EGLSurface)0)" failed.
Abort

hello_video does not work, but with a different error (from gdb)...
(gdb) r
Starting program: /home/david/opengltest/hello_pi/hello_video/hello_video.bin test.h264
[Thread debugging using libthread_db enabled]
[New Thread 0x40af2470 (LWP 1588)]
[New Thread 0x412f2470 (LWP 1589)]
[New Thread 0x41af2470 (LWP 1590)]
[New Thread 0x422f2470 (LWP 1591)]
[New Thread 0x42af2470 (LWP 1592)]
[New Thread 0x432f2470 (LWP 1593)]
^C
Program received signal SIGINT, Interrupt.
0x4021efc0 in sem_wait@@GLIBC_2.4 () from /lib/libpthread.so.0
(gdb) where
#0 0x4021efc0 in sem_wait@@GLIBC_2.4 () from /lib/libpthread.so.0
#1 0x400b1d84 in vcos_semaphore_wait (flags=0x3e1f8, bitmask=1, op=5, suspend=4294967295, retrieved_bits=0xbefff7ac)
at /home/dc4/raspberry/arm_linux/vc4/build/inc/interface/vcos/vcos_platform.h:231
#2 _vcos_thread_sem_wait (flags=0x3e1f8, bitmask=1, op=5, suspend=4294967295, retrieved_bits=0xbefff7ac)
at /home/dc4/raspberry/arm_linux/vc4/build/inc/interface/vcos/vcos_platform.h:549
#3 vcos_generic_event_flags_get (flags=0x3e1f8, bitmask=1, op=5, suspend=4294967295, retrieved_bits=0xbefff7ac)
at /home/dc4/raspberry/arm_linux/vc4/interface/vcos/generic/vcos_generic_event_flags.c:214
#4 0x0000de54 in ilclient_get_input_buffer ()
#5 0x00024010 in video_decode_test (filename=0xbefffbca "test.h264") at video.c:130
#6 0x00024214 in main (argc=2, argv=0xbefffa44) at video.c:270
(gdb)

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5502
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: 3d opengl hello_triangle

Fri May 11, 2012 5:58 pm

Which memory split are you running with?

This won't work with the 224M/32M ARM/GPU split.

quitequick
Posts: 33
Joined: Tue Jan 31, 2012 5:10 pm

Re: 3d opengl hello_triangle

Fri May 11, 2012 7:43 pm

Ah, well yesterday I updated my firmware with Hexxeh's rpi-updater.

Hexxeh's Git says...

[By default, the 224MB memory split will be used.]

So it sounds like I am. What split do you recommend?

@Hexxeh (if you are listening...) @dom : could you tell more about the real meaning of the split and its implications?

Thanks, dom.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5502
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: 3d opengl hello_triangle

Fri May 11, 2012 10:08 pm

224 for no video or 3D
192 for video or simple 3D
128 for video and advanced 3D

gregd72002
Posts: 31
Joined: Tue May 08, 2012 9:17 pm

Re: 3d opengl hello_triangle

Sat May 12, 2012 12:10 am

right and I'm struggling with getting this to compile on my archlinux RPi:

[root@alarmpi hello_triangle]# make
cc -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi -I/opt/vc/include/ -I/opt/vc/include/ -I./ -I../libs -g -c triangle.c -o triangle.o -Wno-deprecated-declarations
cc -o hello_triangle.bin -Wl,--whole-archive -L/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lbcm_host -lvcos ../libs/libilclient.a triangle.o -Wl,--no-whole-archive -rdynamic
/usr/bin/ld: ../libs/libilclient.a(ilclient.o): undefined reference to symbol 'sem_post@@GLIBC_2.4'
/usr/bin/ld: note: 'sem_post@@GLIBC_2.4' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line
/lib/libpthread.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [hello_triangle.bin] Error 1
rm triangle.o 
any help appreciated

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5502
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: 3d opengl hello_triangle

Sat May 12, 2012 12:54 am

Try adding -lpthread.

gregd72002
Posts: 31
Joined: Tue May 08, 2012 9:17 pm

Re: 3d opengl hello_triangle

Sat May 12, 2012 12:06 pm

this worked (adding the right LDFLAGS into Makefile). Thanks!

I had to install additionally libegl and libgles as well as add /opt/vc/lib into ld configuration as it was complaining about libopenmaxil.so.

Now when I run it I get:

[root@alarmpi hello_triangle]# DISPLAY=:0 ./hello_triangle.bin
hello_triangle.bin: triangle.c:167: init_ogl: Assertion `state->surface != ((EGLSurface)0)' failed.
Aborted
I guess this error is to do with me being on a terminal over ssh as oppose to running it from the xorg environment itself. So how do I redirect the output to DISPLAY=:0? I've got xorg initiated using fb driver on the RPi and I can see it on my TV. Moreover, xclock and glxgears work perfectly fine when pre-pended (redirected) with DISPLAY=:0  Cheers,

gregd72002
Posts: 31
Joined: Tue May 08, 2012 9:17 pm

Re: 3d opengl hello_triangle

Sat May 12, 2012 12:25 pm

Right, I will answer my own question - the error was due to me being on 32MB GPU ram. Moving to 64MB GPU ram solved the problem

Thanks

quitequick
Posts: 33
Joined: Tue Jan 31, 2012 5:10 pm

Re: 3d opengl hello_triangle

Sat May 12, 2012 12:56 pm

dom said:


224 for no video or 3D
192 for video or simple 3D
128 for video and advanced 3D


Tried 192 and both 3d and video tests work. Thanks, Dom.

I have to say the quality of the 3d and video are quite amazing - and from such a teeny device!

geeks
Posts: 3
Joined: Thu Jan 29, 2015 8:00 pm

Re: 3d opengl hello_triangle

Sat Jan 31, 2015 9:36 pm

any update?

Raspberry B+
64M video
using tightvnc
---------------------

Code: Select all

pi@pi /opt/vc/src/hello_pi/hello_triangle $ gdb ./hello_triangle.bin
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /opt/vc/src/hello_pi/hello_triangle/hello_triangle.bin...done.
(gdb)
(gdb) run
Starting program: /opt/vc/src/hello_pi/hello_triangle/hello_triangle.bin
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0xb6d4f470 (LWP 2378)]
[New Thread 0xb654f470 (LWP 2379)]
[New Thread 0xb5d4f470 (LWP 2380)]
[New Thread 0xb554f470 (LWP 2381)]

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: 3d opengl hello_triangle

Sat Jan 31, 2015 9:46 pm

geeks wrote:any update?
You did see the thread is nearly three years old didn't you ? And the answer to the OP's question is in the thread !

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “C/C++”