PDA

View Full Version : 2D fragment shader in C , where do I start?



prince_polka
12-12-2017, 01:37 PM
I'd like to make an application displaying a fragment shader in C,
with the abillity to set the uniforms of the shader.

I have written 2D fragment shaders on editor.thebookofshaders.com ,
but only written tiny console applications in C.

What library and boilerplate would be a good place to start?
glfw or something else?

Dark Photon
12-12-2017, 06:09 PM
GLUT or GLFW either one. Either saves you needless wasting time just getting a window opened and a GL context created and active using platform-specific APIs, and also gives you some measure of cross-platform support.

GClements
12-13-2017, 03:43 AM
I'd like to make an application displaying a fragment shader in C,
with the abillity to set the uniforms of the shader.
If you want a UI which allows the user to enter numbers via text fields or sliders, GLUT/GLFW don't have direct support for that.

If you're using C, I'd suggest using GTK. Most of the other popular GUI toolkits are C++. Either way, you're going to need to learn GUI programming concepts.

prince_polka
12-28-2017, 03:37 PM
If you want a UI which allows the user to enter numbers via text fields or sliders, GLUT/GLFW don't have direct support for that.

If you're using C, I'd suggest using GTK. Most of the other popular GUI toolkits are C++. Either way, you're going to need to learn GUI programming concepts.

I don't need textfields or sliders, just a window displaying the shader, to set the uniform I wan't something like glUniformX() (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glUniform.xhtml)

I installed glfw, creating a window works, but most functions creates errors.


puts(glGetString(GL_VERSION)); // 4.5.13469 Compatibility Profile Context 21.19.525.0
glCreateShader() //undefined reference
glGetUniformLocation(,"") //undefined reference

Silence
12-29-2017, 03:53 AM
I don't need textfields or sliders, just a window displaying the shader, to set the uniform I wan't something like glUniformX() (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glUniform.xhtml)

I installed glfw, creating a window works, but most functions creates errors.


puts(glGetString(GL_VERSION)); // 4.5.13469 Compatibility Profile Context 21.19.525.0
glCreateShader() //undefined reference
glGetUniformLocation(,"") //undefined reference


You also need glew (http://glew.sourceforge.net/).

prince_polka
12-29-2017, 05:20 AM
You also need glew (http://glew.sourceforge.net/).

It installed glew and it did not work, then i put -lglew32 in compiler options and now it works.
Setting a uniform and drawing a shader with the uniform works now, I will probably run into more problems but now I have something to start with!