aboutsummaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-05-23 23:38:28 +0200
committerStapleButter <thetotalworm@gmail.com>2017-05-23 23:38:28 +0200
commit4b3caedbe7191ca1dc25304b3dc1c8b2e466730d (patch)
treeb8a498c08214a59ea31e91e8dc17f7ae5c2bf84c /src/wx
parent88d982b7e3138f6f6dc7ce8780375e99c3e360e9 (diff)
first attempt at threading the 3D renderer
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/Platform.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/wx/Platform.cpp b/src/wx/Platform.cpp
index 61aa96e..1fb4373 100644
--- a/src/wx/Platform.cpp
+++ b/src/wx/Platform.cpp
@@ -21,6 +21,11 @@
#include <string.h>
#include "../Platform.h"
+#include <wx/wxprec.h>
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
#ifdef __WXMSW__
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -46,6 +51,29 @@ namespace Platform
{
+class Thread : public wxThread
+{
+public:
+ Thread(void (*func)())
+ : wxThread(wxTHREAD_JOINABLE)
+ {
+ this->Func = func;
+ }
+
+ ~Thread() {}
+
+protected:
+ virtual ExitCode Entry()
+ {
+ Func();
+ return (ExitCode)0;
+ }
+
+private:
+ void (*Func)();
+};
+
+
socket_t MPSocket;
sockaddr_t MPSendAddr;
u8 PacketBuffer[2048];
@@ -53,6 +81,45 @@ u8 PacketBuffer[2048];
#define NIFI_VER 1
+void* Thread_Create(void (*func)())
+{
+ Thread* ret = new Thread(func);
+ ret->Run();
+ return (void*)ret;
+}
+
+void Thread_Free(void* thread)
+{
+ delete (Thread*)thread;
+}
+
+void Thread_Wait(void* thread)
+{
+ ((Thread*)thread)->Wait();
+}
+
+
+void* Semaphore_Create()
+{
+ return (void*)new wxSemaphore();
+}
+
+void Semaphore_Free(void* sema)
+{
+ delete (wxSemaphore*)sema;
+}
+
+void Semaphore_Wait(void* sema)
+{
+ ((wxSemaphore*)sema)->Wait();
+}
+
+void Semaphore_Post(void* sema)
+{
+ ((wxSemaphore*)sema)->Post();
+}
+
+
bool MP_Init()
{
int opt_true = 1;