Category : glsl

When trying to create the following simple vertex shader… #version 330 layout(location = 0) in vec4 position; void main() { gl_Position = position; } …I run into the following errors: Vertex shader failed to compile with the following errors: ERROR: 0:2: error(#325) Invalid layout qualifier for: outputs in vertex shader ERROR: 0:2: error(#5) Extension: "explicit ..

Read more

I’m new at OpenGL and GLSL. I’m trying to write a first program with using those libraries in Qt Creator that would draw in the QOpenGLWindow window an ordinary rectangle. The compilation was implemented successfully, however the program crashes immediately on trying to run this with the following error output: Running /home/andrey/build-opengl_glsl-Desktop-Debug/opengl_glsl … The program ..

Read more

I know gl_FragDepth will take the value of gl_FragCoord.z from opengl wiki. https://www.khronos.org/opengl/wiki/Fragment_Shader/Defined_Outputs But I have a problem. If I enable MSAA and write gl_FragDepth = gl_FragCoord.z in fragment shader, the display will not work fine. You can see a black line on the white triangle as below: If I don’t write gl_FragDepth in fragment ..

Read more

I am semi-experienced in OpenGL and am currently working on simple lighting for a 2D game. My plan is as follows: Create a Uniform Buffer Object to store two arrays of vec4s representing all active lights in the scene: one for position and one for color. Take in that Uniform Buffer Object as a uniform ..

Read more

In the following program the last print function prints -1 which is the location of the uniform named num. I gave right arguments to the function glGetUniformLocation(), yet got -1 as a result , can’t figure out why? P.S. The shader compiles successfully. GLuint program = glCreateProgram(); GLuint computeShader = glCreateShader(GL_COMPUTE_SHADER); const GLchar* const shaderSrc ..

Read more