2
0
Эх сурвалжийг харах

Moved getScreenInfo to Core

Ivan Safrin 13 жил өмнө
parent
commit
40766fd24b

+ 0 - 2
Core/Contents/Include/PolyCocoaCore.h

@@ -126,8 +126,6 @@ namespace Polycode {
 		void initGamepad();
 		void shutdownGamepad();
 		
-//		static pascal OSStatus coreEventHandler (EventHandlerCallRef next, EventRef event, void *data);	
-		
 		void lockMutex(CoreMutex *mutex);
 		void unlockMutex(CoreMutex *mutex);
 		CoreMutex *createMutex();		

+ 9 - 1
Core/Contents/Include/PolyCore.h

@@ -210,7 +210,15 @@ namespace Polycode {
 		* @return An STL vector of video modes.
 		*/															
 		virtual std::vector<Rectangle> getVideoModes() = 0;
-				
+		
+		/**
+		* Provides the current width, height, and refresh rate of the screen.
+		* @param width If non-NULL, current screen width will be written here (or 0 if unknown).
+		* @param hight If non-NULL, current screen height will be written here (or 0 if unknown).
+		* @param hz If non-NULL, current screen refresh rate will be written here (or 0 if unknown).
+		*/
+		static void getScreenInfo(int *width, int *height, int *hz);
+								
 		/**
 		* Creates a folder on disk with the specified path.
 		* @param folderPath Path to create the folder in.

+ 1 - 9
Core/Contents/Include/PolyCoreServices.h

@@ -147,15 +147,7 @@ namespace Polycode {
 			*/																													
 			Config *getConfig();
 		
-			/**
-			 * Provides the current width, height, and refresh rate of the screen.
-			 * @param width If non-NULL, current screen width will be written here (or 0 if unknown).
-			 * @param hight If non-NULL, current screen height will be written here (or 0 if unknown).
-			 * @param hz If non-NULL, current screen refresh rate will be written here (or 0 if unknown).
-			 */
-			void getScreenInfo(int *width, int *height, int *hz);
-		
-			
+				
 			bool drawScreensFirst;
 					
 			~CoreServices();

+ 13 - 0
Core/Contents/Source/PolyCocoaCore.mm

@@ -24,12 +24,25 @@
 #include <iostream>
 #include <limits.h>
 
+#include <ApplicationServices/ApplicationServices.h>
+
+
 using namespace Polycode;
 
 long getThreadID() {
 	return (long)pthread_self();
 }
 
+void Core::getScreenInfo(int *width, int *height, int *hz) {
+	CGDisplayModeRef mode = CGDisplayCopyDisplayMode(CGMainDisplayID());    
+
+    // Copy the relevant data.
+    if (width) *width = CGDisplayModeGetWidth(mode);
+    if (height) *height = CGDisplayModeGetHeight(mode);
+    if (hz) *hz = CGDisplayModeGetRefreshRate(mode);    
+    CGDisplayModeRelease(mode);
+}
+
 CocoaCore::CocoaCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex) : Core(_xRes, _yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {	
 
 	hidManager = NULL;

+ 1 - 1
Core/Contents/Source/PolyCore.cpp

@@ -63,7 +63,7 @@ namespace Polycode {
 		xRes = _xRes;
 		yRes = _yRes;
 		if (fullScreen && !xRes && !yRes) {
-			CoreServices::getInstance()->getScreenInfo(&xRes, &yRes, NULL);
+			getScreenInfo(&xRes, &yRes, NULL);
 		}
 		mouseEnabled = true;
 		lastSleepFrameTicks = 0;

+ 0 - 49
Core/Contents/Source/PolyCoreServices.cpp

@@ -37,15 +37,6 @@
 #include "PolyTweenManager.h"
 #include "PolySoundManager.h"
 
-// For use by getScreenInfo
-#if defined(_WINDOWS)
-#include <windows.h>
-#elif defined(__APPLE__) && defined(__MACH__)
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(__linux) || defined(__linux__) || defined(linux)
-#include <SDL/SDL.h>
-#endif
-
 using namespace Polycode;
 
 std::map<long, CoreServices*> CoreServices::instanceMap;
@@ -259,43 +250,3 @@ ResourceManager *CoreServices::getResourceManager() {
 	return resourceManager;
 }
 
-void CoreServices::getScreenInfo(int *width, int *height, int *hz) {
-#if defined(_WINDOWS)
-	
-	DEVMODE mode = {}; // Zero initialize
-	mode.dmSize = sizeof(DEVMODE);
-	
-    EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &mode);
-	
-    // Store the current display settings.
-    if (width) *width = mode.dmPelsWidth;
-    if (height) *height = mode.dmPelsHeight;
-    if (hz) *hz = mode.dmDisplayFrequency;
-	
-#elif defined(__APPLE__) && defined(__MACH__)
-	
-	CGDisplayModeRef mode = CGDisplayCopyDisplayMode(CGMainDisplayID());
-    
-    // Copy the relevant data.
-    if (width) *width = CGDisplayModeGetWidth(mode);
-    if (height) *height = CGDisplayModeGetHeight(mode);
-    if (hz) *hz = CGDisplayModeGetRefreshRate(mode);
-    
-    CGDisplayModeRelease(mode);
-	
-#elif defined(__linux) || defined(__linux__) || defined(linux)
-	
-	SDL_Init(SDL_INIT_VIDEO); // Or GetVideoInfo will not work
-	const SDL_VideoInfo *video = SDL_GetVideoInfo();
-	if (width) *width = video->current_w;
-	if (height) *height = video->current_h;
-	if (hz) *hz = 0;
-	
-#else
-	
-	if (width) *width = 0;
-	if (height) *height = 0;
-	if (hz) *hz = 0;
-	
-#endif
-}

+ 8 - 0
Core/Contents/Source/PolySDLCore.cpp

@@ -41,6 +41,14 @@ long getThreadID() {
 	return (long)pthread_self();
 }
 
+void Core::getScreenInfo(int *width, int *height, int *hz) {
+	SDL_Init(SDL_INIT_VIDEO); // Or GetVideoInfo will not work
+	const SDL_VideoInfo *video = SDL_GetVideoInfo();
+	if (width) *width = video->current_w;
+	if (height) *height = video->current_h;
+	if (hz) *hz = 0;
+}
+
 SDLCore::SDLCore(PolycodeView *view, int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate) : Core(_xRes, _yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate) {
 
 	String *windowTitle = (String*)view->windowData;

+ 12 - 0
Core/Contents/Source/PolyWinCore.cpp

@@ -55,6 +55,18 @@ void ClientResize(HWND hWnd, int nWidth, int nHeight)
   MoveWindow(hWnd,rcWindow.left, rcWindow.top, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE);
 }
 
+void Core::getScreenInfo(int *width, int *height, int *hz) {
+	DEVMODE mode = {}; // Zero initialize
+	mode.dmSize = sizeof(DEVMODE);
+	
+    EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &mode);
+	
+    // Store the current display settings.
+    if (width) *width = mode.dmPelsWidth;
+    if (height) *height = mode.dmPelsHeight;
+    if (hz) *hz = mode.dmDisplayFrequency;
+}
+
 Win32Core::Win32Core(PolycodeViewBase *view, int _xRes, int _yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate,  int monitorIndex) 
 	: Core(_xRes, _yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {