Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi / ofGraphics and ofFbo not drawing in conjunction with ofShader #5917

Open
sourya-sen opened this issue Mar 1, 2018 · 7 comments

Comments

@sourya-sen
Copy link
Contributor

This is basically what's being discussed here:
https://forum.openframeworks.cc/t/app-for-raspberry-pi-integrating-shaders-and-ofgraphics-objects/28848/7

I've nailed it down to the "%extensions%\n" lines in ofGLProgammableRenderer.cpp (line 1860 and line 1867). It's fairly evident that those lines are causing problems as ofShader reports,

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

Simply commenting out the lines make everything work fine, but looking at the error in more detail it seems like ofStringReplace which is supposed to replace that line with "" from line 2293 is not replacing that line but rather sending %extensions% in the header part of the shader.

Fix option 1: just taking out the %extensions% from the rPi shaders header, but that might lead to problems later if we have to define certain extensions at some point.

Fix option 2: look into why ofStringReplace is not doing it's job on the rPi.

@sourya-sen
Copy link
Contributor Author

sourya-sen commented Mar 1, 2018

You can see that line being sent from what the console is spitting out when running any app on the Pi with ofShader before the above error:

[warning] ofShader: GL_VERTEX_SHADER shader reports:
Compiled
[warning] ofUtils: Couldn't create locale  using default, C.UTF-8
[warning] ofUtils: Couldn't create locale  using default, C.UTF-8
[warning] %extensions%
precision mediump float;
#define IN attribute
#define OUT varying
#define TEXTURE texture2D
#define TARGET_OPENGLES
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:
Compiled
[warning] ofUtils: Couldn't create locale  using default, C.UTF-8
[warning] ofUtils: Couldn't create locale  using default, C.UTF-8
[warning] %extensions%
precision mediump float;
#define IN varying
#define OUT
#define TEXTURE texture2D
#define FRAG_COLOR gl_FragColor
#define TARGET_OPENGLES
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; } }

@sourya-sen
Copy link
Contributor Author

So... I'm guessing locale is the issue here on the rPi for ofStringReplace not working. If do locale on the Pi, it get,

LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

So setting up the correct locale on the Pi should probably be a better overall fix as that'd make sure ofUtils / ofStringReplace functions correctly.

Any clue how to go about this, or what to do regarding this?

@arturoc
Copy link
Member

arturoc commented Mar 1, 2018

yes the correct fix is to solve the locale problem. the extensions line is used in android for video textures so removing it is not an option. there's some code on application start to try to set the locale to something utf8 but it might not be working on the pi? the code is here:

https://github.com/danoli3/openFrameworks/blob/3180a7b5068a037c90d03b276e8526aaed2d9e8a/libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp#L133-L154

@sourya-sen
Copy link
Contributor Author

Can't seem to see any code to set the locales in the above link...?

Do you know what the correct locales should be? Maybe it's a good idea to add a command into the Raspberry Pi install_dependences script (or a have a separate script?) to set the correct locales when installing oF to the Pi?

@arturoc
Copy link
Member

arturoc commented Mar 9, 2018

hey sorry i posted the wrong link and then never saw your next message, the correct place where the locale is set to something utf8 is https://github.com/danoli3/openFrameworks/blob/3180a7b5068a037c90d03b276e8526aaed2d9e8a/libs/openFrameworks/app/ofAppRunner.cpp#L143-L156

@avilleret
Copy link
Contributor

@sourya-sen please look at this #6223

it fixes most of the shader examples for Raspberry Pi

@sourya-sen
Copy link
Contributor Author

@avilleret the shader examples had a different issue, that being the target platform not being defined in the main.cpp file. This is different and has to do with the locale settings of the Pi which might not allow stringify/ofStringReplace() to run properly to compile the default shader. I'd completely forgotten about this since my local fix on the rPi for 0.9.8 - I did update to 0.10 but I cannot remember if it needed this fix on that too or whether I fixed the locale or does oF take care of it now because my stuff is running as it should. Dang, I'll try to find some time to take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants