Addeed support for GLES shaders
This commit is contained in:
parent
3dc3dd3bd6
commit
8b2f61ec2a
@ -469,23 +469,46 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
//useTextureRectangle = false;
|
//useTextureRectangle = false;
|
||||||
|
|
||||||
static const char *shaderSourceTextureRec = {
|
static const char *shaderSourceTextureVertex = {
|
||||||
"uniform vec4 cutoff_color;\n"
|
"#ifdef GL_ES\n"
|
||||||
"uniform samplerRect movie_texture;\n"
|
" precision highp float;\n"
|
||||||
|
" precision highp int;\n"
|
||||||
|
"#endif\n"
|
||||||
|
"varying vec4 texcoord;\n"
|
||||||
"void main(void)\n"
|
"void main(void)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 texture_color = textureRect(movie_texture, gl_TexCoord[0].st); \n"
|
" texcoord = gl_MultiTexCoord0; \n"
|
||||||
|
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||||
|
"}\n"
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *shaderSourceTextureRec = {
|
||||||
|
"#ifdef GL_ES\n"
|
||||||
|
" precision highp float;\n"
|
||||||
|
" precision highp int;\n"
|
||||||
|
"#endif\n"
|
||||||
|
"uniform vec4 cutoff_color;\n"
|
||||||
|
"uniform samplerRect movie_texture;\n"
|
||||||
|
"varying vec4 texcoord;\n"
|
||||||
|
"void main(void)\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 texture_color = textureRect(movie_texture, texcoord.st); \n"
|
||||||
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
||||||
" gl_FragColor = texture_color;\n"
|
" gl_FragColor = texture_color;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *shaderSourceTexture2D = {
|
static const char *shaderSourceTexture2D = {
|
||||||
|
"#ifdef GL_ES\n"
|
||||||
|
" precision highp float;\n"
|
||||||
|
" precision highp int;\n"
|
||||||
|
"#endif\n"
|
||||||
"uniform vec4 cutoff_color;\n"
|
"uniform vec4 cutoff_color;\n"
|
||||||
"uniform sampler2D movie_texture;\n"
|
"uniform sampler2D movie_texture;\n"
|
||||||
|
"varying vec4 texcoord;\n"
|
||||||
"void main(void)\n"
|
"void main(void)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" vec4 texture_color = texture2D(movie_texture, gl_TexCoord[0].st); \n"
|
" vec4 texture_color = texture2D(movie_texture, texcoord.st); \n"
|
||||||
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
" if (all(lessThanEqual(texture_color,cutoff_color))) discard; \n"
|
||||||
" gl_FragColor = texture_color;\n"
|
" gl_FragColor = texture_color;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
@ -493,6 +516,9 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
osg::Program* program = new osg::Program;
|
osg::Program* program = new osg::Program;
|
||||||
|
|
||||||
|
|
||||||
|
program->addShader(new osg::Shader(osg::Shader::VERTEX, shaderSourceTextureVertex));
|
||||||
|
|
||||||
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
|
program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
|
||||||
useTextureRectangle ? shaderSourceTextureRec : shaderSourceTexture2D));
|
useTextureRectangle ? shaderSourceTextureRec : shaderSourceTexture2D));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user