Re: [osg-users] OpenSceneGrah-3.4.0 release candidate 4 tagged

2015-07-20 Thread DizL
Hi,

I was trying to build this version with MSVC++ 11.0 (_MSC_VER 1700, Visual
Studio 2012) and there is a known problem with osgjs and isfinite.

Need to edit at the top of OpenSceneGraph/src/osgPlugins/osgjs/json_stream:
#if defined(WIN32)  !defined(__MINGW32__)  (!defined(_MSC_VER) ||
_MSC_VER1600)
inline int isfinite( double x ) { return _finite( x ); }
inline int isinf( double x ) { return !_finite( x )  !_isnan( x ); }
#endif 

1700 instead of 1600


regards,
DizL

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


Re: [osg-users] OpenSceneGrah-3.4.0 release candidate 4 tagged

2015-07-20 Thread DizL
oops,

#if defined(WIN32)  !defined(__MINGW32__)  (!defined(_MSC_VER) ||
_MSC_VER=1600)
inline int isfinite( double x ) { return _finite( x ); }
inline int isinf( double x ) { return !_finite( x )  !_isnan( x ); }
#endif

should be 1700 instead of 1600
(in last post '=' was lost)

regards,
DizL


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


[osg-users] OpenSceneGraph-3.4.0 release candidate 5 tagged, please test

2015-07-20 Thread Robert Osfield
Hi All,

I have just tagged 3.4.0-rc5, you can get the source from:

  Zip file containing source code : OpenSceneGraph-3.4.0-rc5.zip
http://www.openscenegraph.org/downloads/developer_releases/OpenSceneGraph-3.4.0-rc5.zip

   - Subversion tag for 3.4.0-rc5 : svn co
   http://svn.openscenegraph.org/osg/OpenSceneGraph/tags/OpenSceneGraph-3.4.
   
http://svn.openscenegraph.org/osg/OpenSceneGraph/tags/OpenSceneGraph-3.4.0-rc50-rc5
   OpenSceneGraph

There were only a couple of minor issues reported and needed to be fixed
since rc5, this either means we are now in pretty good shape for the final
stable release, or... we haven't yet had enough testing :-)

Please test and let me know success or failure via this thread,

Thanks,
Robert.

Changes since OSG-3.4.0-rc4:

2015-07-20 07:42  robert

* src/osgPlugins/osgjs/json_stream: Changed the _MSC_VER check to
  = 1700 to support VS2012.

2015-07-19 09:51  robert

* src/osgPlugins/tiff/ReaderWriterTIFF.cpp: Reinstated the
  TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, rowsperstrip);

2015-07-17 18:31  robert

* CMakeModules/FindGStreamer.cmake: From KOS, I've mentioned in
  the osg-users ML about build error with the newest GStreamer
  1.5

  Please, have a look at the attached patch.

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


Re: [osg-users] OpenGL Shader Compile Problem: repeated #version directive

2015-07-20 Thread Elias Tarasov
That would be great if you contact osgHimmel authors :) 
Meanwhile of course i try to fix it by myself.

... 

Thank you!

Cheers,
Elias

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





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


Re: [osg-users] OpenGL Shader Compile Problem: repeated #version directive

2015-07-20 Thread Sebastian Messerschmidt

Hi Elias,

First of all, please try to condense the error logs to a minimum when 
posting them. (and maybe attach them if you think someone wants to read 
them ;-))



Hi!

1.




/snip
0(5) : error C0204: version directive must be first statement and may not be 
repeated


Where is this line of code? Inside your code?



No, that line is in osgHimmel code.

2.


Have you tried to comment out the line above?



Yes, and in this case the error is:

Atmopshere Precomputed (took 7.45826 s)
Warning, can't assign attribute binding as no has been array assigned to set 
binding for.
PNG lib warning : iCCP: known incorrect sRGB profile
PNG lib warning : iCCP: known incorrect sRGB profile
VERTEX glCompileShader  FAILED
VERTEX Shader  infolog:
0(27) : error C5060: out can't be used with non-varying m_eye
0(28) : error C5060: out can't be used with non-varying m_ray

Okay that means you really need version 1.5 or above.

...
3.


Have you debugged with geDebugger or glIntercept to see which shader
source is sent to the driver? (You can also check the osg::Shader apply
i think).



Here is the header pattern of all osgHimmel shaders under gDEBugger:

#ifndef __version__
#define __version__

#version 150 compatibility

#endif // __version__
Okay if I understand your initial error message correctly, the above 
code is the troublemaker

the first line is #ifndef and not the #version ...
I believe the above construct might be considered invalid as #version 
and #ifdef are both preprocessor tags. So first line literally means 
first line of the source.

4.


Also check the osgShader example. Is it running as expected?



Yes, osgShaders works fine.

5. Also, i found that link:
https://www.opengl.org/discussion_boards/showthread.php/185603-Managing-several-versions-in-a-single-shader-file
There is a solution that maybe works: somehow pass version number through API.
I would contact the author of osgHimmel to fix the above problem. You 
could try yourself by removing the #ifdef and put the version in the 
first line for a quick check.
Unfortunately I cannot help you further with this as it seems specific 
to osgHimmel.


Cheers
Sebastian


Or something else maybe?

Thanks for help and patience!

Cheers,
Elias

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





___
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] OpenSceneGrah-3.4.0 release candidate 4 tagged

2015-07-20 Thread Robert Osfield
Hi Dizl,

Thanks for the testing and clarification.  I have checked the
following into OSG svn/trunk and OSG-3.4 branch.  The next 3.4.0-rc
will have this fix.

Cheers,
Robert.

On 20 July 2015 at 08:37, DizL karc...@poczta.onet.pl wrote:
 oops,

 #if defined(WIN32)  !defined(__MINGW32__)  (!defined(_MSC_VER) ||
 _MSC_VER=1600)
 inline int isfinite( double x ) { return _finite( x ); }
 inline int isinf( double x ) { return !_finite( x )  !_isnan( x ); }
 #endif

 should be 1700 instead of 1600
 (in last post '=' was lost)

 regards,
 DizL


 ___
 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] force vsync to false (sofware not hardware) on NVidia

2015-07-20 Thread Christian Schulte

  
  
Hello, 
  
  sorry to pop-up my question, isn't there someone who has any idea
  of how to fix/overcome this problem ? 
  I can try to patch this, but I want to be sure to understand why
  it has been done like this before I break something  :-[ 
  Thanks,
  
  Christian
  
  Le 06/07/2015 10:05, Christian Schulte a crit:


  
  Hello everybody,
  
  I'm trying to switch on or off the vsync on my NVidia K4200 on
  Win7 64 bits by using traits-vsync and setting the NVidia
  parameter to 'Use Application parameters" for the vsync.
  
  Setting vsync to true, works, I can see the OSG_INFO
  "GraphicsWindowWin32::setSyncToVBlank" as expected.
  
  The problem is I cannot set it to false, because by default the
  NVidia behaviour is vsync = true (i.e. if nothing is specified the
  drivers choice is vsync=true). 
  
  After digging a little bit I've found in GraphicWindowWin32.cpp
  GraphicsWindowWin32::realizeImplementation() that :
  
vsync is only changed if it is true - the
  setSyncToVBlank(bool) is only called if the traits-vsync
  is true, so you cannot change it to false.
Removing the protection (if vsync equal true), the
  setSyncToVBlank is not called either because it is in an if
  condition depending on vsync equal true (if (_traits.valid()
   (_traits-sharedContext.valid() ||
  _traits-vsync || _traits-swapGroupEnabled)))

  
  The question is why is there this double protection on the
vsync equal true ? Is there a risk that I don't understand (and
then please can someone explain
:-)  ) about desactivating the vsync ?
  
  Thanks a lot,
  
  Christian
  
  -- 
SCHULTE Christian
Ingnieur Recherche
Responsable du Laboratoire de Simulation
ONERA - DCSD/PSEV
Dpartement Commande des Systmes et Dynamique du Vol
ONERA - Centre de Salon de Provence
BA 701
13661 SALON AIR Cedex - France
Tel :04.90.17.01.45
  
  
  
  ___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
SCHULTE Christian
Ingnieur Recherche
Responsable du Laboratoire de Simulation
ONERA - DCSD/PSEV
Dpartement Commande des Systmes et Dynamique du Vol
ONERA - Centre de Salon de Provence
BA 701
13661 SALON AIR Cedex - France
Tel :04.90.17.01.45
  

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


Re: [osg-users] force vsync to false (sofware not hardware) on NVidia

2015-07-20 Thread Robert Osfield
Hi Christian,

On 20 July 2015 at 09:48, Christian Schulte christian.schu...@onera.fr
wrote:

  sorry to pop-up my question, isn't there someone who has any idea of how
 to fix/overcome this problem ?
 I can try to patch this, but I want to be sure to understand why it has
 been done like this before I break something :-[


I haven't contributed to the GraphcsWindowWin32 as I have spent the vast
majority of my time using Unices, deferring to others in the community for
windows expertise.  I therefore don't feel in a position to dive in on the
topic without others from the Windows side to the community diving in with
their own insights.

In general though, if you can tweak the code and get it working how you
need to work I'll review the changes and consider merging them if they
don't look like they'll break existing functionality.

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


Re: [osg-users] force vsync to false (sofware not hardware) on NVidia

2015-07-20 Thread Christian Schulte

  
  
Thanks Robert,
  
  I will give a try and make some tests on my machines here. If I
  find a stable tweak I will propose it for submission. If in the
  meanwhile some windows expert can give me some advice, I would
  appreciate ! 
  
  Christian
  
  
  
  Le 20/07/2015 11:03, Robert Osfield a crit:


  Hi Christian,

  On 20 July 2015 at 09:48, Christian
Schulte christian.schu...@onera.fr
wrote:

  
sorry to pop-up my question, isn't there someone
  who has any idea of how to fix/overcome this problem ?
  
  I can try to patch this, but I want to be sure to
  understand why it has been done like this before I
  break something  :-[
  



I haven't contributed to the GraphcsWindowWin32 as I
  have spent the vast majority of my time using Unices,
  deferring to others in the community for windows
  expertise. I therefore don't feel in a position to dive
  in on the topic without others from the Windows side to
  the community diving in with their own insights. 


In general though, if you can tweak the code and get it
  working how you need to work I'll review the changes and
  consider merging them if they don't look like they'll
  break existing functionality.


Robert.

  

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




-- 
SCHULTE Christian
Ingnieur Recherche
Responsable du Laboratoire de Simulation
ONERA - DCSD/PSEV
Dpartement Commande des Systmes et Dynamique du Vol
ONERA - Centre de Salon de Provence
BA 701
13661 SALON AIR Cedex - France
Tel :04.90.17.01.45
  

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


[osg-users] Problems with OSG 3.3.7 and VS 2013

2015-07-20 Thread alvaro ginestar rodriguez
Hi, I have a problem when moving from osg 3.0.1 and VS 2008 to 3.3.7 osg and VS 
2013 x64, I just follow the instruction for how to generate project and 
solution files with Cmake, and build with VS 2013. When I build in mode Debug 
it just jump out the error..   The program can't start because osg120-osg.dll 
is missing from your  computer. Try reinstalling the program to fix that 
problem.and its also display this at output'Project1.exe' (Win32): Loaded 
'C:\Users\Alvaro\Desktop\Practicas de 
empresa\Codigo\Project1\x64\Debug\Project1.exe'. Symbols loaded.'Project1.exe' 
(Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB 
file.'Project1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot 
find or open the PDB file.'Project1.exe' (Win32): Loaded 
'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB 
file.First-chance exception at 0x7FFCBCB8C180 (ntdll.dll) in Project1.exe: 
0xC135: Unable to Locate DLL.Unhandled exception at 0x7FFCBCB8C180 
(ntdll.dll) in Project1.exe: 0xC135: Unable to Locate DLL.
The program '[4608] Project1.exe' has exited with code 0 (0x0).I notice I 
wasn't able to see osgversion at cmd, it responed as OpenSceneGraph Library 
3.0.1
The problem is that it dosen´t install the new version (3.3.7), it stays with 
the old version (3.0.1). '¬¬___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OpenGL Shader Compile Problem: repeated #version directive

2015-07-20 Thread Sebastian Messerschmidt

Am 20.07.2015 um 09:42 schrieb Elias Tarasov:

That would be great if you contact osgHimmel authors :)
Meanwhile of course i try to fix it by myself.
Can't you do this yourself? I can delay some information to them or 
explain what might be the problem, but you should establish the contact


Cheers
Sebastian


...

Thank you!

Cheers,
Elias

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





___
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] some questions about Frame Scheme ON_DEMAND

2015-07-20 Thread Gianni Ambrosio

wernerM wrote:
 Hi Gianni,
 I solved it for me by deriving the viewer class and setting a 
 local variable needsUpdate with any mod of the sceene.
 This works pretty good.
 


OK, so there isn't any way in OSG. I think it would be a nice improvement for 
the OSG code to add the scene modification flag to be handled by 
checkNeedToDoFrame().

I can understand your modification and I thought to implement a class for that 
so it can be injected where needed, it can be more testable and the viewer 
would have less resposibilities.

Regards,
Gianni

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





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


Re: [osg-users] some questions about Frame Scheme ON_DEMAND

2015-07-20 Thread Werner Modenbach

Hi Gianni,

I solved it for me by deriving the viewer class and setting a
local variable needsUpdate with any mod of the sceene.
This works pretty good.

- Werner -


Am 20.07.2015 um 10:51 schrieb Gianni Ambrosio:

Hi All,
can anybody tell me please if there is a way to know if the OSG scene has been 
modified (i.e. node added or removed) so that I can check if 
osgViewer::ViewerBase::frame() must be called in a setRunFrameScheme(ON_DEMAND) 
case?

Regards
Gianni

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





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


--
*TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen*
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: i...@texion.eu
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OpenGL Shader Compile Problem: repeated #version directive

2015-07-20 Thread Elias Tarasov
Fixed!  :) 
The solution (in that particular case) is straightforward.
The code:

Code:

const std::string glsl_version_150()
{
static const std::string source(PRAGMA_ONCE(version,#version 150 
compatibility\n\n));
return source;
};




must be replaced by:


Code:

const std::string glsl_version_150()
{
static const std::string source(#version 150 compatibility\n\n);
return source;
};




Thank you for help and great patience!

Cheers,
Elias

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





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


Re: [osg-users] some questions about Frame Scheme ON_DEMAND

2015-07-20 Thread Gianni Ambrosio
Hi All,
can anybody tell me please if there is a way to know if the OSG scene has been 
modified (i.e. node added or removed) so that I can check if 
osgViewer::ViewerBase::frame() must be called in a setRunFrameScheme(ON_DEMAND) 
case?

Regards
Gianni

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





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


[osg-users] my own camera manipulator, moving forward, and stuffs.

2015-07-20 Thread jagernicolas
 

Hi there! 

I try to write my own camera manipulator to work with a gamepad. I get
the status of each axis/button every frame trough glfw, I can make the
camera moving and rotating but I failed when I try to mix both. 

I try for days now to make my camera moving forward. There is any
example somewhere which can show me how to do that ? 

I tried different ways to solve this problem : 

- first, I dug the api, I found this function : _getFrontVector()_ .I
was expecting to get a vector pointing in the direction from the _eye_
to the _center_, but I always get the same result. Of course I can mess
something with my code, so tell me if this function should actualy point
like I was expecting, and if not, I'm curious to know what is the point
to have that function. 

- second, I calculated the vector from eye to center. In that case my
camera was shacking. I quikly forget this method. 

- third one (I burned my time on this one), I tried to compute the
matrix, but I don't remember my matrix-algebra if I should do first the
rotation then the translation or otherwise... also I don't know/remember
If I should set/get the matrix or his inverse... 

- four, today : contact the mailing list. 

Best regards, 

Nicolas. J. 

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


[osg-users] OSG 3.5.0 (130) GLES2 Shaders Example

2015-07-20 Thread Alex Cham
Hi,

Just Simple OSG 3.5.0 (130) GLES2 Shaders Example


Code:
/**

#define OPENSCENEGRAPH_MAJOR_VERSION3
#define OPENSCENEGRAPH_MINOR_VERSION5
#define OPENSCENEGRAPH_PATCH_VERSION0
#define OPENSCENEGRAPH_SOVERSION130

$ git log -1
commit bc3a77cb1561ed2e47e88ab507180bcf15309f31
Author: Robert OSFIELD 
Date:   Fri Jul 17 18:31:22 2015 +



mkdir ./GLES2ContextBuild
cd ./GLES2ContextBuild

cmake \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_CXX_FLAGS=-std=c++11 -v -Wall \
-DBUILD_OSG_EXAMPLES=1 \
-DOSG_GL1_AVAILABLE=OFF \
-DOSG_GL2_AVAILABLE=OFF \
-DOSG_GL3_AVAILABLE=OFF \
-DOSG_GLES1_AVAILABLE=OFF \
-DOSG_GLES2_AVAILABLE=ON \
-DOPENGL_INCLUDE_DIR=/usr/include/ \
-DOPENGL_LIBRARY=/usr/lib/x86_64-linux-gnu/libGLESv2.so \
-DOPENGL_egl_LIBRARY=/usr/lib/x86_64-linux-gnu/libEGL.so \
-DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF \
-DSG_GL_MATRICES_AVAILABLE=OFF \
-DOSG_GL_VERTEX_FUNCS_AVAILABLE=OFF \
-DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=OFF \
-DOSG_GL_FIXED_FUNCTION_AVAILABLE=OFF \
-DOSG_CPP_EXCEPTIONS_AVAILABLE=OFF \
../GLES2ContextSource

http://trac.openscenegraph.org/projects/osg/wiki/Community/OpenGL-ES



Based on OSG osgsimpleshaders.cpp
http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk/examples/osgsimpleshaders/osgsimpleshaders.cpp

See Also Hello Triangle: An OpenGL ES 2.0 Example
https://www.khronos.org/assets/uploads/books/openglr_es_20_programming_guide_sample.pdf


 */
#include osgViewer/Viewer

#include osg/ShapeDrawable
#include osg/Geode
#include osg/Vec3

#include osg/Program
#include osg/Shader
#include osg/Uniform

using namespace osg;


static const char *vertexShaderSource = {
attribute vec4 vPosition;\n
void main()\n
{\n
gl_Position = vPosition;\n
}\n};

static const char *fragmentShaderSource = {
precision mediump float;\n
void main()\n
{\n
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n
}\n};


int main(int, char **)
{
osg::setNotifyLevel(osg::INFO);


// construct the viewer.
osgViewer::Viewer viewer;

// use a geode with a Box ShapeDrawable
osg::Geode* geode = new osg::Geode();
geode-addDrawable(new osg::ShapeDrawable(new 
osg::Box(osg::Vec3(0.0f,0.0f,0.0f),1.0f)));

osg::StateSet *ss = geode-getOrCreateStateSet();
osg::Program* program = new osg::Program;

program-addShader( new osg::Shader( osg::Shader::VERTEX, 
vertexShaderSource ) );
program-addShader( new osg::Shader( osg::Shader::FRAGMENT, 
fragmentShaderSource ) );
ss-setAttributeAndModes(program, osg::StateAttribute::ON);

viewer.setSceneData(geode);
return viewer.run();
}

/*EOF*/




Thank you!

Cheers,
Alex[/code]

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





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


Re: [osg-users] OSG 3.5.0 (130) GLES2 Shaders Example

2015-07-20 Thread Alex Cham
Just OSG 3.5.0 (130) GLES2 Shaders Example V2

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2015 Alex Cham
 *
 * This example is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This example is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.

#define OPENSCENEGRAPH_MAJOR_VERSION3
#define OPENSCENEGRAPH_MINOR_VERSION5
#define OPENSCENEGRAPH_PATCH_VERSION0
#define OPENSCENEGRAPH_SOVERSION130

$ git log -1
commit bc3a77cb1561ed2e47e88ab507180bcf15309f31
Author: Robert OSFIELD robert.osfi...@gmail.com
Date:   Fri Jul 17 18:31:22 2015 +
*/
#include osgViewer/Viewer

#include osg/ShapeDrawable
#include osg/Geode
#include osg/Vec3

#include osg/Program
#include osg/Shader
#include osg/Uniform

using namespace osg;


static const char *vertexShaderSource = {
#version 100\n
//  uniform mat4 mvp_matrix;// model-view-projection matrix\n
uniform mat3 normal_matrix;// normal matrix\n
uniform vec3 ec_light_dir;// light direction in eye coords\n
attribute vec4 a_vertex;// vertex position\n
attribute vec3 a_normal;// vertex normal\n
//  attribute vec2 a_texcoord;// texture coordinates\n
//  varying float v_diffuse;\n
//  varying vec2 v_texcoord;\n
void main(void)\n
{\n
// put vertex normal into eye coords\n
vec3 ec_normal = normalize(normal_matrix * a_normal);\n
//  // emit diffuse scale factor, texcoord, and position\n
//  v_diffuse = max(dot(ec_light_dir, ec_normal), 0.0);\n
//  v_texcoord= a_texcoord;\n
gl_Position = gl_ModelViewProjectionMatrix * a_vertex;\n
}\n};

static const char *fragmentShaderSource = {
#version 100\n
precision mediump float;\n
void main()\n
{\n
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n
}\n};


int main(int, char **)
{
osg::setNotifyLevel(osg::INFO);


// construct the viewer.
osgViewer::Viewer viewer;

// use a geode with a Box ShapeDrawable
osg::Geode* geode = new osg::Geode();
geode-addDrawable(new osg::ShapeDrawable(new 
osg::Box(osg::Vec3(0.0f,0.0f,0.0f),1.0f)));

osg::StateSet *ss = geode-getOrCreateStateSet();
osg::Program* program = new osg::Program;

program-addShader( new osg::Shader( osg::Shader::VERTEX, 
vertexShaderSource ) );
program-addShader( new osg::Shader( osg::Shader::FRAGMENT, 
fragmentShaderSource ) );
ss-setAttributeAndModes(program, osg::StateAttribute::ON);

viewer.setSceneData(geode);
return viewer.run();
}
/*

mkdir ./GLES2ContextBuild
cd ./GLES2ContextBuild

cmake \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_CXX_FLAGS=-std=c++11 -v -Wall \
-DBUILD_OSG_EXAMPLES=1 \
-DOSG_GL1_AVAILABLE=OFF \
-DOSG_GL2_AVAILABLE=OFF \
-DOSG_GL3_AVAILABLE=OFF \
-DOSG_GLES1_AVAILABLE=OFF \
-DOSG_GLES2_AVAILABLE=ON \
-DOPENGL_INCLUDE_DIR=/usr/include/ \
-DOPENGL_LIBRARY=/usr/lib/x86_64-linux-gnu/libGLESv2.so \
-DOPENGL_egl_LIBRARY=/usr/lib/x86_64-linux-gnu/libEGL.so \
-DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF \
-DSG_GL_MATRICES_AVAILABLE=OFF \
-DOSG_GL_VERTEX_FUNCS_AVAILABLE=OFF \
-DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=OFF \
-DOSG_GL_FIXED_FUNCTION_AVAILABLE=OFF \
-DOSG_CPP_EXCEPTIONS_AVAILABLE=OFF \
../GLES2ContextSource

http://trac.openscenegraph.org/projects/osg/wiki/Community/OpenGL-ES



Based on OSG osgsimpleshaders.cpp
http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk/examples/osgsimpleshaders/osgsimpleshaders.cpp

See Also Hello Triangle: An OpenGL ES 2.0 Example
https://www.khronos.org/assets/uploads/books/openglr_es_20_programming_guide_sample.pdf

OpenGL ES 2.0 API  OpenGL ES Shading Language 1.0 Quick Reference Card
https://www.khronos.org/files/opengles20-reference-card.pdf

OpenGL ES Shading Language Version 1.00
https://www.khronos.org/files/opengles_shading_language.pdf
 */


Thank you!

Cheers,
Alex

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





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