<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Dear all,<br>
    <br>
    my project needs gl3 features and so I use the following methods:<br>
    <span style=" color:#c0c0c0;"> <br>
    </span>
    <pre>camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(<span style=" color:#800000;">useGL3</span>);
</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(<span style=" color:#800000;">useGL3</span>);

</pre>
    Of course I need my own shaders then.<br>
    But I also like having built-in functionality like StatsHandler.<br>
    To set a simple shader for the StatsHandlers camera I do like that:<br>
    <span style=" color:#c0c0c0;"><br>
    </span><span style=" color:#800080;">osgViewer</span>::<span style="
      color:#800080;">StatsHandler</span><span style=" color:#c0c0c0;">
    </span>*<span style=" color:#c0c0c0;"> </span>sthd<span style="
      color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span
      style=" color:#808000;">new</span><span style=" color:#c0c0c0;"> </span><span
      style=" color:#800080;">osgViewer</span>::<span style="
      color:#800080;">StatsHandler</span>;
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#800000;">view</span>->addEventHandler(sthd);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">if</span><span style=" color:#c0c0c0;"> </span>(<span style=" color:#800000;">useGL3</span>)<span style=" color:#c0c0c0;"> </span>{
<span style=" color:#c0c0c0;">    </span>stateSet<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>sthd->getCamera()->getOrCreateStateSet();</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>stateSet->getOrCreateUniform(<span style=" color:#000080;">BASE_TEXTURE_UNIFORM</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Uniform</span>::<span style=" color:#800080;">INT_SAMPLER_2D</span>)->set(BASE_TEXTURE_UNIT);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>stateSet->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,<span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">textur_weiss</span>.get(),<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">StateAttribute</span>::<span style=" color:#800080;">ON</span>);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>installDefaultShader(stateSet);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">}</pre>
    <pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
    The shaders are really simple:<br>
    VERTEX<br>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">uniform</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">mat4</span><span style=" color:#c0c0c0;"> </span>osg_ModelViewProjectionMatrix;
<span style=" color:#808000;">uniform</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">mat4</span><span style=" color:#c0c0c0;"> </span>osg_ModelViewMatrix;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">uniform</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">mat3</span><span style=" color:#c0c0c0;"> </span>osg_NormalMatrix;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">uniform</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec3</span><span style=" color:#c0c0c0;"> </span>lightPosition0<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec3</span>(<span style=" color:#000080;">0.0f</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0.0f</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1.0f</span>);

</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>osg_Vertex;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>osg_Normal;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>osg_Color;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>osg_MultiTexCoord0;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" color:#808000;">out</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec3</span><span style=" color:#c0c0c0;"> </span>normal;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">out</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec3</span><span style=" color:#c0c0c0;"> </span>lightDir;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">out</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>vertexColor;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">out</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec2</span><span style=" color:#c0c0c0;"> </span>textureCoord;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" color:#808000;">void</span><span style=" color:#c0c0c0;"> </span>main()<span style=" color:#c0c0c0;"> </span>{</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>normal<span style=" color:#c0c0c0;">    </span>=<span style=" color:#c0c0c0;"> </span>normalize(osg_NormalMatrix<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>osg_Normal.xyz);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">vec3</span><span style=" color:#c0c0c0;"> </span>vertexPos<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec3</span>(osg_ModelViewMatrix<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>osg_Vertex);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>lightDir<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>normalize(lightPosition0<span style=" color:#c0c0c0;"> </span>-<span style=" color:#c0c0c0;"> </span>vertexPos);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>vertexColor<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>osg_Color;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>textureCoord<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>osg_MultiTexCoord0.xy;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span>gl_Position<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>osg_ModelViewProjectionMatrix<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>osg_Vertex;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">}</pre>
    <br>
    FRAGMENT<br>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">uniform</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">sampler2D</span><span style=" color:#c0c0c0;">   </span>baseTexture;

<span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec3</span><span style=" color:#c0c0c0;"> </span>normal;
<span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec3</span><span style=" color:#c0c0c0;"> </span>lightDir;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>vertexColor;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#808000;">in</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec2</span><span style=" color:#c0c0c0;"> </span>textureCoord;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" color:#808000;">out</span><span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>fragData;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
<span style=" color:#808000;">void</span><span style=" color:#c0c0c0;"> </span>main()<span style=" color:#c0c0c0;"> </span>{</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;">    </span><span style=" color:#808000;">vec4</span><span style=" color:#c0c0c0;"> </span>textureColor<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>texture2D(baseTexture,<span style=" color:#c0c0c0;"> </span>textureCoord);
<span style=" color:#c0c0c0;">    </span>fragData<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>vertexColor<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>textureColor<span style=" color:#c0c0c0;"></span><span style=" color:#c0c0c0;"></span>;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">}</pre>
    <br>
    That works fine for the graphics but all text is black. Obviously
    text does not set osg_Color
    .<br>
    Unfortunately I failed discovering the reason in the sources of osg.<br>
    <br>
    Can anyone give me a hint on how to solve this?<br>
    <br>
    Many thanks in advance<br>
    <br>
    - Werner -<br>
    <br>
  </body>
</html>