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

Thread: Loading shader-sourcecode

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Loading shader-sourcecode

    Hello,
    today I've updated my linux-kernel to version 2.6.10. Everything ran okay, but as I tried to compile and run my program (which is using shaders) I became a Segmentation Fault. I've debugged and backtraced the proggy with gdb but the Output of gdb seems a bit confusing to me:
    Code :
    Program received signal SIGSEGV, Segmentation fault.
    0x00000000 in ?? ()
    (gdb) bt
    #0  0x00000000 in ?? ()
    #1  0x0804b914 in installShaders (Vertexx=0xc227794 "\n\nvoid main(void)\n{\n\n\t       gl_Position = gl_ModelViewProjectionMatrix * a;\n\t       }\n", 
        Fragment=0xc227fb4 "void main (void)\n{\n   gl_FragColor = vec4(1.0,0.0,0.0, 1.0);\n   }\n") at main.cpp:79
    #2  0x0804bc3e in OpenShaderSource () at main.cpp:128
    #3  0x0804e438 in initVideo () at main.cpp:877
    #4  0x0804e4d1 in main (argc=1, argv=0xbffffcd4) at main.cpp:886
    the code which is responsible for loading the shaders is:
    </font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> int installShaders(const GLcharARB *Vertex,
    const GLcharARB *Fragment)
    {
    GLhandleARB Prog, VS, FS;
    GLint vertCompiled, fragCompiled, linked;

    VS = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
    FS = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);

    glShaderSourceARB(VS,1,&Vertex, NULL);
    glShaderSourceARB(FS,1,&Fragment, NULL);

    glCompileShaderARB(VS);
    glGetObjectParameterivARB(VS, GL_OBJECT_COMPILE_STATUS_ARB, &vertCompiled);

    glCompileShaderARB(FS);
    glGetObjectParameterivARB(VS,GL_OBJECT_COMPILE_STA TUS_ARB,&fragCompiled);

    if(!vertCompiled

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Re: Loading shader-sourcecode

    uuh it's too late here in Germany
    I've forgotten to post these things(misteriously they became snapped away as I posted ...) so here they are :
    I don't really get why the prog is crashing with the new kernel and running with the old one. Graphics card is a nvidia geforce fx5900 ultra.
    Does anybody of you find the problem in my function? I'm really stuck right here.
    Thanks a lot and greetings

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Re: Loading shader-sourcecode

    right now it attracted my attention, that some of the code was snapped off, too.
    here is the missing code:
    </font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> if(!vertCompiled

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Re: Loading shader-sourcecode

    wtf?
    </font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
    if(!vertCompiled

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Re: Loading shader-sourcecode

    Code :
     if(!vertCompiled OR !fragCompiled)
      {
        cout <<"nix compilieren gehen!";
         return 0;
      }  
     
      Prog=glCreateProgramObjectARB();
      glAttachObjectARB(Prog,VS);
      glAttachObjectARB(Prog,FS);
     
      glLinkProgramARB(Prog);
      glGetObjectParameterivARB(Prog,GL_OBJECT_LINK_STATUS_ARB,&amp;linked);
     
      if(!linked)
         return 0;
     
      glUseProgramObjectARB(Prog);
     
      cout<<"shader installiert!";
      return 1;                                                                                                            
    }
    the OR-Operator made the board snap of the code ... sry for the multiple posts

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    601

    Re: Loading shader-sourcecode

    Just some things to check and verify.

    1) Did you reinstall the NVIDIA drivers for the new kernel? You should - the nvidia drivers appear to be specific for each kernel though it uninstalls it from each prior kernel's /lib/modules (wish they would fix that). Also verify you are using the latest drivers.

    2) Did you build the 2.6.10 kernel yourself? Verify that you did not change an important parameter. You might want to compare the output for the X server start up usually found in /var/log under either Xorg.n.log or XFree86.n.log where n is a number between the 2 kernels. Also verify that vesafb was not vuilt into the kernel as it supposedly causes problems with the NV drivers.

    Other than that I cannot think of anything useful.

    Good luck

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Re: Loading shader-sourcecode

    hello,
    Yes I've built the kernel myself. Rivafb is not compiled into the kernel. And I've reinstalled the nvidia-drivers(newest version) after installing the new kernel.
    I cant check what has changed in the logfile of the xserver because I've deleted the old kernel (the .config, too ).
    Do you think the code is ok or could it be that there are any errors? It could be possible, because today, I've found a bug which didnt make any effect with the old kernel but crashes the system with the new one.

  8. #8
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Re: Loading shader-sourcecode

    okay I got it running now. I think the main reason for the crashing was that I was using GLee to load my extensions. Now the job is done by Glew. Except this I tweaked the code a bit around here and there.

  9. #9
    Junior Member Regular Contributor
    Join Date
    Jun 2004
    Location
    Minneapolis, USA
    Posts
    100

    Re: Loading shader-sourcecode

    McRip, if it is not too much trouble, can
    you post the code with the changes made after you
    went with GLew ? Thanks. Just curious.

  10. #10
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Überlingen, Germany
    Posts
    10

    Re: Loading shader-sourcecode

    im now linking to GLew and have included glew.h

    except this the new code for loading the shaders is now looking like that:
    Code :
     int installShaders(const GLcharARB *Vertex,
                                  const GLcharARB *Fragment)
    {
      GLhandleARB Prog, VS, FS;
      GLint vertCompiled, fragCompiled;
      GLint	linked;
     
      VS = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
      FS = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
     
      glShaderSourceARB(VS,1,&amp;Vertex, NULL);
      glShaderSourceARB(FS,1,&amp;Fragment, NULL);
     
      glCompileShaderARB(VS);
      glGetObjectParameterivARB(VS, GL_OBJECT_COMPILE_STATUS_ARB, &amp;vertCompiled);
     
      glCompileShaderARB(FS);
      glGetObjectParameterivARB(VS,GL_OBJECT_COMPILE_STATUS_ARB,&amp;fragCompiled);
     
      if(!vertCompiled)
      {
        cout <<"\nVertexshader: nix compilieren gehen!";
         return 0;
      }  
      if(!fragCompiled)
      {
    	  cout <<"\nFragmentshader: nix compilieren gehen!";
    	  return 0;
      }
     
      Prog=glCreateProgramObjectARB();
      glAttachObjectARB(Prog,VS);
      glAttachObjectARB(Prog,FS);
     
      glLinkProgramARB(Prog);
      glGetObjectParameterivARB(Prog,GL_OBJECT_LINK_STATUS_ARB,&amp;linked);
     
      if(!linked)
      {
    	  cout <<"\nKonnte Shader nicht linken!";
         return 0;
      }	  
     
      glUseProgramObjectARB(Prog);
     
      cout<<"\nshader installiert!";
      return 1;                                                                                                            
    }
    I hope this is enought information. I dont really know anymore what exactly I've changed, sorry.

Posting Permissions

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