[osg-users] CxxTest: Custom delta-comparison for osg::Vec3
Hi, I'm using CxxTest 3.10.1 to unit-test my code. I wrote an extension to correctly handle osg::Vec3 data, which works fine on MSVC, but won't compile using GCC 4.3.3. The extension consists of two parts - a ValueTraits-implementation to print osg::Vec3 data in readable form, and a delta-function to check if two osg::Vec3 are almost equal. The extension: Code: #include #include namespace CxxTest { CXXTEST_TEMPLATE_INSTANTIATION class ValueTraits { std::string s; public: ValueTraits(const osg::Vec3& v) { std::ostringstream oss; oss << "osg::Vec3(" << v << ")"; s = oss.str(); } const char* asString() const { return s.c_str(); } }; template bool delta (osg::Vec3 x, osg::Vec3 y, D d) { return ((y.x() >= x.x() - d) && y.x() <= x.x() + d) && (y.y() >= x.y() - d) && y.y() <= x.y() + d) && (y.z() >= x.z() - d) && y.z() <= x.z() + d)); } } I use it in a test like this: Code: void test_vec3 { osg::Vec3 a(1.0, 1.0, 1.0); osg::Vec3 b(1.01, 1.01, 1.01); TS_ASSERT_DELTA(a, b, 0.001); // Fails TS_ASSERT_DELTA(a, b, 0.1); // Passes } When compiling with gcc it seems like my delta-function is not found or used, the compiler tries to use the generic templated "delta(X x, Y y, D d)", which tries to test for "y >= x - d && y <= x + d". Compiler-output: Code: /home/docdrum/dev/OsgProjectTests/tests/cpptests/lib/cxxtest/cxxtest/TestSuite.h: In function »bool CxxTest::delta(X, Y, D) [with X = osg::Vec3f, Y = osg::Vec3f, D = double]«: /home/docdrum/dev/OsgProjectTests/tests/cpptests/lib/cxxtest/cxxtest/TestSuite.h:172: instantiated from »void CxxTest::doAssertDelta(const char*, unsigned int, const char*, X, const char*, Y, const char*, D, const char*) [with X = osg::Vec3f, Y = osg::Vec3f, D = double]« /home/docdrum/dev/OsgProjectTests/tests/cpptests/unit/UnitTest.h:122: instantiated from here /home/docdrum/dev/OsgProjectTests/tests/cpptests/lib/cxxtest/cxxtest/TestSuite.h:162: Fehler: no match für »operator+« in »x + d« /usr/include/osg/Vec3f:135: Anmerkung: Kandidaten sind: const osg::Vec3f osg::Vec3f::operator+(const osg::Vec3f&) const /home/docdrum/dev/OsgProjectTests/tests/cpptests/lib/cxxtest/cxxtest/TestSuite.h:162: Fehler: no match für »operator-« in »x - d« /usr/include/osg/Vec3f:152: Anmerkung: Kandidaten sind: const osg::Vec3f osg::Vec3f::operator-(const osg::Vec3f&) const /usr/include/osg/Vec3f:167: Anmerkung: const osg::Vec3f osg::Vec3f::operator-() const make[2]: *** [tests/cpptests/unit/CMakeFiles/UnitTest.dir/UnitTest.cpp.o] Fehler 1 make[1]: *** [tests/cpptests/unit/CMakeFiles/UnitTest.dir/all] Fehler 2 make: *** [all] Fehler 2 I tried using all combinations of osg::Vec3f instead of osg::Vec3, using const-references, float- and double-parameters for d instead of templating... Any ideas how I can make this work on GCC? Thank you! Cheers, Colin [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=45407#45407 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Texture is rendered strange
On Mon, Nov 9, 2009 at 09:50, Ulrich Hertlein wrote: > On 7/11/09 10:18 PM, Thorsten Werner wrote: >> >> osg::Vec2Array* texcoords = new osg::Vec2Array(4); >> (*texcoords)[0].set(0.0f, 0.0f); >> (*texcoords)[0].set(1.0f, 0.0f); >> (*texcoords)[0].set(1.0f, 1.0f); >> (*texcoords)[0].set(0.0f, 1.0f); > > Is this a cut&paste error? > Hi Thorsten, You're assigning the texture coordinates only to the first element ([0]). Colin ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Forward declared classes and ref_ptrs
Hi all, to reduce compile time dependencies, I prefer using forward delcarations instead of #includes, where possible. This doesn't seem to work with osg::ref_ptr<>, which needs complete type informations. Is there a workaround to use ref_ptrs and as few include-files as possible? Greetings, Colin ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [RFC] osgViewer: solution for omitted key release events
Hi Folks, Have you considered some kind of layered approach? Maybe an immediate interface to the physical keycodes, sending events for every _key_ press and release. Another layer could then use the windowing-system mappings to convert these events to _character_ press/release events. If this second layer would be added per default it should not break current applications. Clients that need the physical codes could easily disable the translation layer, or even replace it with their own keyevent-translation scheme. Greetings, Colin ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] missing includes
Hi all, The gcc-team weeded out some includes in their headers for the 4.3 release. If a program uses a cstdlib function, but does not include the header file because it was already pulled in by another c++ header, it will break now. I don't know which gcc version Jaunty defaults to, but if it is a 4.3 release, this would be the problem. Cheers, Colin On Thu, May 7, 2009 at 10:40 PM, Jason Beverage wrote: > Hi Simon, > > I try to build osgEarth pretty regularly on Ubuntu 8.10 and haven't seen > this error before. Perhaps its something to do with Jaunty, I've not tried > it yet. > > I'll try to give it a go when I get a chance, I've been wanting to update > anyway:) > > Jason > > On Thu, May 7, 2009 at 4:23 AM, Simon Loic wrote: >> >> Hi Jason, >> thanks for helping >> I'm on a linux : kubuntu Jaunty. >> To be totally honest in the first place I really doubted that the code I'm >> talking about could compile on another linux. However, as this code (eg >> VTP) must have been extensively tested I turned out to think that I was >> missing something. >> >> Thanks again. >> >> On Wed, May 6, 2009 at 11:24 PM, Jason Beverage >> wrote: >>> >>> Hi Simon, >>> >>> What platform are you compiling on where you are seeing these issues? >>> >>> Jason >>> >>> On Wed, May 6, 2009 at 3:47 PM, Simon Loic wrote: Hello everyone, It may certainly be a stupid question and not the right place to ask. Still I've been compiling a couple of osg based application : VTP, osgEphemeris, osgearth. The fact is that for most of them I had to add a couple of #include directive to make them compile. It's always some c++ wrapping of c headers like or . I don't understand if it is possible that those application compile without problem on some computer. Which would mean that I have to tune some environment variables or whatever. Is this the case or should I report those missing directive to the concerned developper? Thanks for any answer on this. -- Loïc Simon ___ 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 >>> >> >> >> >> -- >> Loïc Simon >> >> ___ >> 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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org