Bläddra i källkod

Use _WIN32 conditional for Win32 code.
Removed redundant IndexBuffer::SetSize() function.

Lasse Öörni 14 år sedan
förälder
incheckning
e80deeab15

+ 0 - 5
Engine/Core/MiniDump.cpp

@@ -34,11 +34,6 @@
 #include <time.h>
 #include <Windows.h>
 #include <DbgHelp.h>
-
-// Enable SHGetSpecialFolderPath on MinGW
-#ifndef _MSC_VER
-#define _WIN32_IE 0x0400
-#endif
 #include <ShlObj.h>
 
 static bool miniDumpWritten = false;

+ 4 - 4
Engine/Core/ProcessUtils.cpp

@@ -28,7 +28,7 @@
 #include <cstdio>
 #include <fcntl.h>
 
-#ifdef WIN32
+#ifdef _WIN32
 #include <Windows.h>
 #include <io.h>
 #else
@@ -48,7 +48,7 @@ static Mutex staticMutex;
 
 void ErrorDialog(const char* title, const char* message)
 {
-    #ifdef WIN32
+    #ifdef _WIN32
     MessageBox(0, message, title, 0);
     #else
     printf("%s\n", message);
@@ -63,7 +63,7 @@ void ErrorExit(const String& message, int exitCode)
 
 void OpenConsoleWindow()
 {
-    #ifdef WIN32
+    #ifdef _WIN32
     if (consoleOpened)
         return;
     
@@ -152,7 +152,7 @@ String GetConsoleInput()
 {
     String ret;
     
-    #ifdef WIN32
+    #ifdef _WIN32
     HANDLE input = GetStdHandle(STD_INPUT_HANDLE);
     if (input == INVALID_HANDLE_VALUE)
         return ret;

+ 1 - 12
Engine/Graphics/Direct3D9/D3D9IndexBuffer.cpp

@@ -83,17 +83,6 @@ void IndexBuffer::Release()
 
 bool IndexBuffer::SetSize(unsigned indexCount, bool largeIndices, bool dynamic)
 {
-    return SetSize(indexCount, largeIndices ? sizeof(unsigned) : sizeof(unsigned short), dynamic);
-}
-
-bool IndexBuffer::SetSize(unsigned indexCount, unsigned indexSize, bool dynamic)
-{
-    if ((indexSize != sizeof(unsigned)) && (indexSize != sizeof(unsigned short)))
-    {
-        LOGERROR("Index size not 2 or 4 bytes");
-        return false;
-    }
-    
     if (dynamic)
     {
         pool_ = D3DPOOL_DEFAULT;
@@ -106,7 +95,7 @@ bool IndexBuffer::SetSize(unsigned indexCount, unsigned indexSize, bool dynamic)
     }
     
     indexCount_ = indexCount;
-    indexSize_ = indexSize;
+    indexSize_ = largeIndices ? sizeof(unsigned) : sizeof(unsigned short);
     
     return Create();
 }

+ 0 - 2
Engine/Graphics/Direct3D9/D3D9IndexBuffer.h

@@ -48,8 +48,6 @@ public:
     
     /// Set buffer size and dynamic mode. Previous data will be lost
     bool SetSize(unsigned indexCount, bool largeIndices, bool dynamic = false);
-    /// Set buffer size and dynamic mode. Previous data will be lost
-    bool SetSize(unsigned indexCount, unsigned indexSize, bool dynamic = false);
     /// Set all data in the buffer,
     bool SetData(const void* data);
     /// Set a data range in the buffer

+ 1 - 1
Engine/Graphics/Model.cpp

@@ -150,7 +150,7 @@ bool Model::Load(Deserializer& source)
         unsigned indexSize = source.ReadUInt();
         
         SharedPtr<IndexBuffer> buffer(new IndexBuffer(context_));
-        buffer->SetSize(indexCount, indexSize);
+        buffer->SetSize(indexCount, indexSize > sizeof(unsigned short));
         
         unsigned char* data = (unsigned char*)buffer->Lock(0, indexCount, LOCK_NORMAL);
         if (data)

+ 1 - 12
Engine/Graphics/OpenGL/OGLIndexBuffer.cpp

@@ -96,20 +96,9 @@ void IndexBuffer::Release()
 
 bool IndexBuffer::SetSize(unsigned indexCount, bool largeIndices, bool dynamic)
 {
-    return SetSize(indexCount, largeIndices ? sizeof(unsigned) : sizeof(unsigned short), dynamic);
-}
-
-bool IndexBuffer::SetSize(unsigned indexCount, unsigned indexSize, bool dynamic)
-{
-    if ((indexSize != sizeof(unsigned)) && (indexSize != sizeof(unsigned short)))
-    {
-        LOGERROR("Index size not 2 or 4 bytes");
-        return false;
-    }
-    
     dynamic_ = dynamic;
     indexCount_ = indexCount;
-    indexSize_ = indexSize;
+    indexSize_ = largeIndices ? sizeof(unsigned) : sizeof(unsigned short);
     
     return Create();
 }

+ 0 - 2
Engine/Graphics/OpenGL/OGLIndexBuffer.h

@@ -48,8 +48,6 @@ public:
     
     /// Set buffer size and dynamic mode. Previous data will be lost
     bool SetSize(unsigned indexCount, bool largeIndices, bool dynamic = false);
-    /// Set buffer size and dynamic mode. Previous data will be lost
-    bool SetSize(unsigned indexCount, unsigned indexSize, bool dynamic = false);
     /// Set all data in the buffer
     bool SetData(const void* data);
     /// Set a data range in the buffer

+ 12 - 12
Engine/IO/FileSystem.cpp

@@ -30,7 +30,7 @@
 
 #include <cstdio>
 
-#ifdef WIN32
+#ifdef _WIN32
 #include <Windows.h>
 #include <Shellapi.h>
 #include <direct.h>
@@ -69,7 +69,7 @@ bool FileSystem::SetCurrentDir(const String& pathName)
         LOGERROR("Access denied to " + pathName);
         return false;
     }
-    #ifdef WIN32
+    #ifdef _WIN32
     if (SetCurrentDirectory(GetNativePath(pathName).CString()) == FALSE)
     {
         LOGERROR("Failed to change directory to " + pathName);
@@ -93,7 +93,7 @@ bool FileSystem::CreateDir(const String& pathName)
         return false;
     }
     
-    #ifdef WIN32
+    #ifdef _WIN32
     bool success = (CreateDirectory(GetNativePath(RemoveTrailingSlash(pathName)).CString(), 0) == TRUE) ||
         (GetLastError() == ERROR_ALREADY_EXISTS);
     #else
@@ -121,7 +121,7 @@ int FileSystem::SystemCommand(const String& commandLine)
 
 int FileSystem::SystemRun(const String& fileName, const Vector<String>& arguments)
 {
-    #ifdef WIN32
+    #ifdef _WIN32
     if (allowedPaths_.Empty())
     {
         String fixedFileName = GetNativePath(fileName);
@@ -148,7 +148,7 @@ int FileSystem::SystemRun(const String& fileName, const Vector<String>& argument
 
 bool FileSystem::SystemOpen(const String& fileName, const String& mode)
 {
-    #ifdef WIN32
+    #ifdef _WIN32
     if (allowedPaths_.Empty())
     {
         if ((!FileExists(fileName)) && (!DirExists(fileName)))
@@ -235,7 +235,7 @@ String FileSystem::GetCurrentDir()
     char path[MAX_PATH];
     path[0] = 0;
     
-    #ifdef WIN32
+    #ifdef _WIN32
     GetCurrentDirectory(MAX_PATH, path);
     #else
     getcwd(path, MAX_PATH);
@@ -273,7 +273,7 @@ bool FileSystem::FileExists(const String& fileName)
         return false;
     
     String fixedName = GetNativePath(RemoveTrailingSlash(fileName));
-    #ifdef WIN32
+    #ifdef _WIN32
     DWORD attributes = GetFileAttributes(fixedName.CString());
     if ((attributes == INVALID_FILE_ATTRIBUTES) || (attributes & FILE_ATTRIBUTE_DIRECTORY))
         return false;
@@ -292,7 +292,7 @@ bool FileSystem::DirExists(const String& pathName)
         return false;
     
     String fixedName = GetNativePath(RemoveTrailingSlash(pathName));
-    #ifdef WIN32
+    #ifdef _WIN32
     DWORD attributes = GetFileAttributes(fixedName.CString());
     if ((attributes == INVALID_FILE_ATTRIBUTES) || (!(attributes & FILE_ATTRIBUTE_DIRECTORY)))
         return false;
@@ -320,7 +320,7 @@ String FileSystem::GetProgramDir()
 {
     char exeName[MAX_PATH];
     exeName[0] = 0;
-    #ifdef WIN32
+    #ifdef _WIN32
     GetModuleFileName(0, exeName, MAX_PATH);
     #else
     unsigned pid = getpid();
@@ -335,7 +335,7 @@ String FileSystem::GetUserDocumentsDir()
 {
     char pathName[MAX_PATH];
     pathName[0] = 0;
-    #ifdef WIN32
+    #ifdef _WIN32
     SHGetSpecialFolderPath(0, pathName, CSIDL_PERSONAL, 0);
     #else
     strcpy(pathName, getenv("HOME"));
@@ -360,7 +360,7 @@ void FileSystem::ScanDirInternal(Vector<String>& result, String path, const Stri
     if (path.Length() > startPath.Length())
         deltaPath = path.Substring(startPath.Length());
     
-    #ifdef WIN32
+    #ifdef _WIN32
     WIN32_FIND_DATA info;
     HANDLE handle = FindFirstFile(pathAndFilter.CString(), &info);
     if (handle != INVALID_HANDLE_VALUE)
@@ -509,7 +509,7 @@ String GetInternalPath(const String& pathName)
 
 String GetNativePath(const String& pathName)
 {
-#ifdef WIN32
+#ifdef _WIN32
     String ret = pathName;
     ret.Replace('/', '\\');
     return ret;

+ 2 - 2
Urho3D/Urho3D.cpp

@@ -32,7 +32,7 @@
 
 #include <stdexcept>
 
-#ifdef WIN32
+#ifdef _WIN32
 #include <Windows.h>
 #endif
 
@@ -40,7 +40,7 @@
 
 void Run(const char* cmdLine);
 
-#ifdef WIN32
+#ifdef _WIN32
 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
 {
     #if defined(_MSC_VER) && defined(_DEBUG)