[osg-users] bug: osgText doesn't work on MacOSX GL4.x with VAO

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Fri Jan 20 12:43:42 PST 2017


Hi Remo,

A more detailed description on how it fails would be helpful.
If you're seeing non-textures quads instead of your glyphs you need to 
adapt your shader as the text-rendering isn't using a normal blending.
I've attached my default core-profile shader which uses pre-multiplied 
alpha.
Additionally I add a default sampler at camera root for the osg_Texture 
and I do:

for (auto index = 0u; index < mMainViewer->getNumViews(); ++index )
             {
getCamera(index)->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(true);
getCamera(index)->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(true);
             }

nsRenderer::Helpers::addTexture( 
stats_handler->getCamera()->getOrCreateStateSet(), "osg_Texture",new 
osg::Texture2D(nsRenderer::Helpers::getDefaultImage(false)), 0);

Hope that helps
Sebastian
> Hi,
>
> I can't render osgText on MacOSX Core Profile:
>
> text->setTextBackdropType(osgText::Text::BackdropType::NONE);
> text->setTextBackdropImplementation(osgText::Text::BackdropImplementation::DELAYED_DEPTH_WRITES);
>      
> text->setBackColor( Color( Color::Black, 0.8 ) );
> text->setHorizAlign( Control::ALIGN_RIGHT );
> text->setVertAlign( Control::ALIGN_BOTTOM );
> text->setVisible( true );
>
> I've also tried to apply a default shader. But it doesn't work at all.
>   
> Cheers,
> Remo
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70020#70020
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

-------------- next part --------------
#version 440
#extension GL_ARB_enhanced_layouts : enable
#extension GL_ARB_separate_shader_objects : enable

layout (location=0) out vec4 FragmentData;

layout(location=1) in block
{
	mediump vec2 tex_coord;
	mediump vec4 color;
} In;

uniform sampler2D osg_Texture;

void main()
{
	vec4 diffuse_color = In.color;
	diffuse_color *=  texture2D(osg_Texture, In.tex_coord).a;

	FragmentData = diffuse_color;
}
-------------- next part --------------
#version 440
#extension GL_ARB_enhanced_layouts : enable
#extension GL_ARB_separate_shader_objects : enable

layout (location=0) in vec4 osg_Vertex;
layout (location=1) in vec3 osg_Normal;
layout (location=2) in vec4 osg_Color;
layout (location=3) in vec4 osg_MultiTexCoord0;
#ifdef HUD_CLIP_PLANES
layout(shared) uniform instanceData
{
	vec4 clipPlane[6];
};
#endif

uniform mat4 osg_ModelViewMatrix;
uniform mat4 osg_ModelViewProjectionMatrix;
uniform mat4 TextureMatrix;

out gl_PerVertex
{
	vec4 gl_Position;
};

layout(location=1) out block
{
	mediump vec2 tex_coord;
	mediump vec4 color;
} Out;

void main()
{
	Out.color = osg_Color;
	Out.tex_coord = vec4(osg_MultiTexCoord0).xy;
	gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;

}


More information about the osg-users mailing list