Commits

ecsv  committed 64cb0b1

Fix build under MinGW

  • Participants
  • Parent commits 070ad76

Comments (0)

Files changed (13)

File projects/unix/Makefile

 	$(SRCDIR)/Glitch64/geometry.cpp \
 	$(SRCDIR)/Glitch64/main.cpp \
 	$(SRCDIR)/Glitch64/textures.cpp \
-	$(SRCDIR)/Glitch64/vram.cpp \
 	$(SRCDIR)/Glide64/3dmath.cpp \
 	$(SRCDIR)/Glide64/Combine.cpp \
 	$(SRCDIR)/Glide64/Config.cpp \

File src/Glide64/3dmath.cpp

 //
 //****************************************************************
 
+#include "Gfx #1.3.h"
+extern "C" {
 #ifndef NOSSE
 #include <xmmintrin.h>
 #endif
+}
 
 #include <math.h>
-#include "Gfx #1.3.h"
 #include "3dmath.h"
 
 void calc_light (VERTEX *v)

File src/Glide64/Debugger.cpp

 static const char *tri_type[4] = { "TRIANGLE", "TEXRECT", "FILLRECT", "BACKGROUND" };
 
 //Platform-specific stuff
-#ifndef __WINDOWS__
+#ifndef WIN32
 typedef struct dbgPOINT {
    int x;
    int y;

File src/Glide64/Gfx #1.3.h

 #define GLIDE64_CATCH catch (...)
 #endif
 
-#ifndef __WINDOWS__
+#ifndef WIN32
 typedef int HWND;
 #endif
 

File src/Glide64/Ini.cpp

 #include <string.h>
 #include <dirent.h>
 #include <stdlib.h>
+#else
+#include <io.h>
 #endif // _WIN32
 
 #include <errno.h>
     else
     {
 #ifdef _WIN32
-    GetModuleFileName (hInstance, path, PATH_MAX);
+    GetModuleFileName (NULL, path, PATH_MAX);
 #else // _WIN32
 # ifdef __FreeBSD__
    int n = readlink("/proc/curproc/files", path, PATH_MAX);

File src/Glide64/Main.cpp

   if(_NSGetExecutablePath(pluginPath, &size) != 0) return;
   #else
     #ifdef _WIN32
-    GetModuleFileName (hInstance, pluginPath, PATH_MAX);
+    GetModuleFileName (NULL, pluginPath, PATH_MAX);
     #else
       #ifdef __FreeBSD__
       int n = readlink("/proc/curproc/files", pluginPath, PATH_MAX);

File src/Glide64/TexLoad4b.h

 
 #define ALOWORD(x)   (*((uint16_t*)&(x)))   // low word
 
-template<class T> static inline T __ROR__(T value, uint count)
+template<class T> static inline T __ROR__(T value, unsigned int count)
 {
-  const uint nbits = sizeof(T) * 8;
+  const unsigned int nbits = sizeof(T) * 8;
   count %= nbits;
 
   T low = value << (nbits - count);

File src/Glide64/rdp.cpp

   if (!hhkLowLevelKybd)
   {
     hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
-      LowLevelKeyboardProc, hInstance, 0);
+      LowLevelKeyboardProc, NULL, 0);
   }
 #endif
 
 }
 
 // rotate left
-template<class T> static T __ROL__(T value, uint count)
+template<class T> static T __ROL__(T value, unsigned int count)
 {
-  const uint nbits = sizeof(T) * 8;
+  const unsigned int nbits = sizeof(T) * 8;
   count %= nbits;
 
   T high = value >> (nbits - count);

File src/Glide64/winlnxdefs.h

 
 #define _T(x) x
 
-#ifndef WIN32
+#if !defined(WIN32) || defined(__GNUC__)
 
 #include <stdint.h>
 
 
 typedef int BOOL;
-typedef unsigned int wxUint32;
-typedef unsigned short wxUint16;
-typedef unsigned char wxUint8;
-typedef unsigned char BYTE;
+typedef uint32_t wxUint32;
+typedef uint16_t wxUint16;
+typedef uint8_t wxUint8;
+typedef uint8_t BYTE;
 typedef long long LONGLONG;
 
 
-typedef int wxInt32;
-typedef short wxInt16;
-typedef char wxInt8;
+typedef int32_t wxInt32;
+typedef int16_t wxInt16;
+typedef int8_t wxInt8;
 
 typedef uint64_t wxUint64;
 typedef int64_t wxInt64;
 typedef unsigned char wxChar;
 typedef uintptr_t wxUIntPtr;
 
+#else
+
+typedef DWORD wxUint32;
+typedef WORD wxUint16;
+typedef BYTE wxUint8;
+
+typedef int wxInt32;
+typedef short wxInt16;
+typedef char wxInt8;
+
+
+typedef BYTE char wxChar;
+typedef uintptr_t wxUIntPtr;
+
+#endif
+
+
+#ifndef WIN32
 
 typedef union _LARGE_INTEGER
 {
 
 #define WINAPI
 
-#else
-
-typedef DWORD wxUint32;
-typedef WORD wxUint16;
-typedef BYTE wxUint8;
-
-typedef int wxInt32;
-typedef short wxInt16;
-typedef char wxInt8;
-
-
-typedef BYTE char wxChar;
-typedef uintptr_t wxUIntPtr;
-
 #endif
 
 #endif

File src/Glitch64/inc/glide.h

 typedef FxU32 GrContext_t;
 typedef int (FX_CALL *GrProc)();
 
+#ifndef WIN32
+typedef int HWND;
+#endif
+
 /*
 ** -----------------------------------------------------------------------
 ** CONSTANTS AND TYPES
 
 FX_ENTRY GrContext_t FX_CALL 
 grSstWinOpen(
-          FxU32                hWnd,
+          HWND                 hWnd,
           GrScreenResolution_t screen_resolution,
           GrScreenRefresh_t    refresh_rate,
           GrColorFormat_t      color_format,

File src/Glitch64/main.cpp

 
 FX_ENTRY GrContext_t FX_CALL
 grSstWinOpenExt(
-                FxU32                hWnd,
+                HWND                 hWnd,
                 GrScreenResolution_t screen_resolution,
                 GrScreenRefresh_t    refresh_rate,
                 GrColorFormat_t      color_format,
 
 FX_ENTRY GrContext_t FX_CALL
 grSstWinOpen(
-             FxU32                hWnd,
+             HWND                 hWnd,
              GrScreenResolution_t screen_resolution,
              GrScreenRefresh_t    refresh_rate,
              GrColorFormat_t      color_format,
   LOG("grSstWinOpen(%08lx, %d, %d, %d, %d, %d %d)\r\n", hWnd, screen_resolution&~0x80000000, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
 
 #ifdef _WIN32
-  if ((HWND)hWnd == NULL) hWnd = (FxU32)GetActiveWindow();
+  if ((HWND)hWnd == NULL) hWnd = GetActiveWindow();
   hwnd_win = (HWND)hWnd;
 #endif // _WIN32
   width = height = 0;
   config.vram_size = vram;
   config.fbo = fbo;
   config.anisofilter = aniso;
-#ifdef _WIN32
-  int getVRAMSize();
-  if (config.vram_size == 0)
-    config.vram_size = getVRAMSize();
-#endif // _WIN32
 }
 
 // unused by glide64

File src/Glitch64/main.h

 #ifdef _WIN32
 #include <windows.h>
 extern "C" {
-#include "gl.h"
-#include "glext.h"
-#include "wglext.h"
+    #include <SDL_opengl.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;
+    typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
 }
 #else
 #include <stdio.h>

File src/Glitch64/vram.cpp

-#include <stdio.h>
-
-#ifdef _WIN32 //Windows, duh!
-#include <objbase.h>
-#include "dxdiag.h"
-#include "main.h"
-#pragma comment(lib, "ole32.lib")
-#pragma comment(lib, "dxguid.lib")
-#define SAFE_RELEASE(x) { if (x != NULL) { x->Release(); x = NULL; } }
-
-IDxDiagProvider* Provider;
-IDxDiagContainer* RootContainer;
-bool ComInitialized;
-
-static void InitCom()
-{
-  try
-  {
-    Provider = NULL;
-    RootContainer = NULL;
-
-    // Init COM
-    ComInitialized = SUCCEEDED(CoInitialize(NULL));
-
-    // Create a provider interface
-    if (FAILED(CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (void**)&Provider)))
-      throw "Unable to create provider instance";
-
-    // Initialize the provider
-    DXDIAG_INIT_PARAMS initParams;
-    ZeroMemory(&initParams, sizeof(DXDIAG_INIT_PARAMS));
-    initParams.dwSize = sizeof(DXDIAG_INIT_PARAMS);
-    initParams.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
-    if (FAILED(Provider->Initialize(&initParams)))
-      throw "Unable to initialize provider";
-
-    // Get the root container
-    if (FAILED(Provider->GetRootContainer(&RootContainer)))
-      throw "Unable to get root container";
-  }
-  catch (const char* msg)
-  {
-    LOG("\nDxDiag Error: %s", msg);
-  }
-}
-
-static IDxDiagContainer* GetContainer(IDxDiagContainer* parent, const WCHAR* name)
-{
-  IDxDiagContainer* container;
-  if (SUCCEEDED(parent->GetChildContainer(name, &container)))
-    return container;
-
-  return NULL;
-}
-
-static void GetPropertyValue(IDxDiagContainer* container, const WCHAR* name, WCHAR* value, int maxValueLen)
-{
-  VARIANT var;
-  VariantInit(&var);
-  if (SUCCEEDED(container->GetProp(name, &var)))
-  {
-    // Assuming an integer or bstring value here
-    // @@ Handle all the VT_* types properly...
-    if (var.vt != VT_BSTR)
-      wsprintf((LPSTR)value, "%i", var.iVal);
-    else
-      wcsncpy(value, var.bstrVal, maxValueLen - 1);
-
-    value[maxValueLen - 1] = 0;
-    VariantClear(&var);
-  }
-  else
-  {
-    value[0] = 0;
-  }
-}
-
-static int GetTotalVideoMemory()
-{
-  if (RootContainer != NULL)
-  {
-    // Get device container
-    IDxDiagContainer* container = GetContainer(RootContainer, L"DxDiag_DisplayDevices");
-    if (container != NULL)
-    {
-      // Get device name
-      container = GetContainer(container, L"0");
-      if (container != NULL)
-      {
-        const int bufferLength = 256;
-        WCHAR buffer[bufferLength];
-        GetPropertyValue(container, L"szDisplayMemoryLocalized", buffer, bufferLength);
-        // Value in MB is first token in string
-        return _wtoi(buffer);
-      }
-    }
-  }
-
-  // No good!
-  return -1;
-}
-
-int getVRAMSize()
-{
-  static int mem;
-  if (!mem) {
-    InitCom();
-    mem = GetTotalVideoMemory();
-  }
-  return mem * 1024 * 1024;
-}
-#endif
-
-