Rpi3, GLES2, OF_PIXELS_NATIVE and Textures



I’m running an application on a Rpi3.

I’m switching to GLES2 in main.cpp:


So I can load videos with OF_PIXELS_NATIVE, which runs smooth and fast on the Pi.

Now the problem arises when I want to do something with the texture, like:


Nothing is displayed then. Just a blank screen.

Disabling GLES2, disabling OF_PIXELS_NATIVE solves the (visual) problem, but CPU usage makes the application unusable.

Any hints? Also just drawing a primitive ofDrawRectangledoes not work.


when OF_PIXELS_NATIVE is enabled OF uses internally up to 3 textures, one per yuv channel to draw the video frame. each texture is then combined through a shader to get the rgb value for each pixel. that’s why getting a reference to only 1 of those textures will at most give you a black and white one.

the easiest is to draw the frame first into an fbo and then draw a subsection of that fbo


Thanks, I’ll give that a try. The bigger problem was, that with GLES2 I was not able to draw a single thing like a rectangle. Does GLES2 on a Rpi need some special treatment when drawing something?


can you put an example of something that doesn’t work? except for lights and materials everything should work the same even if internally the code is different

also please post which version of OF you are using


I’m using git master, running on a Rpi3:


#include "ofMain.h"
#include "ofApp.h"
int main( ){
    ofGLESWindowSettings settings;
    settings.windowMode = OF_FULLSCREEN;
    ofRunApp(new ofApp);


void ofApp::setup(){
   font.load("type/VCR_OSD_MONO_1.001.ttf", 10, true, false, true, 0.4, 72);

void ofApp::update(){}

void ofApp::draw(){

I’m getting just a blank screen.
If I’m commenting out settings.setGLESVersion(2); I see the green “test” in the upper left corner.

Here’s the output after running with GLES2 activated:

make RunRelease
checking pkg-config libraries:   cairo zlib gstreamer-app-1.0 gstreamer-1.0 gstreamer-video-1.0 gstreamer-base-1.0 libudev freetype2 fontconfig sndfile openal openssl libcurl glfw3 rtaudio gtk+-3.0 libmpg123
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): screenRect: 1680x1050
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): windowRect: 1680x1050
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
[notice ] ofAppEGLWindow: createSurface(): EGL Display correctly set 0x1
[notice ] ofAppEGLWindow: createSurface(): no current renderer selected
[notice ] ofAppEGLWindow: createSurface(): GLES2 renderer detected
[notice ] ofAppEGLWindow: createSurface(): surface created correctly
[notice ] ofAppEGLWindow: createSurface(): API bound correctly
[notice ] ofAppEGLWindow: createSurface(): -----EGL-----
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MAJOR = 1
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MINOR = 4
[notice ] ofAppEGLWindow: createSurface(): EGL_CLIENT_APIS = OpenGL_ES OpenVG
[notice ] ofAppEGLWindow: createSurface(): EGL_VENDOR = Broadcom
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION = 1.4
[notice ] ofAppEGLWindow: createSurface(): EGL_EXTENSIONS = EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_vg_parent_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_lock_surface
[notice ] ofAppEGLWindow: createSurface(): GL_RENDERER = VideoCore IV HW
[notice ] ofAppEGLWindow: createSurface(): GL_VERSION  = OpenGL ES 2.0
[notice ] ofAppEGLWindow: createSurface(): GL_VENDOR   = Broadcom
[notice ] ofAppEGLWindow: createSurface(): -------------
[notice ] ofAppEGLWindow: setupPeripherals(): peripheral setup complete
[notice ] ofAppEGLWindow: setupNativeUDev(): created udev object
[notice ] ofAppEGLWindow: setupMouse(): mouse_fd=5 devicePath=/dev/input/event0
[notice ] ofAppEGLWindow: setupMouse(): mouse device name = NOVATEK USB Keyboard
[ error ] ofAppEGLWindow: ioctl GABS failed
[ error ] ofAppEGLWindow: ioctl GABS failed
[notice ] ofAppEGLWindow: setupKeyboard(): keyboard_fd=6 devicePath=/dev/input/by-path/platform-3f980000.usb-usb-0:1.2.3:1.0-event-kbd
[notice ] ofAppEGLWindow: setupKeyboard(): keyboard device name = NOVATEK USB Keyboard
[notice ] ofAppEGLWindow: setupPeripherals(): native event setup complete
[warning] ofShader: GL_VERTEX_SHADER shader reports:
[warning] %extensions%
precision highp float;
#define IN attribute
#define OUT varying
#define TEXTURE texture2D
uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; uniform mat4 textureMatrix; uniform mat4 modelViewProjectionMatrix; uniform float usingTexture; uniform float usingColors; uniform vec4 globalColor; IN vec4 position; IN vec4 color; IN vec4 normal; IN vec2 texcoord; OUT vec4 colorVarying; OUT vec2 texCoordVarying; void main(){ gl_Position = modelViewProjectionMatrix * position; if(usingTexture>.5) texCoordVarying = (textureMatrix*vec4(texcoord.x,texcoord.y,0,1)).xy; if(usingColors>.5) colorVarying = color; else colorVarying = globalColor; }

[warning] ofShader: GL_FRAGMENT_SHADER shader reports:
[warning] %extensions%
precision highp float;
#define IN varying
#define OUT
#define TEXTURE texture2D
#define FRAG_COLOR gl_FragColor
uniform sampler2D src_tex_unit0; uniform float usingTexture; uniform float bitmapText; IN vec4 colorVarying; IN vec2 texCoordVarying; void main(){ vec4 tex; if(usingTexture>.5){ tex = TEXTURE(src_tex_unit0, texCoordVarying); if(bitmapText>.5 && tex.a < 0.5){ discard; }else{ FRAG_COLOR = colorVarying*tex; } }else{ FRAG_COLOR = colorVarying; } }

[ error ] ofShader: checkProgramLinkStatus(): program failed to link
[ error ] ofShader: ofShader: program reports:
ERROR:LEX/PARSE-1 (vertex shader, line 1) Syntax error



at the end of the output you can see there’s an error in the shader. we fixed this some weeks ago so if you pull again from master it should work


thanks arturo - git pull did the trick ; )