Re: [osg-users] OSG and OpenGL ES 2.0

2011-04-18 Thread Robert Osfield
Hi Ankur,

On Sat, Apr 16, 2011 at 10:40 AM, Ankur Gandhi  wrote:
> You are right. both are quire different. I ported OSG over OpenGL ES 2.0 and 
> everything is behaving in different way. I guess I almost need to rewrite my 
> OpenGL application. Also i think i need to go through ShaderGen to understand 
> how well the OpenGL application gets converted to GLSL language.

The big difference with GLES2 is that there is no fixed function
pipeline so you have to provide shaders yourself.  This situtation is
the same for the GL 3.x and beyond profiles where backwards
compatability is dropped, so it's in't really a case of GL vs GLES2,
rather it's GL1/GLES1 fixed function vs GL3/GL4/GLES2 shader based,
with GL2 sitting on the fence - doing both fixed function and shaders.

You can also used shaders entirely with GL2, and even your the CMake
to build only the shader backends, and not implement the fixed
function state, so replicate much of what it takes to program GLES2
entirely on a machine with only GL2 available.  This approach also
allows you to build final applications that will more easily port
between desktop and GLES2 targets.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG and OpenGL ES 2.0

2011-04-16 Thread Ankur Gandhi
Hi Jorge,

You are right. both are quire different. I ported OSG over OpenGL ES 2.0 and 
everything is behaving in different way. I guess I almost need to rewrite my 
OpenGL application. Also i think i need to go through ShaderGen to understand 
how well the OpenGL application gets converted to GLSL language.


Cheers,
Ankur

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38519#38519





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG and OpenGL ES 2.0

2011-04-07 Thread Jorge Izquierdo Ciges
Just an advice. Do not try to start by learning gles in a emulator. It's
tricky and it's not real. There are more differences and incompabilities
that people can think about. Some of them can be very puzzling and difficult
to find inside Osg.
El 07/04/2011 17:39, "Ankur Gandhi"  escribió:
> Hi Christian,
>
> Thanks for your input and source code that you shared. I had tried your
program however my application crashes with segmentation fault. when i check
backtrace, it shows crashing point at the drivers (i am using intel i915
display).
>
> actually I am pretty new to OpenGL & OpenGL ES too. so concept of Shader
is new to me. So i think i need to go through shader first! :-) Also, i used
OpenGL emulation for OSG build. now i think i will try by installing OpenGL
ES library and perform build for actual GLES2.
>
> I will update you soon regarding my activities.
>
> Thanks again for help!
>
> Regards/Ankur
>
>
>
> Christian wrote:
>> Hi,
>>
>> just one addition to my previous post: Normally you wouldn't define an
extra vertex attribute array for the vertex color/normal as I did in this
test code. Just use
>>
>> void Geometry::setColorArray(Array* array);
>> void Geometry::setNormalArray(Array* array);
>>
>> and access the vertex color/normal in the vertex shader via "osg_Color"
and "osg_Normal" (OSG will do the mapping for you).
>>
>> Cheers,
>> Christian
>
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=38291#38291
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG and OpenGL ES 2.0

2011-04-07 Thread Ankur Gandhi
Hi Christian,

Thanks for your input and source code that you shared. I had tried your program 
however my application crashes with segmentation fault. when i check backtrace, 
it shows crashing point at the drivers (i am using intel i915 display).

actually I am pretty new to OpenGL & OpenGL ES too. so concept of Shader is new 
to me. So i think i need to go through shader first! :-) Also, i used OpenGL 
emulation for OSG build. now i think i will try by installing OpenGL ES library 
and perform build for actual GLES2.

I will update you soon regarding my activities.

Thanks again for help!

Regards/Ankur



Christian wrote:
> Hi,
> 
> just one addition to my previous post: Normally you wouldn't define an extra 
> vertex attribute array for the vertex color/normal as I did in this test 
> code. Just use 
> 
> void Geometry::setColorArray(Array* array);
> void Geometry::setNormalArray(Array* array);
> 
> and access the vertex color/normal in the vertex shader via "osg_Color" and 
> "osg_Normal" (OSG will do the mapping for you).
> 
> Cheers,
> Christian


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38291#38291





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG and OpenGL ES 2.0

2011-04-06 Thread Christian Ruzicka
Hi,

just one addition to my previous post: Normally you wouldn't define an extra 
vertex attribute array for the vertex color/normal as I did in this test code. 
Just use 

void Geometry::setColorArray(Array* array);
void Geometry::setNormalArray(Array* array);

and access the vertex color/normal in the vertex shader via "osg_Color" and 
"osg_Normal" (OSG will do the mapping for you).

Cheers,
Christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38270#38270





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG and OpenGL ES 2.0

2011-04-06 Thread Christian Ruzicka
Hi,

it's just a really simple scene but it should help you figuring out, if your 
OpenGLES 2.0 support works (tested on iPhone):


Code:
// create geometry
osg::Group* scene = new osg::Group;
osg::Geode* geode = new osg::Geode;
osg::Geometry* geo = new osg::Geometry;
scene->addChild(geode);
geode->addDrawable(geo);

// set vertices
osg::Vec3Array* vertices = new osg::Vec3Array;
vertices->push_back(osg::Vec3(0.0, 0.0, 0.0));
vertices->push_back(osg::Vec3(0.0, 0.0, 1.0));
vertices->push_back(osg::Vec3(1.0, 0.0, 0.0));
vertices->push_back(osg::Vec3(1.0, 0.0, 1.0));
geo->setVertexArray(vertices);

// set colors
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.0, 0.0, 0.0, 1.0));
colors->push_back(osg::Vec4(0.0, 1.0, 0.0, 1.0));
colors->push_back(osg::Vec4(0.0, 0.0, 1.0, 1.0));
colors->push_back(osg::Vec4(1.0, 0.0, 1.0, 1.0));
geo->setVertexAttribArray(7, colors);
geo->setVertexAttribBinding(7, osg::Geometry::BIND_PER_VERTEX);

// set primitive set
geo->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4));
geo->setUseVertexBufferObjects(true);

// declare shaders
char vertSource[] =
"attribute vec4 osg_Vertex;\n"
"attribute vec4 a_col;"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"varying vec4 v_col;"

"void main(void)\n"
"{\n"
"gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
"v_col = a_col;\n"
"}\n";

char fragSource[] =
"precision mediump float;\n"
"varying vec4 v_col;"

"void main(void)\n"
"{\n"
"gl_FragColor = v_col;\n"
"}\n";

// set shader
osg::Program* program = new osg::Program;
program->setName( "simple shader" );
program->addShader( new osg::Shader( osg::Shader::VERTEX, vertSource ) );
program->addShader( new osg::Shader( osg::Shader::FRAGMENT, fragSource ) );
program->addBindAttribLocation("a_col", 7);
geode->getOrCreateStateSet()->setAttributeAndModes( program, 
osg::StateAttribute::ON );

// set scene in viewer...




HTH,
Christian

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38263#38263





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] OSG and OpenGL ES 2.0

2011-04-06 Thread Ankur Gandhi
Hi,

I am a new member of OSG. I am using 2.9.11 (latest developer release) version 
of OSG. In last few weeks, I used OSG over OpenGL. All the examples and 
Tutorials that are posted on the site have been very useful in learning OSG. 
Now, I want to use OSG over OpenGL ES 2.0. For this, I have modified cmake 
variables accordingly to emulate OpenGL ES on my ubuntu system. However I can't 
seem to get any example work. I get many different kinds of errors as below.


Warning: Material::apply(State&) - not supported.
Warning: TexEnv::apply(State&) - not supported.
Warning: Material::apply(State&) - not supported.
Warning: TexEnv::apply(State&) - not supported.
Warning: Material::apply(State&) - not supported.
Warning: TexEnv::apply(State&) - not supported.
Warning: Material::apply(State&) - not supported.
Warning: TexEnv::apply(State&) - not supported.
Warning: Material::apply(State&) - not supported.
Warning: TexEnv::apply(State&) - not supported.
Warning: Material::apply(State&) - not supported.
Warning: TexEnv::apply(State&) - not supported.
Warning: Material::apply(State&) - not supported.
Warning: TexEnv::apply(State&) - not supported.
Segmentation fault


After going through old posts, i found that these examples won't work directly 
over OpenGL es.

I would like to know if there are any examples available which i can use over 
OpenGL ES. It would really help me in figuring out if my OSG recompilation is 
successful and it will enable me to learn OSG over opengl ES.

Thank you!

Cheers,
Ankur

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38244#38244





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org