[osg-users] osgText and OpenGL ES 3

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Tue Aug 2 06:09:56 PDT 2016


Hi Benjamin,
> Hello,
>
> I am trying to port my project using OSG 3.4.0 on iOS.
> I first tried to modify OSG sources to be fully usable with an OpenGL ES 3 context, as other dependencies require OpenGL ES 3.
>
> I managed to run osg on my iPad, modifying shaders and removing duplicates while merging them, but osgText is making me crazy |-)
> I tried to debug using only the osgtext.cpp example.
>
> I embedded a font with my application in a bundle, and successfully load it. I modified osgText/Glyph to use GL_RED as glyph texture format.
> Only the DefaultFont is correctly rendered. Other Glyphs are not rendered, only their bouding boxes (cf. attached image).
>
> Does anyone has an idea on what could be the cause?
The osgText is build around fixed function set rendering. You need to 
supply a shader for text-rendering in your case.
I've attached my default shaders which I simply assign to the root state 
set of the scenegraph or to nodes with osg-text.
You might need to attach the correct sampler uniform to get the correct 
glyph texture however.


Cheers
Sebastian
>
> Cheers,
> Benjamin
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68251#68251
>
>
>
>
> Attachments:
> http://forum.openscenegraph.org//files/img_0029_454.png
>
>
> _______________________________________________
> 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) 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;

uniform mat4 osg_ModelViewMatrix;
uniform mat4 osg_ModelViewProjectionMatrix;


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;

}
-------------- 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;
}


More information about the osg-users mailing list