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

> >[email protected]

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

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

> >

> _______________________________________________

> osg-users mailing list

> [email protected]

> 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

> [email protected]

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

> http://www.openscenegraph.org/

>

_______________________________________________

osg-users mailing list

[email protected]

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
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to