Commits

wahrhaft  committed db63a1c

win32 support, started consolidating log functions

  • Participants
  • Parent commits 6b7fa2c

Comments (0)

Files changed (19)

File projects/msvc9/mupen64plus-video-glide64.sln

+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mupen64plus-video-glide64", "mupen64plus-video-glide64.vcproj", "{F3E6138A-C318-4020-B408-A9A24D8B3DE7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{F3E6138A-C318-4020-B408-A9A24D8B3DE7}.Debug|Win32.ActiveCfg = Debug|Win32
+		{F3E6138A-C318-4020-B408-A9A24D8B3DE7}.Debug|Win32.Build.0 = Debug|Win32
+		{F3E6138A-C318-4020-B408-A9A24D8B3DE7}.Release|Win32.ActiveCfg = Release|Win32
+		{F3E6138A-C318-4020-B408-A9A24D8B3DE7}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

File projects/msvc9/mupen64plus-video-glide64.vcproj

+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="mupen64plus-video-glide64"
+	ProjectGUID="{F3E6138A-C318-4020-B408-A9A24D8B3DE7}"
+	RootNamespace="mupen64plusvideoglide64"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="../../src;../../src/wrapper;../../../mupen64plus-core/src/api;../../../mupen64plus-win32-deps/SDL-1.2.14/include"
+				PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_WARNINGS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+				CallingConvention="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="opengl32.lib glu32.lib ..\..\..\mupen64plus-win32-deps\SDL-1.2.14\lib\SDL.lib "
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\..\..\mupen64plus-ui-console\projects\msvc8\$(ConfigurationName)&quot;"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				AdditionalIncludeDirectories="../../src;../../src/wrapper;../../../mupen64plus-core/src/api"
+				PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_WARNINGS"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				GenerateDebugInformation="true"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\..\..\mupen64plus-ui-console\projects\msvc8\$(ConfigurationName)&quot;"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\3dmath.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\Combine.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\Config.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\CRC.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\Debugger.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\DepthBufferRender.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\Ini.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\Main.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\osal_dynamiclib_win32.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\rdp.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\TexBuffer.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\TexCache.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\Util.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+		</Filter>
+		<Filter
+			Name="Wrapper"
+			>
+			<File
+				RelativePath="..\..\src\wrapper\2xsai.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\2xsai.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\3dfx.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\combiner.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\config.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\filter.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\g3ext.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\geometry.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\glide.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\glidesys.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\glideutl.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\hq2x.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\hq4x.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\main.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\main.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\sst1vid.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\wrapper\textures.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\wrapper\"
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

File src/3dmath.cpp

   if (IsSSE)
   {
     MulMatrices = MulMatricesSSE;
-    LOG("SSE detected.\n");
+    WriteLog(M64MSG_INFO, "SSE detected.\n");
   }
 }
 

File src/Debugger.cpp

 #include "Util.h"
 #include "Debugger.h"
 #include <stdio.h>
-
+#include "gfx1.3.h"
 #ifndef _WIN32
 #include <stdarg.h>
 #include <string.h>
 
 DEBUGGER debug;
 
+const char *FBLa[] = { "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG" };
+const char *FBLb[] = { "G_BL_A_IN", "G_BL_A_FOG", "G_BL_A_SHADE", "G_BL_0" };
+const char *FBLc[] = { "G_BL_CLR_IN", "G_BL_CLR_MEM", "G_BL_CLR_BL", "G_BL_CLR_FOG"};
+const char *FBLd[] = { "G_BL_1MA", "G_BL_A_MEM", "G_BL_1", "G_BL_0" };
+const char *str_lod[]    = { "1", "2", "4", "8", "16", "32", "64", "128", "256" };
+const char *str_aspect[] = { "1x8", "1x4", "1x2", "1x1", "2x1", "4x1", "8x1" };
+
 #define SX(x) ((x)*rdp.scale_1024)
 #define SY(x) ((x)*rdp.scale_768)
 

File src/Gfx1.3.h

 #include <fstream>
 
 #include <cstddef>      // offsetof
+#ifndef _WIN32
 #include <cmath>
+#endif
 #ifdef _WIN32
 #include <io.h>
 #include <direct.h>
 
 #else
 #ifndef GCC
-#define FRDP(x)
-#define FRDP_E(x)
+#define FRDP(...)
+#define FRDP_E(...)
 #else // _WIN32
 inline void FRDP (const char *fmt, ...) {}
 inline void FRDP_E (const char *fmt, ...) {}
 #include "m64p_config.h"
 #include "m64p_vidext.h"
 #include "Ini.h"
-
-FILE *ini;
-int sectionstart;
-int last_line;      // last good line
-int last_line_ret;  // last line ended in return?
-WORD cr = 0x0A0D;
-static char configdir[PATH_MAX] = {0};
-
+#include "gfx1.3.h"
+#include <limits.h>
 #ifndef _WIN32
 #include <unistd.h>
 #include <string.h>
 #include <sys/resource.h>
 #endif
 
+#ifdef _WIN32
+#define PATH_MAX _MAX_PATH
+#endif
+
+FILE *ini;
+int sectionstart;
+int last_line;      // last good line
+int last_line_ret;  // last line ended in return?
+WORD cr = 0x0A0D;
+static char configdir[PATH_MAX] = {0};
+
 BOOL INI_Open ()
 {
     // Get the path of the dll, ex: C:\Games\Project64\Plugin\Glide64.dll

File src/Main.cpp

 #include <string.h>
 #include <stdlib.h>
 #include "messagebox.h"
+#ifndef _WIN32
 #include <sys/time.h>
+#endif
 
 #include "osal_dynamiclib.h"
 
 char    capture_path[256];
 
 void (*renderCallback)() = NULL;
+static void (*l_DebugCallback)(void *, int, const char *) = NULL;
+static void *l_DebugCallContext = NULL;
 
 
+void WriteLog(m64p_msg_level level, const char *msg, ...)
+{
+  char buf[1024];
+  va_list args;
+  va_start(args, msg);
+  vsnprintf(buf, 1023, msg, args);
+  buf[1023]='\0';
+  va_end(args);
+  if (l_DebugCallback)
+  {
+    l_DebugCallback(l_DebugCallContext, level, buf);
+  }
+}
+
 void ChangeSize ()
 {
   float res_scl_x = (float)settings.res_x / 320.0f;
   //  LOG("ReadSettings\n");
   if (!Config_Open())
   {
-    LOG("Could not open configuration!");
+    WriteLog(M64MSG_ERROR, "Could not open configuration!");
     return;
   }
   settings.card_id = (BYTE)Config_ReadInt ("card_id", 0);
   // bswap on a dword (32 bits) boundry
 }
 
+#ifdef PERFORMANCE
 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
 {
    struct timeval tv;
    frequency->s.HighPart= 0;
    return TRUE;
 }
+#endif
 
 /******************************************************************
 Function: InitiateGFX

File src/Util.cpp

         lodFactor = lodFactor / n;
     }
     long ilod = (long)lodFactor;
-    int lod_tile = min((int)(log(ilod)/log(2)), rdp.cur_tile + rdp.mipmap_level);
+    int lod_tile = min((int)(log((double)ilod)/log(2.0)), rdp.cur_tile + rdp.mipmap_level);
     float lod_fraction = 1.0f;
     if (lod_tile < rdp.cur_tile + rdp.mipmap_level)
     {
-        lod_fraction = max((float)modf(lodFactor / pow(2,lod_tile),&intptr), rdp.prim_lodmin / 255.0f);
+        lod_fraction = max((float)modf(lodFactor / pow(2.0f,lod_tile),&intptr), rdp.prim_lodmin / 255.0f);
     }
     float detailmax;
     if (cmb.dc0_detailmax < 0.5f)
  * Glide64 - Glide video plugin for Nintendo 64 emulators.
  * http://bitbucket.org/wahrhaft/mupen64plus-video-glide64/
  *
- * Copyright (C) 2009 Jon Ring
+ * Copyright (C) 2010 Jon Ring
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
 
 #define LOG(...)
 
+void WriteLog(m64p_msg_level level, const char *msg, ...);
+
 //The Glide API originally used an integer to pick an enumerated resolution.
 //To accomodate arbitrary resolutions, pack it into a 32-bit struct
 //so we don't have to change function signatures
 #include "CRC.h"
 #include "rdp.h"
 
+#include "messagebox.h"
 #ifndef _WIN32
-#include "messagebox.h"
 #include <sys/time.h>
 #endif // _WIN32
 
 BOOL ucode_error_report = TRUE;
 int wrong_tile = -1;
 
-#if defined(NO_ASM)
+#if defined(WIN32) || defined(NO_ASM)
   #define BYTESWAP1(s1) s1 = ((s1 & 0xff) << 24) | ((s1 & 0xff00) << 8) | ((s1 & 0xff0000) >> 8) | ((s1 & 0xff000000) >> 24);
   #define BYTESWAP2(s1,s2) s1 = ((s1 & 0xff) << 24) | ((s1 & 0xff00) << 8) | ((s1 & 0xff0000) >> 8) | ((s1 & 0xff000000) >> 24); \
   s2 = ((s2 & 0xff) << 24) | ((s2 & 0xff00) << 8) | ((s2 & 0xff0000) >> 8) | ((s2 & 0xff000000) >> 24);
         
         ReleaseGfx ();
         sprintf (out_buf, "Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx", (unsigned long)uc_crc);
-#ifdef _WIN32
-        MessageBox (gfx.hWnd, out_buf, "Error", MB_OK|MB_ICONEXCLAMATION);
-#else // _WIN32
-       messagebox("Error", MB_OK|MB_ICONEXCLAMATION, out_buf);
-#endif // _WIN32
+        messagebox("Error", MB_OK|MB_ICONEXCLAMATION, out_buf);
         
         ucode_error_report = FALSE; // don't report any more ucode errors from this game
     }
         
         ReleaseGfx ();
         sprintf (out_buf, "Error: Unsupported uCode!\n\ncrc: %08lx", (unsigned long)uc_crc);
-#ifdef _WIN32
-        MessageBox (gfx.hWnd, out_buf, "Error", MB_OK|MB_ICONEXCLAMATION);
-#else // _WIN32
-       messagebox("Error", MB_OK|MB_ICONEXCLAMATION, out_buf);
-#endif // _WIN32
+        messagebox("Error", MB_OK|MB_ICONEXCLAMATION, out_buf);
         
         ucode_error_report = FALSE; // don't report any more ucode errors from this game
     }
     }
 }
 
-#ifdef _WIN32
-RECT prev_rect;
-#endif // _WIN32
-
 void drawNoFullscreenMessage()
 {
     LOG ("drawNoFullscreenMessage ()\n");
-#ifdef _WIN32
-    SIZE str_size;
-    RECT win_rect;
-    HWND active_wnd = GetForegroundWindow ();
-    
-    GetClientRect (gfx.hWnd, &win_rect);
-    if (win_rect.bottom != prev_rect.bottom ||
-        win_rect.right != prev_rect.right ||
-        rdp.window_changed)
-    {
-        rdp.window_changed = FALSE;
-        
-        prev_rect.bottom = win_rect.bottom;
-        prev_rect.right = win_rect.right;
-        
-        HDC hdc = GetDC(gfx.hWnd);
-        SetBkMode (hdc, TRANSPARENT);
-        SetTextColor (hdc, RGB(255,255,255));
-        
-        FillRect (hdc, &win_rect, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
-        
-        win_rect.bottom >>= 1;
-        win_rect.right >>= 1;
-        
-        sprintf (out_buf, "Glide64");
-        GetTextExtentPoint32 (hdc, out_buf, strlen(out_buf), &str_size);
-        TextOut (hdc, win_rect.right - (str_size.cx>>1),
-            win_rect.bottom - str_size.cy - 32, out_buf, strlen(out_buf));
-        
-        sprintf (out_buf, "Gfx cannot be drawn in windowed mode");
-        GetTextExtentPoint32 (hdc, out_buf, strlen(out_buf), &str_size);
-        TextOut (hdc, win_rect.right - (str_size.cx>>1),
-            win_rect.bottom - str_size.cy - 2, out_buf, strlen(out_buf));
-        
-        sprintf (out_buf, "Press Alt+Enter to switch to fullscreen");
-        GetTextExtentPoint32 (hdc, out_buf, strlen(out_buf), &str_size);
-        TextOut (hdc, win_rect.right - (str_size.cx>>1),
-            win_rect.bottom + 2, out_buf, strlen(out_buf));
-    }
-#endif // _WIN32
 }
 
 static WORD yuv_to_rgb(BYTE y, BYTE u, BYTE v)
             return;
         }
         fullscreen = TRUE;
-#ifdef _WIN32
-        if (gfx.hStatusBar)
-          ShowWindow( gfx.hStatusBar, SW_HIDE );
-        ShowCursor( FALSE );
-#endif // _WIN32
     }
     
     // Clear out the RDP log
     } catch (...) {
         
         if (fullscreen) ReleaseGfx ();
-# ifdef _WIN32
-        if (MessageBox (gfx.hWnd, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?", "Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION) == IDNO)
+        if (messagebox("Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?") == 2)
             exception = TRUE;
-# else // _WIN32
-       if (messagebox("Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?") == 2)
-         exception = TRUE;
-# endif // _WIN32
     }
 #endif
     
             return;
         }
         fullscreen = TRUE;
-#ifdef _WIN32
-        if (gfx.hStatusBar)
-          ShowWindow( gfx.hStatusBar, SW_HIDE );
-        ShowCursor( FALSE );
-#endif // _WIN32
     }
     
     // Clear out the RDP log
     } catch (...) {
         
         if (fullscreen) ReleaseGfx ();
-# ifdef _WIN32
-        if (MessageBox (gfx.hWnd, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?", "Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION) == IDNO)
+        if (messagebox("Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?") == 2)
             exception = TRUE;
-# else // _WIN32
-       if (messagebox("Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?") == 2)
-         exception = TRUE;
-# endif // _WIN32
     }
 #endif
     
 #ifndef RDP_H
 #define RDP_H
 
+#ifdef _WIN32
+#include <windows.h>
+#else // _WIN32
 #include "winlnxdefs.h"
+#endif // _WIN32
 #include "glide.h"
 
 //#ifdef GCC
   BOOL  clock;
   BOOL  clock_24_hr;
    
-#ifndef _WIN32
   DWORD full_res;
   DWORD tex_filter;
   BOOL noditheredalpha;
   BOOL noglsl;
   BOOL FBO;
   BOOL disable_auxbuf;
-#endif // _WIN32
 
   //Frame buffer emulation options
   BOOL  fb_read_always;

File src/winlnxdefs.h

 
 #ifndef WINLNXDEFS_H
 #define WINLNXDEFS_H
-
+#ifndef WIN32
 typedef int BOOL;
 typedef unsigned char BYTE;
 typedef unsigned short WORD;
 
 #define HIWORD(a) ((unsigned int)(a) >> 16)
 #define LOWORD(a) ((a) & 0xFFFF)
-
+#endif
 #endif // WINLNXDEFS_H
 

File src/wrapper/2xsai.cpp

  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
-#include "../winlnxdefs.h"
+#include "../gfx1.3.h"
 
 static __inline int GetResult( DWORD A, DWORD B, DWORD C, DWORD D )
 {

File src/wrapper/combiner.cpp

 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
+#ifndef _WIN32
 #include <string.h>
+#endif
 
-#define GL_GLEXT_PROTOTYPES
 #include <SDL_opengl.h>
 
 #include "glide.h"
 #include "main.h"
+#include "m64p.h"
 
 static int fct[4], source0[4], operand0[4], source1[4], operand1[4], source2[4], operand2[4];
 static int fcta[4],sourcea0[4],operanda0[4],sourcea1[4],operanda1[4],sourcea2[4],operanda2[4];
 FX_ENTRY void FX_CALL 
 grConstantColorValue( GrColor_t value )
 {
-    LOG("grConstantColorValue(%d)\r\n", value);
+    WriteLog(M64MSG_VERBOSE, "grConstantColorValue(%d)\r\n", value);
     switch(lfb_color_fmt)
     {
     case GR_COLORFORMAT_ARGB:
                GrCombineLocal_t local, GrCombineOther_t other,
                FxBool invert )
 {
-    LOG("grColorCombine(%d,%d,%d,%d,%d)\r\n", function, factor, local, other, invert);
+    WriteLog(M64MSG_VERBOSE, "grColorCombine(%d,%d,%d,%d,%d)\r\n", function, factor, local, other, invert);
     if(glsl_support)
     {
         static int last_function = 0;
              FxBool alpha_invert
              )
 {
-    LOG("grTexCombine(%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert);
+    WriteLog(M64MSG_VERBOSE, "grTexCombine(%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert);
     if(glsl_support)
     {
         int num_tex;
                      )
 {
     int sfactorRGB = 0, dfactorRGB = 0, sfactorAlpha = 0, dfactorAlpha = 0;
-    LOG("grAlphaBlendFunction(%d,%d,%d,%d)\r\n", rgb_sf, rgb_df, alpha_sf, alpha_df);
+    WriteLog(M64MSG_VERBOSE, "grAlphaBlendFunction(%d,%d,%d,%d)\r\n", rgb_sf, rgb_df, alpha_sf, alpha_df);
 
     switch(rgb_sf)
     {
 FX_ENTRY void FX_CALL
 grAlphaTestReferenceValue( GrAlpha_t value )
 {
-    LOG("grAlphaTestReferenceValue(%d)\r\n", value);
+    WriteLog(M64MSG_VERBOSE, "grAlphaTestReferenceValue(%d)\r\n", value);
     alpha_ref = value;
     grAlphaTestFunction(alpha_func);
 }
 FX_ENTRY void FX_CALL
 grAlphaTestFunction( GrCmpFnc_t function )
 {
-    LOG("grAlphaTestFunction(%d)\r\n", function);
+    WriteLog(M64MSG_VERBOSE, "grAlphaTestFunction(%d)\r\n", function);
     alpha_func = function;
     switch(function)
     {
 FX_ENTRY void FX_CALL 
 grFogMode( GrFogMode_t mode )
 {
-    LOG("grFogMode(%d)\r\n", mode);
+    WriteLog(M64MSG_VERBOSE, "grFogMode(%d)\r\n", mode);
     switch(mode)
     {
     case GR_FOG_DISABLE:
 FX_ENTRY float FX_CALL
 guFogTableIndexToW( int i )
 {
-    LOG("guFogTableIndexToW(%d)\r\n", i);
+    WriteLog(M64MSG_VERBOSE, "guFogTableIndexToW(%d)\r\n", i);
     return (float)(pow(2.0, 3.0+(double)(i>>2)) / (8-(i&3)));
 }
 
 guFogGenerateLinear(GrFog_t *fogtable,
                     float nearZ, float farZ )
 {
-    LOG("guFogGenerateLinear(%f,%f)\r\n", nearZ, farZ);
+    WriteLog(M64MSG_VERBOSE, "guFogGenerateLinear(%f,%f)\r\n", nearZ, farZ);
     if(!glsl_support)
     {
         glFogi(GL_FOG_MODE, GL_LINEAR);
 FX_ENTRY void FX_CALL 
 grFogTable( const GrFog_t ft[] )
 {
-    LOG("grFogTable()\r\n");
+    WriteLog(M64MSG_VERBOSE, "grFogTable()\r\n");
 }
 
 FX_ENTRY void FX_CALL 
 grFogColorValue( GrColor_t fogcolor )
 {
     float color[4];
-    LOG("grFogColorValue(%x)\r\n", fogcolor);
+    WriteLog(M64MSG_VERBOSE, "grFogColorValue(%x)\r\n", fogcolor);
 
     switch(lfb_color_fmt)
     {
 FX_ENTRY void FX_CALL 
 grChromakeyMode( GrChromakeyMode_t mode )
 {
-    LOG("grChromakeyMode(%d)\r\n", mode);
+    WriteLog(M64MSG_VERBOSE, "grChromakeyMode(%d)\r\n", mode);
     switch(mode)
     {
     case GR_CHROMAKEY_DISABLE:
 FX_ENTRY void FX_CALL 
 grChromakeyValue( GrColor_t value )
 {
-    LOG("grChromakeyValue(%x)\r\n", value);
+    WriteLog(M64MSG_VERBOSE, "grChromakeyValue(%x)\r\n", value);
     if(!glsl_support)
         display_warning("grChromakeyValue");
     else
 grStipplePattern(
             GrStipplePattern_t stipple)
 {
-    LOG("grStipplePattern(%x)\r\n", stipple);
+    WriteLog(M64MSG_VERBOSE, "grStipplePattern(%x)\r\n", stipple);
     srand(stipple);
     setPattern();
 }
 FX_ENTRY void FX_CALL
 grStippleMode( GrStippleMode_t mode )
 {
-    LOG("grStippleMode(%d)\r\n", mode);
+    WriteLog(M64MSG_VERBOSE, "grStippleMode(%d)\r\n", mode);
     if(getDisableDitheredAlpha()) return;
     switch(mode)
     {
                   GrCCUColor_t d, FxBool d_invert,
                   FxU32 shift, FxBool invert)
 {
-    LOG("grColorCombineExt(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+    WriteLog(M64MSG_VERBOSE, "grColorCombineExt(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
     if (invert) display_warning("grColorCombineExt : inverted result");
     if (shift) display_warning("grColorCombineExt : shift = %d", shift);
 
                   GrACUColor_t d, FxBool d_invert,
                   FxU32 shift, FxBool invert)
 {
-    LOG("grAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+    WriteLog(M64MSG_VERBOSE, "grAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
     if (invert) display_warning("grAlphaCombineExt : inverted result");
     if (shift) display_warning("grAlphaCombineExt : shift = %d", shift);
 
                      FxU32 shift, FxBool invert)
 {
     int num_tex;
-    LOG("grTexColorCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+    WriteLog(M64MSG_VERBOSE, "grTexColorCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
 
     if (invert) display_warning("grTexColorCombineExt : inverted result");
     if (shift) display_warning("grTexColorCombineExt : shift = %d", shift);
                      FxU32 shift, FxBool invert)
 {
     int num_tex;
-    LOG("grTexAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+    WriteLog(M64MSG_VERBOSE, "grTexAlphaCombineExt(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)\r\n", tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
 
     if (invert) display_warning("grTexAlphaCombineExt : inverted result");
     if (shift) display_warning("grTexAlphaCombineExt : shift = %d", shift);
                         GrColor_t     value)
 {
     int num_tex;
-    LOG("grConstantColorValueExt(%d,%d)\r\n", tmu, value);
+    WriteLog(M64MSG_VERBOSE, "grConstantColorValueExt(%d,%d)\r\n", tmu, value);
 
     if (tmu == GR_TMU0) num_tex = 1;
     else num_tex = 0;

File src/wrapper/config.cpp

  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 
-#define GL_GLEXT_PROTOTYPES
 #include <SDL_opengl.h>
 
 #include "glide.h"

File src/wrapper/geometry.cpp

 
 #include <stdio.h>
 
-#define GL_GLEXT_PROTOTYPES
 #include <SDL_opengl.h>
 
 #include "glide.h"
     glDepthMask(mask);
 }
 
-#include <SDL/SDL.h>
+#include <SDL.h>
 float biasFactor = 0;
 void FindBestDepthBias()
 {

File src/wrapper/main.cpp

 
 #include <stdlib.h>
 #include <stdio.h>
+#ifndef WIN32
 #include <stdint.h>
+#endif
 #include <stdarg.h>
 #include <string.h>
 
-#include <SDL/SDL.h>
-#define GL_GLEXT_PROTOTYPES
+#include <SDL.h>
 #include <SDL_opengl.h>
 
 #include "glide.h"
 #include <IL/il.h>
 #endif
 
+extern void FindBestDepthBias();
+extern int getEnableFBO();
+extern int getDisableAuxbuf();
+
+PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
+PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
+PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
+PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
+PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
+PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
+PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
+PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
+PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
+PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
+PFNGLFOGCOORDFEXTPROC glFogCoordfEXT;
+PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
+PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
+PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
+PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
+PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
+PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
+PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
+PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
+PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
+PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
+PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
+PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
+PFNGLUNIFORM1FARBPROC glUniform1fARB;
+PFNGLUNIFORM1IARBPROC glUniform1iARB;
+PFNGLUNIFORM4FARBPROC glUniform4fARB;
+PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
+
+static void APIENTRY EmptyFunc(void) { return; }
+
+#define INIT_ENTRY_POINT(type, funcname) \
+  funcname = (type) CoreVideo_GL_GetProcAddress(#funcname); \
+  if (funcname == NULL) { LOG(M64MSG_WARNING, \
+    "Couldn't get address of OpenGL function: '%s'", #funcname); funcname = (type) EmptyFunc; }
+
+static void InitGLPrototypes()
+{
+    INIT_ENTRY_POINT(PFNGLACTIVETEXTUREARBPROC, glActiveTextureARB);
+    INIT_ENTRY_POINT(PFNGLATTACHOBJECTARBPROC, glAttachObjectARB);
+    INIT_ENTRY_POINT(PFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebufferEXT);
+    INIT_ENTRY_POINT(PFNGLBINDRENDERBUFFEREXTPROC, glBindRenderbufferEXT);
+    INIT_ENTRY_POINT(PFNGLBLENDFUNCSEPARATEEXTPROC, glBlendFuncSeparateEXT);
+    INIT_ENTRY_POINT(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC, glCheckFramebufferStatusEXT);
+    INIT_ENTRY_POINT(PFNGLCOMPILESHADERARBPROC, glCompileShaderARB);
+    INIT_ENTRY_POINT(PFNGLCREATEPROGRAMOBJECTARBPROC, glCreateProgramObjectARB);
+    INIT_ENTRY_POINT(PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB);
+    INIT_ENTRY_POINT(PFNGLDELETERENDERBUFFERSEXTPROC, glDeleteRenderbuffersEXT);
+    INIT_ENTRY_POINT(PFNGLDELETEFRAMEBUFFERSEXTPROC, glDeleteFramebuffersEXT);
+    INIT_ENTRY_POINT(PFNGLFOGCOORDFEXTPROC, glFogCoordfEXT);
+    INIT_ENTRY_POINT(PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC, glFramebufferRenderbufferEXT);
+    INIT_ENTRY_POINT(PFNGLFRAMEBUFFERTEXTURE2DEXTPROC, glFramebufferTexture2DEXT);
+    INIT_ENTRY_POINT(PFNGLGENFRAMEBUFFERSEXTPROC, glGenFramebuffersEXT);
+    INIT_ENTRY_POINT(PFNGLGENRENDERBUFFERSEXTPROC, glGenRenderbuffersEXT);
+    INIT_ENTRY_POINT(PFNGLGETINFOLOGARBPROC, glGetInfoLogARB);
+    INIT_ENTRY_POINT(PFNGLGETOBJECTPARAMETERIVARBPROC, glGetObjectParameterivARB);
+    INIT_ENTRY_POINT(PFNGLGETUNIFORMLOCATIONARBPROC, glGetUniformLocationARB);
+    INIT_ENTRY_POINT(PFNGLLINKPROGRAMARBPROC, glLinkProgramARB);
+    INIT_ENTRY_POINT(PFNGLMULTITEXCOORD2FARBPROC, glMultiTexCoord2fARB);
+    INIT_ENTRY_POINT(PFNGLRENDERBUFFERSTORAGEEXTPROC, glRenderbufferStorageEXT);
+    INIT_ENTRY_POINT(PFNGLSECONDARYCOLOR3FPROC, glSecondaryColor3f);
+    INIT_ENTRY_POINT(PFNGLSHADERSOURCEARBPROC, glShaderSourceARB);
+    INIT_ENTRY_POINT(PFNGLUNIFORM1FARBPROC, glUniform1fARB);
+    INIT_ENTRY_POINT(PFNGLUNIFORM1IARBPROC, glUniform1iARB);
+    INIT_ENTRY_POINT(PFNGLUNIFORM4FARBPROC, glUniform4fARB);
+    INIT_ENTRY_POINT(PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB);
+}
+
+
 int screen_width, screen_height;
 
 static inline void opt_glCopyTexImage2D( GLenum target,
     CoreVideo_SetCaption("Glide64");
     fullscreen = 0;
 
+    InitGLPrototypes();
+
    // ZIGGY viewport_offset is WIN32 specific, with SDL just set it to zero
     viewport_offset = 0; //-10 //-20;
 
     if (nbTextureUnits == 1) display_warning("You need a video card that has at least 2 texture units");
   
   nbAuxBuffers = 0;
-  int getDisableAuxbuf();
   if (!getDisableAuxbuf())
     glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &nbAuxBuffers);
   if (nbAuxBuffers > 0)
     else
         fog_coord_support = 1;
 
-  int getEnableFBO();
   use_fbo = getEnableFBO();
 
   printf("use_fbo %d\n", use_fbo);
     save_w = save_h = 0;
   }
 
-  void FindBestDepthBias();
   FindBestDepthBias();
 
     init_geometry();

File src/wrapper/main.h

 
 #include "../winlnxdefs.h"
 
+extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
+extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
+extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
+extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
+extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
+extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
+extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
+extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
+extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
+extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
+extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
+extern PFNGLFOGCOORDFEXTPROC glFogCoordfEXT;
+extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
+extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
+extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
+extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
+extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
+extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
+extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
+extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
+extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
+extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
+extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
+extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
+extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
+extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
+extern PFNGLUNIFORM4FARBPROC glUniform4fARB;
+extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
+
 #ifdef VPDEBUG
 void dump_tex(int id);
 void dump_start();

File src/wrapper/textures.cpp

 #include <stdlib.h>
 #include <stdio.h>
 
-#define GL_GLEXT_PROTOTYPES
 #include <SDL_opengl.h>
 
 #include "glide.h"
 #include "main.h"
 
+extern BOOL isExtensionSupported(const char *extension); // defined in main.cpp
+
 /* Napalm extensions to GrTextureFormat_t */
 #define GR_TEXFMT_ARGB_CMP_FXT1           0x11
 #define GR_TEXFMT_ARGB_8888               0x12
     }
 
     if (packed_pixels_support < 0) {
-      BOOL isExtensionSupported(const char *extension); // defined in main.cpp
       if (isExtensionSupported("GL_EXT_packed_pixels") == FALSE)
         packed_pixels_support = 0;
       else