<div>system Win10& GTX1660 ,osg 3.6.4, osgearth 2.10.0 <br></div><div><br></div><div><br></div><div><img alt="QQ图片20201204163639.jpg" data-iml="1257268.8449999988" width="534px" height="401px" src="cid:4c442f21-4801-458c-ab5d-c93e9fd6f957"> </div><div>static const char* gl3_VertexShader = {</div><div> "#version 330 core\n"</div><div> "// gl3_VertexShader\n"</div><div> "#ifdef GL_ES\n"</div><div> " precision highp float;\n"</div><div> "#endif\n"</div><div> "in vec4 osg_Vertex;\n"</div><div> "in vec4 osg_MultiTexCoord0;\n"</div><div> "uniform mat4 osg_ModelViewProjectionMatrix;\n"</div><div> "out vec2 texCoord;\n"</div><div> "void main(void)\n"</div><div> "{\n"</div><div> " gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"</div><div> " texCoord = osg_MultiTexCoord0.xy;\n"</div><div> "}\n"</div><div>};</div><div><br></div><div>static const char* gl3_FragmentShader = {</div><div> "#
version 330 core "\n"</div><div> "// gl3_FragmentShader\n"</div><div> "#ifdef GL_ES\n"</div><div> " precision highp float;\n"</div><div> "#endif\n"</div><div> "uniform sampler2D baseTexture;\n"</div><div> "in vec2 texCoord;\n"</div><div> "out vec4 color;\n"</div><div> "void main(void)\n"</div><div> "{\n"</div><div> " color = texture(baseTexture, texCoord);\n"</div><div> "}\n"</div><div>};</div><div><br></div><div><br></div><div> Geometry* geom = new Geometry;</div><div><br></div><div> Vec3Array* coords = new Vec3Array(4);</div><div> (*coords)[0] = corner+heightVec;</div><div> (*coords)[1] = corner;</div><div> (*coords)[2] = corner+widthVec;</div><div> (*coords)[3] = corner+widthVec+heightVec;</div><div> geom->setVertexArray(coords);</div><div><br></div><div> Vec2Array* tcoords = new Vec2Array(4);</div><div> (*tcoords)[0].set(l,t);</div><div> (*tcoords)[1].set(l,b);</div><div> (*tcoords)[2].set(r,b);</div><div> (*tcoords)[3].set(r,t);</div><div> geom->setTexCoordArray(0,tcoords);</div><div><br></div><div> osg::Vec4Array* colours = new osg::Vec4Array(1);</div><div> (*colours)[0].set(1.0f,1.0f,1.0,1.0f);</div><div> geom->setColorArray(colours, osg::Array::BIND_OVERALL);</div><div><br></div><div> osg::Vec3Array* normals = new osg::Vec3Array(1);</div><div> (*normals)[0] = widthVec^heightVec;</div><div> (*normals)[0].normalize();</div><div> geom->setNormalArray(normals, osg::Array::BIND_OVERALL);</div><div><br></div><div> DrawElementsUByte* elems = new DrawElementsUByte(PrimitiveSet::TRIANGLES);</div><div> elems->push_back(0);</div><div> elems->push_back(1);</div><div> elems->push_back(2);</div><div><br></div><div> elems->push_back(2);</div><div> elems->push_back(3);</div><div> elems->push_back(0);</div><div> geom->addPrimitiveSet(elems);</div><div><br></div><div><div> osg::ref_ptr<osg::Image> image = new osg::Image;</div><div> image->allocateImage(1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE);</div><div> image->setColor(osg::Vec4(1.0,1.0,1.0,1.0), 0, 0, 0);</div><div><br></div><div> osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D(image.get());</div></div><div><br></div><div><div> osg::ref_ptr<osg::Program> program = new osg::Program;</div><div> program->addShader(new osg::Shader(osg::Shader::VERTEX, gl3_VertexShader));</div><div> program->addShader(new osg::Shader(osg::Shader::FRAGMENT, gl3_FragmentShader));</div><div> setAttributeAndModes(program.get());</div><div> setTextureAttribute(0,
texture);</div><div> addUniform(new osg::Uniform("baseTexture", 0));</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:osg-users+unsubscribe@googlegroups.com">osg-users+unsubscribe@googlegroups.com</a>.<br />
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/osg-users/79f7c364-d90f-4462-890d-e7ec3fbfc7e5n%40googlegroups.com?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/osg-users/79f7c364-d90f-4462-890d-e7ec3fbfc7e5n%40googlegroups.com</a>.<br />