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 1 of 1

Thread: Change in fragmentshader crashes vertexshader

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2013
    Posts
    5

    Question Change in fragmentshader crashes vertexshader

    Hello guys,

    While making a very simple 2d engine using openGL, glew, and glut, I used a fragmentshader that created a julia set fractal to test my shader loading code. However, while deleting the code that generates the fractal, I found a very interesting, and to me inexplicable bug. Deleting/changing certain values in the fragment shader somehow corrupts the vertexshader. I have created a github repository, where you can browse and try out the code. I'll also add both shaders to the end of this post. The fragment and vertex-shader are in the game-directory. This also is the working directory.
    github repo:
    https://github.com/CombustibleLemonade/AI#ai
    I stripped the code of anything that didn't make it crash, so changing pretty much anything in the fragmentshader will make the vertexshader crash. Deleting either of the uniform floats at the beginning, or even replacing gl_FragCoord.x or gl_FragCoord.y with a random float value all does the trick. Any hints that could lead to solving this problem would be greatly appreciated.

    Vertexshader:
    Code :
    #version 330 core
     
    attribute vec2 coord2d;
    uniform float zoom = 0.5;
     
    void main(void) {
    	gl_Position = vec4(coord2d * zoom, 0.0, 1.0);
    }

    Fragmentshader:
    Code :
    #version 330 core
     
    uniform float X = 1.0;
    uniform float Y = 0.0;
     
    vec3 OutputColor;
     
    vec2 multiply(vec2 fac1, vec2 fac2) {
    	return vec2(0.0, 0.0);
    }
     
    vec3 fractal (vec2 location, int iterations){
    	vec2 escape = location;
    	return vec3(0.0, 0.0, 0.0);
    }
     
     
    void main(void) {
    	OutputColor = fractal (vec2(gl_FragCoord.x, gl_FragCoord.y), 100);
    	gl_FragColor = vec4(0.5, 0.5, 0.5 ,0.0);
    }

    Best Regards,
    Jan Heemstra

    Edit:
    Just found out deleting the uniform float in the vertex shader does enable me to delete the stuff in the fragmentshader without crashing the vertex shader. However, I need the uniform value for my engine, and I can't make a new one.

    Another edit:
    It seems my file-loading script is malicious, and somehow doesn't load the shader correctly when I delete certain parts. I have yet to find out why it behaves that way. This is probably not an OpenGL problem, so you can probably disregard this post.

    Another edit:
    Apparently returning a c-string or converting my function directly into a c-string made my code very buggy. I fixed that by making a string variable that's "inbetween".
    Last edited by 8baanknexer; 12-27-2013 at 12:24 PM.

Tags for this Thread

Posting Permissions

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