Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: 2D fragment shader in C , where do I start?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2017
    Posts
    8

    2D fragment shader in C , where do I start?

    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?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,399
    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.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,829
    Quote Originally Posted by prince_polka View Post
    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.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2017
    Posts
    8
    Quote Originally Posted by GClements View Post
    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()

    I installed glfw, creating a window works, but most functions creates errors.
    Code :
    puts(glGetString(GL_VERSION)); // 4.5.13469 Compatibility Profile Context 21.19.525.0
    glCreateShader() //undefined reference
    glGetUniformLocation(,"") //undefined reference

  5. #5
    Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    460
    Quote Originally Posted by prince_polka View Post
    I don't need textfields or sliders, just a window displaying the shader, to set the uniform I wan't something like glUniformX()

    I installed glfw, creating a window works, but most functions creates errors.
    Code :
    puts(glGetString(GL_VERSION)); // 4.5.13469 Compatibility Profile Context 21.19.525.0
    glCreateShader() //undefined reference
    glGetUniformLocation(,"") //undefined reference
    You also need glew.

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2017
    Posts
    8
    Quote Originally Posted by Silence View Post
    You also need glew.
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •