setupShaderFromFile() : couldnt load GL_VERTEX_SHADER

I am attempting to run a game written in OFv0.9.8 on linux that works on both osx and windows.

The game compiles without errors but when I try to run the game I get these errors.

[ error ] ofShader: setupShaderFromFile(): couldn't load GL_VERTEX_SHADER shader  from "shaders/shadersGL2/shader.vert"
[ error ] ofShader: setupShaderFromFile(): couldn't load GL_FRAGMENT_SHADER shader  from "shaders/shadersGL2/shader.frag"
[ error ] ofShader: linkProgram(): trying to link GLSL program, but no shaders created yet

There is a forum post with a similar issue but the error occurs when running some of the provided examples whereas all but example 6 run for me without error. This error seems unrelated. It is

ofGstVideoUtils: update(): ofGstVideoUtils not loaded

That post also mentions file permissions but I verified that the permissions in the game I’m trying to compile are the same as in simpleColorQuad which works without an issue.

Hi, do you have the shader files in the specified path? also, make sure that these are in the correct format. Notice that in the shaders examples there are the same shaders but for GL2 and GL3, and you need to load these accordingly. In main.cpp file is where you set to use gl2 or gl3. Check the shaders examples for this too.

Hello, both the shader.frag and shader.vert files are located in ~/OF/apps/myApps/game/shaders/shadersGL2. I have tried running the game both from game/ and from game/bin in case the issue was a problem of what directory I was running the game from.

What do you mean by having the files in the correct format? The source code I’m using works on both mac and windows and all I did was copy them over so I think these shaders are setup correctly. Is there a different format necessary for gl2 shaders on linux?

This is my main.cpp, the examples use a different way of setting up the window though using ofCreateWindow but that returned the same error.

#include "ofMain.h"
#include "gamePC.h"
#include "ofAppGlutWindow.h"
//hello!
//========================================================================
int main( ){

	ofSetupOpenGL(960, 960, OF_WINDOW);
	ofRunApp( new gamePC());
}

Hi, it depends on how you are passing the file path to the shaders load function.
From what I can see in the error message it is a relative path, shaders/shadersGL2/shader.vert, so the shaders should be in the bin/data folder.
Try to wrap what ever you are passing to the shaders load function with ofToDataPath("the path to the shaders", true) . As such, moving the app around would not help, what you need to move are the shader files into the correct folder, or pass the correct path to it. Or you can simply pass the absolute pass to these.
As for the format, the very first line of the shader usually says #version 120 or #version 150, for GL2 and GL3 respectively. Check that it is correct.

Okay this problem has been solved! I was also having an audio error that I was going to make a different thread for.

Checked the shader files and both say #version 120 so that is good.

The way the game data is structured may not be following the proper format. There was no folder bin/data/ though there is a data/ folder. I tried moving the shaders/ into data/ and recompiling but this did not work. I also tried moving shaders/ into bin/ which also didnt work.

Finally tested creating the folder bin/data/ and moving shaders/ in there at this point the problem was solved. The game was distributed with data/ not in the bin/ folder so I moved that in there and now it works! Thank you!

1 Like

Good to know. Right, that’s the standard folder structure. When in doubt look at the examples and how these are structured.
Cheers

1 Like