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: gldrawelements crash

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    21

    gldrawelements crash

    When I call gldrawelements my program crashes.

    When I comment out my shader code it works fine. The code is as follows:

    Code :
    vshader = glCreateShader(GL_VERTEX_SHADER);
    fshader = glCreateShader(GL_FRAGMENT_SHADER);
     
    glShaderSource(vshader, length,source, NULL);
    glShaderSource(fshader, length,source2, NULL);
     
    glCompileShader(vshader);
    glCompileShader(fshader);
     
    shaderprog = glCreateProgram();
    glAttachShader(shaderprog,vshader);
    glAttachShader(shaderprog,fshader);
    glLinkProgram(shaderprog);
     
    loc = glGetAttribLocation(shaderprog, "Tangent");
    glEnableVertexAttribArray(loc);
    glVertexAttribPointer(loc,3,GL_FLOAT,GL_FALSE,0,tangents);
    Running a Radeon 9600 Pro, latest catalyst drivers. Anybody know what I'm doing wrong?

  2. #2
    Junior Member Regular Contributor execom_rt's Avatar
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    237

    Re: gldrawelements crash

    Originally posted by adamnation:
    loc = glGetAttribLocation(shaderprog, "Tangent");
    glEnableVertexAttribArray(loc);
    glVertexAttribPointer(loc,3,GL_FLOAT,GL_FALSE,0,ta ngents);
    it's non sense. Write instead :
    Code :
    glBindAttribLocationARB(program, 6, "Tangent"); // Use attrib 6 (reserved for tangents - see glTangentPointerEXT).
    glLinkProgramARB(program); // Need to link a second time.	
    glVertexAttribPointer(6,3,GL_FLOAT,GL_FALSE,0,tangents);

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    21

    Re: gldrawelements crash

    What about what I wrote is non-sense? Exactly how is that not the proper way to send vertex attributes to a shader?

    What benefit is derived from using location six for tangents? Its just a vec3 in the shader anyways. Why is glBind AttribLocations being used instead of what I have?

    Confused,
    AdamNation

  4. #4
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    269

    Re: gldrawelements crash

    Dont worry. You can ask for the attribute location AFTER the program was linked, instead of assign manually the slot.

    A crash at a glDrawxxxx call, is caused usually by a bad initialization of the used arrays. You probably forgot to disable any array that was previoulsly enabled but is not used, or some of the used arrays are smaller than they should be (perhaps because you are setting up a vec3 vector and passing an array of vec2 vectors), or you are using an invalid pointer... There are a lot of possibilites.
    "I don't know... with a casual fly"

  5. #5
    Junior Member Regular Contributor execom_rt's Avatar
    Join Date
    Jul 2000
    Location
    Canada
    Posts
    237

    Re: gldrawelements crash

    Yes, it might something else than the vertex attrib binding.

    Try a very simple shader, see what's happening, or use GLIntercept, this will help to track down othe issues.

  6. #6
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    21

    Re: gldrawelements crash

    Okay, I'm using glBindAttribLocation as well as gldrawarrays now, I've also made sure that all the data was where it was supposed to be, so there's no missing values, or too-short arrays or anything like that.

    Still its crashing. Now when I comment all the shader code out, it runs fine.

    One interesting note, after:
    Code :
    glEnableVertexAttribArray(loc);
    glVertexAttribPointer(loc,3,GL_FLOAT,GL_FALSE,0,tangents);
    I have:
    Code :
    void* foo = NULL;
    glGetVertexAttribPointerv(loc[9],GL_VERTEX_ATTRIB_ARRAY_POINTER,&foo);
    The value returned to foo is NULL, so looks like there's trouble with glVertexAttribPointer.

    Thanks!
    AdamNation

Posting Permissions

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