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:

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x0804b914 in installShaders (Vertexx=0xc227794 "

void main(void)
{

	       gl_Position = gl_ModelViewProjectionMatrix * a;
	       }
", 
    Fragment=0xc227fb4 "void main (void)
{
   gl_FragColor = vec4(1.0,0.0,0.0, 1.0);
   }
") 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_STATUS_ARB,&fragCompiled);

if(!vertCompiled

uuh it’s too late here in Germany :wink:
I’ve forgotten to post these things(misteriously they became snapped away as I posted :confused: …) 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

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

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

 
 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,&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

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

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 :frowning: ).
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.

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.

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.

im now linking to GLew and have included glew.h

except this the new code for loading the shaders is now looking like that:

 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,&Vertex, NULL);
  glShaderSourceARB(FS,1,&Fragment, NULL);

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

  glCompileShaderARB(FS);
  glGetObjectParameterivARB(VS,GL_OBJECT_COMPILE_STATUS_ARB,&fragCompiled);

  if(!vertCompiled)
  {
    cout <<"
Vertexshader: nix compilieren gehen!";
     return 0;
  }  
  if(!fragCompiled)
  {
	  cout <<"
Fragmentshader: nix compilieren gehen!";
	  return 0;
  }

  Prog=glCreateProgramObjectARB();
  glAttachObjectARB(Prog,VS);
  glAttachObjectARB(Prog,FS);

  glLinkProgramARB(Prog);
  glGetObjectParameterivARB(Prog,GL_OBJECT_LINK_STATUS_ARB,&linked);

  if(!linked)
  {
	  cout <<"
Konnte Shader nicht linken!";
     return 0;
  }	  

  glUseProgramObjectARB(Prog);

  cout<<"
shader installiert!";
  return 1;                                                                                                            
}     

I hope this is enought information. I dont really know anymore what exactly I’ve changed, sorry.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.