Results 1 to 5 of 5

Thread: glBindFragDataLocation segmentation fault

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2009

    glBindFragDataLocation segmentation fault

    I've got all of my code to gl3+ compliance now, I think, except I'm still using fragdata in the fragment shader because my glBindFragDataLocation function causes a segmentation fault when I try to use it. Also, I'm using glew, and although 'glewinfo | grep glBindFragDataLocation' says I'm good for both glBindFragDataLocation and glBindFragDataLocationEXT, when I do a 'printf("%ld",(long)glBindFragDataLocation);' I get null.

    So... help?

    This is the area of code around my problem:
    GLuint myShaderProgram;
    myShaderProgram = glCreateProgram();
    glAttachShader(myShaderProgram, myVertShader);
    glAttachShader(myShaderProgram, myFragShader);

    glBindAttribLocation(myShaderProgram, 0, "inVertex");
    glBindAttribLocation(myShaderProgram, 1, "inColor");
    glBindFragDataLocation(myShaderProgram, 0, "outColor"); //Comment this out, and it works. (with gl_FragData[0]).


    and this is my fragment shader:
    #version 150 core

    in vec3 exColor;
    out vec4 outColor;

    void main() {
    vec3 tempC;
    tempC = exColor;
    tempC.r = tempC.r * 0.5;
    tempC.g = tempC.g * 0.5;
    tempC.b = tempC.b * 0.5;
    gl_FragData[0] = vec4(tempC,1.0);
    outColor = vec4(tempC,1.0);

    Kinda new to this... so any help is appreciated!

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Watford, UK

    Re: glBindFragDataLocation segmentation fault

    #version 150 core
    So, I assume it's a G80+ with drivers 190.18.05 for Linux?
    I'm with 190.57 for winxp, and glBindFragDataLocation is present (as in "not null").

    P.S but I don't use GLEW

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2007

    Re: glBindFragDataLocation segmentation fault

    How are you getting a gl3 context? Are you using freeglut 2.6 or latest SDL? or other method?

    Why are you checking for the version with EXT appended
    Code :
    printf("glBindFragDataLocationEXT %ld",(long)glBindFragDataLocationEXT);
    but actually calling glBindFragDataLocation without the EXT appended?

    I am on linux with GeForce 9600 GT and OpenGL version 3.2.0 NVIDIA 190.18.05. I run code using glBindFragDataLocation without an errors. Note instead of glew I take an alternative approach -- glew is not quite up to supporting all of gl3.2 features -- although looking at their webpage there was a post about a version that is available but not as a stable release yet. I use the gl3.h instead of glew for this reason ... First I make sure I have the latest gl3.h headers

    Code :
    wget [url][/url]
    wget [url][/url]
    wget [url][/url]
    sudo cp glext.h /usr/include/GL/
    sudo cp glxext.h /usr/include/GL/
    sudo cp gl3.h /usr/include/GL3/

    Then in my code I remove all glew and do instead
    Code :
    #define GL3_PROTOTYPES
    #include <GL3/gl3.h>
    // this replaces GL/GL.h, read the gl3.h itself to see how to properly use it
    // and compile with g++ foo.cpp  -lGL 
    then you have the gl3 functions available in linux

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2009

    Re: glBindFragDataLocation segmentation fault

    Thanks for the replies.

    I'm running x64 9.10 Kubuntu Linux with latest updates kernel and all. I have a 9800GTX+ with latest(190.42 ) x64 Linux drivers.

    I'm getting my gl3 forward compat context via glfw lite 2.6 latest off of svn, using the glfwOpenWindowHint or whatever (not at _my_ computer atm). GL_VERSION does seem to follow these hints, and shows 3.2 at the moment.

    Why are you checking for the version with EXT appended
    I had been trying both and forgot to change back before posting. Both give me a segmentation fault, and are null when cast and printf-ed. Which is why I'm getting the segmentation fault I would guess... trying to call a null function pointer?

    I also have the latest glew. I guess it's screwing up? I was thinking about getting away from glew and using gl3.h and glfw's multi-platform getproc stuff.

    My main issue there is I don't know how to use gl3.h with glfw since glfw.h includes gl.h for me. I guess replace the includes in the glfw source with gl3.h and recompile it?

    Thanks again.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2009

    Re: glBindFragDataLocation segmentation fault

    Found the problem, GLEW wasn't setting the function pointer for some reason, pulled it in on my own and it works.

    Think I'll remove glew and just pull in all the functions I need manually.

    For some reason though, I forgot that I am still only running an opengl 3.1 context. I can change it to 3.2 with the hint, and it shows up, but I get a black render. I thought it was due to using depreciated functions, but I'm pretty sure all of my code is 3.2+ compliant now... and it still doesn't work...

    Anyway, sure I'll figure it out.

    Thanks again

Similar Threads

  1. Segmentation fault with cl2.hpp
    By Mike Zhang in forum OpenCL
    Replies: 0
    Last Post: 02-03-2017, 12:22 AM
  2. Segmentation fault while using PBO
    By SagoO in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-03-2011, 08:03 AM
  3. Segmentation fault
    By SagoO in forum OpenGL: Basic Coding
    Replies: 28
    Last Post: 01-12-2011, 09:45 AM
  4. Segmentation Fault
    By j0rt3g4 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-06-2011, 06:54 PM
  5. Segmentation fault
    By D1G1T4LL in forum OpenGL: Linux
    Replies: 2
    Last Post: 12-09-2003, 08:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean