[osg-users] OSG on OpenGL 3: Example code and cookbook

187 views
Skip to first unread message

Paul Martz

unread,
Dec 31, 2011, 5:05:49 PM12/31/11
to OpenSceneGraph Users
Happy New Year, everyone --

Attached is source code that demonstrates OSG rendering using an OpenGL 3.x
context. At the bottom of the source is a comment block describing how to build
OSG for OpenGL 3.x.

I hope this is helpful.

--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/

gl3example.cpp

Alexandre Amalric

unread,
Jan 2, 2012, 4:37:15 AM1/2/12
to OpenSceneGraph Users
Hi Paul,

Did you benchmark performance improvements with GL3 enabled ?

Can you approximately quantify the FPS gain for example ?

Kind regards.

2011/12/31 Paul Martz <pma...@skew-matrix.com>
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




--
Alexandre AMALRIC                   Ingénieur R&D
===================================
PIXXIM S.A. 73E, rue Perrin-Solliers 13006 Marseille
http://www.pixxim.fr

Chris 'Xenon' Hanson

unread,
Jan 2, 2012, 12:27:36 PM1/2/12
to OpenSceneGraph Users
On 1/2/2012 2:37 AM, Alexandre Amalric wrote:
> Did you benchmark performance improvements with GL3 enabled ?

I'd be surprised if there was much difference. I would guess for a modern GPU, GL2 vs
GL3 is purely a matter of semantics.

--
Chris 'Xenon' Hanson, omo sanza lettere. Xe...@AlphaPixel.com http://www.alphapixel.com/
Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen

Robert Osfield

unread,
Jan 5, 2012, 12:18:37 PM1/5/12
to OpenSceneGraph Users
Happy New Year Paul ;-)

On 31 December 2011 22:05, Paul Martz <pma...@skew-matrix.com> wrote:
> Happy New Year, everyone --
>
> Attached is source code that demonstrates OSG rendering using an OpenGL 3.x
> context. At the bottom of the source is a comment block describing how to
> build OSG for OpenGL 3.x.

Thanks for this. Do you feel it'd be appropriate to have this as an
one of the OpenSceneGraph/examples?

Cheers,
Robert.

Paul Martz

unread,
Jan 6, 2012, 10:32:11 AM1/6/12
to OpenSceneGraph Users
On 1/5/2012 10:18 AM, Robert Osfield wrote:
> Thanks for this. Do you feel it'd be appropriate to have this as an
> one of the OpenSceneGraph/examples?

Hi Robert -- I do think it would be good to have it available, so if you'd like
to include it in the examples, please do. I've attached an updated version that
cleans up the code and comments a little bit. I'll forgo any kind of copyright
and donate the code to the public domain (noted at the top of the file).

I presume this would need to be added in such a way that it only builds for GL3,
and there are a few different ways to do that. I'll leave the decision up to you
to set a precedent for how GL3-specific examples should be added.
-Paul


gl3example.cpp

Robert Osfield

unread,
Feb 9, 2012, 10:34:50 AM2/9/12
to OpenSceneGraph Users
Hi Paul,

I am just working on merging your gl3example.cpp into svn/trunk and
have renamed it osgsimplegl3 as it's a very bare bones little viewer
example. I have also added the following lines just before the
viewer.run() so that the example works fine on GL2 etc. builds.

// for non GL3/GL4 and non GLES2 platforms we need enable the osg_
uniforms that the shaders will use,
// you don't need thse two lines on GL3/GL4 and GLES2 specific
builds as these will be enable by default.
gc->getState()->setUseModelViewAndProjectionUniforms(true);
gc->getState()->setUseVertexAttributeAliasing(true);

Is this OK?

Robert.

Paul Martz

unread,
Feb 9, 2012, 11:29:24 AM2/9/12
to OpenSceneGraph Users
Sounds good to me, thanks for the changes. So this will be included in GL2
builds, excellent.
-Paul


On 2/9/2012 8:34 AM, Robert Osfield wrote:
> Hi Paul,
>
> I am just working on merging your gl3example.cpp into svn/trunk and
> have renamed it osgsimplegl3 as it's a very bare bones little viewer
> example. I have also added the following lines just before the
> viewer.run() so that the example works fine on GL2 etc. builds.
>
> // for non GL3/GL4 and non GLES2 platforms we need enable the osg_
> uniforms that the shaders will use,
> // you don't need thse two lines on GL3/GL4 and GLES2 specific
> builds as these will be enable by default.
> gc->getState()->setUseModelViewAndProjectionUniforms(true);
> gc->getState()->setUseVertexAttributeAliasing(true);
>
> Is this OK?
>
> Robert.

Paul Martz

unread,
Feb 11, 2012, 1:18:15 PM2/11/12
to OpenSceneGraph Users
Hi Robert -- I've verified osgsimplegl3 builds and runs correctly in both GL2
and GL3 builds of trunk r12982. Thanks!
Reply all
Reply to author
Forward
0 new messages