diff options
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/context_gl_win.cpp | 17 | ||||
-rw-r--r-- | platform/windows/context_gl_win.h | 8 | ||||
-rw-r--r-- | platform/windows/detect.py | 14 | ||||
-rw-r--r-- | platform/windows/export/export.cpp | 28 | ||||
-rw-r--r-- | platform/windows/export/export.h | 31 | ||||
-rw-r--r-- | platform/windows/godot.ico | bin | 370070 -> 370070 bytes | |||
-rw-r--r-- | platform/windows/os_windows.cpp | 138 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 8 | ||||
-rw-r--r-- | platform/windows/packet_peer_udp_winsock.cpp | 28 | ||||
-rw-r--r-- | platform/windows/packet_peer_udp_winsock.h | 28 | ||||
-rw-r--r-- | platform/windows/platform_config.h | 2 |
11 files changed, 281 insertions, 21 deletions
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index ab66b81421..fd9e895370 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -96,6 +96,20 @@ static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { } */ +void ContextGL_Win::set_use_vsync(bool p_use) { + + if (wglSwapIntervalEXT) { + wglSwapIntervalEXT(p_use?1:0); + } + use_vsync=p_use; + +} + +bool ContextGL_Win::is_using_vsync() const { + + return use_vsync; +} + Error ContextGL_Win::initialize() { @@ -184,7 +198,7 @@ Error ContextGL_Win::initialize() { printf("Activated GL 3.1 context"); } - + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress ("wglSwapIntervalEXT"); // glWrapperInit(wrapper_get_proc_address); return OK; @@ -194,6 +208,7 @@ ContextGL_Win::ContextGL_Win(HWND hwnd,bool p_opengl_3_context) { opengl_3_context=p_opengl_3_context; hWnd=hwnd; + use_vsync=false; } ContextGL_Win::~ContextGL_Win() { diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_win.h index 055e0b2f51..e1ab6fb26a 100644 --- a/platform/windows/context_gl_win.h +++ b/platform/windows/context_gl_win.h @@ -49,6 +49,8 @@ #include <windows.h> +typedef bool (APIENTRY *PFNWGLSWAPINTERVALEXTPROC) (int interval); + class ContextGL_Win : public ContextGL { HDC hDC; @@ -56,6 +58,10 @@ class ContextGL_Win : public ContextGL { unsigned int pixel_format; HWND hWnd; bool opengl_3_context; + bool use_vsync; + + + PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; public: @@ -69,6 +75,8 @@ public: virtual Error initialize(); + virtual void set_use_vsync(bool p_use); + virtual bool is_using_vsync() const; ContextGL_Win(HWND hwnd,bool p_opengl_3_context); ~ContextGL_Win(); diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 56e8a5d45d..320fb9d269 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -168,7 +168,7 @@ def get_opts(): def get_flags(): return [ - ('freetype','builtin'), #use builtin freetype + ('glew','yes'), ('openssl','builtin'), #use builtin openssl ] @@ -202,10 +202,6 @@ def configure(env): env.Append(CPPPATH=['#platform/windows/include']) env.Append(LIBPATH=['#platform/windows/lib']) - if (env["freetype"]!="no"): - env.Append(CCFLAGS=['/DFREETYPE_ENABLED']) - env.Append(CPPPATH=['#tools/freetype']) - env.Append(CPPPATH=['#tools/freetype/freetype/include']) if (env["target"]=="release"): @@ -242,7 +238,6 @@ def configure(env): env.Append(CCFLAGS=['/DGLES2_ENABLED']) - env.Append(CCFLAGS=['/DGLEW_ENABLED']) LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid'] env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS]) @@ -350,10 +345,7 @@ def configure(env): env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) - if (env["freetype"]!="no"): - env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) - env.Append(CPPPATH=['#tools/freetype']) - env.Append(CPPPATH=['#tools/freetype/freetype/include']) + env["CC"]=mingw_prefix+"gcc" env['AS']=mingw_prefix+"as" @@ -368,7 +360,7 @@ def configure(env): env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows']) env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) - env.Append(CCFLAGS=['-DGLES2_ENABLED','-DGLEW_ENABLED']) + env.Append(CCFLAGS=['-DGLES2_ENABLED']) env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','shlwapi','wsock32','kernel32', 'oleaut32', 'dinput8', 'dxguid']) # if (env["bits"]=="32"): diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 952f51fdd4..9bf9ba93fe 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* export.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "export.h" #include "platform/windows/logo.h" #include "tools/editor/editor_import_export.h" diff --git a/platform/windows/export/export.h b/platform/windows/export/export.h index 68ce500a20..aa3578fb98 100644 --- a/platform/windows/export/export.h +++ b/platform/windows/export/export.h @@ -1,4 +1,29 @@ - - +/*************************************************************************/ +/* export.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ void register_windows_exporter(); - diff --git a/platform/windows/godot.ico b/platform/windows/godot.ico Binary files differindex e57ce36529..3e52f2e52f 100644 --- a/platform/windows/godot.ico +++ b/platform/windows/godot.ico diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index c9c7780a2a..630d5715e9 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -708,7 +708,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { case WM_SETCURSOR: { if(LOWORD(lParam) == HTCLIENT) { - if(mouse_mode == MOUSE_MODE_HIDDEN) { + if(mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED) { //Hide the cursor if(hCursor == NULL) hCursor = SetCursor(NULL); @@ -724,6 +724,32 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { } } break; + case WM_DROPFILES: { + + HDROP hDropInfo = NULL; + hDropInfo = (HDROP) wParam; + const int buffsize=4096; + wchar_t buf[buffsize]; + + int fcount = DragQueryFileW(hDropInfo, 0xFFFFFFFF,NULL,0); + + Vector<String> files; + + for(int i=0;i<fcount;i++) { + + DragQueryFileW(hDropInfo, i, buf, buffsize); + String file=buf; + files.push_back(file); + } + + if (files.size() && main_loop) { + main_loop->drop_files(files,0); + } + + + } break; + + default: { @@ -748,6 +774,8 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { } + + void OS_Windows::process_key_events() { for(int i=0;i<key_event_pos;i++) { @@ -767,7 +795,7 @@ void OS_Windows::process_key_events() { k.mod=ke.mod_state; k.pressed=true; k.scancode=KeyMappingWindows::get_keysym(ke.wParam); - k.unicode=ke.wParam; + k.unicode=ke.wParam; if (k.unicode && gr_mem) { k.mod.alt=false; k.mod.control=false; @@ -819,6 +847,75 @@ void OS_Windows::process_key_events() { key_event_pos=0; } +enum _MonitorDpiType +{ + MDT_Effective_DPI = 0, + MDT_Angular_DPI = 1, + MDT_Raw_DPI = 2, + MDT_Default = MDT_Effective_DPI +}; + + +static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType= MDT_Default) +{ + + + int dpiX = 96, dpiY = 96; + + static HMODULE Shcore = NULL; + typedef HRESULT (WINAPI* GetDPIForMonitor_t)(HMONITOR hmonitor, _MonitorDpiType dpiType, UINT *dpiX, UINT *dpiY); + static GetDPIForMonitor_t getDPIForMonitor = NULL; + + if (Shcore == NULL) + { + Shcore = LoadLibraryW(L"Shcore.dll"); + getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : NULL; + + if ((Shcore == NULL) || (getDPIForMonitor == NULL)) + { + if (Shcore) + FreeLibrary(Shcore); + Shcore = (HMODULE)INVALID_HANDLE_VALUE; + } + } + + UINT x = 0, y = 0; + HRESULT hr = E_FAIL; + bool bSet = false; + if (hmon && (Shcore != (HMODULE)INVALID_HANDLE_VALUE)) + { + hr = getDPIForMonitor(hmon, dpiType/*MDT_Effective_DPI*/, &x, &y); + if (SUCCEEDED(hr) && (x > 0) && (y > 0)) + { + + dpiX = (int)x; + dpiY = (int)y; + } + } + else + { + static int overallX = 0, overallY = 0; + if (overallX <= 0 || overallY <= 0) + { + HDC hdc = GetDC(NULL); + if (hdc) + { + overallX = GetDeviceCaps(hdc, LOGPIXELSX); + overallY = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(NULL, hdc); + } + } + if (overallX > 0 && overallY > 0) + { + dpiX = overallX; dpiY = overallY; + } + } + + + return (dpiX+dpiY)/2; +} + + BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { OS_Windows *self=(OS_Windows*)OS::get_singleton(); MonitorInfo minfo; @@ -829,6 +926,8 @@ BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPR minfo.rect.size.x=lprcMonitor->right - lprcMonitor->left; minfo.rect.size.y=lprcMonitor->bottom - lprcMonitor->top; + minfo.dpi = QueryDpiForMonitor(hMonitor); + self->monitor_info.push_back(minfo); return TRUE; @@ -1035,6 +1134,8 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ _ensure_data_dir(); + DragAcceptFiles(hWnd,true); + } @@ -1338,6 +1439,14 @@ Size2 OS_Windows::get_screen_size(int p_screen) const{ return Vector2( monitor_info[p_screen].rect.size ); } + +int OS_Windows::get_screen_dpi(int p_screen) const { + + ERR_FAIL_INDEX_V(p_screen,monitor_info.size(),72); + UINT dpix,dpiy; + return monitor_info[p_screen].dpi; + +} Point2 OS_Windows::get_window_position() const{ RECT r; @@ -1725,6 +1834,11 @@ uint64_t OS_Windows::get_unix_time() const { }; uint64_t OS_Windows::get_system_time_secs() const { + + + const uint64_t WINDOWS_TICK = 10000000; + const uint64_t SEC_TO_UNIX_EPOCH = 11644473600LL; + SYSTEMTIME st; GetSystemTime(&st); FILETIME ft; @@ -1733,7 +1847,8 @@ uint64_t OS_Windows::get_system_time_secs() const { ret=ft.dwHighDateTime; ret<<=32; ret|=ft.dwLowDateTime; - return ret; + + return (uint64_t)(ret / WINDOWS_TICK - SEC_TO_UNIX_EPOCH); } void OS_Windows::delay_usec(uint32_t p_usec) const { @@ -2134,7 +2249,7 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const { } String OS_Windows::get_data_dir() const { - String an = Globals::get_singleton()->get("application/name"); + String an = get_safe_application_name(); if (an!="") { if (has_environment("APPDATA")) { @@ -2160,6 +2275,21 @@ String OS_Windows::get_joy_guid(int p_device) const { return input->get_joy_guid_remapped(p_device); } +void OS_Windows::set_use_vsync(bool p_enable) { + + if (gl_context) + gl_context->set_use_vsync(p_enable); +} + +bool OS_Windows::is_vsnc_enabled() const{ + + if (gl_context) + return gl_context->is_using_vsync(); + + return true; +} + + OS_Windows::OS_Windows(HINSTANCE _hInstance) { key_event_pos=0; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index adea26308f..509d76abbf 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -103,7 +103,7 @@ class OS_Windows : public OS { HDC hDC; // Private GDI Device Context HINSTANCE hInstance; // Holds The Instance Of The Application HWND hWnd; - + HCURSOR hCursor; Size2 window_rect; @@ -172,6 +172,7 @@ protected: HMONITOR hMonitor; HDC hdcMonitor; Rect2 rect; + int dpi; }; @@ -213,6 +214,8 @@ public: virtual void set_current_screen(int p_screen); virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; + virtual int get_screen_dpi(int p_screen=0) const; + virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; @@ -280,6 +283,9 @@ public: virtual bool is_joy_known(int p_device); virtual String get_joy_guid(int p_device) const; + virtual void set_use_vsync(bool p_enable); + virtual bool is_vsnc_enabled() const; + OS_Windows(HINSTANCE _hInstance); ~OS_Windows(); diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp index 0ca2d358af..2c79365c08 100644 --- a/platform/windows/packet_peer_udp_winsock.cpp +++ b/platform/windows/packet_peer_udp_winsock.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* packet_peer_udp_winsock.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "packet_peer_udp_winsock.h" #include <winsock2.h> diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h index 34dbcbee91..b24dbac592 100644 --- a/platform/windows/packet_peer_udp_winsock.h +++ b/platform/windows/packet_peer_udp_winsock.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* packet_peer_udp_winsock.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef PACKET_PEER_UDP_WINSOCK_H #define PACKET_PEER_UDP_WINSOCK_H diff --git a/platform/windows/platform_config.h b/platform/windows/platform_config.h index 55f6b5547e..9e20750816 100644 --- a/platform/windows/platform_config.h +++ b/platform/windows/platform_config.h @@ -30,6 +30,6 @@ //#else //#include <alloca.h> //#endif -#define GLES2_INCLUDE_H "gl_context/glew.h" +#define GLES2_INCLUDE_H "gl_context/GL/glew.h" |