Commit b5270f9d authored by hybrid's avatar hybrid

Changed the OpenGL header include scheme for OSX. I hope that it does not...

Changed the OpenGL header include scheme for OSX. I hope that it does not break anything as I cannot compile it under OSX. Also some indentation for the OSX stuff.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@865 dfc29bdd-3216-0410-991c-e03cc46cb475
parent d6f8edae
...@@ -24,11 +24,15 @@ ...@@ -24,11 +24,15 @@
#pragma comment(lib, "GLu32.lib") #pragma comment(lib, "GLu32.lib")
#endif #endif
#elif defined(MACOSX) #elif defined(MACOSX)
#define GL_EXT_texture_env_combine 1
#include "CIrrDeviceMacOSX.h" #include "CIrrDeviceMacOSX.h"
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1
#endif
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#include <OpenGL/glu.h> #include <OpenGL/glu.h>
#include <OpenGL/glext.h> #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h"
#endif
#elif defined(_IRR_USE_SDL_DEVICE_) #elif defined(_IRR_USE_SDL_DEVICE_)
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1
......
...@@ -21,11 +21,15 @@ ...@@ -21,11 +21,15 @@
#pragma comment(lib, "GLu32.lib") #pragma comment(lib, "GLu32.lib")
#endif #endif
#elif defined(MACOSX) #elif defined(MACOSX)
#define GL_EXT_texture_env_combine 1
#include "CIrrDeviceMacOSX.h" #include "CIrrDeviceMacOSX.h"
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1
#endif
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#include <OpenGL/glu.h> #include <OpenGL/glu.h>
#include <OpenGL/glext.h> #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h"
#endif
#elif defined(_IRR_USE_SDL_DEVICE_) #elif defined(_IRR_USE_SDL_DEVICE_)
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1
......
...@@ -9,20 +9,21 @@ ...@@ -9,20 +9,21 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <GL/gl.h> #include <GL/gl.h>
#include "glext.h" #include "glext.h"
#elif defined(MACOSX)
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#else #else
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1
#endif
#if defined(MACOSX)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif #endif
#include <GL/gl.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h" #include "glext.h"
#endif #endif
#endif #endif
......
...@@ -9,19 +9,20 @@ ...@@ -9,19 +9,20 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_ #ifdef _IRR_COMPILE_WITH_OPENGL_
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <GL/gl.h> #include <GL/gl.h>
#elif defined(MACOSX)
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#else #else
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1
#endif
#if defined(MACOSX)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif #endif
#include <GL/gl.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h" #include "glext.h"
#endif #endif
#endif #endif
......
...@@ -22,19 +22,20 @@ ...@@ -22,19 +22,20 @@
#pragma comment(lib, "OpenGL32.lib") #pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "GLu32.lib") #pragma comment(lib, "GLu32.lib")
#endif #endif
#elif defined(MACOSX)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
#else #else
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1 #define GL_GLEXT_LEGACY 1
#endif #endif
#include <GL/gl.h> #if defined(MACOSX)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#if defined(_IRR_OPENGL_USE_EXTPOINTER_) #if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h" #include "glext.h"
#endif #endif
#include <GL/glu.h>
#endif #endif
......
...@@ -25,12 +25,12 @@ namespace irr ...@@ -25,12 +25,12 @@ namespace irr
public: public:
//! constructor //! constructor
CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType, CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType,
const core::dimension2d<s32>& windowSize, const core::dimension2d<s32>& windowSize,
u32 bits, bool fullscreen, u32 bits, bool fullscreen,
bool sbuffer, bool vsync, bool sbuffer, bool vsync,
bool antiAlias, IEventReceiver* receiver, bool antiAlias, IEventReceiver* receiver,
const char* version); const char* version);
//! destructor //! destructor
virtual ~CIrrDeviceMacOSX(); virtual ~CIrrDeviceMacOSX();
...@@ -60,10 +60,10 @@ namespace irr ...@@ -60,10 +60,10 @@ namespace irr
//! Sets if the window should be resizeable in windowed mode. //! Sets if the window should be resizeable in windowed mode.
virtual void setResizeAble(bool resize); virtual void setResizeAble(bool resize);
void flush(); void flush();
void setMouseLocation(int x,int y); void setMouseLocation(int x,int y);
void setResize(int width,int height); void setResize(int width,int height);
void setCursorVisible(bool visible); void setCursorVisible(bool visible);
private: private:
...@@ -112,7 +112,7 @@ namespace irr ...@@ -112,7 +112,7 @@ namespace irr
//! Sets the new position of the cursor. //! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<s32> &pos) virtual void setPosition(const core::position2d<s32> &pos)
{ {
if (CursorPos.X != pos.X || CursorPos.Y != pos.Y) if (CursorPos.X != pos.X || CursorPos.Y != pos.Y)
setPosition(pos.X, pos.Y); setPosition(pos.X, pos.Y);
} }
...@@ -169,7 +169,7 @@ namespace irr ...@@ -169,7 +169,7 @@ namespace irr
} }
//! Updates the internal cursor position //! Updates the internal cursor position
void updateInternalCursorPosition(int x,int y) void updateInternalCursorPosition(int x,int y)
{ {
CursorPos.X = x; CursorPos.X = x;
CursorPos.Y = y; CursorPos.Y = y;
...@@ -186,12 +186,12 @@ namespace irr ...@@ -186,12 +186,12 @@ namespace irr
core::rect<s32> ReferenceRect; core::rect<s32> ReferenceRect;
}; };
bool createWindow(const irr::core::dimension2d<irr::s32>& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer); bool createWindow(const irr::core::dimension2d<irr::s32>& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer);
void initKeycodes(); void initKeycodes();
void storeMouseLocation(); void storeMouseLocation();
void postMouseEvent(void *event,irr::SEvent &ievent); void postMouseEvent(void *event,irr::SEvent &ievent);
void postKeyEvent(void *event,irr::SEvent &ievent,bool pressed); void postKeyEvent(void *event,irr::SEvent &ievent,bool pressed);
video::E_DRIVER_TYPE DriverType; video::E_DRIVER_TYPE DriverType;
bool stencilbuffer; bool stencilbuffer;
......
...@@ -30,22 +30,22 @@ namespace irr ...@@ -30,22 +30,22 @@ namespace irr
} }
} // end namespace irr } // end namespace irr
static bool firstLaunch = true; static bool firstLaunch = true;
namespace irr namespace irr
{ {
//! constructor //! constructor
CIrrDeviceMacOSX::CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType, CIrrDeviceMacOSX::CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType,
const core::dimension2d<s32>& windowSize, const core::dimension2d<s32>& windowSize,
u32 bits, bool fullscreen, u32 bits, bool fullscreen,
bool sbuffer, bool vsync, bool sbuffer, bool vsync,
bool antiAlias, IEventReceiver* receiver, bool antiAlias, IEventReceiver* receiver,
const char* version) const char* version)
: CIrrDeviceStub(version, receiver), DriverType(driverType), stencilbuffer(sbuffer) : CIrrDeviceStub(version, receiver), DriverType(driverType), stencilbuffer(sbuffer), _window(NULL), _active(true), _oglcontext(NULL), _cglcontext(NULL)
{ {
struct utsname name; struct utsname name;
NSString *path; NSString *path;
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CIrrDeviceMacOSX"); setDebugName("CIrrDeviceMacOSX");
#endif #endif
...@@ -63,11 +63,6 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType, ...@@ -63,11 +63,6 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(video::E_DRIVER_TYPE driverType,
path = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent]; path = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
chdir([path cString]); chdir([path cString]);
} }
_window = NULL;
_active = true;
_oglcontext = NULL;
_cglcontext = NULL;
uname(&name); uname(&name);
Operator = new COSOperator(name.version); Operator = new COSOperator(name.version);
...@@ -85,7 +80,7 @@ CIrrDeviceMacOSX::~CIrrDeviceMacOSX() ...@@ -85,7 +80,7 @@ CIrrDeviceMacOSX::~CIrrDeviceMacOSX()
closeDevice(); closeDevice();
} }
void CIrrDeviceMacOSX::closeDevice() void CIrrDeviceMacOSX::closeDevice()
{ {
if (_window != NULL) if (_window != NULL)
{ {
...@@ -110,13 +105,13 @@ void CIrrDeviceMacOSX::closeDevice() ...@@ -110,13 +105,13 @@ void CIrrDeviceMacOSX::closeDevice()
CGLClearDrawable(_cglcontext); CGLClearDrawable(_cglcontext);
CGLDestroyContext(_cglcontext); CGLDestroyContext(_cglcontext);
} }
} }
_active = FALSE; _active = FALSE;
_cglcontext = NULL; _cglcontext = NULL;
} }
bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer) bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& windowSize, irr::u32 bits, bool fullscreen, bool vsync, bool stencilBuffer)
{ {
int index; int index;
CGDisplayErr error; CGDisplayErr error;
...@@ -129,7 +124,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind ...@@ -129,7 +124,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind
NSOpenGLPixelFormatAttribute windowattribs[32]; NSOpenGLPixelFormatAttribute windowattribs[32];
CFDictionaryRef displaymode,olddisplaymode; CFDictionaryRef displaymode,olddisplaymode;
long numPixelFormats,newSwapInterval; long numPixelFormats,newSwapInterval;
result = false; result = false;
display = CGMainDisplayID(); display = CGMainDisplayID();
_screenWidth = (int) CGDisplayPixelsWide(display); _screenWidth = (int) CGDisplayPixelsWide(display);
...@@ -141,7 +136,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind ...@@ -141,7 +136,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind
if (_window != NULL) if (_window != NULL)
{ {
index = 0; index = 0;
windowattribs[index++] = NSOpenGLPFANoRecovery; windowattribs[index++] = NSOpenGLPFANoRecovery;
windowattribs[index++] = NSOpenGLPFADoubleBuffer; windowattribs[index++] = NSOpenGLPFADoubleBuffer;
windowattribs[index++] = NSOpenGLPFAAccelerated; windowattribs[index++] = NSOpenGLPFAAccelerated;
windowattribs[index++] = NSOpenGLPFADepthSize; windowattribs[index++] = NSOpenGLPFADepthSize;
...@@ -154,7 +149,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind ...@@ -154,7 +149,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind
windowattribs[index++] = NSOpenGLPFAStencilSize; windowattribs[index++] = NSOpenGLPFAStencilSize;
windowattribs[index++] = (NSOpenGLPixelFormatAttribute)1; windowattribs[index++] = (NSOpenGLPixelFormatAttribute)1;
} }
windowattribs[index++] = (NSOpenGLPixelFormatAttribute)NULL; windowattribs[index++] = (NSOpenGLPixelFormatAttribute)NULL;
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
...@@ -163,7 +158,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind ...@@ -163,7 +158,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind
_oglcontext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL]; _oglcontext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL];
[format release]; [format release];
} }
if (_oglcontext != NULL) if (_oglcontext != NULL)
{ {
[_window center]; [_window center];
...@@ -196,7 +191,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind ...@@ -196,7 +191,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind
numPixelFormats = 0; numPixelFormats = 0;
index = 0; index = 0;
fullattribs[index++] = kCGLPFAFullScreen; fullattribs[index++] = kCGLPFAFullScreen;
fullattribs[index++] = kCGLPFADisplayMask; fullattribs[index++] = kCGLPFADisplayMask;
fullattribs[index++] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display); fullattribs[index++] = (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display);
fullattribs[index++] = kCGLPFADoubleBuffer; fullattribs[index++] = kCGLPFADoubleBuffer;
...@@ -211,16 +206,16 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind ...@@ -211,16 +206,16 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind
fullattribs[index++] = kCGLPFAStencilSize; fullattribs[index++] = kCGLPFAStencilSize;
fullattribs[index++] = (CGLPixelFormatAttribute)1; fullattribs[index++] = (CGLPixelFormatAttribute)1;
} }
fullattribs[index++] = (CGLPixelFormatAttribute)NULL; fullattribs[index++] = (CGLPixelFormatAttribute)NULL;
CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats); CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats);
if (pixelFormat != NULL) if (pixelFormat != NULL)
{ {
CGLCreateContext(pixelFormat,NULL,&_cglcontext); CGLCreateContext(pixelFormat,NULL,&_cglcontext);
CGLDestroyPixelFormat(pixelFormat); CGLDestroyPixelFormat(pixelFormat);
} }
if (_cglcontext != NULL) if (_cglcontext != NULL)
{ {
CGLSetFullScreen(_cglcontext); CGLSetFullScreen(_cglcontext);
...@@ -249,7 +244,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind ...@@ -249,7 +244,7 @@ bool CIrrDeviceMacOSX::createWindow(const irr::core::dimension2d<irr::s32>& wind
return (result); return (result);
} }
void CIrrDeviceMacOSX::setResize(int width,int height) void CIrrDeviceMacOSX::setResize(int width,int height)
{ {
_width = width; _width = width;
_height = height; _height = height;
...@@ -257,7 +252,7 @@ void CIrrDeviceMacOSX::setResize(int width,int height) ...@@ -257,7 +252,7 @@ void CIrrDeviceMacOSX::setResize(int width,int height)
getVideoDriver()->OnResize(core::dimension2d<s32>(width, height)); getVideoDriver()->OnResize(core::dimension2d<s32>(width, height));
} }
void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core::dimension2d<s32>& windowSize,u32 bits,bool fullscreen,bool stencilbuffer, bool vsync, bool antiAlias) void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core::dimension2d<s32>& windowSize,u32 bits,bool fullscreen,bool stencilbuffer, bool vsync, bool antiAlias)
{ {
switch (driverType) switch (driverType)
{ {
...@@ -268,7 +263,7 @@ void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core:: ...@@ -268,7 +263,7 @@ void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core::
os::Printer::log("No Software driver support compiled in.", ELL_ERROR); os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif #endif
break; break;
case video::EDT_BURNINGSVIDEO: case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createSoftwareDriver2(windowSize, fullscreen, FileSystem, this); VideoDriver = video::createSoftwareDriver2(windowSize, fullscreen, FileSystem, this);
...@@ -284,7 +279,7 @@ void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core:: ...@@ -284,7 +279,7 @@ void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core::
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR); os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
#endif #endif
break; break;
case video::EDT_DIRECT3D8: case video::EDT_DIRECT3D8:
case video::EDT_DIRECT3D9: case video::EDT_DIRECT3D9:
os::Printer::log("This driver is not available in OSX. Try OpenGL or Software renderer.", ELL_ERROR); os::Printer::log("This driver is not available in OSX. Try OpenGL or Software renderer.", ELL_ERROR);
...@@ -300,7 +295,7 @@ void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core:: ...@@ -300,7 +295,7 @@ void CIrrDeviceMacOSX::createDriver(video::E_DRIVER_TYPE driverType,const core::
} }
} }
void CIrrDeviceMacOSX::flush() void CIrrDeviceMacOSX::flush()
{ {
if (_cglcontext != NULL) if (_cglcontext != NULL)
{ {
...@@ -309,11 +304,11 @@ void CIrrDeviceMacOSX::flush() ...@@ -309,11 +304,11 @@ void CIrrDeviceMacOSX::flush()
} }
} }
bool CIrrDeviceMacOSX::run() bool CIrrDeviceMacOSX::run()
{ {
NSEvent *event; NSEvent *event;
irr::SEvent ievent; irr::SEvent ievent;
os::Timer::tick(); os::Timer::tick();
storeMouseLocation(); storeMouseLocation();
...@@ -327,7 +322,7 @@ bool CIrrDeviceMacOSX::run() ...@@ -327,7 +322,7 @@ bool CIrrDeviceMacOSX::run()
case NSKeyDown: case NSKeyDown:
postKeyEvent(event,ievent,true); postKeyEvent(event,ievent,true);
break; break;
case NSKeyUp: case NSKeyUp:
postKeyEvent(event,ievent,false); postKeyEvent(event,ievent,false);
break; break;
...@@ -351,7 +346,7 @@ bool CIrrDeviceMacOSX::run() ...@@ -351,7 +346,7 @@ bool CIrrDeviceMacOSX::run()
ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED; ievent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
postMouseEvent(event,ievent); postMouseEvent(event,ievent);
break; break;
case NSRightMouseDown: case NSRightMouseDown:
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
ievent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN; ievent.MouseInput.Event = irr::EMIE_RMOUSE_PRESSED_DOWN;
...@@ -378,12 +373,12 @@ bool CIrrDeviceMacOSX::run() ...@@ -378,12 +373,12 @@ bool CIrrDeviceMacOSX::run()
break; break;
} }
} }
return (![[NSApp delegate] isQuit] && _active); return (![[NSApp delegate] isQuit] && _active);
} }
//! Pause the current process for the minimum time allowed only to allow other processes to execute //! Pause the current process for the minimum time allowed only to allow other processes to execute
void CIrrDeviceMacOSX::yield() void CIrrDeviceMacOSX::yield()
{ {
// TODO: Does this work or maybe is there a better way? // TODO: Does this work or maybe is there a better way?
struct timespec ts = {0,0}; struct timespec ts = {0,0};
...@@ -394,9 +389,9 @@ void CIrrDeviceMacOSX::yield() ...@@ -394,9 +389,9 @@ void CIrrDeviceMacOSX::yield()
void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false) void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false)
{ {
// TODO: Does this work or maybe is there a better way? // TODO: Does this work or maybe is there a better way?
bool wasStopped = Timer ? Timer->isStopped() : true; bool wasStopped = Timer ? Timer->isStopped() : true;
struct timespec ts; struct timespec ts;
ts.tv_sec = (time_t) (timeMs / 1000); ts.tv_sec = (time_t) (timeMs / 1000);
ts.tv_nsec = (long) (timeMs % 1000) * 1000000; ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
...@@ -410,11 +405,11 @@ void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false) ...@@ -410,11 +405,11 @@ void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false)
Timer->start(); Timer->start();
} }
void CIrrDeviceMacOSX::present(video::IImage* image, s32 windowId, core::rect<s32>* src ) void CIrrDeviceMacOSX::present(video::IImage* image, s32 windowId, core::rect<s32>* src )
{ {
} }
void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text) void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text)
{ {
size_t size; size_t size;
char title[1024]; char title[1024];
...@@ -427,19 +422,19 @@ void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text) ...@@ -427,19 +422,19 @@ void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text)
} }
} }
bool CIrrDeviceMacOSX::isWindowActive() bool CIrrDeviceMacOSX::isWindowActive()
{ {
return (_active); return (_active);
} }
void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed) void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed)
{ {
NSString *str; NSString *str;
std::map<int,int>::const_iterator iter; std::map<int,int>::const_iterator iter;
unsigned int result,c,mkey,mchar; unsigned int result,c,mkey,mchar;
const unsigned char *cStr; const unsigned char *cStr;
BOOL skipCommand; BOOL skipCommand;
str = [event characters]; str = [event characters];
if (str != nil && [str length] > 0) if (str != nil && [str length] > 0)
{ {
...@@ -474,17 +469,19 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed ...@@ -474,17 +469,19 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
ievent.KeyInput.Control = ([event modifierFlags] & NSControlKeyMask) != 0; ievent.KeyInput.Control = ([event modifierFlags] & NSControlKeyMask) != 0;
ievent.KeyInput.Char = (irr::EKEY_CODE)mchar; ievent.KeyInput.Char = (irr::EKEY_CODE)mchar;
if (skipCommand) ievent.KeyInput.Control = true; if (skipCommand)
else if ([event modifierFlags] & NSCommandKeyMask) [NSApp sendEvent:(NSEvent *)event]; ievent.KeyInput.Control = true;
else if ([event modifierFlags] & NSCommandKeyMask)
[NSApp sendEvent:(NSEvent *)event];
postEventFromUser(ievent); postEventFromUser(ievent);
} }
} }
void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
{ {
BOOL post = true; BOOL post = true;
if (_window != NULL) if (_window != NULL)
{ {
ievent.MouseInput.X = (int)[event locationInWindow].x; ievent.MouseInput.X = (int)[event locationInWindow].x;
...@@ -501,13 +498,13 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) ...@@ -501,13 +498,13 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
[NSApp sendEvent:(NSEvent *)event]; [NSApp sendEvent:(NSEvent *)event];
} }
void CIrrDeviceMacOSX::storeMouseLocation() void CIrrDeviceMacOSX::storeMouseLocation()
{ {
NSPoint p; NSPoint p;
int x,y; int x,y;
p = [NSEvent mouseLocation]; p = [NSEvent mouseLocation];
if (_window != NULL) if (_window != NULL)
{ {
p = [_window convertScreenToBase:p]; p = [_window convertScreenToBase:p];
...@@ -523,11 +520,11 @@ void CIrrDeviceMacOSX::storeMouseLocation() ...@@ -523,11 +520,11 @@ void CIrrDeviceMacOSX::storeMouseLocation()
((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y); ((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y);
} }
void CIrrDeviceMacOSX::setMouseLocation(int x,int y) void CIrrDeviceMacOSX::setMouseLocation(int x,int y)
{ {
NSPoint p; NSPoint p;
CGPoint c; CGPoint c;
if (_window != NULL) if (_window != NULL)
{ {
p.x = (float) x; p.x = (float) x;
...@@ -547,7 +544,7 @@ void CIrrDeviceMacOSX::setMouseLocation(int x,int y) ...@@ -547,7 +544,7 @@ void CIrrDeviceMacOSX::setMouseLocation(int x,int y)
CGWarpMouseCursorPosition(c); CGWarpMouseCursorPosition(c);
} }
void CIrrDeviceMacOSX::setCursorVisible(bool visible) void CIrrDeviceMacOSX::setCursorVisible(bool visible)
{ {
CGDirectDisplayID display; CGDirectDisplayID display;
...@@ -556,7 +553,7 @@ void CIrrDeviceMacOSX::setCursorVisible(bool visible) ...@@ -556,7 +553,7 @@ void CIrrDeviceMacOSX::setCursorVisible(bool visible)
else CGDisplayHideCursor(display); else CGDisplayHideCursor(display);
} }
void CIrrDeviceMacOSX::initKeycodes() void CIrrDeviceMacOSX::initKeycodes()
{ {
_keycodes[NSUpArrowFunctionKey] = irr::KEY_UP; _keycodes[NSUpArrowFunctionKey] = irr::KEY_UP;
_keycodes[NSDownArrowFunctionKey] = irr::KEY_DOWN; _keycodes[NSDownArrowFunctionKey] = irr::KEY_DOWN;
...@@ -598,23 +595,20 @@ void CIrrDeviceMacOSX::initKeycodes() ...@@ -598,23 +595,20 @@ void CIrrDeviceMacOSX::initKeycodes()
//! Sets if the window should be resizeable in windowed mode. //! Sets if the window should be resizeable in windowed mode.
void CIrrDeviceMacOSX::setResizeAble(bool resize) void CIrrDeviceMacOSX::setResizeAble(bool resize)
{ {
// todo: implement resize // todo: implement resize
} }
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param) IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationParameters& param)
{ {
CIrrDeviceMacOSX* dev = new CIrrDeviceMacOSX( CIrrDeviceMacOSX* dev = new CIrrDeviceMacOSX(
param.DriverType, param.DriverType,
param.WindowSize, param.WindowSize,
param.Bits, param.Bits,
param.Fullscreen, param.Fullscreen,
param.Stencilbuffer, param.Stencilbuffer,
param.Vsync, param.Vsync,
param.AntiAlias, param.AntiAlias,
param.EventReceiver, param.EventReceiver,
...@@ -625,7 +619,7 @@ IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationP ...@@ -625,7 +619,7 @@ IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDeviceEx(const SIrrlichtCreationP
dev->drop(); dev->drop();
dev = 0; dev = 0;
} }
return dev; return dev;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment