forked from Mirrorlandia_minetest/irrlicht
CIrrDeviceOSX: drop all video mode code
This commit is contained in:
parent
0afd799002
commit
b2b000597a
@ -95,10 +95,6 @@ namespace irr
|
|||||||
//! Activate any joysticks, and generate events for them.
|
//! Activate any joysticks, and generate events for them.
|
||||||
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_;
|
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo) _IRR_OVERRIDE_;
|
||||||
|
|
||||||
//! \return Returns a pointer to a list with all video modes
|
|
||||||
//! supported by the gfx adapter.
|
|
||||||
virtual video::IVideoModeList* getVideoModeList() _IRR_OVERRIDE_;
|
|
||||||
|
|
||||||
//! Get the device type
|
//! Get the device type
|
||||||
virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_
|
virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_
|
||||||
{
|
{
|
||||||
|
@ -597,8 +597,6 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
|
|||||||
|
|
||||||
initKeycodes();
|
initKeycodes();
|
||||||
|
|
||||||
VideoModeList->setDesktop(CreationParams.Bits, core::dimension2d<u32>([[NSScreen mainScreen] frame].size.width, [[NSScreen mainScreen] frame].size.height));
|
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
if (CreationParams.DriverType != video::EDT_NULL)
|
if (CreationParams.DriverType != video::EDT_NULL)
|
||||||
@ -639,9 +637,6 @@ void CIrrDeviceMacOSX::closeDevice()
|
|||||||
Window = nil;
|
Window = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsFullscreen)
|
|
||||||
CGReleaseAllDisplays();
|
|
||||||
|
|
||||||
IsFullscreen = false;
|
IsFullscreen = false;
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
}
|
}
|
||||||
@ -660,7 +655,8 @@ bool CIrrDeviceMacOSX::createWindow()
|
|||||||
|
|
||||||
const NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained;
|
const NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained;
|
||||||
|
|
||||||
if (!CreationParams.Fullscreen)
|
// TODO: fullscreen
|
||||||
|
//if (!CreationParams.Fullscreen)
|
||||||
{
|
{
|
||||||
if (!CreationParams.WindowId) //create another window when WindowId is null
|
if (!CreationParams.WindowId) //create another window when WindowId is null
|
||||||
{
|
{
|
||||||
@ -684,66 +680,6 @@ bool CIrrDeviceMacOSX::createWindow()
|
|||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
IsFullscreen = true;
|
|
||||||
|
|
||||||
displaymode = CGDisplayCopyDisplayMode(Display);
|
|
||||||
|
|
||||||
CFArrayRef Modes = CGDisplayCopyAllDisplayModes(Display, NULL);
|
|
||||||
|
|
||||||
for(int i = 0; i < CFArrayGetCount(Modes); ++i)
|
|
||||||
{
|
|
||||||
CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i);
|
|
||||||
|
|
||||||
u8 Depth = 0;
|
|
||||||
|
|
||||||
CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode);
|
|
||||||
|
|
||||||
if (CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
|
||||||
Depth = 32;
|
|
||||||
else if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
|
||||||
Depth = 16;
|
|
||||||
else if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
|
||||||
Depth = 8;
|
|
||||||
|
|
||||||
if(Depth == CreationParams.Bits)
|
|
||||||
if((CGDisplayModeGetWidth(CurrentMode) == CreationParams.WindowSize.Width) && (CGDisplayModeGetHeight(CurrentMode) == CreationParams.WindowSize.Height))
|
|
||||||
{
|
|
||||||
displaymode = CurrentMode;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (displaymode != NULL)
|
|
||||||
{
|
|
||||||
olddisplaymode = CGDisplayCopyDisplayMode(Display);
|
|
||||||
|
|
||||||
error = CGCaptureAllDisplays();
|
|
||||||
if (error == CGDisplayNoErr)
|
|
||||||
{
|
|
||||||
error = CGDisplaySetDisplayMode(Display, displaymode, NULL);
|
|
||||||
|
|
||||||
if (error == CGDisplayNoErr)
|
|
||||||
{
|
|
||||||
Window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:NSBorderlessWindowMask backing:type defer:FALSE screen:[NSScreen mainScreen]];
|
|
||||||
|
|
||||||
[Window setLevel: CGShieldingWindowLevel()];
|
|
||||||
[Window setBackgroundColor:[NSColor blackColor]];
|
|
||||||
|
|
||||||
displayRect = CGDisplayBounds(Display);
|
|
||||||
ScreenWidth = DeviceWidth = (int)displayRect.size.width;
|
|
||||||
ScreenHeight = DeviceHeight = (int)displayRect.size.height;
|
|
||||||
CreationParams.WindowSize.set(ScreenWidth, ScreenHeight);
|
|
||||||
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
CGReleaseAllDisplays();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@ -754,11 +690,6 @@ bool CIrrDeviceMacOSX::createWindow()
|
|||||||
[Window setIsVisible:TRUE];
|
[Window setIsVisible:TRUE];
|
||||||
[Window makeKeyAndOrderFront:nil];
|
[Window makeKeyAndOrderFront:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsFullscreen) //hide menus in fullscreen mode only
|
|
||||||
{
|
|
||||||
[NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -1193,6 +1124,7 @@ void CIrrDeviceMacOSX::storeMouseLocation()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Do we still need this?
|
||||||
CGEventRef ourEvent = CGEventCreate(NULL);
|
CGEventRef ourEvent = CGEventCreate(NULL);
|
||||||
CGPoint point = CGEventGetLocation(ourEvent);
|
CGPoint point = CGEventGetLocation(ourEvent);
|
||||||
CFRelease(ourEvent);
|
CFRelease(ourEvent);
|
||||||
@ -1203,7 +1135,6 @@ void CIrrDeviceMacOSX::storeMouseLocation()
|
|||||||
const core::position2di& curr = ((CCursorControl *)CursorControl)->getPosition(true);
|
const core::position2di& curr = ((CCursorControl *)CursorControl)->getPosition(true);
|
||||||
if (curr.X != x || curr.Y != y)
|
if (curr.X != x || curr.Y != y)
|
||||||
{
|
{
|
||||||
// In fullscreen mode, events are not sent regularly so rely on polling
|
|
||||||
irr::SEvent ievent;
|
irr::SEvent ievent;
|
||||||
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
||||||
ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
|
ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
|
||||||
@ -1745,44 +1676,6 @@ void CIrrDeviceMacOSX::pollJoysticks()
|
|||||||
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||||
}
|
}
|
||||||
|
|
||||||
video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList()
|
|
||||||
{
|
|
||||||
if (!VideoModeList->getVideoModeCount())
|
|
||||||
{
|
|
||||||
CGDirectDisplayID display;
|
|
||||||
display = CGMainDisplayID();
|
|
||||||
|
|
||||||
CFArrayRef Modes = CGDisplayCopyAllDisplayModes(display, NULL);
|
|
||||||
|
|
||||||
for(int i = 0; i < CFArrayGetCount(Modes); ++i)
|
|
||||||
{
|
|
||||||
CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i);
|
|
||||||
|
|
||||||
u8 Depth = 0;
|
|
||||||
|
|
||||||
CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode);
|
|
||||||
|
|
||||||
if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
|
||||||
Depth = 32;
|
|
||||||
else
|
|
||||||
if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
|
||||||
Depth = 16;
|
|
||||||
else
|
|
||||||
if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
|
|
||||||
Depth = 8;
|
|
||||||
|
|
||||||
if(Depth)
|
|
||||||
{
|
|
||||||
unsigned int Width = CGDisplayModeGetWidth(CurrentMode);
|
|
||||||
unsigned int Height = CGDisplayModeGetHeight(CurrentMode);
|
|
||||||
|
|
||||||
VideoModeList->addMode(core::dimension2d<u32>(Width, Height), Depth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return VideoModeList;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
||||||
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
|
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
|
||||||
|
Loading…
Reference in New Issue
Block a user