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 | 163 | ||||
-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 | 163 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 9 | ||||
-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, 427 insertions, 50 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 1ad0f164d2..320fb9d269 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -1,4 +1,4 @@ -# +# # tested on | Windows native | Linux cross-compilation # ------------------------+-------------------+--------------------------- # MSVS C++ 2010 Express | WORKS | n/a @@ -24,11 +24,11 @@ # ( example : "C:/Mingw-w32", "C:/Mingw-w64" ) # # - if you want to compile faster using the "-j" option, don't forget -# to install the appropriate version of the Pywin32 python extension +# to install the appropriate version of the Pywin32 python extension # available from : http://sourceforge.net/projects/pywin32/files/ # -# - before running scons, you must add into the environment path -# the path to the "/bin" directory of the Mingw version you want +# - before running scons, you must add into the environment path +# the path to the "/bin" directory of the Mingw version you want # to use : # # set PATH=C:/Mingw-w32/bin;%PATH% @@ -37,9 +37,9 @@ # - Mingw-w32 only compiles 32bits. # - Mingw-w64 only compiles 64bits. # -# - it is possible to add them both at the same time into the PATH env, -# if you also define the MINGW32_PREFIX and MINGW64_PREFIX environment -# variables. +# - it is possible to add them both at the same time into the PATH env, +# if you also define the MINGW32_PREFIX and MINGW64_PREFIX environment +# variables. # For instance, you could store that set of commands into a .bat script # that you would run just before scons : # @@ -61,14 +61,14 @@ # # - it is possible to manually override prefixes by defining # the MINGW32_PREFIX and MINGW64_PREFIX environment variables. -# +# ##### # Notes about Mingw under Windows : # -# - this is the MinGW version from http://mingw.org/ +# - this is the MinGW version from http://mingw.org/ # - install it into a path that does not contain spaces # ( example : "C:/MinGW" ) -# - several DirectX headers might be missing. You can copy them into +# - several DirectX headers might be missing. You can copy them into # the C:/MinGW/include" directory from this page : # https://code.google.com/p/mingw-lib/source/browse/trunk/working/avcodec_to_widget_5/directx_include/ # - before running scons, add the path to the "/bin" directory : @@ -84,7 +84,7 @@ # - confirm it works well with other Visual Studio versions. # - update the wiki about the pywin32 extension required for the "-j" option under Windows. # - update the wiki to document MINGW32_PREFIX and MINGW64_PREFIX -# +# import os @@ -93,16 +93,16 @@ import sys def is_active(): return True - + def get_name(): return "Windows" def can_build(): - + if (os.name=="nt"): #building natively on windows! if (os.getenv("VSINSTALLDIR")): - return True + return True else: print("\nMSVC not detected, attempting Mingw.") mingw32 = "" @@ -111,7 +111,7 @@ def can_build(): mingw32 = os.getenv("MINGW32_PREFIX") if ( os.getenv("MINGW64_PREFIX") ) : mingw64 = os.getenv("MINGW64_PREFIX") - + test = "gcc --version > NUL 2>&1" if os.system(test)!= 0 and os.system(mingw32+test)!=0 and os.system(mingw64+test)!=0 : print("- could not detect gcc.") @@ -119,27 +119,27 @@ def can_build(): return False else: print("- gcc detected.") - + return True - + if (os.name=="posix"): mingw = "i586-mingw32msvc-" mingw64 = "x86_64-w64-mingw32-" mingw32 = "i686-w64-mingw32-" - + if (os.getenv("MINGW32_PREFIX")): mingw32=os.getenv("MINGW32_PREFIX") mingw = mingw32 if (os.getenv("MINGW64_PREFIX")): mingw64=os.getenv("MINGW64_PREFIX") - + test = "gcc --version &>/dev/null" if (os.system(mingw+test) == 0 or os.system(mingw64+test) == 0 or os.system(mingw32+test) == 0): return True - + return False - + def get_opts(): mingw="" @@ -149,10 +149,10 @@ def get_opts(): mingw = "i586-mingw32msvc-" mingw32 = "i686-w64-mingw32-" mingw64 = "x86_64-w64-mingw32-" - + if os.system(mingw32+"gcc --version &>/dev/null") != 0 : mingw32 = mingw - + if (os.getenv("MINGW32_PREFIX")): mingw32=os.getenv("MINGW32_PREFIX") mingw = mingw32 @@ -164,14 +164,14 @@ def get_opts(): ('mingw_prefix','Mingw Prefix',mingw32), ('mingw_prefix_64','Mingw Prefix 64 bits',mingw64), ] - + def get_flags(): return [ - ('freetype','builtin'), #use builtin freetype + ('glew','yes'), ('openssl','builtin'), #use builtin openssl ] - + def build_res_file( target, source, env ): cmdbase = "" @@ -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,10 +238,9 @@ 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]) - + env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"]) if (os.getenv("DXSDK_DIR")): DIRECTX_PATH=os.getenv("DXSDK_DIR") @@ -262,7 +257,35 @@ def configure(env): env.Append(CCFLAGS=["/I"+DIRECTX_PATH+"/Include"]) env.Append(LIBPATH=[DIRECTX_PATH+"/Lib/x86"]) env['ENV'] = os.environ; + + # This detection function needs the tools env (that is env['ENV'], not SCons's env), and that is why it's this far bellow in the code + compiler_version_str = detect_visual_c_compiler_version(env['ENV']) + + # Note: this detection/override code from here onward should be here instead of in SConstruct because it's platform and compiler specific (MSVC/Windows) + if(env["bits"] != "default"): + print "Error: bits argument is disabled for MSVC" + print ("Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings)" + +" that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler" + +" will be executed and inform you.") + sys.exit() + + # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt + # that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with) + env["bits"]="32" env["x86_opt_vc"]=True + + print "Detected MSVC compiler: "+compiler_version_str + # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writting)... vc compiler for 64bit can not compile _asm + if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): + env["bits"]="64" + env["x86_opt_vc"]=False + print "Compiled program architecture will be a 64 bit executable (forcing bits=64)." + elif (compiler_version_str=="x86" or compiler_version_str == "amd64_x86"): + print "Compiled program architecture will be a 32 bit executable. (forcing bits=32)." + else: + print "Failed to detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." + if env["bits"]=="64": + env.Append(CCFLAGS=['/D_WIN64']) else: # Workaround for MinGW. See: @@ -304,7 +327,7 @@ def configure(env): # sys.exit(255) if (env["target"]=="release"): - + env.Append(CCFLAGS=['-msse2']) if (env["bits"]=="64"): @@ -319,13 +342,10 @@ def configure(env): env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) elif (env["target"]=="debug"): - + 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" @@ -340,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"): @@ -366,4 +386,67 @@ def configure(env): env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) - +def detect_visual_c_compiler_version(tools_env): + # tools_env is the variable scons uses to call tools that execute tasks, SCons's env['ENV'] that executes tasks... + # (see the SCons documentation for more information on what it does)... + # in order for this function to be well encapsulated i choose to force it to recieve SCons's TOOLS env (env['ENV'] + # and not scons setup environment (env)... so make sure you call the right environment on it or it will fail to detect + # the propper vc version that will be called + + # These is no flag to give to visual c compilers to set the architecture, ie scons bits argument (32,64,ARM etc) + # There are many different cl.exe files that are run, and each one compiles & links to a different architecture + # As far as I know, the only way to figure out what compiler will be run when Scons calls cl.exe via Program() + # is to check the PATH varaible and figure out which one will be called first. Code bellow does that and returns: + # the following string values: + + # "" Compiler not detected + # "amd64" Native 64 bit compiler + # "amd64_x86" 64 bit Cross Compiler for 32 bit + # "x86" Native 32 bit compiler + # "x86_amd64" 32 bit Cross Compiler for 64 bit + + # There are other architectures, but Godot does not support them currently, so this function does not detect arm/amd64_arm + # and similar architectures/compilers + + # Set chosen compiler to "not detected" + vc_chosen_compiler_index = -1 + vc_chosen_compiler_str = "" + + # find() works with -1 so big ifs bellow are needed... the simplest solution, in fact + # First test if amd64 and amd64_x86 compilers are present in the path + vc_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"]+"BIN\\amd64;") + if(vc_amd64_compiler_detection_index > -1): + vc_chosen_compiler_index = vc_amd64_compiler_detection_index + vc_chosen_compiler_str = "amd64" + + vc_amd64_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"]+"BIN\\amd64_x86;") + if(vc_amd64_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index + vc_chosen_compiler_str = "amd64_x86" + + + # Now check the 32 bit compilers + vc_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"]+"BIN;") + if(vc_x86_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_compiler_detection_index + vc_chosen_compiler_str = "x86" + + vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env['VCINSTALLDIR']+"BIN\\x86_amd64;") + if(vc_x86_amd64_compiler_detection_index > -1 + and (vc_chosen_compiler_index == -1 + or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): + vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index + vc_chosen_compiler_str = "x86_amd64" + + # debug help + #print vc_amd64_compiler_detection_index + #print vc_amd64_x86_compiler_detection_index + #print vc_x86_compiler_detection_index + #print vc_x86_amd64_compiler_detection_index + #print "chosen "+str(vc_chosen_compiler_index)+ " | "+str(vc_chosen_compiler_str) + + return vc_chosen_compiler_str 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 9def8d4f9c..630d5715e9 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -55,6 +55,7 @@ #include "shlobj.h" #include <regstr.h> +#include <process.h> static const WORD MAX_CONSOLE_LINES = 1500; @@ -704,6 +705,51 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { joystick->probe_joysticks(); } break; + case WM_SETCURSOR: { + + if(LOWORD(lParam) == HTCLIENT) { + if(mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED) { + //Hide the cursor + if(hCursor == NULL) + hCursor = SetCursor(NULL); + else + SetCursor(NULL); + } + else { + if(hCursor != NULL) { + SetCursor(hCursor); + hCursor = NULL; + } + } + } + + } 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: { @@ -728,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++) { @@ -747,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; @@ -799,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; @@ -809,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; @@ -1015,6 +1134,8 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ _ensure_data_dir(); + DragAcceptFiles(hWnd,true); + } @@ -1210,7 +1331,6 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) { if (mouse_mode==p_mode) return; - ShowCursor(p_mode==MOUSE_MODE_VISIBLE); mouse_mode=p_mode; if (p_mode==MOUSE_MODE_CAPTURED) { RECT clipRect; @@ -1319,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; @@ -1478,7 +1606,7 @@ void OS_Windows::set_window_resizable(bool p_enabled){ if (p_enabled) { SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); } else { - SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE); + SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE); } @@ -1706,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; @@ -1714,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 { @@ -1884,6 +2018,10 @@ Error OS_Windows::kill(const ProcessID& p_pid) { return ret != 0?OK:FAILED; }; +int OS_Windows::get_process_ID() const { + return _getpid(); +} + Error OS_Windows::set_cwd(const String& p_cwd) { if (_wchdir(p_cwd.c_str())!=0) @@ -2111,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")) { @@ -2137,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 3116847daa..509d76abbf 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -104,6 +104,8 @@ class OS_Windows : public OS { HINSTANCE hInstance; // Holds The Instance Of The Application HWND hWnd; + HCURSOR hCursor; + Size2 window_rect; VideoMode video_mode; @@ -170,6 +172,7 @@ protected: HMONITOR hMonitor; HDC hdcMonitor; Rect2 rect; + int dpi; }; @@ -211,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; @@ -245,6 +250,7 @@ public: virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL); virtual Error kill(const ProcessID& p_pid); + virtual int get_process_ID() const; virtual bool has_environment(const String& p_var) const; virtual String get_environment(const String& p_var) const; @@ -277,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" |