Re: [osg-users] EXTERNAL: Re: Help on multitexturing..

2018-04-20 Thread Robert Osfield
On 19 April 2018 at 20:30, Rowley, Marlin R 
wrote:

> I thought the sampler value was a pointer to a texture?
>
>
Where did you get that idea?  None of the OSG example attempt this.  When
using OpenGL you pass the sampler uniforms as int, when it comes to OpenGL
the OSG is just a lightweight wrapper around it.



>
> I set the texture unit to 1 because we’ll need the base texture unit 0
> later on.  My goal is to turn on up to 10 texture units and blend them all
> together.
>
>
>
> To be more clear, he is some more code:
>
>
>
> mGroupState = mBoundGeometry->getOrCreateStateSet();
>
>   mGroupState->getOrCreateUniform("BaseTexSampler", osg::Uniform::
> SAMPLER_2D)->set(mBaseColor.get());
>
>   mGroupState->getOrCreateUniform("BaseWeight", osg::Uniform::FLOAT)->
> set(mBaseWeight);
>
>   mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,
> mBaseColor, osg::StateAttribute::ON);
>
>
>
> This sets the base texture unit 1 to be bound to the mBaseColor (which is
> a osg::ref_ptr) created before the function call.
>
>
I tell you want the problem is and you copy and paste more code with that
exact problem in.  Pass in an int value for the sampler texture unit, so
BASE_TEXTURE_UNIT, not the texture pointer.

For future reference, could you refrrame from using this black and white
blocks, it's painful to look at.  Just putting everything in plain texture
but using indentation for code is perfectly fine.

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


Re: [osg-users] Memory problems in Windows/Visual Studio

2018-04-20 Thread Voerman, L.
I suspect you are mixing debug and release builds.
Basic guess is that you build osg in release and are trying to run a debug
build of your main application. Try a release or RelWithDebinfo build.
Regards, Laurens.

On Thu, Apr 19, 2018 at 9:33 PM, Mark Jablin 
wrote:

> Robert,
>
> That doesn't solve the problem.
>
> My log file handler:
>
>
> Code:
> class LogFileHandler : public osg::NotifyHandler
> {
> public:
>LogFileHandler(const std::string& file)
>{
>   m_log.open(file.c_str());
>}
>virtual ~LogFileHandler() { m_log.close(); }
>virtual void notify(osg::NotifySeverity severity,
>   const char* msg)
>{
>   m_log << msg;
>}
> protected:
>std::ofstream m_log;
> };
>
>
>
> I took that out of OpenSceneGraph 3.0 Beginner's Guide.
>
> I'm using OSG 3.4.1.
>
> Thanks for your help.
>
> Mark
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73457#73457
>
>
>
>
>
> ___
> 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] EXTERNAL: Re: EXTERNAL: Re: Help on multitexturing..

2018-04-20 Thread Robert Osfield
Hi Marlin,

On 19 April 2018 at 21:24, Rowley, Marlin R 
wrote:

> Robert,
>
>
>
> Changing the sampler_2d to an (int) doesn’t seem to fix the problem.  I
> still get a black texture in the scene.
>
>
>
> Here is my updated code:
>

What still wrong I can't say as I know snippets of your code.

The best thing I can recommend is to start simple, write a small example
program that just sets up a couple of textures and the uniforms and shaders
for them.

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


Re: [osg-users] Help on multitexturing..

2018-04-20 Thread Sebastian Messerschmidt

Hi Marlin,


Re-phrasing Roberts advice:

osg::Uniform* sampler = new osg::Uniform(osg::Uniform::SAMPLER_2D, 
"NameOfTheSamplerInGLSL");

sampler->set(0); //assign unit
ss->addUniform(sampler);
ss->setTextureAttribute(0/*unit*/, texture0 ,osg::StateAttribute:ON );

osg::Uniform* sampler_1 = new osg::Uniform(osg::Uniform::SAMPLER_2D, 
"NameOfTheSamplerInGLSL_1");

sampler->set(1); //assign unit
ss->addUniform(sampler);
ss->setTextureAttribute(1/*unit*/, texture1 ,osg::StateAttribute:ON );

This works fine with two sampler2D objects in GLSL.


HTH & Cheers
Sebastian

Am 19.04.2018 um 20:06 schrieb Rowley, Marlin R:

Hello,

I’ve been wracking my brain all day on trying to figure out how to do 
this with no clear examples found online.


I have this set of calls in my C++:

mGroupState = mBoundGeometry->getOrCreateStateSet();

   
mGroupState->getOrCreateUniform("BaseTexSampler",osg::Uniform::SAMPLER_2D)->set(mBaseColor);


   
mGroupState->getOrCreateUniform("BaseWeight",osg::Uniform::FLOAT)->set(mBaseWeight);


   
mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor,osg::StateAttribute::ON);


I’ve bound this base texture to texture unit (BASE_TEXTURE_UNIT = 1).

Later in the code, I have this in another function if I create another 
layer with another texture:


mGroupState->getOrCreateUniform("TexLayerSampler0",osg::Uniform::SAMPLER_2D)->set(tex);

 
mGroupState->setTextureAttribute(BASE_TEXTURE_UNIT+1,tex,osg::StateAttribute::ON);


Where I’ve created a second texture and want it to reside in texture unit 2.

However, in my shader code when indexing the TexLayerSampler0, I only 
get base texture.


finalColor = texture(TexLayerSampler0, LayeredTexCoords[0].st);

Which is wrong.  I’m stil trying to figure out OpenGL and how it works 
along with OSG so sorry for the inexperience.


-M



Marlin Rowley

Software Engineer, Staff

cid:image002.jpg@01D39374.DEC5A2E0

/Missiles and Fire Control/

972-603-1931 (office)

214-926-0622 (mobile)

marlin.r.row...@lmco.com 



___
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


[osg-users] Please test OpenSceneGraph-3.6 branch in prep for 3.6.1

2018-04-20 Thread Robert Osfield
Hi All,

I have made several bug fixes and other improvements to the 3.6 branch
since the 3.6.0 stable release a couple of weeks ago and now feel that
they are worthwhile rolling into a 3.6.1 stable release so that all
users get to benefit from them.

The key changes I have made are:

  1) Fix a bug where the OSG was creating VBO's within Display Lists
(caused a crash on a particular driver.)

  2) Fix a bug in osg::Geometry::set*Binding() where it wasn't
assigning a BufferObject when it should have (this caused a
performance regression and crash with VAO usage.)

  3) Replaced all remaining IntersectVisitor (which has been
deprecated for many years) usage with the modern IntersectionVisitor
and made the deprecated messages clearer in
include/osgUtil/IntersectVisitor.  (In OSG master I've removed this
old class completely.)

  4) Changed places that invoked the old osgUtil::TriStripVisitor so
that they use the
osgUtil::MeshOptimizers instead as these work far better when using
VBO/VAO's.  (In OSG master I also completely removed TriStripVisitor.)

I don't expect my changes to break the build, but it's still not safe
enough for me to tag 3.6.1 straight without getting some community
feedback, so here I am again asking members of the community to check
out the OpenSceneGraph-3.6 branch from github and tests the build and
runtime on your build tools.

If you are using OSG master then there is chance that your build will
break if you use the old IntersectVisitor and TriStripVisitor classes,
but then that's good, you should have rewritten you code long ago so
now you have a reason to make the required improvements :-)

Please let me know of success and failures, or any bugs you've seen in
3.6.0 but haven't reported yet :-)

Cheers,
Robert.

ChangeLog since 3.6.0

Fri, 20 Apr 2018 14:32:34 +0100
Author : Robert Osfield
Replaced osgUtil::IntersectVisitor usage with osgUtil::InteresectionVisitor

Fri, 20 Apr 2018 10:24:17 +0100
Author : Robert Osfield
Removed TriStripVisitor for default set of Optimizer passes as it
doesn't generate efficient scene graphs

Fri, 20 Apr 2018 09:57:04 +0100
Author : Robert Osfield
Added osgUtil::optimizeMesh(osg::Node* node) convinience method

Fri, 20 Apr 2018 11:42:31 +0100
Author : Robert Osfield
Removed usage of the osgUtil::TriStripVisitor is it generates
osg::Geometry that perform very poorly when using VBO and VAO's vs GL
DisplayLists. With DisplayLists being deprecated in GL and VBO and VAO
becoming standard it's best to standardize on using the
osgUtil::MeshOptimizers instead of TripStrupVisitor

Thu, 19 Apr 2018 19:43:14 +0100
Author : Robert Osfield
Fixed the set*Binding() methods so that they assign BufferObjects when required

Thu, 19 Apr 2018 19:42:51 +0100
Author : Robert Osfield
Fixed messages

Thu, 19 Apr 2018 19:41:51 +0100
Author : Robert Osfield
Fixed the GLBufferObject size computation so that it takes into account padding.

Thu, 19 Apr 2018 19:36:19 +0100
Author : Robert Osfield
Replaced the use of osgUtil::TriStripVisitor with
ogUtil::MeshOptimizer usage to improve performance. Fixed set
setColorArray assignement to pass in the color binding

Wed, 18 Apr 2018 10:02:43 +0100
Author : Robert Osfield
Fixed the handle of boundary equalization

Wed, 18 Apr 2018 09:33:12 +0100
Author : Robert Osfield
Added --equalize-boundaries -e command line option to call
terrain->setEqualizeBoundaries(true)

Mon, 16 Apr 2018 17:53:38 +0100
Author : Robert Osfield
Updated version number in prep for future 3.6.1 release.

Mon, 16 Apr 2018 15:08:24 +0100
Author : Robert Osfield
Fixed inline Drawable::draw(..) method

Mon, 16 Apr 2018 15:05:11 +0100
Author : Robert Osfield
Fixed Geometry::drawImplmentation() handling of VBO's to prevent them
from being used when display lists are used.

Sun, 15 Apr 2018 08:25:57 +0100
Author : Robert Osfield
Replaced osgViewer::GraphicsWindow dynamic_cast as it's not neccessary.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] Building OpenSceneGraph-3.6.0 on Windows 10 with VS2017

2018-04-20 Thread André Martins
Thank you so much for your kind input Ravi and Laurens.
Thanks to you I managed to compile sucessfully release build of the source on 
VS2017 however, when testing the result I cant seem to compile my own project...


Project-Properties
x64
- General -> Character Set -> Use Multi-Byte Character Set 
- C/C++ -> General -> Additional Include Directories -> 
"C:/OSGraph/build/include” 
- C/C++ -> Code Generation -> Runtime Library -> Multi-threaded Debug DLL (/MD) 
- C/C++ -> Language -> Enable Run-Time Type Info -> Yes (/GR) 
- Linker -> General -> Additional Library Directories -> "C:/OSGraph/build/lib“ 
- Linker -> Input -> Additional Dependencies -> "osg.lib, osgAnimation.lib, 
osgDB.lib, osgFX.lib, osgGA.lib, osgManipulator.lib, osgParticle.lib, 
osgPresentation.lib, osgShadow.lib, osgSim.lib, osgTerrain.lib, osgText.lib, 
osgUI.lib, osgUtil.lib, osgViewer.lib, osgVolume.lib, osgWidget.lib, 
OpenThreads.lib“ 


the code:

Code:

#include osgViewer/Viewer //with square brackets around it

int main(int argc, char *argv[])
{
return 0;
}





The compilation result:

Code:

1>-- Compilação iniciada: Projeto: Project2, Configuração: Debug x64 --
1>main.cpp
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
error C2144: erro de sintaxe: 'void' deve ser precedido por ';'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
error C4430: faltando especificador de tipo - int assumido. Observação: C++ não 
suporta default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1158): 
error C2144: erro de sintaxe: 'void' deve ser precedido por ';'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1158): 
error C4430: faltando especificador de tipo - int assumido. Observação: C++ não 
suporta default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1158): 
error C2086: 'int WINGDIAPI': redefinição
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
note: consulte a declaração de 'WINGDIAPI'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1159): 
error C4430: faltando especificador de tipo - int assumido. Observação: C++ não 
suporta default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1159): 
error C2086: 'int WINGDIAPI': redefinição
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
note: consulte a declaração de 'WINGDIAPI'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1159): 
error C2146: erro de sintaxe: ';' ausente antes do identificador 'GLboolean'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1160): 
error C2144: erro de sintaxe: 'void' deve ser precedido por ';'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1160): 
error C4430: faltando especificador de tipo - int assumido. Observação: C++ não 
suporta default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1160): 
error C2086: 'int WINGDIAPI': redefinição
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
note: consulte a declaração de 'WINGDIAPI'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1161): 
error C2144: erro de sintaxe: 'void' deve ser precedido por ';'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1161): 
error C4430: faltando especificador de tipo - int assumido. Observação: C++ não 
suporta default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1161): 
error C2086: 'int WINGDIAPI': redefinição
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
note: consulte a declaração de 'WINGDIAPI'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1162): 
error C2144: erro de sintaxe: 'void' deve ser precedido por ';'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1162): 
error C4430: faltando especificador de tipo - int assumido. Observação: C++ não 
suporta default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1162): 
error C2086: 'int WINGDIAPI': redefinição
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
note: consulte a declaração de 'WINGDIAPI'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1163): 
error C2144: erro de sintaxe: 'void' deve ser precedido por ';'
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1163): 
error C4430: faltando especificador de tipo - int assumido. Observação: C++ não 
suporta default-int
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1163): 
error C2086: 'int WINGDIAPI': redefinição
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\gl\gl.h(1157): 
note: consulte a declaração de 'WINGDIAPI'
1>c:\program files (x86)\windows ki

[osg-users] Reference Count too high and memory not being freed

2018-04-20 Thread Adrian Jelffs
Hello,

I am add a layer to my scene using osgEarth. I am using a ref_ptr but when I 
come to remove the layer I find that my ref_ptr is in the 1000's. It looks like 
it goes up everytime I call frame().

Why would this be?


Code:

/* Adding the layer */

osg::ref_ptr imageryLayer = NULL;
TMSOptions tmsOptImg;
tmsOptImg.url() = url;
imageryLayer = new ImageLayer(name, tmsOptImg);
_map->addImageLayer(imageryLayer);


Only thing that runs in between is frame() from a different thread

/* Removing Layer */

osg::ref_ptr layer = _map->getImageLayerByName(name);
int count = layer->referenceCount(); /* REF COUNT IS VERY HIGH */
_map->removeImageLayer(layer);




Am I doing something wrong? 

Can somebody please explain or give me some suggestions to try?

Many thanks for your help!!

Adrian
[/code]

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





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