Andy,
 
Glad you figured it out.  I was pretty much doing the same thing, but added the extra step of checking the log for instances of "error".
 
I originally added this functionality to check for obvious compilation errors (syntax, etc), but this doesn't work if the user's system doesn't support GLSL.  I don't know if you're already performing this check, but if not here's a code snippet that someone recommended:
 
osg::GL2Extensions* gl2Ext = osg::GL2Extensions::Get(contextID, true);
if (!gl2Ext->isGlslSupported())
{
    // do whatever here
}
 
Basically I do this quick test first.  If it passes I continue on to the test compile and info log checking.
 
-- Dan


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andy Preece
Sent: Friday, November 03, 2006 7:11 AM
To: osg users
Subject: RE: [osg-users] Shader debug

Just had a thought…. My shader compiles successfully as it has no errors, so I tried introducing an error into the shader and Bingo!

 

Now I get ‘Loaded Shader OK: ‘Error: <error message>’ for context 0.

 

I guess you don’t get a log if the shader compiles OK. J

 

Andy.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andy Preece
Sent: 03 November 2006 14:42
To: osg users
Subject: RE: [osg-users] Shader debug

 

Hi Dan,

 

Here is my code snippet. Can you spot what I am doing wrong? It looks like your suggested fix!

 

I always get the message ‘Loaded Shader failed: ‘’ for context 0.’

 

I am using OSG 1.1.

 

Regards,

Andy

 

void CSockTestView::OnShowWindow( BOOL bShow,UINT nStatus )

{

  printf( "\nIn CSockTestView::OnShowWindow\n" ) ;

  if ( bShow && !renderSurfaceRealized )

  {

    m_RenderSurface -> realize() ;

    renderSurfaceRealized = true ;

 

    unsigned int contextID = m_SceneView -> getState() -> getContextID() ;

    osg::Shader *fragShad = noiseProgram -> getShader( 0 ) ;

    printf( "Fragment prog: 0x%p.\n", fragShad ) ;

 

    fragShad -> compileShader( contextID ) ;

 

    // Added these lines out of desperation!!

    m_SceneView -> update();

    m_SceneView -> cull();

    m_SceneView -> draw();

 

    std::string logStr ;

 

    if ( fragShad -> getGlShaderInfoLog( contextID, logStr ) )

      printf( "\nLoaded shader OK: '%s' for context %d.\n", logStr.c_str(), contextID ) ;

    else

      printf( "\nLoaded shader failed: '%s' for context %d.\n", logStr.c_str(), contextID  ) ;

  }

 

  CView::OnShowWindow(bShow, nStatus);

}

 

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gilbert, Daniel R.
Sent: 26 October 2006 17:16
To: osg users
Subject: RE: [osg-users] Shader debug

 

Hi Andy,

 

I had to do something similar recently, as I wanted to be able to fall back

to a non-shader approach for some functionality if anything went wrong

during the compile.

 

I'm not sure when you're attempting to access shader->getGlShaderInfoLog(),

but I also was getting false and and empty string when I first tried.  In my

case it was because I was trying to access it before it was actually

compiled.  Forcing it to compile first worked for me:

 

 osg::Shader* shader = program->getShader(0);  // I only have 1 shader

attached

 shader->compileShader(contextID);   // contextID

 bool logFound = shader->getGlShaderInfoLog(contextID, log);

 

This did the trick for me at least.

 

Hope this helps,

 

-- Dan

 

> -----Original Message-----

> From: [EMAIL PROTECTED]

> [mailto:[EMAIL PROTECTED] On Behalf Of Andy Preece

> Sent: Thursday, October 26, 2006 9:06 AM

> To: osg users

> Subject: RE: [osg-users] Shader debug

>

> Hi,

>

> That's fine for applications that have a console. I am

> writing a Windows

> based application that has no console so stdout output is lost.

>

> However, I would like to catch a situation where a shader fails to

> compile and display a pop up screen with the shader info.

>

> Is there a way I can achieve this?

>

> Andy.

>

> -----Original Message-----

> From: [EMAIL PROTECTED]

> [mailto:[EMAIL PROTECTED] On Behalf Of

> Charles Cosse

> Sent: 26 October 2006 15:19

> To: osg users

> Subject: Re: [osg-users] Shader debug

>

> Hi,

>

> on linux you can export OSG_NOTIFY_LEVEL=DEBUG and recompile ... then

> shader info is printed to the terminal when you run.  Maybe

> that helps..

>

> -charlie

>

> Andy Preece wrote:

>

> > Hi All,

> >

> > 

> >

> > Can anyone show me how to get the shader info log from an

> osg::shader

> > class?

> >

> > I have tried using the osg::Shader::getGlShaderInfoLog()

> method but it

>

> > always return false and the string returned is always NULL.

> >

> > 

> >

> > Regards,

> >

> > Andy

> >

> >

> >

> ______________________________________________________________

> __________

> > This e-mail has been scanned for all viruses by Star.The service is

> > powered by MessageLabs.

> >

> ______________________________________________________________

> __________

> >

> >-------------------------------------------------------------

> ----------

> -

> >

> >_______________________________________________

> >osg-users mailing list

> >osg-users@openscenegraph.net

> >http://openscenegraph.net/mailman/listinfo/osg-users

> >http://www.openscenegraph.org/

> >

> _______________________________________________

> osg-users mailing list

> osg-users@openscenegraph.net

> http://openscenegraph.net/mailman/listinfo/osg-users

> http://www.openscenegraph.org/

>

> ______________________________________________________________

> __________

> This e-mail has been scanned for all viruses by Star.The

> service is powered by MessageLabs.

> ______________________________________________________________

> __________

> _______________________________________________

> osg-users mailing list

> osg-users@openscenegraph.net

> http://openscenegraph.net/mailman/listinfo/osg-users

> http://www.openscenegraph.org/

>

_______________________________________________

osg-users mailing list

osg-users@openscenegraph.net

http://openscenegraph.net/mailman/listinfo/osg-users

http://www.openscenegraph.org/


________________________________________________________________________
This e-mail has been scanned for all viruses by Star.The service is powered by MessageLabs.
________________________________________________________________________


________________________________________________________________________
This e-mail has been scanned for all viruses by Star.The service is powered by MessageLabs.
________________________________________________________________________
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to