diff options
-rw-r--r-- | Editor/EditorMain.cpp | 45 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.cpp | 10 | ||||
-rw-r--r-- | Editor/GUI/EditorWindows.h | 22 | ||||
-rw-r--r-- | Editor/main.cpp | 33 | ||||
-rw-r--r-- | Editor/wog.c | 746 | ||||
-rw-r--r-- | Editor/wog.h | 219 | ||||
-rw-r--r-- | Projects/VisualStudio/Editor/Editor.vcxproj | 10 | ||||
-rw-r--r-- | Projects/VisualStudio/Editor/Editor.vcxproj.filters | 4 | ||||
-rw-r--r-- | Runtime/Math/FloatConversion.h | 4 | ||||
-rw-r--r-- | Runtime/main.cpp | 6 |
10 files changed, 73 insertions, 1026 deletions
diff --git a/Editor/EditorMain.cpp b/Editor/EditorMain.cpp new file mode 100644 index 0000000..d45d08b --- /dev/null +++ b/Editor/EditorMain.cpp @@ -0,0 +1,45 @@ +#include <windows.h>
+#include <vector>
+#include "GUI/EditorWindows.h"
+
+static int MainMessageLoop() +{
+ BOOL returnValue; + MSG msg, lastMsg; + msg.message = WM_NULL; + std::vector<MSG> messages; + PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); + bool isQuitSignaled = msg.message == WM_QUIT; +
+ while (!isQuitSignaled)
+ {
+ MSG msg; + while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + + if (msg.message == WM_QUIT) + isQuitSignaled = true; + + } +
+ }
+
+ return (INT)msg.wParam; +}
+
+int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) +{
+ RegisterWindowClasses();
+
+ ContainnerWindow* wnd = new ContainnerWindow();
+
+ Vector2f min = Vector2f(100, 100);
+ Vector2f max = Vector2f(700, 700);
+ wnd->Init(Rectf(400, 400, 500, 500), ContainnerWindow::kShowMainWindow, min, max);
+
+ MainMessageLoop();
+
+ return 0;
+}
diff --git a/Editor/GUI/EditorWindows.cpp b/Editor/GUI/EditorWindows.cpp index 18f2e3a..00c573a 100644 --- a/Editor/GUI/EditorWindows.cpp +++ b/Editor/GUI/EditorWindows.cpp @@ -14,7 +14,7 @@ void RegisterWindowClasses() {
s_ContainerWindowClassAtom = winutils::RegisterWindowClass(kContainerWindowClassName, ContainnerWindow::ContainerWndProc, CS_HREDRAW | CS_VREDRAW); s_PopupWindowClassAtom = winutils::RegisterWindowClass(kPopupWindowClassName, ContainnerWindow::ContainerWndProc, CS_HREDRAW | CS_VREDRAW | CS_DROPSHADOW);//CS_HREDRAW宽度(水平)变化时重绘、CS_VREDRAW高度(垂直)变化时重绘 - s_GUIViewClassAtom = winutils::RegisterWindowClass(kViewportClassName, Viewport::ViewportWndProc, CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS); + s_GUIViewClassAtom = winutils::RegisterWindowClass(kViewportClassName, GUIView::GUIViewWndProc, CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS); }
LRESULT CALLBACK ContainnerWindow::ContainerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -156,9 +156,15 @@ void ContainnerWindow::Init(Rectf pixelRect, int showMode, const Vector2f& minSi }
-LRESULT CALLBACK Viewport::ViewportWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+//------------------------------------------------------------------------------------------------------------------
+
+LRESULT CALLBACK GUIView::GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
long flag = DefWindowProcW(hWnd, message, wParam, lParam); return flag; } +void GUIView::DoPaint() +{
+ +}
\ No newline at end of file diff --git a/Editor/GUI/EditorWindows.h b/Editor/GUI/EditorWindows.h index ca1c059..a78e163 100644 --- a/Editor/GUI/EditorWindows.h +++ b/Editor/GUI/EditorWindows.h @@ -2,7 +2,7 @@ #define EDITOR_WINDOW_H #include <windows.h> -#include "../../Runtime/Math/Rect.h" +#include "Runtime/Math/Rect.h" void RegisterWindowClasses(); @@ -29,22 +29,24 @@ public: private: HWND m_Window; POINT m_Size; - ShowMode m_ShowMode; - bool m_IsClosing; - bool m_InMenuLoop; - bool m_CloseFromScriptDontShutdown; - Rectf m_InternalRect; - POINT m_MinSize; - POINT m_MaxSize; + ShowMode m_ShowMode; // 窗口类型 + bool m_IsClosing; + bool m_InMenuLoop; + bool m_CloseFromScriptDontShutdown; + Rectf m_InternalRect; + POINT m_MinSize; + POINT m_MaxSize; }; // 窗口内的单个子窗口,是事件相应、绘制、布局的单元 -class Viewport +class GUIView { public: - static LRESULT CALLBACK ViewportWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + static LRESULT CALLBACK GUIViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + + void DoPaint(); private: HWND m_View; diff --git a/Editor/main.cpp b/Editor/main.cpp deleted file mode 100644 index 193a52a..0000000 --- a/Editor/main.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include <windows.h>
-#include "GUI/EditorWindows.h"
-
-int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) -{
- RegisterWindowClasses();
-
- ContainnerWindow* wnd = new ContainnerWindow();
-
- Vector2f min = Vector2f(100, 100);
- Vector2f max = Vector2f(700, 700);
- wnd->Init(Rectf(400, 400, 500, 500), ContainnerWindow::ShowMode::kShowMainWindow, min, max);
-
- while (1)
- {
- MSG msg; - //if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - //{
- // if (msg.message == WM_QUIT) return 0; - // TranslateMessage(&msg); - //}
- if (GetMessage(&msg, NULL, 0U, 0U) != 0) - { - //ResetGfxDeviceIfNeeded(); - TranslateMessage(&msg); - DispatchMessage(&msg); - } -
- }
-
-
- return 0;
-}
diff --git a/Editor/wog.c b/Editor/wog.c deleted file mode 100644 index 29f0810..0000000 --- a/Editor/wog.c +++ /dev/null @@ -1,746 +0,0 @@ -/** -* Copyright (c) 2015~2017 chai(neonum) -* -* This library is free software; you can redistribute it and/or modify it -* under the terms of the MIT license. See LICENSE for details. -*/ - -#include "wog.h" -#include <windows.h> -#include <malloc.h> -#include <stdio.h> -#include <memory.h> -#include <assert.h> - -#if WOG_API == WOG_GL -#include <gl/GL.h> -#include <gl/GLU.h> -#endif - - -#if WOG_API == WOG_GL -/** -* We need opengl32.lib and glu32.lib for using opengl functions on -* windows platform. -*/ -#pragma comment( lib, "opengl32.lib" ) -//#pragma comment( lib, "glu32.lib" ) -#endif - -#define WINDOW_CLASS "WOG_WND" - -#define heap_alloc(T, C) (T*)malloc(sizeof(T)*(C)) -#define stack_alloc(T, C) (T*)alloca(sizeof(T)*(C)) -#define zero_mem(I, L) memset(I, 0, L) - -#define max(a, b) (a < b ? b : a) -#define min(a, b) (a < b ? a : b) -#define clamp(x, minv, maxv) (max(minv, min(x, maxv))) - -static HINSTANCE g_hinstance = NULL; - -typedef struct wog_Window -{ - HWND hwnd; // Window handler - HINSTANCE hInstance; - HDC hdc; // Device Context - HDC mdc; // Memory Device Contexts -#if WOG_API == WOG_GDI - wog_Surface* surface; // render buffer -#endif - int mouse_capture; // mouse capture count -}wog_Window; - -#if WOG_API == WOG_GL -typedef struct wog_GLContext -{ - HGLRC hrc; // Rendering Context -}wog_GLContext; -#endif - -// A mouse capture count is used -void wog_setMouseCapture(wog_Window* wnd) -{ - if (wnd->mouse_capture <= 0) - { - SetCapture(wnd->hwnd); - wnd->mouse_capture = 0; - } - ++wnd->mouse_capture; -} - -void wog_releaseMouseCapture(wog_Window* wnd) -{ - --wnd->mouse_capture; - if (wnd->mouse_capture <= 0) - ReleaseCapture(); -} - -void wog_handleEvent(wog_Window* window, MSG* msg, wog_Event* e) -{ - UINT uMsg; - WPARAM wParam; - LPARAM lParam; - uMsg = msg->message; - wParam = msg->wParam; - lParam = msg->lParam; - HWND hWnd = window->hwnd; - - switch (uMsg) - { - case WM_SYSCOMMAND: - { - switch (wParam) - { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return ; - } - break; - } - return ; - - case WM_CLOSE: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_ECLOSE; - return ; - } - - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - if ((wParam >= 0) && (wParam <= 255)) - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EKEYDOWN; - e->key = wParam; - - return ; - } - break; - - case WM_KEYUP: - case WM_SYSKEYUP: - if ((wParam >= 0) && (wParam <= 255)) - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EKEYUP; - e->key = wParam; - - return ; - } - break; - - case WM_MOUSEMOVE: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEMOTION; - wog_getMouse(window, &e->pos.x, &e->pos.y); - return ; - } - - case WM_MOUSEWHEEL: // mousewheel scroll - { - int zDelta = GET_WHEEL_DELTA_WPARAM(wParam); - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEWHEEL; - e->wheel = zDelta > 0 ? 1 : -1; - return ; - } - - case WM_LBUTTONDOWN: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEBUTTONDOWN; - e->button = WOG_MOUSE_LBUTTON; - wog_getMouse(window, &e->pos.x, &e->pos.y); - wog_setMouseCapture(window); - return ; - } - - case WM_RBUTTONDOWN: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEBUTTONDOWN; - e->button = WOG_MOUSE_RBUTTON; - wog_getMouse(window, &e->pos.x, &e->pos.y); - wog_setMouseCapture(window); - return ; - } - - case WM_MBUTTONDOWN: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEBUTTONDOWN; - e->button = WOG_MOUSE_MIDDLE; - wog_getMouse(window, &e->pos.x, &e->pos.y); - wog_setMouseCapture(window); - return ; - } - - case WM_LBUTTONUP: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEBUTTONUP; - e->button = WOG_MOUSE_LBUTTON; - wog_getMouse(window, &e->pos.x, &e->pos.y); - wog_releaseMouseCapture(window); - return ; - } - - case WM_RBUTTONUP: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEBUTTONUP; - e->button = WOG_MOUSE_RBUTTON; - wog_getMouse(window, &e->pos.x, &e->pos.y); - wog_releaseMouseCapture(window); - return ; - } - - case WM_MBUTTONUP: - { - zero_mem(e, sizeof(wog_Event)); - e->type = WOG_EMOUSEBUTTONUP; - e->button = WOG_MOUSE_MIDDLE; - wog_getMouse(window, &e->pos.x, &e->pos.y); - wog_releaseMouseCapture(window); - return ; - } - - case WM_PAINT: - - UpdateWindow(window->hwnd); - - return 0; - - break; - - default: - e->type = WOG_EUNKNOWN; - break; - } - DefWindowProc(hWnd, uMsg, wParam, lParam); - return ; -} - - -int wog_pollEvent(wog_Window* wnd, wog_Event* e) -{ - MSG msg; - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - if (msg.message == WM_QUIT) return 0; - TranslateMessage(&msg); - wog_handleEvent(wnd, &msg, e); - return 1; - } - return 0; -} - - -// on size changed callback; -static wog_Callback onSizeChanged = 0; -static wog_Callback onQuit = 0; - - -static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - // Get The Window Context - wog_Window* window = (wog_Window*)(GetWindowLong(hWnd, GWLP_WNDPROC)); - - // call callback functions -#define call(callback)\ - if (callback) \ - callback(window) - - switch (uMsg) - { - case WM_CREATE: - { - CREATESTRUCT* creation = (CREATESTRUCT*)(lParam); // Store Window Structure Pointer - window = (wog_Window*)(creation->lpCreateParams); // Get wog_Window - SetWindowLong(hWnd, GWLP_WNDPROC, (LONG)(window)); // Save it - } - return 0; - - case WM_CLOSE: // Post WM_CLOSE to message queue. - PostMessage(hWnd, WM_CLOSE, wParam, lParam); - return 0; - - case WM_SIZE: - call(onSizeChanged); - return 0; - - case WM_QUIT: - call(onQuit); - return 0; - - } - - return DefWindowProc(hWnd, uMsg, wParam, lParam); -#undef call -} - - -void wog_registerResizeCallback(wog_Callback cal) -{ - onSizeChanged = cal; -} - - -void wog_registerQuitCallback(wog_Callback cal) -{ - onQuit = cal; -} - -#if WOG_API == WOG_GDI -wog_Surface* wog_getsurface(wog_Window* wnd) { - return wnd->surface; -} -#endif - -static int registerWindowClass() -{ - // Register A Window Class - WNDCLASSEX windowClass; // Window Class - zero_mem(&windowClass, sizeof(WNDCLASSEX)); // Make Sure Memory Is Cleared - - windowClass.cbSize = sizeof(WNDCLASSEX); // Size Of The windowClass Structure - windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraws The Window For Any Movement / Resizing - windowClass.lpfnWndProc = (WNDPROC)(WindowProc); // WindowProc Handles Messages - windowClass.hInstance = g_hinstance; // Set The Instance - windowClass.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE); // Class Background Brush Color - windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer - windowClass.lpszClassName = WINDOW_CLASS; // Sets The Applications Classname - //windowClass.hIcon = (HICON)LoadIcon(g_hinstance, "icon.ico"); - - if (RegisterClassEx(&windowClass) == 0) // Did Registering The Class Fail? - { - // NOTE: Failure, Should Never Happen - MessageBox(HWND_DESKTOP, "RegisterClassEx Failed!", "Error", MB_OK | MB_ICONEXCLAMATION); - return FALSE; // Return False (Failure) - } - return TRUE; -} - -/* - * for memory device context, see - * https://docs.microsoft.com/en-us/windows/desktop/gdi/memory-device-contexts - * also - * SDL_windowsframebuffer.c WIN_CreateWindowFramebuffer - */ -static void create_surface(wog_Window* wnd, int width, int height) { - BITMAPINFOHEADER bi_header; - HDC memory_dc; - HBITMAP dib_bitmap; - HBITMAP old_bitmap; - unsigned char *buffer; // color buffer - wog_Surface *surface; - - memory_dc = CreateCompatibleDC(wnd->hdc); /*memory device contexts*/ - - memset(&bi_header, 0, sizeof(BITMAPINFOHEADER)); - bi_header.biSize = sizeof(BITMAPINFOHEADER); - bi_header.biWidth = width; - bi_header.biHeight = -height; /* top-down */ - bi_header.biPlanes = 1; - bi_header.biBitCount = 32; - bi_header.biCompression = BI_RGB; - /*create bitmap*/ - dib_bitmap = CreateDIBSection(memory_dc, (BITMAPINFO*)&bi_header, DIB_RGB_COLORS, (void**)&buffer, NULL, 0); - assert(dib_bitmap != NULL); - old_bitmap = (HBITMAP)SelectObject(memory_dc, dib_bitmap); - DeleteObject(old_bitmap); - - surface = (wog_Surface*)malloc(sizeof(wog_Surface)); - surface->width = width; - surface->height = height; - surface->channels = 4; - surface->buffer = buffer; - -#if WOG_API == WOG_GDI - wnd->surface = surface; -#endif - wnd->mdc = memory_dc; -} - - -wog_Window* wog_createWindow(const char* title, int width, int height, int x, int y, uint32 flags) -{ - int client_w = width, client_h = height; - - if (g_hinstance == NULL) - { - g_hinstance = GetModuleHandle(NULL); - } - - if (! registerWindowClass()) - { - printf("Register window class failed.\n"); - return 0; - } - - wog_Window* wnd = heap_alloc(wog_Window, 1); - zero_mem(wnd, sizeof(wog_Window)); - - DWORD windowStyle = 0; // Define Our Window Style - windowStyle |= WS_POPUP; - windowStyle |= WS_OVERLAPPED; - windowStyle |= WS_CAPTION; - windowStyle |= WS_SYSMENU; - windowStyle |= WS_MINIMIZEBOX; - windowStyle |= WS_MAXIMIZEBOX; - //windowStyle |= WS_VISIBLE; -#define hasbit(fs, f) ((fs & f) == f) - /*if (hasbit(flags, WOG_RESIZABLE)) */windowStyle |= WS_SIZEBOX; - if (hasbit(flags, WOG_DISABLE)) windowStyle |= WS_DISABLED; - - DWORD windowExtendedStyle = WS_EX_APPWINDOW; // Define The Window's Extended Style - RECT windowRect = { 0, 0, width, height }; - AdjustWindowRectEx(&windowRect, windowStyle, 0, windowExtendedStyle); - width = windowRect.right - windowRect.left; - height = windowRect.bottom - windowRect.top; - wnd->hwnd = CreateWindowEx( - windowExtendedStyle, - WINDOW_CLASS, - title, - windowStyle, - x, y, - width, height, - HWND_DESKTOP, - 0, - GetModuleHandle(NULL), - wnd - ); - - wnd->hInstance = g_hinstance; - - if (wnd->hwnd == 0) - return 0; - - if (hasbit(flags, WOG_HIDDEN)) wog_hide(wnd); - - // init device context - wnd->hdc = GetDC(wnd->hwnd); - if (wnd->hdc== 0) - { - DestroyWindow(wnd->hwnd); - wnd->hwnd = 0; - return 0; - } - - wnd->mouse_capture = 0; - -#if WOG_API == WOG_GDI - create_surface(wnd, client_w, client_h); -#endif - -#if WOG_API == WOG_GL - PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be - { - sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor - 1, // Version Number - PFD_DRAW_TO_WINDOW | // Format Must Support Window - PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - PFD_DOUBLEBUFFER, // Must Support Double Buffering - PFD_TYPE_RGBA, // Request An RGBA Format - 32, // Select Our Color Depth - 0, 0, 0, 0, 0, 0, // Color Bits Ignored - 0, // No Alpha Buffer - 0, // Shift Bit Ignored - 0, // No Accumulation Buffer - 0, 0, 0, 0, // Accumulation Bits Ignored - 16, // 16Bit Z-Buffer (Depth Buffer) - 0, // No Stencil Buffer - 0, // No Auxiliary Buffer - PFD_MAIN_PLANE, // Main Drawing Layer - 0, // Reserved - 0, 0, 0 // Layer Masks Ignored - }; - // set pixel format - unsigned int pixelformat; - pixelformat = ChoosePixelFormat(wnd->hdc, &pfd); - if (pixelformat == 0) - { - wog_destroyWindow(wnd); - return 0; - } - - // set pixel format - if (SetPixelFormat(wnd->hdc, pixelformat, &pfd) == 0 ) - { - wog_destroyWindow(wnd); - return 0; - } -#endif - - return wnd; -} - -#if WOG_API == WOG_GL -wog_GLContext* wog_createGLContext(wog_Window* wnd) -{ - wog_GLContext* cxt = heap_alloc(wog_GLContext, 1); - zero_mem(cxt, sizeof(wog_GLContext)); - cxt->hrc = wglCreateContext(wnd->hdc); // create opengl context base on device context - if (cxt->hrc == 0) - { - free(cxt); - return 0; - } - return cxt; -} -#endif - -#if WOG_API == WOG_GL -int wog_makeCurrent(wog_Window* wnd, wog_GLContext* cxt) -{ - if (wnd && cxt) - { - if (wglMakeCurrent(wnd->hdc, cxt->hrc) == 0) - { - return 0; - } - return 1; - } - - return 0; -} -#endif - -#if WOG_API == WOG_GL -void wog_destroyGLContext(wog_GLContext* cxt) -{ - if (cxt && cxt->hrc) - { - wglDeleteContext(cxt->hrc); - free(cxt); - } -} -#endif - -#if WOG_API == WOG_GDI -void wog_updateSurface(wog_Window* wnd) { - if(wnd->surface == NULL) return ; - int width = wnd->surface->width, height = wnd->surface->height; - BitBlt(wnd->hdc, 0, 0, wnd->surface, height, wnd->mdc, 0, 0, SRCCOPY); -} -#endif - -void wog_destroyWindow(wog_Window* wnd) -{ - if (wnd) - { - ReleaseDC(wnd->hwnd, wnd->hdc); - DestroyWindow(wnd->hwnd); - free(wnd); - } -} - - -static void UnEscapeQuotes(char *arg) -{ - char *last = NULL; - - while (*arg) { - if (*arg == '"' && *last == '\\') { - char *c_curr = arg; - char *c_last = last; - - while (*c_curr) { - *c_last = *c_curr; - c_last = c_curr; - c_curr++; - } - *c_last = '\0'; - } - last = arg; - arg++; - } -} - - -/* Parse a command line buffer into arguments */ -static int ParseCommandLine(char *cmdline, char **argv) -{ - char *bufp; - char *lastp = NULL; - int argc, last_argc; - - argc = last_argc = 0; - for (bufp = cmdline; *bufp; ) { - /* Skip leading whitespace */ - while (isspace(*bufp)) { - ++bufp; - } - /* Skip over argument */ - if (*bufp == '"') { - ++bufp; - if (*bufp) { - if (argv) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while (*bufp && (*bufp != '"' || (lastp && *lastp == '\\'))) { - lastp = bufp; - ++bufp; - } - } - else { - if (*bufp) { - if (argv) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while (*bufp && !isspace(*bufp)) { - ++bufp; - } - } - if (*bufp) { - if (argv) { - *bufp = '\0'; - } - ++bufp; - } - - /* Strip out \ from \" sequences */ - if (argv && last_argc != argc) { - UnEscapeQuotes(argv[last_argc]); - } - last_argc = argc; - } - if (argv) { - argv[argc] = NULL; - } - return(argc); -} - - -#ifdef main -#undef main -#endif - - -#if defined(_MSC_VER) && !defined(_WIN32_WCE) -/* The VC++ compiler needs main defined */ -#define console_main main -#endif - -//extern int wog_main(int argc, char* argv[]); - -/** -* Entry of console application. -*/ -//int console_main(int argc, char* argv[]) -//{ -// int status = wog_main(argc, argv); -// return status; -//} - - -/** -* Entry of windows application. -*/ -//int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) -//{ -// g_hinstance = hInst; -// -// char* temp = GetCommandLine(); -// int len = strlen(temp) + 1; -// char* cmd = stack_alloc(char, len); -// strcpy(cmd, temp); -// cmd[len - 1] = '\0'; -// -// int argc = 0; -// char** argv = 0; -// argc = ParseCommandLine(cmd, 0); -// ParseCommandLine(cmd, 0); -// argv = stack_alloc(char*, argc + 1); -// ParseCommandLine(cmd, argv); -// -// int status = console_main(argc, argv); -// -// return status; -//} - - -void wog_swapBuffers(wog_Window* wnd) -{ - if (wnd) - { - SwapBuffers(wnd->hdc); - } -} - - -void wog_getMouse(wog_Window* wnd, int *x, int *y) -{ - POINT p; - GetCursorPos(&p); - ScreenToClient(wnd->hwnd, &p); - int w, h; - wog_getwindowsize(wnd, &w, &h); - //*x = clamp(p.x, 0, w); - //*y = clamp(p.y, 0, h); - *x = p.x; - *y = p.y; -} - - -void wog_getwindowsize(wog_Window* wnd, int* width, int* height) -{ - RECT r; - GetClientRect(wnd->hwnd, &r); - *width = r.right; - *height = r.bottom; -} - - -void wog_show(wog_Window* wnd) -{ - ShowWindow(wnd->hwnd, SW_SHOW); -} - - -void wog_hide(wog_Window* wnd) -{ - ShowWindow(wnd->hwnd, SW_HIDE); -} - - -void wog_sleep(int ms) -{ - Sleep(ms); -} - -int wog_tick() -{ - return GetTickCount(); -} - - -void wog_setcursor(wog_Window* wnd, unsigned int cursor) -{ - SetCursor(LoadCursor(NULL, cursor)); -} - -//void wog_setcursorImage(wog_Window* wnd, const char* path) -//{ -// SetCursor(LoadImageA(NULL, path, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE)); -// printf("wog_setcursorImage\n"); -//} - -void wog_setcursorImage(wog_Window* wnd, Wog_Cursor icon) -{ - SetCursor(icon); -} - -HINSTANCE wog_get_instance() -{ - return g_hinstance; -} diff --git a/Editor/wog.h b/Editor/wog.h deleted file mode 100644 index f5661db..0000000 --- a/Editor/wog.h +++ /dev/null @@ -1,219 +0,0 @@ -/* -* Copyright (c) 2015~2020 chai -*/ - -#ifndef _WOG_H -#define _WOG_H -#include <Windows.h> // for virtual key value - -#define WOG_GL 1 -#define WOG_GDI 2 - -#define WOG_API WOG_GL - -typedef unsigned int uint32; -typedef unsigned short uint16; - -enum // event type -{ - WOG_EUNKNOWN = 0, // unknown event - - WOG_EKEYDOWN, // key pressed - WOG_EKEYUP, // key released - - WOG_EMOUSEMOTION, // mouse motion - WOG_EMOUSEWHEEL, // mouse wheel scrolling - WOG_EMOUSEBUTTONDOWN, // mosue button down - WOG_EMOUSEBUTTONUP, // mosue button down - - WOG_ECLOSE, // close window -}; - -enum // mouse button event, e.button value -{ - WOG_MOUSE_LBUTTON, // left mouse button - WOG_MOUSE_RBUTTON, // right mouse button - WOG_MOUSE_MIDDLE, // middle button -}; - -typedef struct wog_Event -{ - int type; - //union // event value - //{ - int key; // for key, simply use windows virtual key value - // see https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx - struct // for mouse motion - { - int x, y; // mouse position - }pos; - int wheel; // 1 indicate scroll up and -1 indicate scrool down - int button; // mouse button - //}; -}wog_Event; - -//* VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39) - //* 0x40 : unassigned - //* VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) - -//定义数据字符0~9 -#define VK_0 0x30 -#define VK_1 0x31 -#define VK_2 0x32 -#define VK_3 0x33 -#define VK_4 0x34 -#define VK_5 0x35 -#define VK_6 0x36 -#define VK_7 0x37 -#define VK_8 0x38 -#define VK_9 0x39 - -//定义数据字符A~Z -#define VK_A 0x41 -#define VK_B 0x42 -#define VK_C 0x43 -#define VK_D 0x44 -#define VK_E 0x45 -#define VK_F 0x46 -#define VK_G 0x47 -#define VK_H 0x48 -#define VK_I 0x49 -#define VK_J 0x4A -#define VK_K 0x4B -#define VK_L 0x4C -#define VK_M 0x4D -#define VK_N 0x4E -#define VK_O 0x4F -#define VK_P 0x50 -#define VK_Q 0x51 -#define VK_R 0x52 -#define VK_S 0x53 -#define VK_T 0x54 -#define VK_U 0x55 -#define VK_V 0x56 -#define VK_W 0x57 -#define VK_X 0x58 -#define VK_Y 0x59 -#define VK_Z 0x5A - -//定义数据字符a~z -#define VK_a 0x61 -#define VK_b 0x62 -#define VK_c 0x63 -#define VK_d 0x64 -#define VK_e 0x65 -#define VK_f 0x66 -#define VK_g 0x67 -#define VK_h 0x68 -#define VK_i 0x69 -#define VK_j 0x6A -#define VK_k 0x6B -#define VK_l 0x6C -#define VK_m 0x6D -#define VK_n 0x6E -#define VK_o 0x6F -#define VK_p 0x70 -#define VK_q 0x71 -#define VK_r 0x72 -#define VK_s 0x73 -#define VK_t 0x74 -#define VK_u 0x75 -#define VK_v 0x76 -#define VK_w 0x77 -#define VK_x 0x78 -#define VK_y 0x79 -#define VK_z 0x7A - -typedef struct { - int width, height, channels; - unsigned char* buffer; -} wog_Surface; - -/** -* Entry of user program which defined in user project. You need provide -* this function's defination. -*/ -#define main wog_main -extern int wog_main(int argc, char* argv[]); - -typedef struct wog_Window wog_Window; - -#if WOG_API == WOG_GL -/** -* Struct that hold opengl context generated by wglCreateContext() which -* defined in opengl32.lib -*/ -typedef struct wog_GLContext wog_GLContext; -#endif - -enum // window style flag -{ - WOG_HIDDEN = 4, - WOG_RESIZABLE = 8, - WOG_DISABLE = 16, -}; - -/** -* Create window with given configures. -* flag would be: -* WOG_HIDDEN -* WOG_RESIZABLE -* WOG_DISABLE -* or just 0; -*/ -wog_Window* wog_createWindow(const char* title, int width, int height, int x, int y, uint32 flags); - -#if WOG_API == WOG_GL -wog_GLContext* wog_createGLContext(wog_Window* wnd); - -int wog_makeCurrent(wog_Window* wnd, wog_GLContext* cxt); - -void wog_destroyGLContext(wog_GLContext* cxt); -#endif - -void wog_destroyWindow(wog_Window* wnd); - -#if WOG_API == WOG_GL -void wog_swapBuffers(wog_Window* wnd); -#endif - -#if WOG_API == WOG_GDI -void wog_updateSurface(wog_Window* wnd); -#endif - -int wog_pollEvent(wog_Window* wnd, wog_Event* e); - -void wog_getMouse(wog_Window* wnd, int *x, int *y); - -// get current ticks -int wog_tick(); - -void wog_sleep(int ms); - -void wog_getwindowsize(wog_Window* wnd, int* width, int* height); - -void wog_show(wog_Window* wnd); - -void wog_hide(wog_Window* wnd); - -typedef void(*wog_Callback)(wog_Window* wnd) ; - -/** -* Register callback functions. -*/ -void wog_registerResizeCallback(wog_Callback cal); -void wog_registerQuitCallback(wog_Callback cal); - -wog_Surface* wog_getsurface(wog_Window* wnd); - -void wog_setcursor(wog_Window* wnd, unsigned int cursor); -//void wog_setcursorImage(wog_Window* wnd, const char* path); -typedef HANDLE Wog_Cursor; -void wog_setcursorImage(wog_Window* wnd, Wog_Cursor icon); - -void wog_setMouseCapture(wog_Window* wnd); -void wog_releaseMouseCapture(wog_Window* wnd); - -HINSTANCE wog_get_instance(); - -#endif
\ No newline at end of file diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj b/Projects/VisualStudio/Editor/Editor.vcxproj index 3d76a3e..5cc1f52 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj +++ b/Projects/VisualStudio/Editor/Editor.vcxproj @@ -88,7 +88,7 @@ <SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\GameLab\ThirdParty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -101,7 +101,7 @@ <SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\GameLab\ThirdParty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -116,6 +116,7 @@ <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -131,6 +132,7 @@ <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -143,8 +145,7 @@ <ClCompile Include="..\..\..\Editor\GUI\EditorWindows.cpp" />
<ClCompile Include="..\..\..\Editor\GUI\MenuController.cpp" />
<ClCompile Include="..\..\..\Editor\GUI\WinUtils.cpp" />
- <ClCompile Include="..\..\..\Editor\main.cpp" />
- <ClCompile Include="..\..\..\Editor\wog.c" />
+ <ClCompile Include="..\..\..\Editor\EditorMain.cpp" />
<ClCompile Include="..\..\..\Runtime\Math\Vector2.cpp" />
<ClCompile Include="..\..\..\Runtime\Math\Vector3.cpp" />
<ClCompile Include="..\..\..\Runtime\Utilities\Base64.cpp" />
@@ -155,7 +156,6 @@ <ClInclude Include="..\..\..\Editor\GUI\EditorWindows.h" />
<ClInclude Include="..\..\..\Editor\GUI\MenuController.h" />
<ClInclude Include="..\..\..\Editor\GUI\WinUtils.h" />
- <ClInclude Include="..\..\..\Editor\wog.h" />
<ClInclude Include="..\..\..\Runtime\Math\AABB.h" />
<ClInclude Include="..\..\..\Runtime\Math\FloatConversion.h" />
<ClInclude Include="..\..\..\Runtime\Math\Rect.h" />
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters index ff49931..606b1c8 100644 --- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters +++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters @@ -18,8 +18,6 @@ <ClCompile Include="..\..\..\Editor\GUI\Dock.cpp">
<Filter>GUI</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\Editor\main.cpp" />
- <ClCompile Include="..\..\..\Editor\wog.c" />
<ClCompile Include="..\..\..\Editor\GUI\EditorWindows.cpp">
<Filter>GUI</Filter>
</ClCompile>
@@ -38,6 +36,7 @@ <ClCompile Include="..\..\..\Runtime\Utilities\Utf8.cpp">
<Filter>Utilities</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\Editor\EditorMain.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\Editor\GUI\MenuController.h">
@@ -46,7 +45,6 @@ <ClInclude Include="..\..\..\Editor\GUI\Dock.h">
<Filter>GUI</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\Editor\wog.h" />
<ClInclude Include="..\..\..\Editor\GUI\EditorWindows.h">
<Filter>GUI</Filter>
</ClInclude>
diff --git a/Runtime/Math/FloatConversion.h b/Runtime/Math/FloatConversion.h index 4077415..e5c0f23 100644 --- a/Runtime/Math/FloatConversion.h +++ b/Runtime/Math/FloatConversion.h @@ -6,8 +6,8 @@ #include <limits> #include <math.h> -#include "../../Runtime/Utilities/Type.h" -#include "../../Runtime/Utilities/Assert.h" +#include "Runtime/Utilities/Type.h" +#include "Runtime/Utilities/Assert.h" #if defined(SN_TARGET_PS3) # include <ppu_intrinsics.h> diff --git a/Runtime/main.cpp b/Runtime/main.cpp deleted file mode 100644 index 8e8dba0..0000000 --- a/Runtime/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "SDL2/SDL.h" - -int main(int argn, char* args[]) -{ - return 0; -} |