소스 검색

Feature: On desktop, center window on screen

Ray San 10 년 전
부모
커밋
d218534fff
1개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 14 2
      src/core.c

+ 14 - 2
src/core.c

@@ -477,7 +477,7 @@ void BeginDrawing(void)
     updateTime = currentTime - previousTime;
     previousTime = currentTime;
 
-    if (IsPosproShaderEnabled()) rlEnableFBO();
+    if (IsPosproShaderEnabled()) rlEnablePostproFBO();
 
     rlClearScreenBuffers();
 
@@ -1050,7 +1050,19 @@ static void InitDisplay(int width, int height)
     {
         // No-fullscreen window creation
         window = glfwCreateWindow(screenWidth, screenHeight, windowTitle, NULL, NULL);
-
+        
+#if defined(PLATFORM_DESKTOP)
+        // Center window on screen
+        const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
+        
+        int windowPosX = mode->width/2 - screenWidth/2;
+        int windowPosY = mode->height/2 - screenHeight/2;
+        
+        if (windowPosX < 0) windowPosX = 0;
+        if (windowPosY < 0) windowPosY = 0;
+        
+        glfwSetWindowPos(window, windowPosX, windowPosY);
+#endif
         renderWidth = screenWidth;
         renderHeight = screenHeight;
     }