diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/dir_access_osx.mm | 4 | ||||
-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/os_windows.cpp | 15 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 3 | ||||
-rw-r--r-- | platform/x11/context_gl_x11.cpp | 38 | ||||
-rw-r--r-- | platform/x11/context_gl_x11.h | 4 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 14 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 3 |
9 files changed, 103 insertions, 3 deletions
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm index 20dc1df8f4..d123c5c648 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/osx/dir_access_osx.mm @@ -319,10 +319,10 @@ size_t DirAccessOSX::get_space_left() { struct statvfs vfs; if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) { - return -1; + return 0; }; - return vfs.f_bfree * vfs.f_bsize; + return (size_t) (vfs.f_bavail * vfs.f_bsize); #else #warning THIS IS BROKEN return 0; 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/os_windows.cpp b/platform/windows/os_windows.cpp index 65ee39f4da..5e3dc438d0 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2269,6 +2269,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 6dd5b78bfd..509d76abbf 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -283,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/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index 9f987e1376..cd325dfc99 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -34,7 +34,9 @@ #include <unistd.h> #include <stdlib.h> +#define GLX_GLXEXT_PROTOTYPES #include <GL/glx.h> +#include <GL/glxext.h> #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 @@ -176,6 +178,41 @@ int ContextGL_X11::get_window_height() { return xwa.height; } +void ContextGL_X11::set_use_vsync(bool p_use) { + static bool setup = false; + static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL; + static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = NULL; + static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL; + + if (!setup) { + setup = true; + String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display)); + if (extensions.find("GLX_EXT_swap_control") != -1) + glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT"); + if (extensions.find("GLX_MESA_swap_control") != -1) + glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA"); + if (extensions.find("GLX_SGI_swap_control") != -1) + glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI"); + } + int val = p_use ? 1:0; + if (glXSwapIntervalMESA) { + glXSwapIntervalMESA(val); + } + else if (glXSwapIntervalSGI) { + glXSwapIntervalSGI(val); + } + else if (glXSwapIntervalEXT) { + GLXDrawable drawable = glXGetCurrentDrawable(); + glXSwapIntervalEXT(x11_display, drawable, val); + } + else return; + use_vsync = p_use; +} +bool ContextGL_X11::is_using_vsync() const { + + return use_vsync; +} + ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context) : x11_window(p_x11_window) { @@ -189,6 +226,7 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,con glx_minor=glx_major=0; p = memnew( ContextGL_X11_Private ); p->glx_context=0; + use_vsync=false; } diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h index c77fb3e333..4474542c0b 100644 --- a/platform/x11/context_gl_x11.h +++ b/platform/x11/context_gl_x11.h @@ -55,6 +55,7 @@ class ContextGL_X11 : public ContextGL { bool direct_render; int glx_minor,glx_major; bool opengl_3_context; + bool use_vsync; public: virtual void release_current(); @@ -65,6 +66,9 @@ public: virtual Error initialize(); + virtual void set_use_vsync(bool p_use); + virtual bool is_using_vsync() const; + ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,const OS::VideoMode& p_default_video_mode,bool p_opengl_3_context); ~ContextGL_X11(); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 66723c0295..b089436a17 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1952,6 +1952,20 @@ String OS_X11::get_joy_guid(int p_device) const { return input->get_joy_guid_remapped(p_device); } +void OS_X11::set_use_vsync(bool p_enable) { + if (context_gl) + return context_gl->set_use_vsync(p_enable); +} + +bool OS_X11::is_vsnc_enabled() const { + + if (context_gl) + return context_gl->is_using_vsync(); + + return true; +} + + void OS_X11::set_context(int p_context) { XClassHint* classHint = NULL; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 1369340b04..311f26d4d3 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -240,6 +240,9 @@ public: virtual void set_context(int p_context); + virtual void set_use_vsync(bool p_enable); + virtual bool is_vsnc_enabled() const; + void run(); OS_X11(); |