[osg-users] osgText and OpenGL ES 3
Sebastian Messerschmidt
sebastian.messerschmidt at gmx.de
Tue Aug 2 08:55:04 PDT 2016
Hi Benjamin,
Can you simply set the color to red in the fragment shader to see, if it
is indeed applied?
Cheers
Sebastian
> Thanks for your answer Sebastian.
>
> I am using the gl3TextVertexShader and gl3TextFragmentShader shaders from the example, juste modifying the version to be GLES 3 compatible: #version 300 es
>
> Here is the code:
>
> Code:
>
> static const char *gl3TextVertexShader = {
> "#version 300 es\n"
> "in vec4 osg_Vertex;\n"
> "in vec4 osg_Color;\n"
> "in vec4 osg_MultiTexCoord0;\n"
> "uniform mat4 osg_ModelViewProjectionMatrix;\n"
> "out vec2 texCoord;\n"
> "out vec4 vertexColor;\n"
> "void main(void)\n"
> "{\n"
> " gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
> " texCoord = osg_MultiTexCoord0.xy;\n"
> " vertexColor = osg_Color; \n"
> "}\n"
> };
>
> static const char *gl3TextFragmentShader = {
> "#version 300 es\n"
> "uniform sampler2D GlyphTexture;\n"
> "in vec2 texCoord;\n"
> "in vec4 vertexColor;\n"
> "out vec4 color;\n"
> "void main(void)\n"
> "{\n"
> " color = vertexColor * texture(GlyphTexture, texCoord).rrrr;\n"
> "}\n"
> };
>
>
>
>
> Following the example and your recommendation, I specified the uniform (not present in the original example):
>
> Code:
>
> osg::Group* rootNode = new osg::Group;
>
> osgText::Font* font = osgText::readFontFile("fonts/ArialMT.ttf");
>
> //osg::setNotifyLevel(osg::INFO);
>
> osg::Geode* geode = new osg::Geode;
> rootNode->addChild(geode);
>
> bool useVBOs = true;
> osg::Program* program = new osg::Program;
> program->addShader(new osg::Shader(osg::Shader::VERTEX, gl3TextVertexShader));
> program->addShader(new osg::Shader(osg::Shader::FRAGMENT, gl3TextFragmentShader));
>
> osg::ref_ptr<osg::Uniform> textTexture = new osg::Uniform("GlyphTexture",0);
>
> osg::StateSet* ss = geode->getOrCreateStateSet();
> ss->addUniform(textTexture);
> ss->setAttributeAndModes(program, osg::StateAttribute::ON);
>
>
>
>
> But the result is the same.
> What I am doing wrong?
>
> Cheers,
> Benjamin
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68255#68255
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list