|
A5 OpenGL RPi Hello World |
myoung
Member #12,934
June 2011
|
Hey all, Wondering if someone could point me in the right direction for getting a very basic OpenGL Hello World working on a Raspberry Pi. I have a Raspberry Pi 3 B+ running Raspbian Stretch. I have Allegro working on MSVC++ 2008 Express on a Windows workstation and an OpenGL example utilizing Allegro gleaned from this website works without a hitch... http://cplussplussatplay.blogspot.com/2011/12/open-gl-allegro-51-basics-textures.html ...though I run into a bunch of problems getting it to compile and run on a Raspberry Pi that I otherwise have Allegro 5 running on just fine. The first issue I ran into was OpenGL library files seemingly not in the right location -- GLES2/gl2.h not found. I see it's in /opt/vc/include as opposed to /usr/include. I was using Geany and decided to just revert to CLI as I did get example 3 of an OpenGL example in this YouTube video working fine on the RPi... https://www.youtube.com/watch?v=NBGMeGEDVY4 Okay, so by specifying -I /opt/vc/include I get the Allegro OpenGL example to compile. Though I run it and I get this error... * failed to add service - already in use? X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 10 (X_UnmapWindow) Resource id in failed request: 0x0 Serial number of failed request: 8 Current serial number in output stream: 11 Wondering if anyone can point me in the right direction. Attached is the simplistic example derived from the first link (texture mapping removed for simplicity -- just drawing a green wireframe quad). Thanks! |
myoung
Member #12,934
June 2011
|
Thanks for the reply! Yeah, I already have Allegro 5.2.4.0 otherwise working great on the Raspberry Pi. I'm assembling instructions on setting up a Raspberry Pi for introductory game and graphics development for middle and high school students where I work. Instructions cobbled together that I'm working on start on page 6... https://docs.google.com/document/d/13__NNObHjweuM1B_o49lcUmoakAmDdekVDgHulc3OVQ/edit?usp=sharing Thought I'd try including some basics on OpenGL as well seeing as everything else is working great and seeing as the RPi has some 3D capabilities. I'm trying to figure out a clearly defined set of steps from imaging Raspbian Stretch w/Desktop (latest release -- Nov. 2018) to getting OpenGL functionality working through Allegro. Basically getting sort of a "bouncer" like tutorial in C going on it for basic 3D -- a skeleton project to build off of and one that's cross platform. As someone who dabbles in smaller projects, then lets my programming skills atrophy, I find concise, example-based learning like from that "bouncer" example in the Allegro 5 Tutorial/Bitmaps page of the Allegro Wiki to be great. |
Chris Katko
Member #1,881
January 2002
|
The Pi 3 might be better but my Pi 2 definitely did not have proper OpenGL support. Only OpenGL ES. AFAIK, as of even October 2018, OpenGL support is still "experimental": -----sig: |
myoung
Member #12,934
June 2011
|
That makes sense -- issues of OpenGL vs. OpenGL ES. I did try with the GL driver enabled and no change. I did got things compiling and building, though in the dark on how to get OpenGL ES and Allegro 5 to cooperate. Guess I need to keep tinkering or look into non-OpenGL 3D capabilities provided by Allegro for code portability. The OpenGL examples provided by Broadcom and/or the Raspberry Pi Foundation in /opt/vc/src run great. I suppose trimming one of those examples down and pulling Allegro in for non-graphical aspects might be an option. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I'm almost positive other people have gotten Allegro and OpenGL to work together before on the RPi. In fact, a duck duck go search for allegro 5 raspberry pi opengl reveals some very useful tidbits : https://github.com/liballeg/allegro5/issues/745 https://www.raspberrypi.org/forums/viewtopic.php?t=191857#p1203490 Be sure to read both. So, to use the GLES drivers, you need to link to the brcm versions, and to use GL, don't build with the raspberry pi toolchain.cmake, just build for linux. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
myoung
Member #12,934
June 2011
|
I got it to work. Thanks for the tips. I ended-up starting all over, re-imaging my SD card with Raspbian Stretch (using the 2018-06-27 build). I enabled the experimental GL driver (full KMS, the fake KMS driver didn't work for this), and followed instructions for building Allegro 5 on Ubuntu on the Wiki... https://wiki.allegro.cc/index.php?title=Ubuntu_and_Allegro_5 Proceeded with that after downloading Allegro 5.2.4.0 (Unix friendly format). I took the sample source code I attached in my first message on this thread and was able to compile and run it with... gcc main.c -o gltest `pkg-config --libs allegro-5` -lGLU -lGL ./gltest I do get some warnings/errors when running it stating... libGL error: MESA-LOADER: failed to retrieve device information MESA-LOADER: failed to retrieve device information MESA-LOADER: failed to retrieve device information libGL error: MESA-LOADER: failed to retrieve device information MESA-LOADER: failed to retrieve device information MESA-LOADER: failed to retrieve device information Though I see others commenting about that message. The program still starts okay. I also was getting a segmentation fault when running the program, though I figured out I needed to allocate more memory to the GPU using raspi-config to resolve that. I went from allocating 64MB to 256MB to the GPU. Finally, I used xrandr to increase the resolution of the desktop (perhaps unnecessary if using HDMI, though I'm using a HDMI to VGA adapter)... xrandr --output HDMI-1 --mode 1280x1024 I do see that I cannot run the program in the terminal without the desktop environment running, which is a bummer. I get a seg fault when trying to run it. I take that as meaning use of OpenGL relies on the desktop environment. I like how Allegro otherwise can work fine fullscreen in the terminal without X running. One of my projects was making my own game console using Raspbian Lite with fully suppressed start-up text/interface, looking for and mounting an attached USB flash drive and auto-running a predefined executable on it or running a setup program if no USB flash drive or properly named executable was found -- cartridge-like system where USB flash drives are the cartridges. Alas, that can be accomplished with a desktop environment, just seems like lots of extra junk to run. |
|