diff --git a/src/framework/platform.h b/src/framework/platform.h index 60bf7727..054f81c6 100644 --- a/src/framework/platform.h +++ b/src/framework/platform.h @@ -46,8 +46,11 @@ namespace Platform void setWindowTitle(const char *title); bool isWindowFocused(); bool isWindowVisible(); + int getWindowX(); + int getWindowY(); int getWindowWidth(); int getWindowHeight(); + bool isWindowMaximized(); /// Get GL extension function address void *getExtensionProcAddress(const char *ext); diff --git a/src/framework/win32platform.cpp b/src/framework/win32platform.cpp index 799303fb..db05102f 100644 --- a/src/framework/win32platform.cpp +++ b/src/framework/win32platform.cpp @@ -24,6 +24,8 @@ #include "platform.h" #include "engine.h" +#include +#include #include LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -231,20 +233,23 @@ void *Platform::getExtensionProcAddress(const char *ext) bool Platform::isExtensionSupported(const char *ext) { - const char *exts = NULL;//glXQueryExtensionsString(x11.display, DefaultScreen(x11.display)); + typedef const char* _wglGetExtensionsStringARB(HDC hdc); + _wglGetExtensionsStringARB *wglGetExtensionsStringARB = (_wglGetExtensionsStringARB*)getExtensionProcAddress("wglGetExtensionsStringARB"); + + const char *exts = wglGetExtensionsStringARB(win32.hdc); if(strstr(exts, ext)) return true; - return true; + return false; } -void Platform::showMouseCursor() +void Platform::hideMouseCursor() { ShowCursor(false); - /*XUndefineCursor(x11.display, x11.window); - if(x11.cursor != None) { - XFreeCursor(x11.display, x11.cursor); - x11.cursor = None; - }*/ +} + +void Platform::showMouseCursor() +{ + ShowCursor(true); } void Platform::setVsync(bool enable) @@ -252,10 +257,8 @@ void Platform::setVsync(bool enable) typedef GLint (*glSwapIntervalProc)(GLint); glSwapIntervalProc glSwapInterval = NULL; - if(isExtensionSupported("GLX_MESA_swap_control")) - glSwapInterval = (glSwapIntervalProc)getExtensionProcAddress("glXSwapIntervalMESA"); - else if(isExtensionSupported("GLX_SGI_swap_control")) - glSwapInterval = (glSwapIntervalProc)getExtensionProcAddress("glXSwapIntervalSGI"); + if(isExtensionSupported("WGL_EXT_swap_control")) + glSwapInterval = (glSwapIntervalProc)getExtensionProcAddress("wglSwapIntervalEXT"); if(glSwapInterval) glSwapInterval(enable ? 1 : 0); @@ -266,6 +269,16 @@ void Platform::swapBuffers() SwapBuffers(win32.hdc); } +int Platform::getWindowX() +{ + return win32.x; +} + +int Platform::getWindowY() +{ + return win32.y; +} + int Platform::getWindowWidth() { return win32.width; @@ -276,14 +289,18 @@ int Platform::getWindowHeight() return win32.height; } +bool Platform::isWindowMaximized() +{ + return win32.maximized; +} + const char *Platform::getAppUserDir(const char *appName) { - /*std::stringstream sdir; - sdir << PHYSFS_getUserDir() << "/." << APP_NAME << "/"; - if((mkdir(sdir.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) && (errno != EEXIST)) + std::stringstream sdir; + sdir << PHYSFS_getUserDir() << "/." << appName << "/"; + if((mkdir(sdir.str().c_str()) != 0) && (errno != EEXIST)) error("Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str()); - return sdir.str().c_str();*/ - return "lol"; + return sdir.str().c_str(); } LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) diff --git a/src/framework/x11platform.cpp b/src/framework/x11platform.cpp index 5e3172de..fcdc8610 100644 --- a/src/framework/x11platform.cpp +++ b/src/framework/x11platform.cpp @@ -596,7 +596,7 @@ bool Platform::isExtensionSupported(const char *ext) const char *exts = glXQueryExtensionsString(x11.display, DefaultScreen(x11.display)); if(strstr(exts, ext)) return true; - return true; + return false; } const char *Platform::getTextFromClipboard() @@ -707,6 +707,16 @@ bool Platform::isWindowVisible() return x11.visible; } +int Platform::getWindowX() +{ + return 0; +} + +int Platform::getWindowY() +{ + return 0; +} + int Platform::getWindowWidth() { return x11.width; @@ -717,6 +727,11 @@ int Platform::getWindowHeight() return x11.height; } +bool Platform::isWindowMaximized() +{ + return false; +} + const char *Platform::getAppUserDir(const char *appName) { std::stringstream sdir; diff --git a/src/main.cpp b/src/main.cpp index c9cf2a6d..5b91a04d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,14 +48,20 @@ void signal_handler(int sig) /// Default configurations void setDefaultConfigs() { - g_config.setValue("width", 640); - g_config.setValue("height", 480); + g_config.setValue("window x", 0); + g_config.setValue("window y", 0); + g_config.setValue("window width", 640); + g_config.setValue("window height", 480); + g_config.setValue("window maximized", false); } void saveConfigs() { - g_config.setValue("width", Platform::getWindowWidth()); - g_config.setValue("height", Platform::getWindowHeight()); + g_config.setValue("window x", Platform::getWindowX()); + g_config.setValue("window y", Platform::getWindowY()); + g_config.setValue("window width", Platform::getWindowWidth()); + g_config.setValue("window height", Platform::getWindowHeight()); + g_config.setValue("window maximized", Platform::isWindowMaximized()); g_config.save(); } @@ -84,7 +90,10 @@ int main(int argc, const char *argv[]) Platform::init(); // create the window - Platform::createWindow(0, 0, g_config.getInteger("width"), g_config.getInteger("height"), 640, 480, false); + Platform::createWindow(g_config.getInteger("window x"), g_config.getInteger("window y"), + g_config.getInteger("window width"), g_config.getInteger("window height"), + 640, 480, + g_config.getBoolean("window maximized")); Platform::setWindowTitle("OTClient"); Platform::setVsync();