fixes toward mingw compatibility
authorPerttu Ahola <celeron55@gmail.com>
Thu, 10 Feb 2011 13:55:15 +0000 (15:55 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 10 Feb 2011 13:55:15 +0000 (15:55 +0200)
src/CMakeLists.txt
src/debug.cpp
src/debug.h
src/main.cpp
src/mapblock.cpp
src/tile.cpp

index 071beeadc626016cdd0a8610af1e8f7152d9526f..4d2ba0d294c88186ff6a41db6b3c6c5c9980b2f8 100644 (file)
@@ -10,8 +10,10 @@ add_definitions ( -DUSE_CMAKE_CONFIG_H )
 
 if(WIN32)
        # Windows
-       # Surpress some useless warnings
-       add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
+       if(MSVC)
+               # Surpress some useless warnings
+               add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
+       endif()
        # Zlib stuff
        set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
                        CACHE PATH "Zlib include directory")
index ec23235cbd817d88bbd340b00bba661a47dceb29..d4d07375d90831a69bd90aca609f384e30a5f973 100644 (file)
@@ -197,7 +197,7 @@ DebugStacker::~DebugStacker()
 }
 
 
-#ifdef _WIN32
+#ifdef _MSC_VER
 #if CATCH_UNHANDLED_EXCEPTIONS == 1
 void se_trans_func(unsigned int u, EXCEPTION_POINTERS* pExp)
 {
index 1973bb51062432f41d57b1af830eacaf6c177d4d..092bb03a819f67486ecca67964fdbd4855bd773b 100644 (file)
@@ -238,18 +238,7 @@ private:
                        assert(0);\
                }
        #ifdef _WIN32 // Windows
-
-/*class SE_Exception : public std::exception
-{
-private:
-    unsigned int nSE;
-public:
-    SE_Exception() {}
-    SE_Exception( unsigned int n ) : nSE( n ) {}
-    ~SE_Exception() {}
-    unsigned int getSeNumber() { return nSE; }
-};*/
-
+               #ifdef _MSC_VER // MSVC
 void se_trans_func(unsigned int, EXCEPTION_POINTERS*);
 
 class FatalSystemException : public BaseException
@@ -259,14 +248,18 @@ public:
                BaseException(s)
        {}
 };
-
-               #define BEGIN_DEBUG_EXCEPTION_HANDLER \
-                       BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER\
-                       _set_se_translator(se_trans_func);
-
-               #define END_DEBUG_EXCEPTION_HANDLER \
-                       END_PORTABLE_DEBUG_EXCEPTION_HANDLER
-
+                       #define BEGIN_DEBUG_EXCEPTION_HANDLER \
+                               BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER\
+                               _set_se_translator(se_trans_func);
+
+                       #define END_DEBUG_EXCEPTION_HANDLER \
+                               END_PORTABLE_DEBUG_EXCEPTION_HANDLER
+               #else // Probably mingw
+                       #define BEGIN_DEBUG_EXCEPTION_HANDLER\
+                               BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER
+                       #define END_DEBUG_EXCEPTION_HANDLER\
+                               END_PORTABLE_DEBUG_EXCEPTION_HANDLER
+               #endif
        #else // Posix
                #define BEGIN_DEBUG_EXCEPTION_HANDLER\
                        BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER
index 433ec4fe07ad9516c26d6cc7b9efd2bd13169d29..1a576b28df0860c5469563a34fb3598a124be2fb 100644 (file)
@@ -2050,6 +2050,8 @@ int main(int argc, char *argv[])
        // A test\r
        //throw con::PeerNotFoundException("lol");\r
 \r
+       core::list<float> frametime_log;\r
+\r
        /*\r
                Main loop\r
        */\r
@@ -2147,6 +2149,23 @@ int main(int argc, char *argv[])
                        dtime = 0;\r
                lasttime = time;\r
 \r
+               /*\r
+                       Log frametime for visualization\r
+               */\r
+               frametime_log.push_back(dtime);\r
+               if(frametime_log.size() > 100)\r
+               {\r
+                       core::list<float>::Iterator i = frametime_log.begin();\r
+                       frametime_log.erase(i);\r
+               }\r
+\r
+               /*\r
+                       Visualize frametime in terminal\r
+               */\r
+               /*for(u32 i=0; i<dtime*400; i++)\r
+                       std::cout<<"X";\r
+               std::cout<<std::endl;*/\r
+\r
                /*\r
                        Time average and jitter calculation\r
                */\r
@@ -2979,8 +2998,25 @@ int main(int argc, char *argv[])
                                displaycenter + core::vector2d<s32>(0,10),\r
                                video::SColor(255,255,255,255));\r
 \r
+               /*\r
+                       Frametime log\r
+               */\r
+               {\r
+                       s32 x = 10;\r
+                       for(core::list<float>::Iterator\r
+                                       i = frametime_log.begin();\r
+                                       i != frametime_log.end();\r
+                                       i++)\r
+                       {\r
+                               driver->draw2DLine(v2s32(x,50),\r
+                                               v2s32(x,50+(*i)*1000),\r
+                                               video::SColor(255,255,255,255));\r
+                               x++;\r
+                       }\r
                }\r
 \r
+               } // timer\r
+\r
                //timer10.stop();\r
                //TimeTaker //timer11("//timer11");\r
 \r
index 2ec63dbde6e21bdf4f142bc78d273eb8980f2e7b..e66d4dd8f2954f52cf4fd17a7081709e77e22576 100644 (file)
@@ -755,7 +755,7 @@ void MapBlock::updateMesh(u32 daynight_ratio)
                material.Lighting = false;
                material.BackfaceCulling = false;
                material.setFlag(video::EMF_BILINEAR_FILTER, false);
-               material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
+               //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
                //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE);
                material.setFlag(video::EMF_FOG_ENABLE, true);
 
index d71055c7a33b85317a049d549af3a4f3a36b49c4..7b19b3651f1d71b87301d82930695d8320d7b009 100644 (file)
@@ -387,10 +387,16 @@ void TextureSource::buildMainAtlas()
        sourcelist.push_back("sand.png^mineral_coal.png");
        sourcelist.push_back("sand.png^mineral_iron.png");
        
+       // Padding to disallow texture bleeding
+       s32 padding = 8;
+
        /*
                First pass: generate almost everything
        */
        core::position2d<s32> pos_in_atlas(0,0);
+       
+       pos_in_atlas.Y += padding;
+
        for(u32 i=0; i<sourcelist.size(); i++)
        {
                std::string name = sourcelist[i];
@@ -423,6 +429,28 @@ void TextureSource::buildMainAtlas()
                                        NULL);
                }
 
+               // Copy the borders a few times to disallow texture bleeding
+               for(u32 side=0; side<2; side++) // top and bottom
+               for(s32 y0=0; y0<padding; y0++)
+               for(s32 x0=0; x0<(s32)xwise_tiling*(s32)dim.Width; x0++)
+               {
+                       s32 dst_y;
+                       s32 src_y;
+                       if(side==0)
+                       {
+                               dst_y = y0 + pos_in_atlas.Y + dim.Height;
+                               src_y = pos_in_atlas.Y + dim.Height - 1;
+                       }
+                       else
+                       {
+                               dst_y = -y0 + pos_in_atlas.Y-1;
+                               src_y = pos_in_atlas.Y;
+                       }
+                       s32 x = x0 + pos_in_atlas.X * dim.Width;
+                       video::SColor c = atlas_img->getPixel(x, src_y);
+                       atlas_img->setPixel(x,dst_y,c);
+               }
+
                img2->drop();
 
                /*
@@ -447,7 +475,7 @@ void TextureSource::buildMainAtlas()
                m_name_to_id.insert(name, id);
                        
                // Increment position
-               pos_in_atlas.Y += dim.Height;
+               pos_in_atlas.Y += dim.Height + padding * 2;
        }
 
        /*