diff --git a/vcg/simplex/vertexplus/component.h b/vcg/simplex/vertexplus/component.h index 7a65dc3e..d2f834f4 100644 --- a/vcg/simplex/vertexplus/component.h +++ b/vcg/simplex/vertexplus/component.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -129,7 +129,7 @@ All the Components that can be added to a vertex should be defined in the namesp */ -/*------------------------- EMPTY COORD & NORMAL -----------------------------------------*/ +/*------------------------- EMPTY COORD & NORMAL -----------------------------------------*/ template class EmptyCoordNormal: public T { public: typedef vcg::Point3f CoordType; @@ -147,11 +147,11 @@ public: static bool HasNormal() { return false; } static bool HasNormalOcc() { return false; } template < class LeftV> - void ImportLocal(const LeftV & left ) { T::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { T::ImportLocal( left); } static void Name(std::vector & name){T::Name(name);} }; -/*-------------------------- COORD ----------------------------------------*/ +/*-------------------------- COORD ----------------------------------------*/ template class Coord: public T { public: @@ -163,12 +163,12 @@ public: CoordType &UberP() { return _coord; } template < class LeftV> - void ImportLocal(const LeftV & left ) { P().Import(left.cP()); T::ImportLocal( left); } + void ImportLocal(const LeftV & left ) { P().Import(left.cP()); T::ImportLocal( left); } static bool HasCoord() { return true; } static void Name(std::vector & name){name.push_back(std::string("Coord"));T::Name(name);} private: - CoordType _coord; + CoordType _coord; }; template class Coord3f: public Coord { public: static void Name(std::vector & name){name.push_back(std::string("Coord3f"));T::Name(name);} @@ -177,7 +177,7 @@ template class Coord3d: public Coord { public: static void Name(std::vector & name){name.push_back(std::string("Coord3d"));T::Name(name);} }; -/*-------------------------- NORMAL ----------------------------------------*/ +/*-------------------------- NORMAL ----------------------------------------*/ template class Normal: public T { public: @@ -190,7 +190,7 @@ public: static void Name(std::vector & name){name.push_back(std::string("Normal"));T::Name(name);} private: - NormalType _norm; + NormalType _norm; }; template class Normal3s: public Normal { @@ -204,7 +204,7 @@ public: static void Name(std::vector & name){name.push_back(std::st }; -/*-------------------------- INCREMENTAL MARK ----------------------------------------*/ +/*-------------------------- INCREMENTAL MARK ----------------------------------------*/ template class EmptyMark: public T { public: @@ -228,12 +228,12 @@ public: template < class LeftV> void ImportLocal(const LeftV & left ) { IMark() = left.IMark(); T::ImportLocal( left); } static void Name(std::vector & name){name.push_back(std::string("Mark"));T::Name(name);} - + private: int _imark; }; -/*-------------------------- TEXCOORD ----------------------------------------*/ +/*-------------------------- TEXCOORD ----------------------------------------*/ template class EmptyTexCoord: public TT { public: @@ -256,7 +256,7 @@ public: static void Name(std::vector & name){name.push_back(std::string("TexCoord"));TT::Name(name);} private: - TexCoordType _t; + TexCoordType _t; }; template class TexCoord2s: public TexCoord, TT> { @@ -270,7 +270,7 @@ template class TexCoord2d: public TexCoord, TT> { static void Name(std::vector & name){name.push_back(std::string("TexCoord2d"));TT::Name(name);} }; -/*------------------------- FLAGS -----------------------------------------*/ +/*------------------------- FLAGS -----------------------------------------*/ template class EmptyBitFlags: public T { public: typedef int FlagType; @@ -296,10 +296,10 @@ public: static void Name(std::vector & name){name.push_back(std::string("BitFlags"));T::Name(name);} private: - int _flags; + int _flags; }; -/*-------------------------- EMPTY COLOR & QUALITY ----------------------------------*/ +/*-------------------------- EMPTY COLOR & QUALITY ----------------------------------*/ template class EmptyColorQuality: public T { public: @@ -315,7 +315,7 @@ public: static void Name(std::vector & name){T::Name(name);} }; -/*-------------------------- Color ----------------------------------*/ +/*-------------------------- Color ----------------------------------*/ template class Color: public T { public: @@ -330,14 +330,14 @@ public: static void Name(std::vector & name){name.push_back(std::string("Color"));T::Name(name);} private: - ColorType _color; + ColorType _color; }; template class Color4b: public Color { public: static void Name(std::vector & name){name.push_back(std::string("Color4b"));TT::Name(name);} }; -/*-------------------------- Quality ----------------------------------*/ +/*-------------------------- Quality ----------------------------------*/ template class Quality: public TT { public: @@ -350,7 +350,7 @@ public: static void Name(std::vector & name){name.push_back(std::string("Quality"));TT::Name(name);} private: - QualityType _quality; + QualityType _quality; }; template class Qualitys: public Quality { @@ -392,7 +392,7 @@ public: static void Name(std::vector & name){TT::Name(name);} }; -/*-------------------------- Curvature ----------------------------------*/ +/*-------------------------- Curvature ----------------------------------*/ template class EmptyCurvature: public TT { public: @@ -422,7 +422,7 @@ public: static void Name(std::vector & name){name.push_back(std::string("Curvature"));TT::Name(name);} private: - Point2 _hk; + Point2 _hk; }; @@ -433,14 +433,14 @@ template class Curvatured: public Curvature { public: static void Name(std::vector & name){name.push_back(std::string("Curvatured"));T::Name(name);} }; -/*-------------------------- Curvature Direction ----------------------------------*/ +/*-------------------------- Curvature Direction ----------------------------------*/ template struct CurvatureDirBaseType{ typedef Point3 VecType; typedef S ScalarType; CurvatureDirBaseType () {} - Point3max_dir,min_dir; // max and min curvature direction + Point3max_dir,min_dir; // max and min curvature direction S k1,k2;// max and min curvature values }; @@ -482,7 +482,7 @@ public: static void Name(std::vector & name){name.push_back(std::string("CurvatureDir"));TT::Name(name);} private: - CurvatureDirType _curv; + CurvatureDirType _curv; }; @@ -493,25 +493,25 @@ template class CurvatureDird: public CurvatureDir & name){name.push_back(std::string("CurvatureDird"));T::Name(name);} }; -/*-------------------------- Empty Radius ----------------------------------*/ +/*-------------------------- Empty Radius ----------------------------------*/ template class EmptyRadius: public T { public: - + typedef float RadiusType; typedef RadiusType ScalarType; - RadiusType &R(){ static ScalarType v = 0.0; assert(0); return v; } - const RadiusType &cR() const { static const ScalarType & v = 0.0; assert(0); return v; } + RadiusType &R(){ static ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } + const RadiusType &cR() const { static const ScalarType v = 0.0; assert(0 && "the radius component is not available"); return v; } - static bool HasRadius() { return true; } - static bool HasRadiusOcf() { return true; } + static bool HasRadius() { return false; } + static bool HasRadiusOcf() { return false; } static void Name(std::vector & name){ T::Name(name);} }; -/*----------------------------- VEADJ ------------------------------*/ +/*----------------------------- VEADJ ------------------------------*/ template class EmptyVEAdj: public T { @@ -537,13 +537,13 @@ public: static bool HasVEAdjacency() { return true; } static bool HasVEAdjacencyOcc() { return true; } static void Name(std::vector & name){name.push_back(std::string("VEAdj"));T::Name(name);} - + private: - typename T::EdgePointer _ep ; - int _zp ; + typename T::EdgePointer _ep ; + int _zp ; }; -/*----------------------------- VFADJ ------------------------------*/ +/*----------------------------- VFADJ ------------------------------*/ template class EmptyVFAdj: public T { @@ -571,11 +571,11 @@ public: static void Name(std::vector & name){name.push_back(std::string("VFAdj"));T::Name(name);} private: - typename T::FacePointer _fp ; - int _zp ; + typename T::FacePointer _fp ; + int _zp ; }; -/*----------------------------- VTADJ ------------------------------*/ +/*----------------------------- VTADJ ------------------------------*/ template class EmptyVTAdj: public T { @@ -599,8 +599,8 @@ public: static void Name( std::vector< std::string > & name ) { name.push_back( std::string("VTAdj") ); T::Name(name); } private: - typename T::TetraPointer _tp ; - int _zp ; + typename T::TetraPointer _tp ; + int _zp ; }; } // end namespace vert diff --git a/vcg/simplex/vertexplus/component_ocf.h b/vcg/simplex/vertexplus/component_ocf.h index 32735465..3a11e520 100644 --- a/vcg/simplex/vertexplus/component_ocf.h +++ b/vcg/simplex/vertexplus/component_ocf.h @@ -557,7 +557,7 @@ public: typedef A RadiusType; typedef RadiusType ScalarType; - RadiusType &R(){ assert((*this).Base().RadiusEnabled); return (*this).Base().RadiusV[(*this).Index()];} + RadiusType &R(){ assert((*this).Base().RadiusEnabled); return (*this).Base().RadiusV[(*this).Index()];} const RadiusType &cR() const { assert((*this).Base().RadiusEnabled); return (*this).Base().RadiusV[(*this).Index()];} template diff --git a/wrap/gl/shaders.h b/wrap/gl/shaders.h index b1df0369..acaa5d76 100644 --- a/wrap/gl/shaders.h +++ b/wrap/gl/shaders.h @@ -6,6 +6,9 @@ #include #include "gl_object.h" +#include "../../vcg/space/point2.h" +#include "../../vcg/space/point3.h" +#include "../../vcg/space/point4.h" class Shader : public GLObject, public Bindable { @@ -49,6 +52,9 @@ public: void SetSource(const char * src) { + if (this->objectID==0) + Gen(); + this->flags |= SOURCE_DIRTY; this->compiled = false; this->source = src; @@ -59,6 +65,9 @@ public: bool LoadSource(const char * fileName) { + if (this->objectID==0) + Gen(); + this->flags |= SOURCE_DIRTY; this->compiled = false; FILE * f = fopen(fileName, "rb"); @@ -375,6 +384,8 @@ public: void Attach(Shader * shd) { + if (this->objectID==0) + Gen(); this->shaders.insert(shd); this->linked = false; glAttachShader(this->objectID, shd->ObjectID()); @@ -405,15 +416,19 @@ public: bool Link(void) { + bool ok = true; for (std::set::iterator it=this->shaders.begin(); it!=this->shaders.end(); ++it) { Shader * shd = (*it); if (!shd->IsCompiled()) { - shd->Compile(); + ok = shd->Compile() && ok; } } + if (!ok) + return false; + glLinkProgram(this->objectID); GLint cm = 0; @@ -487,6 +502,24 @@ public: glUniform4f(loc, x, y, z, w); } + void Uniform(const char * name, const vcg::Point3f& p) + { + const GLint loc = glGetUniformLocation(this->objectID, name); + glUniform2fv(loc, 1, p.V()); + } + + void Uniform(const char * name, const vcg::Point2f& p) + { + const GLint loc = glGetUniformLocation(this->objectID, name); + glUniform3fv(loc, 1, p.V()); + } + + void Uniform(const char * name, const vcg::Point4f& p) + { + const GLint loc = glGetUniformLocation(this->objectID, name); + glUniform4fv(loc, 1, p.V()); + } + void Parameter(GLenum pname, int value) { glProgramParameteriEXT(this->objectID, pname, value); @@ -525,18 +558,26 @@ public: void SetSources(const char * vsrc, const char * fsrc) { - this->vshd.SetSource(vsrc); - this->fshd.SetSource(fsrc); - this->prog.Attach(&(this->vshd)); - this->prog.Attach(&(this->fshd)); + if (vsrc) { + this->vshd.SetSource(vsrc); + this->prog.Attach(&(this->vshd)); + } + if (fsrc) { + this->fshd.SetSource(fsrc); + this->prog.Attach(&(this->fshd)); + } } void LoadSources(const char * vfile, const char * ffile) { - this->vshd.LoadSource(vfile); - this->fshd.LoadSource(ffile); - this->prog.Attach(&(this->vshd)); - this->prog.Attach(&(this->fshd)); + if (vfile) { + this->vshd.LoadSource(vfile); + this->prog.Attach(&(this->vshd)); + } + if (ffile) { + this->fshd.LoadSource(ffile); + this->prog.Attach(&(this->fshd)); + } } protected: diff --git a/wrap/io_trimesh/import.h b/wrap/io_trimesh/import.h index e80217ce..8bc1e100 100644 --- a/wrap/io_trimesh/import.h +++ b/wrap/io_trimesh/import.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -75,8 +75,8 @@ namespace vcg { namespace tri { namespace io { -/** -This class encapsulate a filter for automatically importing meshes by guessing +/** +This class encapsulate a filter for automatically importing meshes by guessing the right filter according to the extension */ @@ -151,7 +151,7 @@ static bool ErrorCritical(int error) case KT_OBJ : return ImporterOBJ::ErrorCritical(error); break; } - return true; + return true; } static const char *ErrorMsg(int error) @@ -163,7 +163,7 @@ static const char *ErrorMsg(int error) case KT_OFF : return ImporterOFF::ErrorMsg(error); break; case KT_OBJ : return ImporterOBJ::ErrorMsg(error); break; } - return "Unknown type"; + return "Unknown type"; } static bool LoadMask(const char * filename, int &mask) @@ -192,7 +192,7 @@ static bool LoadMask(const char * filename, int &mask) err = ImporterOBJ::LoadMask(filename, mask); LastType()=KT_OBJ; } - else + else { err = false; LastType()=KT_UNKNOWN;