View Full Version : Combining GLSL with OpenGl

04-12-2018, 08:41 AM

I am working to implement a technique, which reconstructs visible position seen by the camera from the depth buffer. I am having an issue in the sense that I am unable to use the texture coordinates and depth buffer together to reverse my way back to world coordinates.

Everywhere I have seen, I would need texture coordinates and I am having trouble accessing that on my program as there are GLSL commands needed for it to be recognized by OpenGl and Visual Studio 2017. How can I incorporate GLSL into Visual Studio? What packages do I need to include in my visual studio program? Thank you for your help and time

04-13-2018, 03:46 AM
GLSL doesn't involve the development environment. GLSL support is provided by the OpenGL API. The primary functions are glCreateShader, glShaderSource, glCompileShader, glCreateProgram, glAttachShader, glLinkProgram and glUseProgram. Look for a tutorial which uses those functions.

Also, it's not strictly necessary to use texture coordinates; you can use gl_FragCoord.xy in combination with the depth value to obtain 3D window-space coordinates.

04-14-2018, 05:39 PM

I was given a shader.cpp file to use. I don't know how I can use values from there to incorporate into my program. Would you mind please giving me an example code as to how I can use texture coordinates or gl_FragCoord.xy so I can try to implement my program? This part is the only piece of the puzzle, which I am unable to get.