From 6bf2d2697ef13c776a32e0565358cf22b749bd66 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 18 Oct 2011 06:09:58 +0000 Subject: [PATCH] - fix for compiling md5 files on windows --- mk/windoze/shared_lib.vcproj | 36 +++++++- .../shared_lib/include/graphics/md5/Image.h | 9 ++ .../include/graphics/md5/Md5Model.h | 5 +- .../md5/{Shader.h => ShaderManager.h} | 0 .../shared_lib/include/graphics/md5/Texture.h | 2 + .../shared_lib/include/graphics/md5/md5util.h | 2 +- .../shared_lib/sources/graphics/md5/Image.cpp | 4 +- .../sources/graphics/md5/Md5Model.cpp | 84 +++++++++---------- .../md5/{Shader.cpp => ShaderManager.cpp} | 2 +- .../sources/graphics/md5/md5util.cpp | 2 +- 10 files changed, 90 insertions(+), 56 deletions(-) rename source/shared_lib/include/graphics/md5/{Shader.h => ShaderManager.h} (100%) rename source/shared_lib/sources/graphics/md5/{Shader.cpp => ShaderManager.cpp} (99%) diff --git a/mk/windoze/shared_lib.vcproj b/mk/windoze/shared_lib.vcproj index c9dfb5f31..4267efa08 100644 --- a/mk/windoze/shared_lib.vcproj +++ b/mk/windoze/shared_lib.vcproj @@ -40,7 +40,7 @@ + + @@ -395,6 +399,10 @@ + + @@ -427,10 +435,18 @@ RelativePath="..\..\source\shared_lib\sources\graphics\gl\font_textFTGL.cpp" > + + + + @@ -443,6 +459,14 @@ RelativePath="..\..\source\shared_lib\sources\graphics\JPGReader.cpp" > + + + + @@ -479,6 +503,10 @@ RelativePath="..\..\source\shared_lib\sources\graphics\texture.cpp" > + + diff --git a/source/shared_lib/include/graphics/md5/Image.h b/source/shared_lib/include/graphics/md5/Image.h index 880c7c811..6e56cc738 100644 --- a/source/shared_lib/include/graphics/md5/Image.h +++ b/source/shared_lib/include/graphics/md5/Image.h @@ -20,11 +20,14 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include +#include #endif // _WIN32 #include +#ifndef _WIN32 //#include #include +#endif #include #include #include @@ -39,10 +42,16 @@ using std::cout; using std::endl; using std::string; +#ifdef _WIN32 +using std::tr1::shared_ptr; +#endif + namespace Shared { namespace Graphics { namespace md5 { +#ifndef _WIN32 //using boost::shared_ptr; using std::tr1::shared_ptr; +#endif ///////////////////////////////////////////////////////////////////////////// // Image class diagram: diff --git a/source/shared_lib/include/graphics/md5/Md5Model.h b/source/shared_lib/include/graphics/md5/Md5Model.h index a4dff0e4e..18d891f47 100644 --- a/source/shared_lib/include/graphics/md5/Md5Model.h +++ b/source/shared_lib/include/graphics/md5/Md5Model.h @@ -21,6 +21,7 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include +#include #endif // _WIN32 #include @@ -40,7 +41,9 @@ using std::string; using std::vector; using std::map; -//using std::shared_ptr; +#ifdef _WIN32 +using std::tr1::shared_ptr; +#endif // Forward declarations class Md5Skeleton; diff --git a/source/shared_lib/include/graphics/md5/Shader.h b/source/shared_lib/include/graphics/md5/ShaderManager.h similarity index 100% rename from source/shared_lib/include/graphics/md5/Shader.h rename to source/shared_lib/include/graphics/md5/ShaderManager.h diff --git a/source/shared_lib/include/graphics/md5/Texture.h b/source/shared_lib/include/graphics/md5/Texture.h index 9f80b174c..faf4264f3 100644 --- a/source/shared_lib/include/graphics/md5/Texture.h +++ b/source/shared_lib/include/graphics/md5/Texture.h @@ -23,7 +23,9 @@ #endif // _WIN32 #include +#ifndef _WIN32 #include +#endif #include #include #include diff --git a/source/shared_lib/include/graphics/md5/md5util.h b/source/shared_lib/include/graphics/md5/md5util.h index 29b7d6e59..a7f1792d7 100644 --- a/source/shared_lib/include/graphics/md5/md5util.h +++ b/source/shared_lib/include/graphics/md5/md5util.h @@ -18,7 +18,7 @@ namespace Shared { namespace Graphics { namespace md5 { class Md5Object; -class Real; +//class Real; template class Matrix4x4; typedef Matrix4x4 Matrix4x4f; diff --git a/source/shared_lib/sources/graphics/md5/Image.cpp b/source/shared_lib/sources/graphics/md5/Image.cpp index ae7b53b59..47f8811de 100644 --- a/source/shared_lib/sources/graphics/md5/Image.cpp +++ b/source/shared_lib/sources/graphics/md5/Image.cpp @@ -1347,7 +1347,7 @@ ImagePNG::ImagePNG (const ImageBuffer &ibuff) memcpy (sig, reinterpret_cast(ibuff.data ()), 8); // Check for valid magic number - if (!png_check_sig (sig, 8)) + if (!png_sig_cmp (sig, 0, 8)) throw ImageException ("Not a valid PNG file", _name); // Create PNG read struct @@ -1381,7 +1381,7 @@ ImagePNG::ImagePNG (const ImageBuffer &ibuff) // Convert 1-2-4 bits grayscale images to 8 bits // grayscale. if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8 (png_ptr); + png_set_expand_gray_1_2_4_to_8(png_ptr); if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha (png_ptr); diff --git a/source/shared_lib/sources/graphics/md5/Md5Model.cpp b/source/shared_lib/sources/graphics/md5/Md5Model.cpp index d56142898..cb9713935 100644 --- a/source/shared_lib/sources/graphics/md5/Md5Model.cpp +++ b/source/shared_lib/sources/graphics/md5/Md5Model.cpp @@ -28,7 +28,7 @@ #include "Texture.h" #include "ArbProgram.h" -#include "Shader.h" +#include "ShaderManager.h" #include "Md5Model.h" namespace Shared { namespace Graphics { namespace md5 { @@ -666,19 +666,15 @@ Md5Mesh::computeWeightTangents (Md5Skeleton *skel) // Compute mesh bounding box for a given skeleton. // -------------------------------------------------------------------------- -void -Md5Mesh::computeBoundingBox (Md5Skeleton *skel) -{ - Vector3f max (-99999.0f, -99999.0f, -99999.0f); - Vector3f min ( 99999.0f, 99999.0f, 99999.0f); +void Md5Mesh::computeBoundingBox (Md5Skeleton *skel) { + Vector3f maxValue(-99999.0f, -99999.0f, -99999.0f); + Vector3f minValue( 99999.0f, 99999.0f, 99999.0f); - for (int i = 0; i < _numVerts; ++i) - { + for (int i = 0; i < _numVerts; ++i) { Vector3f finalVertex = kZeroVectorf; // Calculate final vertex to draw with weights - for (int j = 0; j < _verts[i]->countWeight; ++j) - { + for (int j = 0; j < _verts[i]->countWeight; ++j) { const Md5Weight_t *pWeight = _weights[_verts[i]->startWeight + j].get (); const Md5Joint_t *pJoint @@ -692,30 +688,29 @@ Md5Mesh::computeBoundingBox (Md5Skeleton *skel) finalVertex += (pJoint->pos + wv) * pWeight->bias; } - if (finalVertex._x > max._x) - max._x = finalVertex._x; + if (finalVertex._x > maxValue._x) + maxValue._x = finalVertex._x; - if (finalVertex._x < min._x) - min._x = finalVertex._x; + if (finalVertex._x < minValue._x) + minValue._x = finalVertex._x; - if (finalVertex._y > max._y) - max._y = finalVertex._y; + if (finalVertex._y > maxValue._y) + maxValue._y = finalVertex._y; - if (finalVertex._y < min._y) - min._y = finalVertex._y; + if (finalVertex._y < minValue._y) + minValue._y = finalVertex._y; - if (finalVertex._z > max._z) - max._z = finalVertex._z; + if (finalVertex._z > maxValue._z) + maxValue._z = finalVertex._z; - if (finalVertex._z < min._z) - min._z = finalVertex._z; + if (finalVertex._z < minValue._z) + minValue._z = finalVertex._z; } - _boundingBox.min = min; - _boundingBox.max = max; + _boundingBox.min = minValue; + _boundingBox.max = maxValue; } - // -------------------------------------------------------------------------- // Md5Mesh::preRenderVertexArrays // @@ -1265,38 +1260,35 @@ Md5Model::anim (const string &name) const // Compute model's bounding box in bind-pose. // -------------------------------------------------------------------------- -void -Md5Model::computeBindPoseBoundingBox () -{ - Vector3f max (-99999.0f, -99999.0f, -99999.0f); - Vector3f min ( 99999.0f, 99999.0f, 99999.0f); +void Md5Model::computeBindPoseBoundingBox() { + Vector3f maxValue(-99999.0f, -99999.0f, -99999.0f); + Vector3f minValue( 99999.0f, 99999.0f, 99999.0f); // Get the min and the max from all mesh bounding boxes - for (int i = 0; i < _numMeshes; ++i) - { + for (int i = 0; i < _numMeshes; ++i) { const BoundingBox_t &meshBox = _meshes[i]->boundingBox (); - if (meshBox.max._x > max._x) - max._x = meshBox.max._x; + if (meshBox.max._x > maxValue._x) + maxValue._x = meshBox.max._x; - if (meshBox.min._x < min._x) - min._x = meshBox.min._x; + if (meshBox.min._x < minValue._x) + minValue._x = meshBox.min._x; - if (meshBox.max._y > max._y) - max._y = meshBox.max._y; + if (meshBox.max._y > maxValue._y) + maxValue._y = meshBox.max._y; - if (meshBox.min._y < min._y) - min._y = meshBox.min._y; + if (meshBox.min._y < minValue._y) + minValue._y = meshBox.min._y; - if (meshBox.max._z > max._z) - max._z = meshBox.max._z; + if (meshBox.max._z > maxValue._z) + maxValue._z = meshBox.max._z; - if (meshBox.min._z < min._z) - min._z = meshBox.min._z; + if (meshBox.min._z < minValue._z) + minValue._z = meshBox.min._z; } - _bindPoseBox.min = min; - _bindPoseBox.max = max; + _bindPoseBox.min = minValue; + _bindPoseBox.max = maxValue; } diff --git a/source/shared_lib/sources/graphics/md5/Shader.cpp b/source/shared_lib/sources/graphics/md5/ShaderManager.cpp similarity index 99% rename from source/shared_lib/sources/graphics/md5/Shader.cpp rename to source/shared_lib/sources/graphics/md5/ShaderManager.cpp index dab5f5430..529bac42e 100644 --- a/source/shared_lib/sources/graphics/md5/Shader.cpp +++ b/source/shared_lib/sources/graphics/md5/ShaderManager.cpp @@ -18,7 +18,7 @@ #include #include -#include "Shader.h" +#include "ShaderManager.h" #include "GlErrors.h" namespace Shared { namespace Graphics { namespace md5 { diff --git a/source/shared_lib/sources/graphics/md5/md5util.cpp b/source/shared_lib/sources/graphics/md5/md5util.cpp index 0c0d21497..0c2d6583c 100644 --- a/source/shared_lib/sources/graphics/md5/md5util.cpp +++ b/source/shared_lib/sources/graphics/md5/md5util.cpp @@ -26,7 +26,7 @@ #include "Md5Model.h" #include "TextureManager.h" #include "ArbProgram.h" -#include "Shader.h" +#include "ShaderManager.h" #include "md5util.h" namespace Shared { namespace Graphics { namespace md5 {