Merging r5863 through r5876 from trunk to ogl-es branch

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5891 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2019-10-17 14:50:20 +00:00 committed by MoNTE48
parent c9f5503436
commit 14ffa95ccd
11 changed files with 66 additions and 39 deletions

View File

@ -9,6 +9,7 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point)
--------------------------
Changes in 1.9 (not yet released)
- Add flag SIrrlichtCreationParameters.WindowResizable. Mainly to work around troubles with SDL+OpenGL on some platforms where resizing later can be tricky/impossible.
- Add operator[] to vector2d and vector3d
- Bugfix: IrrlichtDevice::isWindowMinimized no longer returns true when it's maximized on Windows.
- Ignore degenerated faces in obj file loader when they would generate triangles where 2 vertices use identical indices.
@ -244,6 +245,11 @@ should now be fps independentn
--------------------------
Changes in 1.8.5
- CIrrDeviceMacOSX now sets the SEvent.MouseInput Shift and Control values on mouse events like the other devices. Thanks @ Zero King for patch (#321)
- isWindowFocused in IrrDeviceSDL device now returns the input focus like the other devices. Before it was returning a mouse-over-window state.
- Prevent SDL device from dropping OpenGL resources on Win32 when setResizable was called with OpenGL driver. Thanks @ kas1e for reporting (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=52083&start=0)
And thanks to http://www.bytehazard.com/articles/sdlres.html for the workaround.
- Fix isWindowActive when using SDL device. Before it was only active when the mouse was over the window. Thanks @ kas1e for reporting (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=52083&start=0)
- Fix SViewFrustum::clipLine. Was before clipping at wrong points (inverse places along lines).
- Fix compilation on OSX and prevent capturing mouse cursor when Window is not on top (Patch #319)
Thanks at Artem Shoobovych for bugreport and patch (https://sourceforge.net/p/irrlicht/patches/319/)

View File

@ -798,7 +798,7 @@ void CDemo::startSound()
SDL_Init(SDL_INIT_AUDIO);
if (Mix_OpenAudio(22050, AUDIO_S16, 2, 128))
if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 4096))
return;
const io::path mediaPath = getExampleMediaPath();
@ -807,8 +807,8 @@ void CDemo::startSound()
if (stream)
Mix_PlayMusic(stream, -1);
ballSound = Mix_LoadWAV(mediaPath + "ball.wav");
impactSound = Mix_LoadWAV(mediaPath + "impact.wav");
ballSound = Mix_LoadWAV((mediaPath + "ball.wav").c_str());
impactSound = Mix_LoadWAV((mediaPath + "impact.wav").c_str());
}
void CDemo::playSound(Mix_Chunk *sample)

View File

@ -1227,7 +1227,10 @@ namespace video
\param data A byte array with pixel color information
\param ownForeignMemory If true, the image will use the data
pointer directly and own it afterward. If false, the memory
will by copied internally.
will by copied internally.
WARNING: Setting this to 'true' will not work across dll boundaries.
So unless you link Irrlicht statically you should keep this to 'false'.
The parameter is mainly for internal usage.
\param deleteMemory Whether the memory is deallocated upon
destruction.
\return The created image.

View File

@ -174,7 +174,7 @@ namespace irr
\return True if window is active. */
virtual bool isWindowActive() const = 0;
//! Checks if the Irrlicht window has focus
//! Checks if the Irrlicht window has the input focus
/** \return True if window has focus. */
virtual bool isWindowFocused() const = 0;

View File

@ -30,6 +30,7 @@ namespace irr
Bits(32),
ZBufferBits(24),
Fullscreen(false),
WindowResizable(false),
Stencilbuffer(true),
Vsync(false),
AntiAlias(0),
@ -72,6 +73,7 @@ namespace irr
Bits = other.Bits;
ZBufferBits = other.ZBufferBits;
Fullscreen = other.Fullscreen;
WindowResizable = other.WindowResizable;
Stencilbuffer = other.Stencilbuffer;
Vsync = other.Vsync;
AntiAlias = other.AntiAlias;
@ -84,8 +86,8 @@ namespace irr
EventReceiver = other.EventReceiver;
WindowId = other.WindowId;
LoggingLevel = other.LoggingLevel;
DriverMultithreaded = other.DriverMultithreaded;
DisplayAdapter = other.DisplayAdapter;
DriverMultithreaded = other.DriverMultithreaded;
UsePerformanceTimer = other.UsePerformanceTimer;
PrivateData = other.PrivateData;
OGLES2ShaderPath = other.OGLES2ShaderPath;
@ -127,6 +129,11 @@ namespace irr
/** Otherwise the device runs in windowed mode. Default: false. */
bool Fullscreen;
//! Should a non-fullscreen window be resizable.
/** Might not be supported by all devices. Ignored when Fullscreen is true.
Default: false */
bool WindowResizable;
//! Specifies if the stencil buffer should be enabled.
/** Set this to true, if you want the engine be able to draw
stencil buffer shadows. Note that not all drivers are able to

View File

@ -139,6 +139,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
// create the window, only if we do not use the null device
if (!createWindow())
return;
setResizable(param.WindowResizable);
}
// create cursor control

View File

@ -1192,7 +1192,12 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
}
if (post)
{
ievent.MouseInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask) != 0;
ievent.MouseInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0;
postEventFromUser(ievent);
}
[NSApp sendEvent:(NSEvent *)event];
}

View File

@ -187,7 +187,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT),
MouseX(0), MouseY(0), MouseXRel(0), MouseYRel(0), MouseButtonStates(0),
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
Resizable(false), WindowHasFocus(false), WindowMinimized(false)
Resizable(param.WindowResizable), WindowMinimized(false)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceSDL");
@ -249,6 +249,8 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
if ( CreationParams.Fullscreen )
SDL_Flags |= SDL_FULLSCREEN;
else if ( Resizable )
SDL_Flags |= SDL_RESIZABLE;
if (CreationParams.DriverType == video::EDT_OPENGL)
SDL_Flags |= SDL_OPENGL;
else if (CreationParams.Doublebuffer)
@ -447,12 +449,7 @@ void CIrrDeviceSDL::createDriver()
case video::EDT_DIRECT3D9:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd);
if (!VideoDriver)
{
os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR);
}
os::Printer::log("SDL device does not support DIRECT3D9 driver. Try another one.", ELL_ERROR);
#else
os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
@ -716,10 +713,6 @@ bool CIrrDeviceSDL::run()
break;
case SDL_ACTIVEEVENT:
if ((SDL_event.active.state == SDL_APPMOUSEFOCUS) ||
(SDL_event.active.state == SDL_APPINPUTFOCUS))
WindowHasFocus = (SDL_event.active.gain==1);
else
if (SDL_event.active.state == SDL_APPACTIVE)
WindowMinimized = (SDL_event.active.gain!=1);
break;
@ -1029,7 +1022,6 @@ video::IVideoModeList* CIrrDeviceSDL::getVideoModeList()
#endif // !_IRR_EMSCRIPTEN_PLATFORM_
}
//! Sets if the window should be resizable in windowed mode.
void CIrrDeviceSDL::setResizable(bool resize)
{
@ -1039,10 +1031,21 @@ void CIrrDeviceSDL::setResizable(bool resize)
#else // !_IRR_EMSCRIPTEN_PLATFORM_
if (resize != Resizable)
{
#if defined(_IRR_COMPILE_WITH_OPENGL_) && defined(_IRR_WINDOWS_)
if ( SDL_Flags & SDL_OPENGL )
{
// For unknown reasons the hack with sharing resources which was added in Irrlicht 1.8.5 for this no longer works in 1.9
// But at least we got a new WindowResizable flag since Irrlicht 1.9.
os::Printer::log("setResizable not supported with this device/driver combination. Use SIrrCreationParameters.WindowResizable instead.", ELL_WARNING);
return;
}
#endif
if (resize)
SDL_Flags |= SDL_RESIZABLE;
else
SDL_Flags &= ~SDL_RESIZABLE;
Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags );
Resizable = resize;
}
@ -1099,17 +1102,15 @@ bool CIrrDeviceSDL::isWindowActive() const
if ( emVisibility.hidden )
return false;
}
// TODO: not sure yet if/what WindowHasFocus and WindowMinimized do in sdl/emscripten
#endif
return (WindowHasFocus && !WindowMinimized);
return (SDL_GetAppState()&SDL_APPACTIVE) ? true : false;
}
//! returns if window has focus.
bool CIrrDeviceSDL::isWindowFocused() const
{
return WindowHasFocus;
return (SDL_GetAppState()&SDL_APPINPUTFOCUS) ? true : false;
}

View File

@ -248,7 +248,6 @@ namespace irr
u32 Width, Height;
bool Resizable;
bool WindowHasFocus;
bool WindowMinimized;
struct SKeyMap

View File

@ -1001,8 +1001,8 @@ namespace irr
//! constructor
CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
: CIrrDeviceStub(params), ChangedToFullScreen(false), Resized(false),
ExternalWindow(false), Win32CursorControl(0), JoyControl(0), HWnd(0)
: CIrrDeviceStub(params), HWnd(0), ChangedToFullScreen(false), Resized(false),
ExternalWindow(false), Win32CursorControl(0), JoyControl(0)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceWin32");
@ -1057,11 +1057,7 @@ CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
clientSize.right = CreationParams.WindowSize.Width;
clientSize.bottom = CreationParams.WindowSize.Height;
DWORD style = WS_POPUP;
if (!CreationParams.Fullscreen)
style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
DWORD style = getWindowStyle(CreationParams.Fullscreen, CreationParams.WindowResizable);
AdjustWindowRect(&clientSize, style, FALSE);
const s32 realWidth = clientSize.right - clientSize.left;
@ -1339,6 +1335,17 @@ void CIrrDeviceWin32::resizeIfNecessary()
}
DWORD CIrrDeviceWin32::getWindowStyle(bool fullscreen, bool resizable) const
{
if ( fullscreen )
return WS_POPUP;
if ( resizable )
return WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
return WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
}
//! sets the caption of the window
void CIrrDeviceWin32::setWindowCaption(const wchar_t* text)
{
@ -1800,13 +1807,7 @@ void CIrrDeviceWin32::setResizable(bool resize)
if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen)
return;
LONG_PTR style = WS_POPUP;
if (!resize)
style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
else
style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
LONG_PTR style = (LONG_PTR)getWindowStyle(false, resize);
if (!SetWindowLongPtr(HWnd, GWL_STYLE, style))
os::Printer::log("Could not change window style.");

View File

@ -418,13 +418,17 @@ namespace irr
void resizeIfNecessary();
DWORD getWindowStyle(bool fullscreen, bool resizable) const;
HWND HWnd;
bool ChangedToFullScreen;
bool Resized;
bool ExternalWindow;
CCursorControl* Win32CursorControl;
SJoystickWin32Control* JoyControl;
DEVMODE DesktopMode;
HWND HWnd;
SJoystickWin32Control* JoyControl;
};
} // end namespace irr