Skip to content

Commit

Permalink
Fixes for gcc and clang compiler errors and warnings.
Browse files Browse the repository at this point in the history
Documentation updates.
  • Loading branch information
cemyuksel committed Feb 6, 2017
1 parent 8a06666 commit d82d25e
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 87 deletions.
36 changes: 21 additions & 15 deletions cyBVH.h
Expand Up @@ -40,15 +40,21 @@
namespace cy {
//-------------------------------------------------------------------------------

#define CY_BVH_ELEMENT_COUNT_BITS 3 // Determines the maximum number of elements in a node (8)
#define CY_BVH_MAX_ELEMENT_COUNT (1<<CY_BVH_ELEMENT_COUNT_BITS)
#define CY_BVH_NODE_DATA_BITS (sizeof(unsigned int)*8)
#define CY_BVH_ELEMENT_COUNT_MASK ((1<<CY_BVH_ELEMENT_COUNT_BITS)-1)
#define CY_BVH_LEAF_BIT_MASK ((unsigned int)1<<(CY_BVH_NODE_DATA_BITS-1))
#define CY_BVH_CHILD_INDEX_BITS (CY_BVH_NODE_DATA_BITS-1)
#define CY_BVH_CHILD_INDEX_MASK (CY_BVH_LEAF_BIT_MASK-1)
#define CY_BVH_ELEMENT_OFFSET_BITS (CY_BVH_NODE_DATA_BITS-1-CY_BVH_ELEMENT_COUNT_BITS)
#define CY_BVH_ELEMENT_OFFSET_MASK ((1<<CY_BVH_ELEMENT_OFFSET_BITS)-1)
#ifndef CY_BVH_ELEMENT_COUNT_BITS
#define CY_BVH_ELEMENT_COUNT_BITS 3 //!< Determines the number of bits needed to represent the maximum number of elements in a node (8)
#endif

#ifndef CY_BVH_MAX_ELEMENT_COUNT
#define CY_BVH_MAX_ELEMENT_COUNT (1<<CY_BVH_ELEMENT_COUNT_BITS) //!< Determines the maximum number of elements in a node (8)
#endif

#define _CY_BVH_NODE_DATA_BITS (sizeof(unsigned int)*8)
#define _CY_BVH_ELEMENT_COUNT_MASK ((1<<CY_BVH_ELEMENT_COUNT_BITS)-1)
#define _CY_BVH_LEAF_BIT_MASK ((unsigned int)1<<(_CY_BVH_NODE_DATA_BITS-1))
#define _CY_BVH_CHILD_INDEX_BITS (_CY_BVH_NODE_DATA_BITS-1)
#define _CY_BVH_CHILD_INDEX_MASK (_CY_BVH_LEAF_BIT_MASK-1)
#define _CY_BVH_ELEMENT_OFFSET_BITS (_CY_BVH_NODE_DATA_BITS-1-CY_BVH_ELEMENT_COUNT_BITS)
#define _CY_BVH_ELEMENT_OFFSET_MASK ((1<<_CY_BVH_ELEMENT_OFFSET_BITS)-1)

//-------------------------------------------------------------------------------

Expand Down Expand Up @@ -181,12 +187,12 @@ class BVH
class Node
{
public:
void SetLeafNode( const Box &bound, unsigned int elemCount, unsigned int elemOffset ) { box=bound; data=(elemOffset&CY_BVH_ELEMENT_OFFSET_MASK)|((elemCount-1)<<CY_BVH_ELEMENT_OFFSET_BITS)|CY_BVH_LEAF_BIT_MASK; }
void SetInternalNode( const Box &bound, unsigned int chilIndex ) { box=bound; data=(chilIndex&CY_BVH_CHILD_INDEX_MASK); }
unsigned int ChildIndex() const { return (data&CY_BVH_CHILD_INDEX_MASK); } //!< returns the index to the first child (must be internal node)
unsigned int ElementOffset() const { return (data&CY_BVH_ELEMENT_OFFSET_MASK); } //!< returns the offset to the first element (must be leaf node)
unsigned int ElementCount() const { return ((data>>CY_BVH_ELEMENT_OFFSET_BITS)&CY_BVH_ELEMENT_COUNT_MASK)+1; } //!< returns the number of elements in this node (must be leaf node)
bool IsLeafNode() const { return (data&CY_BVH_LEAF_BIT_MASK)>0; } //!< returns true if this is a leaf node
void SetLeafNode( const Box &bound, unsigned int elemCount, unsigned int elemOffset ) { box=bound; data=(elemOffset&_CY_BVH_ELEMENT_OFFSET_MASK)|((elemCount-1)<<_CY_BVH_ELEMENT_OFFSET_BITS)|_CY_BVH_LEAF_BIT_MASK; }
void SetInternalNode( const Box &bound, unsigned int chilIndex ) { box=bound; data=(chilIndex&_CY_BVH_CHILD_INDEX_MASK); }
unsigned int ChildIndex() const { return (data&_CY_BVH_CHILD_INDEX_MASK); } //!< returns the index to the first child (must be internal node)
unsigned int ElementOffset() const { return (data&_CY_BVH_ELEMENT_OFFSET_MASK); } //!< returns the offset to the first element (must be leaf node)
unsigned int ElementCount() const { return ((data>>_CY_BVH_ELEMENT_OFFSET_BITS)&_CY_BVH_ELEMENT_COUNT_MASK)+1; } //!< returns the number of elements in this node (must be leaf node)
bool IsLeafNode() const { return (data&_CY_BVH_LEAF_BIT_MASK)>0; } //!< returns true if this is a leaf node
const float* GetBounds() const { return box.b; } //!< returns the bounding box of the node
private:
Box box; //!< bounding box of the node
Expand Down
12 changes: 6 additions & 6 deletions cyCore.h
Expand Up @@ -67,15 +67,15 @@

// constexpr
#ifndef __cpp_constexpr
# if (defined(_MSC_VER) && _MSC_VER >= 1900) || (defined(_CY_GCC_VER) && _CY_GCC_VER >= 40600) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER >= 301000) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1310)
# if (defined(_MSC_VER) && _MSC_VER >= 1900) || (defined(_CY_GCC_VER) && _CY_GCC_VER >= 40600) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER >= 30100) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1310)
# define __cpp_constexpr
# else
# define constexpr
# endif
#endif

// nullptr
#if (defined(_MSC_VER) && _MSC_VER < 1600) || (defined(_CY_GCC_VER) && _CY_GCC_VER < 40600) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER < 209000) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1210)
#if (defined(_MSC_VER) && _MSC_VER < 1600) || (defined(_CY_GCC_VER) && _CY_GCC_VER < 40600) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER < 20900) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1210)
class _cy_nullptr_t {
public:
template<class T> operator T*() const { return 0; }
Expand All @@ -88,14 +88,14 @@ static _cy_nullptr_t nullptr;

// template aliases
# define _CY_TEMPLATE_ALIAS_UNPACK(...) __VA_ARGS__
#if (defined(_MSC_VER) && _MSC_VER < 1800) || (defined(_CY_GCC_VER) && _CY_GCC_VER < 40700) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER < 300000) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1210)
#if (defined(_MSC_VER) && _MSC_VER < 1800) || (defined(_CY_GCC_VER) && _CY_GCC_VER < 40700) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER < 30000) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1210)
# define _CY_TEMPLATE_ALIAS(template_name,template_equivalent) class template_name : public _CY_TEMPLATE_ALIAS_UNPACK template_equivalent {}
#else
# define _CY_TEMPLATE_ALIAS(template_name,template_equivalent) using template_name = _CY_TEMPLATE_ALIAS_UNPACK template_equivalent
#endif

// std::is_trivially_copyable
#if (defined(_MSC_VER) && _MSC_VER >= 1700) || (defined(_CY_GCC_VER) && _CY_GCC_VER >= 50000) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER < 304000)
#if (defined(_MSC_VER) && _MSC_VER >= 1700) || (defined(_CY_GCC_VER) && _CY_GCC_VER >= 50000) || (defined(_CY_CLANG_VER) && _CY_CLANG_VER < 30400)
#define _cy_has_std_is_trivially_copyable 1
#endif

Expand All @@ -108,11 +108,11 @@ static _cy_nullptr_t nullptr;
# define _CY_IVDEP __pragma(loop(ivdep))
# endif
#elif defined __GNUC__
# if _CY_GCC_VER >= 409000
# if _CY_GCC_VER >= 40900
# define _CY_IVDEP _Pragma("GCC ivdep");
# endif
#elif defined __clang__
# if _CY_CLANG_VER >= 305000
# if _CY_CLANG_VER >= 30500
# define _CY_IVDEP _Pragma("clang loop vectorize(enable) interleave(enable)");
# endif
#else
Expand Down
63 changes: 35 additions & 28 deletions cyGL.h
Expand Up @@ -89,45 +89,52 @@ namespace cy {

//-------------------------------------------------------------------------------

//! This global function prints the OpenGL version to the given stream.
inline void GLPrintVersion(std::ostream *outStream=&std::cout)
//! General OpenGL queries
//!
//! This class includes static functions for general OpenGL queries.
class GL
{
const GLubyte* version = glGetString(GL_VERSION);
if ( version ) *outStream << version;
else {
int versionMajor=0, versionMinor=0;
public:
//! Prints the OpenGL version to the given stream.
static void PrintVersion(std::ostream *outStream=&std::cout)
{
const GLubyte* version = glGetString(GL_VERSION);
if ( version ) *outStream << version;
else {
int versionMajor=0, versionMinor=0;
#ifdef GL_VERSION_3_0
glGetIntegerv(GL_MAJOR_VERSION,&versionMajor);
glGetIntegerv(GL_MINOR_VERSION,&versionMinor);
glGetIntegerv(GL_MAJOR_VERSION,&versionMajor);
glGetIntegerv(GL_MINOR_VERSION,&versionMinor);
#endif
if ( versionMajor > 0 && versionMajor < 100 ) {
*outStream << versionMajor << "." << versionMinor;
} else *outStream << "Unknown";
if ( versionMajor > 0 && versionMajor < 100 ) {
*outStream << versionMajor << "." << versionMinor;
} else *outStream << "Unknown";
}
}
}

//-------------------------------------------------------------------------------
//! Checks all previously triggered OpenGL errors and prints them to the given output stream.
static void CheckError(const char *sourcefile, int line, const char *call=nullptr, std::ostream *outStream=&std::cout)
{
GLenum error;
while ( (error = glGetError()) != GL_NO_ERROR) {
*outStream << "OpenGL ERROR: " << sourcefile << " (line " << line << "): ";
if ( call ) *outStream << call << " triggered ";
*outStream << gluErrorString(error) << std::endl;
}
}
};

//! Checks all previously triggered OpenGL errors and prints them to the given output stream.
static void GLCheckError(const char *sourcefile, int line, const char *call=nullptr, std::ostream *outStream=&std::cout)
{
GLenum error;
while ( (error = glGetError()) != GL_NO_ERROR) {
*outStream << "OpenGL ERROR: " << sourcefile << " (line " << line << "): ";
if ( call ) *outStream << call << " triggered ";
*outStream << gluErrorString(error) << std::endl;
}
}
//-------------------------------------------------------------------------------

//! Checks and prints OpenGL error messages to the default output stream.
#define CY_GL_ERROR _CY_GL_ERROR
#define _CY_GL_ERROR cy::GLCheckError(__FILE__,__LINE__)
#define _CY_GL_ERROR cy::GL::CheckError(__FILE__,__LINE__)

//! Checks OpenGL errors before calling the given function,
//! calls the function, and then checks OpenGL errors again.
//! If an error is found, it is printed to the default output stream.
#define CY_GL_ERR(gl_function_call) _CY_GL_ERR(gl_function_call)
#define _CY_GL_ERR(f) cy::GLCheckError(__FILE__,__LINE__,"a prior call"); f; cy::GLCheckError(__FILE__,__LINE__,#f)
#define _CY_GL_ERR(f) cy::GL::CheckError(__FILE__,__LINE__,"a prior call"); f; cy::GL::CheckError(__FILE__,__LINE__,#f)

#ifdef _DEBUG
# define CY_GL_ERROR_D CY_GL_ERROR //!< Checks and prints OpenGL error messages using CY_GL_ERROR in code compiled in debug mode only (with _DEBUG defined).
Expand Down Expand Up @@ -544,7 +551,7 @@ inline void _CY_APIENTRY GLDebugCallback::Callback( GLenum source,
*outStream << std::endl;
*outStream << "OpenGL Debug Output:" << std::endl;
*outStream << "VERSION: ";
GLPrintVersion(outStream);
GL::PrintVersion(outStream);
*outStream << std::endl;

*outStream << "SOURCE: ";
Expand Down Expand Up @@ -647,7 +654,7 @@ inline bool GLSLShader::Compile( const char *shaderSourceCode, GLenum shaderType
if ( outStream ) {
if ( !result ) *outStream << "ERROR: Cannot compile shader." << std::endl;
*outStream << "OpenGL Version: ";
GLPrintVersion(outStream);
GL::PrintVersion(outStream);
*outStream << std::endl;
*outStream << compilerMessage.data() << std::endl;
}
Expand All @@ -656,7 +663,7 @@ inline bool GLSLShader::Compile( const char *shaderSourceCode, GLenum shaderType
if ( result ) {
GLint stype;
glGetShaderiv(shaderID, GL_SHADER_TYPE, &stype);
if ( stype != shaderType ) {
if ( stype != (GLint)shaderType ) {
if ( outStream ) *outStream << "ERROR: Incorrect shader type." << std::endl;
return false;
}
Expand Down
72 changes: 36 additions & 36 deletions cyHairFile.h
Expand Up @@ -44,23 +44,23 @@
namespace cy {
//-------------------------------------------------------------------------------

#define CY_HAIR_FILE_SEGMENTS_BIT 1
#define CY_HAIR_FILE_POINTS_BIT 2
#define CY_HAIR_FILE_THICKNESS_BIT 4
#define CY_HAIR_FILE_TRANSPARENCY_BIT 8
#define CY_HAIR_FILE_COLORS_BIT 16
#define _CY_HAIR_FILE_SEGMENTS_BIT 1
#define _CY_HAIR_FILE_POINTS_BIT 2
#define _CY_HAIR_FILE_THICKNESS_BIT 4
#define _CY_HAIR_FILE_TRANSPARENCY_BIT 8
#define _CY_HAIR_FILE_COLORS_BIT 16

#define CY_HAIR_FILE_INFO_SIZE 88
#define _CY_HAIR_FILE_INFO_SIZE 88

// File read errors
#define CY_HAIR_FILE_ERROR_CANT_OPEN_FILE -1
#define CY_HAIR_FILE_ERROR_CANT_READ_HEADER -2
#define CY_HAIR_FILE_ERROR_WRONG_SIGNATURE -3
#define CY_HAIR_FILE_ERROR_READING_SEGMENTS -4
#define CY_HAIR_FILE_ERROR_READING_POINTS -5
#define CY_HAIR_FILE_ERROR_READING_THICKNESS -6
#define CY_HAIR_FILE_ERROR_READING_TRANSPARENCY -7
#define CY_HAIR_FILE_ERROR_READING_COLORS -8
#define CY_HAIR_FILE_ERROR_CANT_OPEN_FILE -1 //!< Error code cannot open file
#define CY_HAIR_FILE_ERROR_CANT_READ_HEADER -2 //!< Error code cannot read header
#define CY_HAIR_FILE_ERROR_WRONG_SIGNATURE -3 //!< Error code wrong signature
#define CY_HAIR_FILE_ERROR_READING_SEGMENTS -4 //!< Error code failed reading segments
#define CY_HAIR_FILE_ERROR_READING_POINTS -5 //!< Error code failed reading points
#define CY_HAIR_FILE_ERROR_READING_THICKNESS -6 //!< Error code failed reading thickness
#define CY_HAIR_FILE_ERROR_READING_TRANSPARENCY -7 //!< Error code failed reading transparency
#define CY_HAIR_FILE_ERROR_READING_COLORS -8 //!< Error code failed reading colors

//-------------------------------------------------------------------------------

Expand All @@ -85,7 +85,7 @@ class HairFile
float d_transparency; //!< default transparency of hair strands
float d_color[3]; //!< default color of hair strands

char info[CY_HAIR_FILE_INFO_SIZE]; //!< information about the file
char info[_CY_HAIR_FILE_INFO_SIZE]; //!< information about the file
};

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -133,7 +133,7 @@ class HairFile
header.d_color[0] = 1.0f;
header.d_color[1] = 1.0f;
header.d_color[2] = 1.0f;
memset( header.info, '\0', CY_HAIR_FILE_INFO_SIZE );
memset( header.info, '\0', _CY_HAIR_FILE_INFO_SIZE );
}

//! Sets the hair count, re-allocates segments array if necessary.
Expand Down Expand Up @@ -174,16 +174,16 @@ class HairFile
void SetArrays( int array_types )
{
header.arrays = array_types;
if ( (header.arrays & CY_HAIR_FILE_SEGMENTS_BIT ) && !segments ) { segments = new unsigned short[header.hair_count]; }
if ( !(header.arrays & CY_HAIR_FILE_SEGMENTS_BIT ) && segments ) { delete [] segments; segments=nullptr; }
if ( (header.arrays & CY_HAIR_FILE_POINTS_BIT ) && !points ) { points = new float[header.point_count*3]; }
if ( !(header.arrays & CY_HAIR_FILE_POINTS_BIT ) && points ) { delete [] points; points=nullptr; }
if ( (header.arrays & CY_HAIR_FILE_THICKNESS_BIT ) && !thickness ) { thickness = new float[header.point_count]; }
if ( !(header.arrays & CY_HAIR_FILE_THICKNESS_BIT ) && thickness ) { delete [] thickness; thickness=nullptr; }
if ( (header.arrays & CY_HAIR_FILE_TRANSPARENCY_BIT) && !transparency ) { transparency = new float[header.point_count]; }
if ( !(header.arrays & CY_HAIR_FILE_TRANSPARENCY_BIT) && transparency ) { delete [] transparency; transparency=nullptr; }
if ( (header.arrays & CY_HAIR_FILE_COLORS_BIT ) && !colors ) { colors = new float[header.point_count*3]; }
if ( !(header.arrays & CY_HAIR_FILE_COLORS_BIT ) && colors ) { delete [] colors; colors=nullptr; }
if ( (header.arrays & _CY_HAIR_FILE_SEGMENTS_BIT ) && !segments ) { segments = new unsigned short[header.hair_count]; }
if ( !(header.arrays & _CY_HAIR_FILE_SEGMENTS_BIT ) && segments ) { delete [] segments; segments=nullptr; }
if ( (header.arrays & _CY_HAIR_FILE_POINTS_BIT ) && !points ) { points = new float[header.point_count*3]; }
if ( !(header.arrays & _CY_HAIR_FILE_POINTS_BIT ) && points ) { delete [] points; points=nullptr; }
if ( (header.arrays & _CY_HAIR_FILE_THICKNESS_BIT ) && !thickness ) { thickness = new float[header.point_count]; }
if ( !(header.arrays & _CY_HAIR_FILE_THICKNESS_BIT ) && thickness ) { delete [] thickness; thickness=nullptr; }
if ( (header.arrays & _CY_HAIR_FILE_TRANSPARENCY_BIT) && !transparency ) { transparency = new float[header.point_count]; }
if ( !(header.arrays & _CY_HAIR_FILE_TRANSPARENCY_BIT) && transparency ) { delete [] transparency; transparency=nullptr; }
if ( (header.arrays & _CY_HAIR_FILE_COLORS_BIT ) && !colors ) { colors = new float[header.point_count*3]; }
if ( !(header.arrays & _CY_HAIR_FILE_COLORS_BIT ) && colors ) { delete [] colors; colors=nullptr; }
}

//! Sets default number of segments for all hair strands, which is used if segments array does not exist.
Expand Down Expand Up @@ -224,35 +224,35 @@ class HairFile
if ( strncmp( header.signature, "HAIR", 4) != 0 ) _CY_FAILED_RETURN(CY_HAIR_FILE_ERROR_WRONG_SIGNATURE);

// Read segments array
if ( header.arrays & CY_HAIR_FILE_SEGMENTS_BIT ) {
if ( header.arrays & _CY_HAIR_FILE_SEGMENTS_BIT ) {
segments = new unsigned short[ header.hair_count ];
size_t readcount = fread( segments, sizeof(unsigned short), header.hair_count, fp );
if ( readcount < header.hair_count ) _CY_FAILED_RETURN(CY_HAIR_FILE_ERROR_READING_SEGMENTS);
}

// Read points array
if ( header.arrays & CY_HAIR_FILE_POINTS_BIT ) {
if ( header.arrays & _CY_HAIR_FILE_POINTS_BIT ) {
points = new float[ header.point_count*3 ];
size_t readcount = fread( points, sizeof(float), header.point_count*3, fp );
if ( readcount < header.point_count*3 ) _CY_FAILED_RETURN(CY_HAIR_FILE_ERROR_READING_POINTS);
}

// Read thickness array
if ( header.arrays & CY_HAIR_FILE_THICKNESS_BIT ) {
if ( header.arrays & _CY_HAIR_FILE_THICKNESS_BIT ) {
thickness = new float[ header.point_count ];
size_t readcount = fread( thickness, sizeof(float), header.point_count, fp );
if ( readcount < header.point_count ) _CY_FAILED_RETURN(CY_HAIR_FILE_ERROR_READING_THICKNESS);
}

// Read thickness array
if ( header.arrays & CY_HAIR_FILE_TRANSPARENCY_BIT ) {
if ( header.arrays & _CY_HAIR_FILE_TRANSPARENCY_BIT ) {
transparency = new float[ header.point_count ];
size_t readcount = fread( transparency, sizeof(float), header.point_count, fp );
if ( readcount < header.point_count ) _CY_FAILED_RETURN(CY_HAIR_FILE_ERROR_READING_TRANSPARENCY);
}

// Read colors array
if ( header.arrays & CY_HAIR_FILE_COLORS_BIT ) {
if ( header.arrays & _CY_HAIR_FILE_COLORS_BIT ) {
colors = new float[ header.point_count*3 ];
size_t readcount = fread( colors, sizeof(float), header.point_count*3, fp );
if ( readcount < header.point_count*3 ) _CY_FAILED_RETURN(CY_HAIR_FILE_ERROR_READING_COLORS);
Expand All @@ -274,11 +274,11 @@ class HairFile
fwrite( &header, sizeof(Header), 1, fp );

// Write arrays
if ( header.arrays & CY_HAIR_FILE_SEGMENTS_BIT ) fwrite( segments, sizeof(unsigned short), header.hair_count, fp );
if ( header.arrays & CY_HAIR_FILE_POINTS_BIT ) fwrite( points, sizeof(float), header.point_count*3, fp );
if ( header.arrays & CY_HAIR_FILE_THICKNESS_BIT ) fwrite( thickness, sizeof(float), header.point_count, fp );
if ( header.arrays & CY_HAIR_FILE_TRANSPARENCY_BIT ) fwrite( transparency, sizeof(float), header.point_count, fp );
if ( header.arrays & CY_HAIR_FILE_COLORS_BIT ) fwrite( colors, sizeof(float), header.point_count*3, fp );
if ( header.arrays & _CY_HAIR_FILE_SEGMENTS_BIT ) fwrite( segments, sizeof(unsigned short), header.hair_count, fp );
if ( header.arrays & _CY_HAIR_FILE_POINTS_BIT ) fwrite( points, sizeof(float), header.point_count*3, fp );
if ( header.arrays & _CY_HAIR_FILE_THICKNESS_BIT ) fwrite( thickness, sizeof(float), header.point_count, fp );
if ( header.arrays & _CY_HAIR_FILE_TRANSPARENCY_BIT ) fwrite( transparency, sizeof(float), header.point_count, fp );
if ( header.arrays & _CY_HAIR_FILE_COLORS_BIT ) fwrite( colors, sizeof(float), header.point_count*3, fp );

fclose( fp );

Expand Down
4 changes: 2 additions & 2 deletions cyTriMesh.h
Expand Up @@ -305,7 +305,7 @@ inline bool TriMesh::LoadFromFileObj( const char *filename, bool loadMtl )
}
};
MtlList mtlList;
MtlData *currentMtlData = nullptr;

std::vector<Point3f> _v; // vertices
std::vector<TriFace> _f; // faces
std::vector<Point3f> _vn; // vertex normal
Expand Down Expand Up @@ -473,7 +473,7 @@ inline bool TriMesh::LoadFromFileObj( const char *filename, bool loadMtl )
FILE *fp = fopen(mtlFullFilename,"r");
if ( !fp ) continue;
int mtlID = -1;
while ( int rb = buffer.ReadLine(fp) ) {
while ( buffer.ReadLine(fp) ) {
if ( buffer.IsCommand("newmtl") ) {
char mtlName[256];
buffer.Copy(mtlName,256,7);
Expand Down

0 comments on commit d82d25e

Please sign in to comment.