Convert GL 2 shader to GL 3

Hello,

How can i convert a GL2 shader to GL3 ?

Are there existing converter tools ?

Thanks a lot

Hey a first step is to set the openGL version in ofMain (to 3.3 say), and then use a corresponding version in the shader files:
// in main.cpp:

int main( ){
	//Use ofGLFWWindowSettings for more options like multi-monitor fullscreen
	ofGLWindowSettings settings;
        settings.setGLVersion(3, 3);
	settings.setSize(1920, 1080);
	settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN

	auto window = ofCreateWindow(settings);
	ofRunApp(window, make_shared<ofApp>());
	ofRunMainLoop();
}

then at the top of each shader file:

#version 330

Depending on the shader, this might be enough, while others may need a bit more modification.

Also you might get a good idea of how the versions compare by looking at the projects in /examples/shader/. They (all ?) have 3 different folders of the shaders in each project in /bin/data/: openGL 2 (#version 120); openGL 3 (#version 150); openGLES.

1 Like

this might help GLSL Versions · mattdesl/lwjgl-basics Wiki · GitHub

2 Likes