Procházet zdrojové kódy

Merge remote-tracking branch 'refs/remotes/origin/development' into ogg_support

Conflicts:
	engine/compilers/VisualStudio 2013/Torque 2D.vcxproj.filters
chaigler před 10 roky
rodič
revize
139981b914

+ 1 - 0
engine/compilers/VisualStudio 2013/Torque 2D.vcxproj

@@ -1078,6 +1078,7 @@
     <ClInclude Include="..\..\source\platformWin32\winInput_ScriptBinding.h" />
     <ClInclude Include="..\..\source\platformWin32\winMath_ScriptBinding.h" />
     <ClInclude Include="..\..\source\platformWin32\winOGLVideo_ScriptBinding.h" />
+    <ClInclude Include="..\..\source\platformWin32\winVersion.h" />
     <ClInclude Include="..\..\source\platformWin32\winWindow.h" />
     <ClInclude Include="..\..\source\platform\CursorManager_ScriptBinding.h" />
     <ClInclude Include="..\..\source\platform\event.h" />

+ 2 - 0
engine/compilers/VisualStudio 2013/Torque 2D.vcxproj.filters

@@ -3164,6 +3164,8 @@
     </ClInclude>
     <ClInclude Include="..\..\source\audio\vorbisStreamSource.h">
       <Filter>audio</Filter>
+    <ClInclude Include="..\..\source\platformWin32\winVersion.h">
+      <Filter>platformWin32</Filter>
     </ClInclude>
   </ItemGroup>
   <ItemGroup>

+ 1 - 1
engine/source/2d/sceneobject/SceneObject_ScriptBinding.h

@@ -2065,7 +2065,7 @@ ConsoleMethodWithDocs(SceneObject, growTo, ConsoleBool, 4, 4, (targetSize width
 	}
 
 	Vector2 rate;
-	const U32 rateCount = Utility::mGetStringElementCount(argv[2]);
+	const U32 rateCount = Utility::mGetStringElementCount(argv[3]);
 	if (rateCount == 1)
 	{
 		rate.x = dAtof(Utility::mGetStringElement(argv[3], 0));

+ 5 - 0
engine/source/platform/types.h

@@ -170,6 +170,11 @@ inline U32 endianSwap(const U32 in_swap)
 #define Offset(x, cls) _Offset_Normal(x, cls)
 #define OffsetNonConst(x, cls) _Offset_Variant_1(x, cls)
 
+#elif defined(TORQUE_COMPILER_GCC) && (__GNUC__ == 5)
+#include <stddef.h>
+#define Offset(x, cls) offsetof(cls, x)
+#define OffsetNonConst(x, cls) _Offset_Normal(x, cls)
+
 #endif
 #endif
 

binární
engine/source/platformWin32/winConsole_ScriptBinding.h


+ 10 - 21
engine/source/platformWin32/winInput.cc

@@ -78,29 +78,18 @@ void Input::init()
    smLastMouseActivated = true;
    smLastJoystickActivated = true;
 
-   OSVERSIONINFO OSVersionInfo;
-   dMemset( &OSVersionInfo, 0, sizeof( OSVERSIONINFO ) );
-   OSVersionInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
-   if ( GetVersionEx( &OSVersionInfo ) )
+   smManager = new DInputManager;
+   if (!smManager->enable())
    {
+	   Con::printf("   DirectInput not enabled.");
 
-      if ( !( OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && OSVersionInfo.dwMajorVersion < 5 ) )
-      {
-         smManager = new DInputManager;
-         if ( !smManager->enable() )
-         {
-            Con::printf( "   DirectInput not enabled." );
-            delete smManager;
-            smManager = NULL;
-         }
-         else
-         {
-            DInputManager::init();
-            Con::printf( "   DirectInput enabled." );
-         }
-      }
-      else
-         Con::printf( "  WinNT detected -- DirectInput not enabled." );
+	   delete smManager;
+	   smManager = NULL;
+   }
+   else
+   {
+	   DInputManager::init();
+	   Con::printf("   DirectInput enabled.");
    }
 
    // Startup the Cursor Manager

+ 0 - 374
engine/source/platformWin32/winOGLVideo.cc

@@ -30,312 +30,8 @@
 #include "console/consoleInternal.h"
 #include "console/ast.h"
 #include "io/fileStream.h"
-
-//------------------------------------------------------------------------------
-
-struct CardProfile
-{
-   const char *vendor;     // manufacturer
-   const char *renderer;   // driver name
-
-   bool safeMode;          // destroy rendering context for resolution change
-   bool lockArray;         // allow compiled vertex arrays
-   bool subImage;          // allow glTexSubImage*
-   bool fogTexture;        // require bound texture for combine extension
-   bool noEnvColor;        // no texture environment color
-   bool clipHigh;          // clip high resolutions
-    bool deleteContext;		// delete rendering context
-    bool texCompress;			// allow texture compression
-    bool interiorLock;		// lock arrays for Interior render
-    bool skipFirstFog;		// skip first two-pass fogging (dumb 3Dfx hack)
-    bool only16;				// inhibit 32-bit resolutions
-    bool noArraysAlpha;	// don't use glDrawArrays with a GL_ALPHA texture
-
-    const char *proFile;		// explicit profile of graphic settings
-};
-
-struct OSCardProfile
-{
-   const char *vendor;     // manufacturer
-   const char *renderer;   // driver name
-
-   bool allowOpenGL;			// allow OpenGL driver
-    bool preferOpenGL;		// prefer OpenGL driver
-};
-
-static Vector<CardProfile> sCardProfiles(__FILE__, __LINE__);
-static Vector<OSCardProfile> sOSCardProfiles(__FILE__, __LINE__);
-
-//------------------------------------------------------------------------------
-
 #include "winOGLVideo_ScriptBinding.h"
 
-//------------------------------------------------------------------------------
-
-struct ProcessorProfile
-{
-    U16 clock;  // clock range max
-    U16 adjust; // CPU adjust
-};
-
-static U8 sNumProcessors = 4;
-static ProcessorProfile sProcessorProfiles[] =
-{
-    {  400,  0 },
-    {  600,  5 },
-    {  800, 10 },
-    { 1000, 15 },
-};
-
-struct SettingProfile
-{
-    U16 performance;        // metric range max
-    const char *settings;   // default file
-};
-
-static U8 sNumSettings = 3;
-static SettingProfile sSettingProfiles[] =
-{
-    {  33, "LowProfile.cs" },
-    {  66, "MediumProfile.cs" },
-    { 100, "HighProfile.cs" },
-};
-
-//------------------------------------------------------------------------------
-
-static void clearCardProfiles()
-{
-   while (sCardProfiles.size())
-   {
-      dFree((char *) sCardProfiles.last().vendor);
-      dFree((char *) sCardProfiles.last().renderer);
-
-        dFree((char *) sCardProfiles.last().proFile);
-
-      sCardProfiles.decrement();
-   }
-}
-
-static void clearOSCardProfiles()
-{
-   while (sOSCardProfiles.size())
-   {
-      dFree((char *) sOSCardProfiles.last().vendor);
-      dFree((char *) sOSCardProfiles.last().renderer);
-
-      sOSCardProfiles.decrement();
-   }
-}
-
-static void execScript(const char *scriptFile)
-{
-    // execute the script
-   FileStream str;
-
-   if (!str.open(scriptFile, FileStream::Read))
-      return;
-
-   U32 size = str.getStreamSize();
-   char *script = new char[size + 1];
-
-   str.read(size, script);
-   str.close();
-
-   script[size] = 0;
-   Con::executef(2, "eval", script);
-   delete[] script;
-}
-
-static void profileSystem(const char *vendor, const char *renderer)
-{
-
-   //Con::executef(2, "exec", "scripts/CardProfiles.cs");
-    execScript("CardProfiles.cs");
-
-    const char *arch;
-    OSVERSIONINFO OSVersionInfo;
-    const char *os = NULL;
-    char osProfiles[64];
-
-    if (dStrstr(PlatformSystemInfo.processor.name,"AMD") != NULL)
-        arch = "AMD";
-    else
-        arch = "Intel";
-
-    
-    dMemset( &OSVersionInfo, 0, sizeof( OSVERSIONINFO ) );
-   OSVersionInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
-   if ( GetVersionEx( &OSVersionInfo )	)
-    {
-        if (OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
-            if ( OSVersionInfo.dwMinorVersion == 0 )
-            {
-                if (dStrcmp(arch,"Intel") == 0)
-                    os = "W95";
-            }
-            else if ( OSVersionInfo.dwMinorVersion == 10 )	
-                if ( OSVersionInfo.szCSDVersion[1] != 'A' )
-                    os = "W98";
-                else
-                    os = "W98SE";
-            else
-                os = "WME";
-        else
-            if ( OSVersionInfo.dwMajorVersion >= 5 )
-                os = "W2K";
-        
-        if ( os != NULL )
-        {
-            dSprintf(osProfiles,64,"%s%sCardProfiles.cs",arch,os);
-            //Con::executef(2, "exec", osProfiles);
-            execScript(osProfiles);
-        }
-    }
-
-    const char *proFile = NULL;
-   U32 i;
-
-   for (i = 0; i < (U32)sCardProfiles.size(); ++i)
-      if (dStrstr(vendor, sCardProfiles[i].vendor) &&
-          (!dStrcmp(sCardProfiles[i].renderer, "*") ||
-           dStrstr(renderer, sCardProfiles[i].renderer)))
-      {
-         Con::setBoolVariable("$pref::Video::safeModeOn", sCardProfiles[i].safeMode);
-         Con::setBoolVariable("$pref::OpenGL::disableEXTCompiledVertexArray", !sCardProfiles[i].lockArray);
-         Con::setBoolVariable("$pref::OpenGL::disableSubImage", !sCardProfiles[i].subImage);
-         Con::setBoolVariable("$pref::TS::fogTexture", sCardProfiles[i].fogTexture);
-         Con::setBoolVariable("$pref::OpenGL::noEnvColor", sCardProfiles[i].noEnvColor);
-         Con::setBoolVariable("$pref::Video::clipHigh", sCardProfiles[i].clipHigh);
-            if (!sCardProfiles[i].deleteContext)
-            {
-                OSVERSIONINFO OSVersionInfo;
-
-            // HACK: The Voodoo3/5 on W2K crash when deleting a rendering context
-                // So we're not deleting it.
-                // Oh, and the Voodoo3 returns a Banshee renderer string under W2K
-            dMemset( &OSVersionInfo, 0, sizeof( OSVERSIONINFO ) );
-            OSVersionInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
-            if ( GetVersionEx( &OSVersionInfo ) &&
-                      OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
-                      OSVersionInfo.dwMajorVersion == 5)
-                    Con::setBoolVariable("$pref::Video::deleteContext", false);
-                else
-                    Con::setBoolVariable("$pref::Video::deleteContext", true);
-            }
-            else
-                Con::setBoolVariable("$pref::Video::deleteContext", true);
-            Con::setBoolVariable("$pref::OpenGL::disableARBTextureCompression", !sCardProfiles[i].texCompress);
-            Con::setBoolVariable("$pref::Interior::lockArrays", sCardProfiles[i].interiorLock);
-            Con::setBoolVariable("$pref::TS::skipFirstFog", sCardProfiles[i].skipFirstFog);
-            Con::setBoolVariable("$pref::Video::only16", sCardProfiles[i].only16);
-            Con::setBoolVariable("$pref::OpenGL::noDrawArraysAlpha", sCardProfiles[i].noArraysAlpha);
-
-            proFile = sCardProfiles[i].proFile;
-
-         break;
-      }
-
-   // defaults
-    U16 glProfile;
-
-   if (!proFile)
-   {
-      // no driver GL profile -- make one via weighting GL extensions
-      glProfile = 25;
-
-      glProfile += gGLState.suppARBMultitexture * 25;
-      glProfile += gGLState.suppLockedArrays * 15;
-      glProfile += gGLState.suppVertexArrayRange * 10;
-      glProfile += gGLState.suppTextureEnvCombine * 5;
-      glProfile += gGLState.suppPackedPixels * 5;
-      glProfile += gGLState.suppTextureCompression * 5;
-      glProfile += gGLState.suppS3TC * 5;
-      glProfile += gGLState.suppFXT1 * 5;
-
-      Con::setBoolVariable("$pref::Video::safeModeOn", true);
-      Con::setBoolVariable("$pref::OpenGL::disableEXTCompiledVertexArray", false);
-      Con::setBoolVariable("$pref::OpenGL::disableSubImage", false);
-      Con::setBoolVariable("$pref::TS::fogTexture", false);
-      Con::setBoolVariable("$pref::OpenGL::noEnvColor", false);
-      Con::setBoolVariable("$pref::Video::clipHigh", false);
-        Con::setBoolVariable("$pref::Video::deleteContext", true);
-        Con::setBoolVariable("$pref::OpenGL::disableARBTextureCompression", false);
-        Con::setBoolVariable("$pref::Interior::lockArrays", true);
-        Con::setBoolVariable("$pref::TS::skipFirstFog", false);
-        Con::setBoolVariable("$pref::Video::only16", false);
-        Con::setBoolVariable("$pref::OpenGL::noDrawArraysAlpha", false);
-   }
-
-    Con::setVariable("$pref::Video::profiledVendor", vendor);
-   Con::setVariable("$pref::Video::profiledRenderer", renderer);
-
-    if (!Con::getBoolVariable("$DisableSystemProfiling") &&
-         ( dStrcmp(vendor, Con::getVariable("$pref::Video::defaultsVendor")) ||
-        dStrcmp(renderer, Con::getVariable("$pref::Video::defaultsRenderer")) ))
-    {
-        if (proFile)
-        {
-            char settings[64];
-
-            dSprintf(settings,64,"%s.cs",proFile);
-            //Con::executef(2, "exec", settings);
-            execScript(settings);
-        }
-        else
-        {
-        U16 adjust;
-
-        // match clock with profile
-        for (i = 0; i < sNumProcessors; ++i)
-        {
-            adjust = sProcessorProfiles[i].adjust;
-
-            if (PlatformSystemInfo.processor.mhz < sProcessorProfiles[i].clock) break;
-        }
-
-        const char *settings;
-
-        // match performance metric with profile
-        for (i = 0; i < sNumSettings; ++i)
-        {
-            settings = sSettingProfiles[i].settings;
-
-            if (glProfile+adjust <= sSettingProfiles[i].performance) break;
-        }
-
-        //Con::executef(2, "exec", settings);
-            execScript(settings);
-        }
-
-        bool match = false;
-
-        for (i = 0; i < (U32)sOSCardProfiles.size(); ++i)
-            if (dStrstr(vendor, sOSCardProfiles[i].vendor) &&
-                 (!dStrcmp(sOSCardProfiles[i].renderer, "*") ||
-              dStrstr(renderer, sOSCardProfiles[i].renderer)))
-            {
-                Con::setBoolVariable("$pref::Video::allowOpenGL", sOSCardProfiles[i].allowOpenGL);
-                Con::setBoolVariable("$pref::Video::preferOpenGL", sOSCardProfiles[i].preferOpenGL);
-            
-                match = true;
-
-                break;
-            }
-
-        if (!match)
-        {
-            Con::setBoolVariable("$pref::Video::allowOpenGL", true);
-            Con::setBoolVariable("$pref::Video::preferOpenGL", true);
-        }
-
-        Con::setVariable("$pref::Video::defaultsVendor", vendor);
-    Con::setVariable("$pref::Video::defaultsRenderer", renderer);
-    }
-
-   clearCardProfiles();
-    clearOSCardProfiles();
-}
-
 //------------------------------------------------------------------------------
 OpenGLDevice::OpenGLDevice()
 {
@@ -413,41 +109,6 @@ bool OpenGLDevice::activate( U32 width, U32 height, U32 bpp, bool fullScreen )
 
    GL_Init( "opengl32", "glu32" );
 
-    static bool onceAlready = false;
-    bool profiled = false;
-
-    if ( !mFullScreenOnly && fullScreen && !onceAlready )
-    {	
-        OSVERSIONINFO OSVersionInfo;
-
-        // HACK: The Voodoo5 on W2K will only work if the initial rendering
-        // context is windowed.  Can you believe this crap?
-        dMemset( &OSVersionInfo, 0, sizeof( OSVERSIONINFO ) );
-        OSVersionInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
-        if ( GetVersionEx( &OSVersionInfo ) &&
-              OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
-              OSVersionInfo.dwMajorVersion == 5 )
-
-              //MIN_RESOLUTION defined in platformWin32/platformGL.h
-            if ( !setScreenMode(	MIN_RESOLUTION_X, MIN_RESOLUTION_Y, bpp, false, true, false ) )
-                return false;
-            else
-            {
-                const char* vendorString   = (const char*) glGetString( GL_VENDOR );
-                const char* rendererString = (const char*) glGetString( GL_RENDERER );
-
-                // only do this for the first session
-                if (!Con::getBoolVariable("$DisableSystemProfiling") &&
-                     ( dStrcmp(vendorString, Con::getVariable("$pref::Video::profiledVendor")) ||
-                    dStrcmp(rendererString, Con::getVariable("$pref::Video::profiledRenderer")) ))
-                {
-                profileSystem(vendorString, rendererString);
-                    profiled = true;
-                }
-            }
-
-        onceAlready = true;
-    }
     // Set the resolution:
    if ( !setScreenMode( width, height, bpp, ( fullScreen || mFullScreenOnly ), true, false ) )
       return false;
@@ -478,44 +139,9 @@ bool OpenGLDevice::activate( U32 width, U32 height, U32 bpp, bool fullScreen )
 
    Con::setVariable( "$pref::Video::displayDevice", mDeviceName );
 
-   // only do this for the first session
-   if (!profiled &&
-     !Con::getBoolVariable("$DisableSystemProfiling") &&
-     (	dStrcmp(vendorString, Con::getVariable("$pref::Video::profiledVendor")) ||
-        dStrcmp(rendererString, Con::getVariable("$pref::Video::profiledRenderer")) ))
-   {
-      profileSystem(vendorString, rendererString);
-        profiled = true;
-    }
-
-    if (profiled)
-    {
-      U32 width, height, bpp;
-
-        if (Con::getBoolVariable("$pref::Video::clipHigh", false))
-            for (S32 i = mResolutionList.size()-1; i >= 0; --i)
-                if (mResolutionList[i].w > 1152 || mResolutionList[i].h > 864)
-                    mResolutionList.erase(i);
-
-        if (Con::getBoolVariable("$pref::Video::only16", false))
-            for (S32 i = mResolutionList.size()-1; i >= 0; --i)
-                if (mResolutionList[i].bpp == 32)
-                    mResolutionList.erase(i);
-
-        bool bPrefFullScreen = Con::getBoolVariable("$pref::Video::fullScreen", true);
-      
-      if( bPrefFullScreen || fullScreen )
-         dSscanf(Con::getVariable("$pref::Video::resolution"), "%d %d %d", &width, &height, &bpp);
-      else
-         dSscanf(Con::getVariable("$pref::Video::windowedRes"), "%d %d %d", &width, &height, &bpp);
-      setScreenMode(width, height, bpp,
-                    bPrefFullScreen || fullScreen, false, false);
-   }
-
    // Do this here because we now know about the extensions:
    if ( gGLState.suppSwapInterval )
       setVerticalSync( !Con::getBoolVariable( "$pref::Video::disableVerticalSync" ) );
-    Con::setBoolVariable("$pref::OpenGL::allowTexGen", true);
 
    return true;
 }

binární
engine/source/platformWin32/winOGLVideo_ScriptBinding.h


+ 60 - 0
engine/source/platformWin32/winVersion.h

@@ -0,0 +1,60 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+#include <windows.h>
+#include <stdio.h>
+#include <iostream>
+#include <VersionHelpers.h>
+#include <string>
+#include <sstream>
+
+std::string getWinNTVersion()
+{
+	RTL_OSVERSIONINFOEXW *pk_OsVer = new RTL_OSVERSIONINFOEXW;
+	typedef LONG(WINAPI* tRtlGetVersion)(RTL_OSVERSIONINFOEXW*);
+
+	memset(pk_OsVer, 0, sizeof(RTL_OSVERSIONINFOEXW));
+	pk_OsVer->dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
+
+	HMODULE h_NtDll = GetModuleHandleW(L"ntdll.dll");
+	tRtlGetVersion f_RtlGetVersion = (tRtlGetVersion)GetProcAddress(h_NtDll, "RtlGetVersion");
+
+	if (!f_RtlGetVersion) {
+		delete pk_OsVer;
+		return "0";
+	}
+
+	LONG Status = f_RtlGetVersion(pk_OsVer);
+
+	std::string res = "";
+
+	if (Status == 0) {
+		std::stringstream ss;
+		ss << pk_OsVer->dwMajorVersion << "." << pk_OsVer->dwMinorVersion;
+		res = "OS version: Windows NT " + ss.str();
+	} else
+		res = "0";
+
+	delete pk_OsVer;
+
+	return res;
+}