]> Chaos Git - console/XDS.git/commitdiff
Build works on OSX
authorYifan Lu <me@yifanlu.com>
Fri, 25 Mar 2016 01:48:05 +0000 (20:48 -0500)
committerYifan Lu <me@yifanlu.com>
Fri, 25 Mar 2016 01:48:05 +0000 (20:48 -0500)
16 files changed:
Makefile
include/Platform.h
include/kernel/Scheduler.h
include/util/Mutex.h
source/Bootloader.cpp
source/Main.cpp
source/arm/skyeye_common/armdefs.h
source/citraimport/GPU/video_core/debug_utils/debug_utils.cpp
source/citraimport/GPU/video_core/rasterizer.cpp
source/citraimport/common/citra_key_map.cpp [deleted file]
source/citraimport/common/emu_window.cpp [deleted file]
source/citraimport/common/x64/emitter.cpp
source/citraimport/common/x64/emitter.h
source/gui/imgui_impl_glfw_gl3.cpp [deleted file]
source/gui/imgui_impl_glfw_gl3.h [deleted file]
source/util/CMutex.cpp

index e81aa1de5d08582708cba9e628d0dbe643a661b4..f4542ecd2b4b6e38050a22ced2ffbd8873a64828 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,13 +8,16 @@ PROCESS9_FILES := source/process9/*.cpp source/process9/archive/*.cpp
 UTIL_FILES := source/util/*.cpp
 
 
-COMMON_FILES := source/Bootloader.cpp source/arm/*.cpp $(ARM_FILES) $(KERNEL_FILES) $(HARDWARE_FILES) $(PROCESS9_FILES) $(UTIL_FILES)
+#COMMON_FILES := source/Bootloader.cpp source/arm/*.cpp $(ARM_FILES) $(KERNEL_FILES) $(HARDWARE_FILES) $(PROCESS9_FILES) $(UTIL_FILES)
+COMMON_FILES := source/citraimport/glad/src/glad.c external/imgui/imgui.cpp external/imgui/imgui_draw.cpp external/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.cpp $(shell for file in `find source -name *.cpp`; do echo $$file; done)
 
 
-BUILD_FLAGS := -Iinclude -g --std=c++11 $(ARM_FLAGS) -lpthread
+BUILD_FLAGS := -I/opt/local/include -Iinclude -Isource/citraimport -Iexternal/gl3w/include -Iexternal/imgui -g --std=c++11 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors
+LINK_FLAGS := -L/opt/local/lib -Lexternal/gl3w -lglfw -lpthread -lgl3w -liconv -framework OpenGL -framework Cocoa
 
 main:
-       g++ -o xds source/Main.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+       g++ -c source/Main.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
+       g++ -o xds $(TEST_DEFS) $(BUILD_FLAGS) $(LINK_FLAGS) *.o
 
 test:
        g++ -o xds_test_memorymap tests/kernel/MemoryMap.cpp $(TEST_DEFS) $(BUILD_FLAGS) $(COMMON_FILES)
@@ -31,4 +34,4 @@ runtests:
        ./xds_test_mutex
 
 clean:
-       rm ./xds ./xds_test_memorymap ./xds_test_handletable ./xds_test_linkedlist ./xds_test_resourcelimit ./xds_test_mutex
+       rm ./*.o ./xds ./xds_test_memorymap ./xds_test_handletable ./xds_test_linkedlist ./xds_test_resourcelimit ./xds_test_mutex
index e51943cedb387feabe2bb00e97bb3d3f8f88aab0..eb15fd058f45b318214f02168ceb8f34f74fc204 100644 (file)
@@ -5,15 +5,15 @@
 /// Enumeration for defining the supported platforms
 #define PLATFORM_NULL 0
 #define PLATFORM_WINDOWS 1
-#define PLATFORM_LINUX 2
+#define PLATFORM_UNIX 2
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 // Platform detection
 #ifndef EMU_PLATFORM
 #if defined( __WIN32__ ) || defined( _WIN32 )
 #define EMU_PLATFORM PLATFORM_WINDOWS
-#elif defined(__linux__)
-#define EMU_PLATFORM PLATFORM_LINUX
+#elif defined(__linux__) || defined(__APPLE__)
+#define EMU_PLATFORM PLATFORM_UNIX
 #else
 #error unsupported platform
 #endif
index 29e382a108fc9d4e46f692c97bc4245cfe0f9e34..2dba79bd60aacc35d06e94304eb29daf76c32873 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once 
 
+#undef PRIO_MAX
 
 #define PRIO_FIELD_COUNT    0x20
 #define PRIO_FIELD_MASK     0x1F
index 4c0e5b31470d9172be2b5112cf8b17d8d97997c6..90da8ecbdecff7a5f565cf369ba9e8882e9878e6 100644 (file)
@@ -1,6 +1,6 @@
 #include "Platform.h"
 
-#if EMU_PLATFORM == PLATFORM_LINUX
+#if EMU_PLATFORM == PLATFORM_UNIX
 #include <pthread.h>
 #elif EMU_PLATFORM == PLATFORM_WINDOWS
 #include <windows.h>
@@ -17,7 +17,7 @@ public:
 private:
     bool m_locked;
 
-#if EMU_PLATFORM == PLATFORM_LINUX
+#if EMU_PLATFORM == PLATFORM_UNIX
     pthread_mutex_t m_mutex;
 #elif EMU_PLATFORM == PLATFORM_WINDOWS
     HANDLE m_mutex;
index 857ee17a1ca7736cca5e557c8471dca508bebbed..0b0b990a21053497ab4b209446d1349786abf183 100644 (file)
@@ -508,7 +508,7 @@ int Boot(KKernel* kernel)
                fclose(fd);
                return 0; //it worked
        }
-    fclose(fd);
+    if (fd) fclose(fd);
     XDSERROR("finding .firm section");
     return -1;
     XDSERROR("finding firm");
index 6689694710566802768d5f9128c36bacfd5535dc..00a8779b3551e50a8059496bc89ac52ea47a4ff5 100644 (file)
@@ -35,10 +35,11 @@ int main(int argc, char* argv[]) {
     Mem_Init(false);
     Mem_SharedMemInit();
 
-       Boot(mykernel);
-
+       if (Boot(mykernel) == 0)
+  {
     //kernel->AddQuickCodeProcess(&code[0], size);
     mykernel->ThreadsRunTemp();
+  }
     return 0;
 }
 extern "C" void citraFireInterrupt(int id)
index 3706c92d0bcf8c5c2dc4f87d28c9729af9d25067..573c493e7939752081f2db58482225193e7bbab9 100644 (file)
@@ -33,7 +33,7 @@
 #include "arm/skyeye_common/armmmu.h"
 #include "arm/skyeye_common/skyeye_defs.h"
 
-#if EMU_PLATFORM == PLATFORM_LINUX
+#if EMU_PLATFORM == PLATFORM_UNIX
 #include <sys/time.h>
 #include <unistd.h>
 #endif
index 1a0c604a2834f69844271556766bec2e9b027596..e382a2365d204b92be0ff0e58c61c21743e450e5 100644 (file)
 
 #include "citraimport/settings.h"
 
-#include "citraimport/GPU\video_core/pica.h"
-#include "citraimport/GPU\video_core/renderer_base.h"
-#include "citraimport/GPU\video_core/utils.h"
-#include "citraimport/GPU\video_core/video_core.h"
-#include "citraimport/GPU\video_core/debug_utils/debug_utils.h"
+#include "citraimport/GPU/video_core/pica.h"
+#include "citraimport/GPU/video_core/renderer_base.h"
+#include "citraimport/GPU/video_core/utils.h"
+#include "citraimport/GPU/video_core/video_core.h"
+#include "citraimport/GPU/video_core/debug_utils/debug_utils.h"
 
 using nihstro::DVLBHeader;
 using nihstro::DVLEHeader;
index c074aad9c52ed336ff6f5747a48a8596407da5df..d1c5a4cc5da308c0abcab8e7ef4da889e6a77167 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <algorithm>
 #include <cmath>
+#include <cassert>
 
 #include "citraimport/common/color.h"
 #include "citraimport/common/common_types.h"
diff --git a/source/citraimport/common/citra_key_map.cpp b/source/citraimport/common/citra_key_map.cpp
deleted file mode 100644 (file)
index 844d5df..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "key_map.h"
-#include <map>
-
-namespace KeyMap {
-
-static std::map<HostDeviceKey, Service::HID::PadState> key_map;
-static int next_device_id = 0;
-
-int NewDeviceId() {
-    return next_device_id++;
-}
-
-void SetKeyMapping(HostDeviceKey key, Service::HID::PadState padState) {
-    key_map[key].hex = padState.hex;
-}
-
-Service::HID::PadState GetPadKey(HostDeviceKey key) {
-    return key_map[key];
-}
-
-}
diff --git a/source/citraimport/common/emu_window.cpp b/source/citraimport/common/emu_window.cpp
deleted file mode 100644 (file)
index b69b05c..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include <algorithm>
-#include <cmath>
-
-#include "common/assert.h"
-#include "common/key_map.h"
-
-#include "emu_window.h"
-#include "video_core/video_core.h"
-
-void EmuWindow::KeyPressed(KeyMap::HostDeviceKey key) {
-    pad_state.hex |= KeyMap::GetPadKey(key).hex;
-}
-
-void EmuWindow::KeyReleased(KeyMap::HostDeviceKey key) {
-    pad_state.hex &= ~KeyMap::GetPadKey(key).hex;
-}
-
-/**
- * Check if the given x/y coordinates are within the touchpad specified by the framebuffer layout
- * @param layout FramebufferLayout object describing the framebuffer size and screen positions
- * @param framebuffer_x Framebuffer x-coordinate to check
- * @param framebuffer_y Framebuffer y-coordinate to check
- * @return True if the coordinates are within the touchpad, otherwise false
- */
-static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsigned framebuffer_x,
-                                unsigned framebuffer_y) {
-    return (framebuffer_y >= layout.bottom_screen.top    &&
-            framebuffer_y <  layout.bottom_screen.bottom &&
-            framebuffer_x >= layout.bottom_screen.left   &&
-            framebuffer_x <  layout.bottom_screen.right);
-}
-
-std::tuple<unsigned,unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) {
-
-    new_x = std::max(new_x, framebuffer_layout.bottom_screen.left);
-    new_x = std::min(new_x, framebuffer_layout.bottom_screen.right-1);
-
-    new_y = std::max(new_y, framebuffer_layout.bottom_screen.top);
-    new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom-1);
-
-    return std::make_tuple(new_x, new_y);
-}
-
-void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
-    if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
-        return;
-
-    touch_x = VideoCore::kScreenBottomWidth * (framebuffer_x - framebuffer_layout.bottom_screen.left) /
-        (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left);
-    touch_y = VideoCore::kScreenBottomHeight * (framebuffer_y - framebuffer_layout.bottom_screen.top) /
-        (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top);
-
-    touch_pressed = true;
-    pad_state.touch = 1;
-}
-
-void EmuWindow::TouchReleased() {
-    touch_pressed = false;
-    touch_x = 0;
-    touch_y = 0;
-    pad_state.touch = 0;
-}
-
-void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) {
-    if (!touch_pressed)
-        return;
-
-    if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
-        std::tie(framebuffer_x, framebuffer_y) = ClipToTouchScreen(framebuffer_x, framebuffer_y);
-
-    TouchPressed(framebuffer_x, framebuffer_y);
-}
-
-EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(unsigned width, unsigned height) {
-
-    ASSERT(width > 0);
-    ASSERT(height > 0);
-
-    EmuWindow::FramebufferLayout res = { width, height, {}, {} };
-
-    float window_aspect_ratio = static_cast<float>(height) / width;
-    float emulation_aspect_ratio = static_cast<float>(VideoCore::kScreenTopHeight * 2) /
-        VideoCore::kScreenTopWidth;
-
-    if (window_aspect_ratio > emulation_aspect_ratio) {
-        // Window is narrower than the emulation content => apply borders to the top and bottom
-        int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width));
-
-        res.top_screen.left = 0;
-        res.top_screen.right = res.top_screen.left + width;
-        res.top_screen.top = (height - viewport_height) / 2;
-        res.top_screen.bottom = res.top_screen.top + viewport_height / 2;
-
-        int bottom_width = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomWidth) /
-            VideoCore::kScreenTopWidth) * (res.top_screen.right - res.top_screen.left));
-        int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2;
-
-        res.bottom_screen.left = bottom_border;
-        res.bottom_screen.right = res.bottom_screen.left + bottom_width;
-        res.bottom_screen.top = res.top_screen.bottom;
-        res.bottom_screen.bottom = res.bottom_screen.top + viewport_height / 2;
-    } else {
-        // Otherwise, apply borders to the left and right sides of the window.
-        int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio));
-
-        res.top_screen.left = (width - viewport_width) / 2;
-        res.top_screen.right = res.top_screen.left + viewport_width;
-        res.top_screen.top = 0;
-        res.top_screen.bottom = res.top_screen.top + height / 2;
-
-        int bottom_width = static_cast<int>((static_cast<float>(VideoCore::kScreenBottomWidth) /
-            VideoCore::kScreenTopWidth) * (res.top_screen.right - res.top_screen.left));
-        int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2;
-
-        res.bottom_screen.left = res.top_screen.left + bottom_border;
-        res.bottom_screen.right = res.bottom_screen.left + bottom_width;
-        res.bottom_screen.top = res.top_screen.bottom;
-        res.bottom_screen.bottom = res.bottom_screen.top + height / 2;
-    }
-
-    return res;
-}
index 2584016ba4f04d58b03ad3cd794c6978d40aca43..93082321b2f9b703eaa07878452bf23473574352 100644 (file)
@@ -27,6 +27,8 @@
 #include "cpu_detect.h"
 #include "emitter.h"
 
+#define assertf(cond, ...) assert(cond)
+
 namespace Gen
 {
 
@@ -168,7 +170,7 @@ const u8 *XEmitter::AlignCodePage()
 // causing a subtle JIT bug.
 void XEmitter::CheckFlags()
 {
-    assert(!flags_locked, "Attempt to modify flags while flags locked!");
+    assertf(!flags_locked, "Attempt to modify flags while flags locked!");
 }
 
 void XEmitter::WriteModRM(int mod, int reg, int rm)
@@ -202,16 +204,16 @@ void OpArg::WriteRex(XEmitter *emit, int opBits, int bits, int customOp) const
     {
         emit->Write8(op);
         // Check the operation doesn't access AH, BH, CH, or DH.
-        DEBUG_ASSERT((offsetOrBaseReg & 0x100) == 0);
-        DEBUG_ASSERT((customOp & 0x100) == 0);
+        DEBUG_assertf((offsetOrBaseReg & 0x100) == 0);
+        DEBUG_assertf((customOp & 0x100) == 0);
     }
 #else
-    assert(opBits != 64);
-       assert((customOp & 8) == 0 || customOp == -1);
-       assert((indexReg & 8) == 0);
-       assert((offsetOrBaseReg & 8) == 0);
-       assert(opBits != 8 || (customOp & 0x10c) != 4 || customOp == -1);
-       assert(scale == SCALE_ATREG || bits != 8 || (offsetOrBaseReg & 0x10c) != 4);
+    assertf(opBits != 64);
+       assertf((customOp & 8) == 0 || customOp == -1);
+       assertf((indexReg & 8) == 0);
+       assertf((offsetOrBaseReg & 8) == 0);
+       assertf(opBits != 8 || (customOp & 0x10c) != 4 || customOp == -1);
+       assertf(scale == SCALE_ATREG || bits != 8 || (offsetOrBaseReg & 0x10c) != 4);
 #endif
 }
 
@@ -259,7 +261,7 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg,
 #ifdef ARCHITECTURE_x86_64
         u64 ripAddr = (u64)emit->GetCodePtr() + 4 + extraBytes;
         s64 distance = (s64)offset - (s64)ripAddr;
-        assert(
+        assertf(
                      (distance < 0x80000000LL &&
                       distance >=  -0x80000000LL) ||
                      !warn_64bit_offset,
@@ -364,7 +366,7 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg,
         case SCALE_NOBASE_4: ss = 2; break;
         case SCALE_NOBASE_8: ss = 3; break;
         case SCALE_ATREG: ss = 0; break;
-               default: assert(0, "Invalid scale for SIB byte"); ss = 0; break;
+               default: assertf(0, "Invalid scale for SIB byte"); ss = 0; break;
         }
         emit->Write8((u8)((ss << 6) | ((ireg&7)<<3) | (_offsetOrBaseReg&7)));
     }
@@ -400,7 +402,7 @@ void XEmitter::JMP(const u8* addr, bool force5Bytes)
     if (!force5Bytes)
     {
         s64 distance = (s64)(fn - ((u64)code + 2));
-               assert(distance >= -0x80 && distance < 0x80,
+               assertf(distance >= -0x80 && distance < 0x80,
                  "Jump target too far away, needs force5Bytes = true");
         //8 bits will do
         Write8(0xEB);
@@ -410,7 +412,7 @@ void XEmitter::JMP(const u8* addr, bool force5Bytes)
     {
         s64 distance = (s64)(fn - ((u64)code + 5));
 
-               assert(
+               assertf(
                      distance >= -0x80000000LL && distance < 0x80000000LL,
                      "Jump target too far away, needs indirect register");
         Write8(0xE9);
@@ -421,7 +423,7 @@ void XEmitter::JMP(const u8* addr, bool force5Bytes)
 void XEmitter::JMPptr(const OpArg& arg2)
 {
     OpArg arg = arg2;
-       if (arg.IsImm()) assert(0, "JMPptr - Imm argument");
+       if (arg.IsImm()) assertf(0, "JMPptr - Imm argument");
     arg.operandReg = 4;
     arg.WriteRex(this, 0, 0);
     Write8(0xFF);
@@ -438,7 +440,7 @@ void XEmitter::JMPself()
 
 void XEmitter::CALLptr(OpArg arg)
 {
-       if (arg.IsImm()) assert(0, "CALLptr - Imm argument");
+       if (arg.IsImm()) assertf(0, "CALLptr - Imm argument");
     arg.operandReg = 2;
     arg.WriteRex(this, 0, 0);
     Write8(0xFF);
@@ -448,7 +450,7 @@ void XEmitter::CALLptr(OpArg arg)
 void XEmitter::CALL(const void* fnptr)
 {
     u64 distance = u64(fnptr) - (u64(code) + 5);
-    assert(
+    assertf(
                  distance < 0x0000000080000000ULL ||
                  distance >=  0xFFFFFFFF80000000ULL,
                  "CALL out of range (%p calls %p)", code, fnptr);
@@ -502,7 +504,7 @@ void XEmitter::J_CC(CCFlags conditionCode, const u8* addr, bool force5bytes)
     if (distance < -0x80 || distance >= 0x80 || force5bytes)
     {
         distance = (s64)(fn - ((u64)code + 6));
-        assert(
+        assertf(
                      distance >= -0x80000000LL && distance < 0x80000000LL,
                      "Jump target too far away, needs indirect register");
         Write8(0x0F);
@@ -521,13 +523,13 @@ void XEmitter::SetJumpTarget(const FixupBranch& branch)
     if (branch.type == 0)
     {
         s64 distance = (s64)(code - branch.ptr);
-               assert(distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true");
+               assertf(distance >= -0x80 && distance < 0x80, "Jump target too far away, needs force5Bytes = true");
         branch.ptr[-1] = (u8)(s8)distance;
     }
     else if (branch.type == 1)
     {
         s64 distance = (s64)(code - branch.ptr);
-               assert(distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register");
+               assertf(distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register");
         ((s32*)branch.ptr)[-1] = (s32)distance;
     }
 }
@@ -541,7 +543,7 @@ void XEmitter::RET_FAST()  {Write8(0xF3); Write8(0xC3);} //two-byte return (rep
 // The first sign of decadence: optimized NOPs.
 void XEmitter::NOP(size_t size)
 {
-    assert((int)size > 0);
+    assertf((int)size > 0);
     while (true)
     {
         switch (size)
@@ -685,7 +687,7 @@ void XEmitter::PUSH(int bits, const OpArg& reg)
             Write32((u32)reg.offset);
             break;
         default:
-            assert(0, "PUSH - Bad imm bits");
+            assertf(0, "PUSH - Bad imm bits");
             break;
         }
     }
@@ -704,7 +706,7 @@ void XEmitter::POP(int /*bits*/, const OpArg& reg)
     if (reg.IsSimpleReg())
         POP(reg.GetSimpleReg());
     else
-        assert(0, "POP - Unsupported encoding");
+        assertf(0, "POP - Unsupported encoding");
 }
 
 void XEmitter::BSWAP(int bits, X64Reg reg)
@@ -723,7 +725,7 @@ void XEmitter::BSWAP(int bits, X64Reg reg)
     }
     else
     {
-        assert(0, "BSWAP - Wrong number of bits");
+        assertf(0, "BSWAP - Wrong number of bits");
     }
 }
 
@@ -737,7 +739,7 @@ void XEmitter::UD2()
 
 void XEmitter::PREFETCH(PrefetchLevel level, OpArg arg)
 {
-    assert(!arg.IsImm(), "PREFETCH - Imm argument");
+    assertf(!arg.IsImm(), "PREFETCH - Imm argument");
     arg.operandReg = (u8)level;
     arg.WriteRex(this, 0, 0);
     Write8(0x0F);
@@ -747,7 +749,7 @@ void XEmitter::PREFETCH(PrefetchLevel level, OpArg arg)
 
 void XEmitter::SETcc(CCFlags flag, OpArg dest)
 {
-    assert(!dest.IsImm(), "SETcc - Imm argument");
+    assertf(!dest.IsImm(), "SETcc - Imm argument");
     dest.operandReg = 0;
     dest.WriteRex(this, 0, 8);
     Write8(0x0F);
@@ -757,8 +759,8 @@ void XEmitter::SETcc(CCFlags flag, OpArg dest)
 
 void XEmitter::CMOVcc(int bits, X64Reg dest, OpArg src, CCFlags flag)
 {
-    assert(!src.IsImm(), "CMOVcc - Imm argument");
-    assert(bits != 8, "CMOVcc - 8 bits unsupported");
+    assertf(!src.IsImm(), "CMOVcc - Imm argument");
+    assertf(bits != 8, "CMOVcc - 8 bits unsupported");
     if (bits == 16)
         Write8(0x66);
     src.operandReg = dest;
@@ -770,7 +772,7 @@ void XEmitter::CMOVcc(int bits, X64Reg dest, OpArg src, CCFlags flag)
 
 void XEmitter::WriteMulDivType(int bits, OpArg src, int ext)
 {
-    assert(!src.IsImm(), "WriteMulDivType - Imm argument");
+    assertf(!src.IsImm(), "WriteMulDivType - Imm argument");
     CheckFlags();
     src.operandReg = ext;
     if (bits == 16)
@@ -796,7 +798,7 @@ void XEmitter::NOT(int bits, const OpArg& src)  {WriteMulDivType(bits, src, 2);}
 
 void XEmitter::WriteBitSearchType(int bits, X64Reg dest, OpArg src, u8 byte2, bool rep)
 {
-    assert(!src.IsImm(), "WriteBitSearchType - Imm argument");
+    assertf(!src.IsImm(), "WriteBitSearchType - Imm argument");
     CheckFlags();
     src.operandReg = (u8)dest;
     if (bits == 16)
@@ -812,7 +814,7 @@ void XEmitter::WriteBitSearchType(int bits, X64Reg dest, OpArg src, u8 byte2, bo
 void XEmitter::MOVNTI(int bits, const OpArg& dest, X64Reg src)
 {
     if (bits <= 16)
-        assert(0, "MOVNTI - bits<=16");
+        assertf(0, "MOVNTI - bits<=16");
     WriteBitSearchType(bits, src, dest, 0xC3);
 }
 
@@ -823,20 +825,20 @@ void XEmitter::TZCNT(int bits, X64Reg dest, const OpArg& src)
 {
     CheckFlags();
     if (!Common::GetCPUCaps().bmi1)
-        assert(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
+        assertf(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
     WriteBitSearchType(bits, dest, src, 0xBC, true);
 }
 void XEmitter::LZCNT(int bits, X64Reg dest, const OpArg& src)
 {
     CheckFlags();
     if (!Common::GetCPUCaps().lzcnt)
-        assert(0, "Trying to use LZCNT on a system that doesn't support it. Bad programmer.");
+        assertf(0, "Trying to use LZCNT on a system that doesn't support it. Bad programmer.");
     WriteBitSearchType(bits, dest, src, 0xBD, true);
 }
 
 void XEmitter::MOVSX(int dbits, int sbits, X64Reg dest, OpArg src)
 {
-    assert(!src.IsImm(), "MOVSX - Imm argument");
+    assertf(!src.IsImm(), "MOVSX - Imm argument");
     if (dbits == sbits)
     {
         MOV(dbits, R(dest), src);
@@ -869,7 +871,7 @@ void XEmitter::MOVSX(int dbits, int sbits, X64Reg dest, OpArg src)
 
 void XEmitter::MOVZX(int dbits, int sbits, X64Reg dest, OpArg src)
 {
-    assert(!src.IsImm(), "MOVZX - Imm argument");
+    assertf(!src.IsImm(), "MOVZX - Imm argument");
     if (dbits == sbits)
     {
         MOV(dbits, R(dest), src);
@@ -896,14 +898,14 @@ void XEmitter::MOVZX(int dbits, int sbits, X64Reg dest, OpArg src)
     }
     else
     {
-        assert(0, "MOVZX - Invalid size");
+        assertf(0, "MOVZX - Invalid size");
     }
     src.WriteRest(this);
 }
 
 void XEmitter::MOVBE(int bits, const OpArg& dest, const OpArg& src)
 {
-    assert(Common::GetCPUCaps().movbe, "Generating MOVBE on a system that does not support it.");
+    assertf(Common::GetCPUCaps().movbe, "Generating MOVBE on a system that does not support it.");
     if (bits == 8)
     {
         MOV(bits, dest, src);
@@ -915,28 +917,28 @@ void XEmitter::MOVBE(int bits, const OpArg& dest, const OpArg& src)
 
     if (dest.IsSimpleReg())
     {
-        assert(!src.IsSimpleReg() && !src.IsImm(), "MOVBE: Loading from !mem");
+        assertf(!src.IsSimpleReg() && !src.IsImm(), "MOVBE: Loading from !mem");
         src.WriteRex(this, bits, bits, dest.GetSimpleReg());
         Write8(0x0F); Write8(0x38); Write8(0xF0);
         src.WriteRest(this, 0, dest.GetSimpleReg());
     }
     else if (src.IsSimpleReg())
     {
-        assert(!dest.IsSimpleReg() && !dest.IsImm(), "MOVBE: Storing to !mem");
+        assertf(!dest.IsSimpleReg() && !dest.IsImm(), "MOVBE: Storing to !mem");
         dest.WriteRex(this, bits, bits, src.GetSimpleReg());
         Write8(0x0F); Write8(0x38); Write8(0xF1);
         dest.WriteRest(this, 0, src.GetSimpleReg());
     }
     else
     {
-        assert(0, "MOVBE: Not loading or storing to mem");
+        assertf(0, "MOVBE: Not loading or storing to mem");
     }
 }
 
 
 void XEmitter::LEA(int bits, X64Reg dest, OpArg src)
 {
-    assert(!src.IsImm(), "LEA - Imm argument");
+    assertf(!src.IsImm(), "LEA - Imm argument");
     src.operandReg = (u8)dest;
     if (bits == 16)
         Write8(0x66); //TODO: performance warning
@@ -952,11 +954,11 @@ void XEmitter::WriteShift(int bits, OpArg dest, const OpArg& shift, int ext)
     bool writeImm = false;
     if (dest.IsImm())
     {
-        assert(0, "WriteShift - can't shift imms");
+        assertf(0, "WriteShift - can't shift imms");
     }
     if ((shift.IsSimpleReg() && shift.GetSimpleReg() != ECX) || (shift.IsImm() && shift.GetImmBits() != 8))
     {
-        assert(0, "WriteShift - illegal argument");
+        assertf(0, "WriteShift - illegal argument");
     }
     dest.operandReg = ext;
     if (bits == 16)
@@ -1001,11 +1003,11 @@ void XEmitter::WriteBitTest(int bits, const OpArg& dest, const OpArg& index, int
     CheckFlags();
     if (dest.IsImm())
     {
-        assert(0, "WriteBitTest - can't test imms");
+        assertf(0, "WriteBitTest - can't test imms");
     }
     if ((index.IsImm() && index.GetImmBits() != 8))
     {
-        assert(0, "WriteBitTest - illegal argument");
+        assertf(0, "WriteBitTest - illegal argument");
     }
     if (bits == 16)
         Write8(0x66);
@@ -1036,15 +1038,15 @@ void XEmitter::SHRD(int bits, const OpArg& dest, const OpArg& src, const OpArg&
     CheckFlags();
     if (dest.IsImm())
     {
-        assert(0, "SHRD - can't use imms as destination");
+        assertf(0, "SHRD - can't use imms as destination");
     }
     if (!src.IsSimpleReg())
     {
-        assert(0, "SHRD - must use simple register as source");
+        assertf(0, "SHRD - must use simple register as source");
     }
     if ((shift.IsSimpleReg() && shift.GetSimpleReg() != ECX) || (shift.IsImm() && shift.GetImmBits() != 8))
     {
-        assert(0, "SHRD - illegal shift");
+        assertf(0, "SHRD - illegal shift");
     }
     if (bits == 16)
         Write8(0x66);
@@ -1068,15 +1070,15 @@ void XEmitter::SHLD(int bits, const OpArg& dest, const OpArg& src, const OpArg&
     CheckFlags();
     if (dest.IsImm())
     {
-        assert(0, "SHLD - can't use imms as destination");
+        assertf(0, "SHLD - can't use imms as destination");
     }
     if (!src.IsSimpleReg())
     {
-        assert(0, "SHLD - must use simple register as source");
+        assertf(0, "SHLD - must use simple register as source");
     }
     if ((shift.IsSimpleReg() && shift.GetSimpleReg() != ECX) || (shift.IsImm() && shift.GetImmBits() != 8))
     {
-        assert(0, "SHLD - illegal shift");
+        assertf(0, "SHLD - illegal shift");
     }
     if (bits == 16)
         Write8(0x66);
@@ -1112,7 +1114,7 @@ void OpArg::WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg& o
     X64Reg _operandReg;
     if (IsImm())
     {
-        assert(0, "WriteNormalOp - Imm argument, wrong order");
+        assertf(0, "WriteNormalOp - Imm argument, wrong order");
     }
 
     if (bits == 16)
@@ -1126,7 +1128,7 @@ void OpArg::WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg& o
 
         if (!toRM)
         {
-            assert(0, "WriteNormalOp - Writing to Imm (!toRM)");
+            assertf(0, "WriteNormalOp - Writing to Imm (!toRM)");
         }
 
         if (operand.scale == SCALE_IMM8 && bits == 8)
@@ -1202,7 +1204,7 @@ void OpArg::WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg& o
         {
             if (scale)
             {
-                assert(0, "WriteNormalOp - MOV with 64-bit imm requres register destination");
+                assertf(0, "WriteNormalOp - MOV with 64-bit imm requres register destination");
             }
             // mov reg64, imm64
             else if (op == nrmMOV)
@@ -1211,11 +1213,11 @@ void OpArg::WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg& o
                 emit->Write64((u64)operand.offset);
                 return;
             }
-            assert(0, "WriteNormalOp - Only MOV can take 64-bit imm");
+            assertf(0, "WriteNormalOp - Only MOV can take 64-bit imm");
         }
         else
         {
-            assert(0, "WriteNormalOp - Unhandled case");
+            assertf(0, "WriteNormalOp - Unhandled case");
         }
         _operandReg = (X64Reg)normalops[op].ext; //pass extension in REG of ModRM
     }
@@ -1249,7 +1251,7 @@ void OpArg::WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg& o
         emit->Write32((u32)operand.offset);
         break;
     default:
-        assert(0, "WriteNormalOp - Unhandled case");
+        assertf(0, "WriteNormalOp - Unhandled case");
     }
 }
 
@@ -1258,7 +1260,7 @@ void XEmitter::WriteNormalOp(XEmitter *emit, int bits, NormalOp op, const OpArg&
     if (a1.IsImm())
     {
         //Booh! Can't write to an imm
-        assert(0, "WriteNormalOp - a1 cannot be imm");
+        assertf(0, "WriteNormalOp - a1 cannot be imm");
         return;
     }
     if (a2.IsImm())
@@ -1273,7 +1275,7 @@ void XEmitter::WriteNormalOp(XEmitter *emit, int bits, NormalOp op, const OpArg&
         }
         else
         {
-            assert(a2.IsSimpleReg() || a2.IsImm(), "WriteNormalOp - a1 and a2 cannot both be memory");
+            assertf(a2.IsSimpleReg() || a2.IsImm(), "WriteNormalOp - a1 and a2 cannot both be memory");
             a1.WriteNormalOp(emit, true, op, a2, bits);
         }
     }
@@ -1301,19 +1303,19 @@ void XEmitter::IMUL(int bits, X64Reg regOp, const OpArg& a1, const OpArg& a2)
     CheckFlags();
     if (bits == 8)
     {
-        assert(0, "IMUL - illegal bit size!");
+        assertf(0, "IMUL - illegal bit size!");
         return;
     }
 
     if (a1.IsImm())
     {
-        assert(0, "IMUL - second arg cannot be imm!");
+        assertf(0, "IMUL - second arg cannot be imm!");
         return;
     }
 
     if (!a2.IsImm())
     {
-        assert(0, "IMUL - third arg must be imm!");
+        assertf(0, "IMUL - third arg must be imm!");
         return;
     }
 
@@ -1344,7 +1346,7 @@ void XEmitter::IMUL(int bits, X64Reg regOp, const OpArg& a1, const OpArg& a2)
         }
         else
         {
-            assert(0, "IMUL - unhandled case!");
+            assertf(0, "IMUL - unhandled case!");
         }
     }
 }
@@ -1354,7 +1356,7 @@ void XEmitter::IMUL(int bits, X64Reg regOp, const OpArg& a)
     CheckFlags();
     if (bits == 8)
     {
-        assert(0, "IMUL - illegal bit size!");
+        assertf(0, "IMUL - illegal bit size!");
         return;
     }
 
@@ -1417,7 +1419,7 @@ static int GetVEXpp(u8 opPrefix)
 void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, const OpArg& arg, int extrabytes)
 {
     if (!Common::GetCPUCaps().avx)
-        assert(0, "Trying to use AVX on a system that doesn't support it. Bad programmer.");
+        assertf(0, "Trying to use AVX on a system that doesn't support it. Bad programmer.");
     int mmmmm = GetVEXmmmmm(op);
     int pp = GetVEXpp(opPrefix);
     // FIXME: we currently don't support 256-bit instructions, and "size" is not the vector size here
@@ -1430,7 +1432,7 @@ void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, con
 void XEmitter::WriteVEXOp(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, const OpArg& arg, int extrabytes)
 {
     if (size != 32 && size != 64)
-        assert(0, "VEX GPR instructions only support 32-bit and 64-bit modes!");
+        assertf(0, "VEX GPR instructions only support 32-bit and 64-bit modes!");
     int mmmmm = GetVEXmmmmm(op);
     int pp = GetVEXpp(opPrefix);
     arg.WriteVex(this, regOp1, regOp2, 0, pp, mmmmm, size == 64);
@@ -1442,7 +1444,7 @@ void XEmitter::WriteBMI1Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg
 {
     CheckFlags();
     if (!Common::GetCPUCaps().bmi1)
-        assert(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
+        assertf(0, "Trying to use BMI1 on a system that doesn't support it. Bad programmer.");
     WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
 }
 
@@ -1450,7 +1452,7 @@ void XEmitter::WriteBMI2Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg
 {
     CheckFlags();
     if (!Common::GetCPUCaps().bmi2)
-        assert(0, "Trying to use BMI2 on a system that doesn't support it. Bad programmer.");
+        assertf(0, "Trying to use BMI2 on a system that doesn't support it. Bad programmer.");
     WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes);
 }
 
@@ -1504,7 +1506,7 @@ void XEmitter::MOVQ_xmm(OpArg arg, X64Reg src)
 void XEmitter::WriteMXCSR(OpArg arg, int ext)
 {
     if (arg.IsImm() || arg.IsSimpleReg())
-        assert(0, "MXCSR - invalid operand");
+        assertf(0, "MXCSR - invalid operand");
 
     arg.operandReg = ext;
     arg.WriteRex(this, 0, 0);
@@ -1735,14 +1737,14 @@ void XEmitter::PSRAD(X64Reg reg, int shift)
 void XEmitter::WriteSSSE3Op(u8 opPrefix, u16 op, X64Reg regOp, const OpArg& arg, int extrabytes)
 {
     if (!Common::GetCPUCaps().ssse3)
-        assert(0, "Trying to use SSSE3 on a system that doesn't support it. Bad programmer.");
+        assertf(0, "Trying to use SSSE3 on a system that doesn't support it. Bad programmer.");
     WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
 }
 
 void XEmitter::WriteSSE41Op(u8 opPrefix, u16 op, X64Reg regOp, const OpArg& arg, int extrabytes)
 {
     if (!Common::GetCPUCaps().sse4_1)
-        assert(0, "Trying to use SSE4.1 on a system that doesn't support it. Bad programmer.");
+        assertf(0, "Trying to use SSE4.1 on a system that doesn't support it. Bad programmer.");
     WriteSSEOp(opPrefix, op, regOp, arg, extrabytes);
 }
 
@@ -1956,13 +1958,13 @@ void XEmitter::FWAIT()
 void XEmitter::WriteFloatLoadStore(int bits, FloatOp op, FloatOp op_80b, const OpArg& arg)
 {
     int mf = 0;
-    assert(!(bits == 80 && op_80b == floatINVALID), "WriteFloatLoadStore: 80 bits not supported for this instruction");
+    assertf(!(bits == 80 && op_80b == floatINVALID), "WriteFloatLoadStore: 80 bits not supported for this instruction");
     switch (bits)
     {
     case 32: mf = 0; break;
     case 64: mf = 4; break;
     case 80: mf = 2; break;
-    default: assert(0, "WriteFloatLoadStore: invalid bits (should be 32/64/80)");
+    default: assertf(0, "WriteFloatLoadStore: invalid bits (should be 32/64/80)");
     }
     Write8(0xd9 | mf);
     // x87 instructions use the reg field of the ModR/M byte as opcode:
index 7cab6eb0088fa9e33d38f418b1a16512b0f69c2f..3a0dbaaf1c3e26ef0d533f809227e6edce619116 100644 (file)
@@ -286,7 +286,7 @@ inline OpArg SImmAuto(s32 imm) {
 #ifdef _ARCH_64
 inline OpArg ImmPtr(const void* imm) {return Imm64((u64)imm);}
 #else
-inline OpArg ImmPtr(const void* imm) {return Imm32((u32)imm);}
+inline OpArg ImmPtr(const void* imm) {return Imm32((u32)(u64)imm);}
 #endif
 
 inline u32 PtrOffset(const void* ptr, const void* base)
@@ -302,7 +302,7 @@ inline u32 PtrOffset(const void* ptr, const void* base)
 
     return (u32)distance;
 #else
-    return (u32)ptr-(u32)base;
+    return (u32)(u64)ptr-(u32)(u64)base;
 #endif
 }
 
diff --git a/source/gui/imgui_impl_glfw_gl3.cpp b/source/gui/imgui_impl_glfw_gl3.cpp
deleted file mode 100644 (file)
index 9825d64..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-// ImGui GLFW binding with OpenGL3 + shaders
-// https://github.com/ocornut/imgui
-
-#include "../external/imgui/imgui.h"
-#include "imgui_impl_glfw_gl3.h"
-
-// GL3W/GLFW
-#include <GL/gl3w.h>
-#include <GLFW/glfw3.h>
-#ifdef _MSC_VER
-#undef APIENTRY
-#define GLFW_EXPOSE_NATIVE_WIN32
-#define GLFW_EXPOSE_NATIVE_WGL
-#include <GLFW/glfw3native.h>
-#endif
-
-// Data
-static GLFWwindow*  g_Window = NULL;
-static double       g_Time = 0.0f;
-static bool         g_MousePressed[3] = { false, false, false };
-static float        g_MouseWheel = 0.0f;
-static GLuint       g_FontTexture = 0;
-static int          g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
-static int          g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
-static int          g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0;
-static size_t       g_VboSize = 0;
-static unsigned int g_VboHandle = 0, g_VaoHandle = 0;
-
-// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
-// If text or lines are blurry when integrating ImGui in your engine:
-// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
-static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
-{
-    if (cmd_lists_count == 0)
-        return;
-
-    // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
-    GLint last_program, last_texture;
-    glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
-    glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
-    glEnable(GL_BLEND);
-    glBlendEquation(GL_FUNC_ADD);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-    glDisable(GL_CULL_FACE);
-    glDisable(GL_DEPTH_TEST);
-    glEnable(GL_SCISSOR_TEST);
-    glActiveTexture(GL_TEXTURE0);
-
-    // Setup orthographic projection matrix
-    const float width = ImGui::GetIO().DisplaySize.x;
-    const float height = ImGui::GetIO().DisplaySize.y;
-    const float ortho_projection[4][4] =
-    {
-        { 2.0f/width,  0.0f,                   0.0f,           0.0f },
-        { 0.0f,                        2.0f/-height,   0.0f,           0.0f },
-        { 0.0f,                        0.0f,                   -1.0f,          0.0f },
-        { -1.0f,               1.0f,                   0.0f,           1.0f },
-    };
-    glUseProgram(g_ShaderHandle);
-    glUniform1i(g_AttribLocationTex, 0);
-    glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
-
-    // Grow our buffer according to what we need
-    size_t total_vtx_count = 0;
-    for (int n = 0; n < cmd_lists_count; n++)
-        total_vtx_count += cmd_lists[n]->vtx_buffer.size();
-    glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
-    size_t needed_vtx_size = total_vtx_count * sizeof(ImDrawVert);
-    if (g_VboSize < needed_vtx_size)
-    {
-        g_VboSize = needed_vtx_size + 5000 * sizeof(ImDrawVert);  // Grow buffer
-        glBufferData(GL_ARRAY_BUFFER, g_VboSize, NULL, GL_STREAM_DRAW);
-    }
-
-    // Copy and convert all vertices into a single contiguous buffer
-    unsigned char* buffer_data = (unsigned char*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
-    if (!buffer_data)
-        return;
-    for (int n = 0; n < cmd_lists_count; n++)
-    {
-        const ImDrawList* cmd_list = cmd_lists[n];
-        memcpy(buffer_data, &cmd_list->vtx_buffer[0], cmd_list->vtx_buffer.size() * sizeof(ImDrawVert));
-        buffer_data += cmd_list->vtx_buffer.size() * sizeof(ImDrawVert);
-    }
-    glUnmapBuffer(GL_ARRAY_BUFFER);
-    glBindBuffer(GL_ARRAY_BUFFER, 0);
-    glBindVertexArray(g_VaoHandle);
-
-    int cmd_offset = 0;
-    for (int n = 0; n < cmd_lists_count; n++)
-    {
-        const ImDrawList* cmd_list = cmd_lists[n];
-        int vtx_offset = cmd_offset;
-        const ImDrawCmd* pcmd_end = cmd_list->commands.end();
-        for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++)
-        {
-            if (pcmd->user_callback)
-            {
-                pcmd->user_callback(cmd_list, pcmd);
-            }
-            else
-            {
-                glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id);
-                glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
-                glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count);
-            }
-            vtx_offset += pcmd->vtx_count;
-        }
-        cmd_offset = vtx_offset;
-    }
-
-    // Restore modified state
-    glBindVertexArray(0);
-    glUseProgram(last_program);
-    glDisable(GL_SCISSOR_TEST);
-    glBindTexture(GL_TEXTURE_2D, last_texture);
-}
-
-static const char* ImGui_ImplGlfwGL3_GetClipboardText()
-{
-    return glfwGetClipboardString(g_Window);
-}
-
-static void ImGui_ImplGlfwGL3_SetClipboardText(const char* text)
-{
-    glfwSetClipboardString(g_Window, text);
-}
-
-void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
-{
-    if (action == GLFW_PRESS && button >= 0 && button < 3)
-        g_MousePressed[button] = true;
-}
-
-void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
-{
-    g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
-}
-
-void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
-{
-    ImGuiIO& io = ImGui::GetIO();
-    if (action == GLFW_PRESS)
-        io.KeysDown[key] = true;
-    if (action == GLFW_RELEASE)
-        io.KeysDown[key] = false;
-
-    (void)mods; // Modifiers are not reliable across systems
-    io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
-    io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
-    io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
-}
-
-void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c)
-{
-    ImGuiIO& io = ImGui::GetIO();
-    if (c > 0 && c < 0x10000)
-        io.AddInputCharacter((unsigned short)c);
-}
-
-void ImGui_ImplGlfwGL3_CreateFontsTexture()
-{
-    ImGuiIO& io = ImGui::GetIO();
-
-    unsigned char* pixels;
-    int width, height;
-    io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);   // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
-
-    glGenTextures(1, &g_FontTexture);
-    glBindTexture(GL_TEXTURE_2D, g_FontTexture);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
-    // Store our identifier
-    io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
-
-    // Cleanup (don't clear the input data if you want to append new fonts later)
-    io.Fonts->ClearInputData();
-    io.Fonts->ClearTexData();
-}
-
-bool ImGui_ImplGlfwGL3_CreateDeviceObjects()
-{
-    const GLchar *vertex_shader =
-        "#version 330\n"
-        "uniform mat4 ProjMtx;\n"
-        "in vec2 Position;\n"
-        "in vec2 UV;\n"
-        "in vec4 Color;\n"
-        "out vec2 Frag_UV;\n"
-        "out vec4 Frag_Color;\n"
-        "void main()\n"
-        "{\n"
-        "      Frag_UV = UV;\n"
-        "      Frag_Color = Color;\n"
-        "      gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
-        "}\n";
-
-    const GLchar* fragment_shader =
-        "#version 330\n"
-        "uniform sampler2D Texture;\n"
-        "in vec2 Frag_UV;\n"
-        "in vec4 Frag_Color;\n"
-        "out vec4 Out_Color;\n"
-        "void main()\n"
-        "{\n"
-        "      Out_Color = Frag_Color * texture( Texture, Frag_UV.st);\n"
-        "}\n";
-
-    g_ShaderHandle = glCreateProgram();
-    g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
-    g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
-    glShaderSource(g_VertHandle, 1, &vertex_shader, 0);
-    glShaderSource(g_FragHandle, 1, &fragment_shader, 0);
-    glCompileShader(g_VertHandle);
-    glCompileShader(g_FragHandle);
-    glAttachShader(g_ShaderHandle, g_VertHandle);
-    glAttachShader(g_ShaderHandle, g_FragHandle);
-    glLinkProgram(g_ShaderHandle);
-
-    g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
-    g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
-    g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position");
-    g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV");
-    g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color");
-
-    glGenBuffers(1, &g_VboHandle);
-
-    glGenVertexArrays(1, &g_VaoHandle);
-    glBindVertexArray(g_VaoHandle);
-    glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
-    glEnableVertexAttribArray(g_AttribLocationPosition);
-    glEnableVertexAttribArray(g_AttribLocationUV);
-    glEnableVertexAttribArray(g_AttribLocationColor);
-
-#define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
-    glVertexAttribPointer(g_AttribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, pos));
-    glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, uv));
-    glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, col));
-#undef OFFSETOF
-    glBindVertexArray(0);
-    glBindBuffer(GL_ARRAY_BUFFER, 0);
-
-    ImGui_ImplGlfwGL3_CreateFontsTexture();
-
-    return true;
-}
-
-bool    ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks)
-{
-    g_Window = window;
-
-    ImGuiIO& io = ImGui::GetIO();
-    io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;                 // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
-    io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
-    io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
-    io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
-    io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
-    io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
-    io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
-    io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
-    io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
-    io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
-    io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
-    io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
-    io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
-    io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
-    io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
-    io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
-    io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
-
-    io.RenderDrawListsFn = ImGui_ImplGlfwGL3_RenderDrawLists;
-    io.SetClipboardTextFn = ImGui_ImplGlfwGL3_SetClipboardText;
-    io.GetClipboardTextFn = ImGui_ImplGlfwGL3_GetClipboardText;
-#ifdef _MSC_VER
-    io.ImeWindowHandle = glfwGetWin32Window(g_Window);
-#endif
-
-    if (install_callbacks)
-    {
-        glfwSetMouseButtonCallback(window, ImGui_ImplGlfwGL3_MouseButtonCallback);
-        glfwSetScrollCallback(window, ImGui_ImplGlfwGL3_ScrollCallback);
-        glfwSetKeyCallback(window, ImGui_ImplGlfwGL3_KeyCallback);
-        glfwSetCharCallback(window, ImGui_ImplGlfwGL3_CharCallback);
-    }
-
-    return true;
-}
-
-void ImGui_ImplGlfwGL3_Shutdown()
-{
-    if (g_VaoHandle) glDeleteVertexArrays(1, &g_VaoHandle);
-    if (g_VboHandle) glDeleteBuffers(1, &g_VboHandle);
-    g_VaoHandle = 0;
-    g_VboHandle = 0;
-
-    glDetachShader(g_ShaderHandle, g_VertHandle);
-    glDeleteShader(g_VertHandle);
-    g_VertHandle = 0;
-
-    glDetachShader(g_ShaderHandle, g_FragHandle);
-    glDeleteShader(g_FragHandle);
-    g_FragHandle = 0;
-
-    glDeleteProgram(g_ShaderHandle);
-    g_ShaderHandle = 0;
-
-    if (g_FontTexture)
-    {
-        glDeleteTextures(1, &g_FontTexture);
-        ImGui::GetIO().Fonts->TexID = 0;
-        g_FontTexture = 0;
-    }
-    ImGui::Shutdown();
-}
-
-void ImGui_ImplGlfwGL3_NewFrame()
-{
-    if (!g_FontTexture)
-        ImGui_ImplGlfwGL3_CreateDeviceObjects();
-
-    ImGuiIO& io = ImGui::GetIO();
-
-    // Setup display size (every frame to accommodate for window resizing)
-    int w, h;
-    int display_w, display_h;
-    glfwGetWindowSize(g_Window, &w, &h);
-    glfwGetFramebufferSize(g_Window, &display_w, &display_h);
-    io.DisplaySize = ImVec2((float)display_w, (float)display_h);
-
-    // Setup time step
-    double current_time =  glfwGetTime();
-    io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
-    g_Time = current_time;
-
-    // Setup inputs
-    // (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
-    if (glfwGetWindowAttrib(g_Window, GLFW_FOCUSED))
-    {
-       double mouse_x, mouse_y;
-       glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
-       mouse_x *= (float)display_w / w;                        // Convert mouse coordinates to pixels
-       mouse_y *= (float)display_h / h;
-       io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);   // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
-    }
-    else
-    {
-       io.MousePos = ImVec2(-1,-1);
-    }
-
-    for (int i = 0; i < 3; i++)
-    {
-        io.MouseDown[i] = g_MousePressed[i] || glfwGetMouseButton(g_Window, i) != 0;    // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
-        g_MousePressed[i] = false;
-    }
-
-    io.MouseWheel = g_MouseWheel;
-    g_MouseWheel = 0.0f;
-
-    // Hide OS mouse cursor if ImGui is drawing it
-    glfwSetInputMode(g_Window, GLFW_CURSOR, io.MouseDrawCursor ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_NORMAL);
-
-    // Start the frame
-    ImGui::NewFrame();
-}
diff --git a/source/gui/imgui_impl_glfw_gl3.h b/source/gui/imgui_impl_glfw_gl3.h
deleted file mode 100644 (file)
index 81b5952..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// ImGui GLFW binding with OpenGL3 + shaders
-// https://github.com/ocornut/imgui
-
-struct GLFWwindow;
-
-bool        ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks);
-void        ImGui_ImplGlfwGL3_Shutdown();
-void        ImGui_ImplGlfwGL3_NewFrame();
-
-// Use if you want to reset your rendering device without losing ImGui state.
-void        ImGui_ImplGlfwGL3_InvalidateDeviceObjects();
-bool        ImGui_ImplGlfwGL3_CreateDeviceObjects();
-
-// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
-// Provided here if you want to chain callbacks.
-// You can also handle inputs yourself and use those as a reference.
-void        ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-void        ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-void        ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-void        ImGui_ImplGlfwGL3_CharCallback(GLFWwindow* window, unsigned int c);
index d6cb8f54a7bab320029547df79d3c541847a72ad..2d14a728461dff8c2901dce6b804ab1d596d8409 100644 (file)
@@ -4,7 +4,7 @@
 
 PMutex::PMutex() {
     m_locked = false;
-#if EMU_PLATFORM == PLATFORM_LINUX
+#if EMU_PLATFORM == PLATFORM_UNIX
     while(pthread_mutex_init(&m_mutex, NULL) != 0);
 #elif EMU_PLATFORM == PLATFORM_WINDOWS
     while((m_mutex = CreateMutex(NULL, FALSE, NULL)) == NULL);
@@ -12,7 +12,7 @@ PMutex::PMutex() {
 }
 
 PMutex::~PMutex() {
-#if EMU_PLATFORM == PLATFORM_LINUX
+#if EMU_PLATFORM == PLATFORM_UNIX
     while(pthread_mutex_destroy(&m_mutex) != 0);
 #elif EMU_PLATFORM == PLATFORM_WINDOWS
     CloseHandle(m_mutex);
@@ -20,7 +20,7 @@ PMutex::~PMutex() {
 }
 
 void PMutex::Lock() {
-#if EMU_PLATFORM == PLATFORM_LINUX
+#if EMU_PLATFORM == PLATFORM_UNIX
     pthread_mutex_lock(&m_mutex);
 #elif EMU_PLATFORM == PLATFORM_WINDOWS
     WaitForSingleObject(m_mutex, INFINITE);
@@ -34,7 +34,7 @@ bool PMutex::IsLocked() {
 
 void PMutex::Unlock() {
     m_locked = false;
-#if EMU_PLATFORM == PLATFORM_LINUX
+#if EMU_PLATFORM == PLATFORM_UNIX
     pthread_mutex_unlock(&m_mutex);
 #elif EMU_PLATFORM == PLATFORM_WINDOWS
     ReleaseMutex(m_mutex);