Merging r5780 through r5786 from trunk to ogl-es branch

Note: EGL context manager continues to ignore calls trying to change the context.
So no multithreading support for that one so far.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5787 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2019-03-14 23:03:26 +00:00
parent 990d475fbb
commit 902aa7fa5e
12 changed files with 67 additions and 36 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)
- EditBox now still allows overwriting characters when the text-length is at max.
- Bugfix: CMatrix4::transformPlane was calculating the wrong plane-normal before.
- SViewFrustum::recalculateBoundingBox no longer includes camera position in the bounding-box. Only using frustum corners now. Thx @DevSH for bugreport & patch.
- Camera uses now OGL projection matrices with OpenGL driver. Fixes wrong near-plane values with OpenGL (showed too much before).

View File

@ -12,6 +12,7 @@ namespace irr
{
namespace video
{
// For system specific window contexts (used for OpenGL)
class IContextManager : public virtual IReferenceCounted
{
public:
@ -37,7 +38,15 @@ namespace video
virtual const SExposedVideoData& getContext() const =0;
//! Change render context, disable old and activate new defined by videoData
virtual bool activateContext(const SExposedVideoData& videoData) =0;
//\param restorePrimaryOnZero When true: restore original driver context when videoData is set to 0 values.
// When false: resets the context when videoData is set to 0 values.
/** This is mostly used internally by IVideoDriver::beginScene().
But if you want to switch threads which access your OpenGL driver you will have to
call this function as follows:
Old thread gives up context with: activateContext(irr::video::SExposedVideoData());
New thread takes over context with: activateContext(videoDriver->getExposedVideoData());
Note that only 1 thread at a time may access an OpenGL context. */
virtual bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero=false) =0;
//! Swap buffers.
virtual bool swapBuffers() =0;

View File

@ -573,7 +573,7 @@ void CEGLManager::destroyContext()
EglContext = EGL_NO_CONTEXT;
}
bool CEGLManager::activateContext(const SExposedVideoData& videoData)
bool CEGLManager::activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero)
{
eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);

View File

@ -69,7 +69,7 @@ namespace video
virtual const SExposedVideoData& getContext() const _IRR_OVERRIDE_;
virtual bool activateContext(const SExposedVideoData& videoData) _IRR_OVERRIDE_;
virtual bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero) _IRR_OVERRIDE_;
// Swap buffers.
virtual bool swapBuffers() _IRR_OVERRIDE_;

View File

@ -345,8 +345,10 @@ const SExposedVideoData& CGLXManager::getContext() const
return CurrentContext;
}
bool CGLXManager::activateContext(const SExposedVideoData& videoData)
bool CGLXManager::activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero)
{
//TODO: handle restorePrimaryOnZero
if (videoData.OpenGLLinux.X11Window)
{
if (videoData.OpenGLLinux.X11Display && videoData.OpenGLLinux.X11Context)
@ -377,6 +379,16 @@ bool CGLXManager::activateContext(const SExposedVideoData& videoData)
}
}
}
else if (!restorePrimaryOnZero && !videoData.OpenGLLinux.X11Window && !videoData.OpenGLLinux.X11Display)
{
if (!glXMakeCurrent((Display*)PrimaryContext.OpenGLLinux.X11Display, None, NULL))
{
os::Printer::log("Render Context reset failed.");
return false;
}
CurrentContext.OpenGLLinux.X11Window = 0;
CurrentContext.OpenGLLinux.X11Display = 0;
}
// set back to main context
else if (CurrentContext.OpenGLLinux.X11Display != PrimaryContext.OpenGLLinux.X11Display)
{

View File

@ -55,7 +55,7 @@ namespace video
virtual const SExposedVideoData& getContext() const _IRR_OVERRIDE_;
//! Change render context, disable old and activate new defined by videoData
virtual bool activateContext(const SExposedVideoData& videoData) _IRR_OVERRIDE_;
virtual bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero) _IRR_OVERRIDE_;
// Swap buffers.
virtual bool swapBuffers() _IRR_OVERRIDE_;

View File

@ -937,7 +937,7 @@ void CGUIEditBox::draw()
}
// draw cursor
if ( IsEnabled )
if ( isEnabled() )
{
if (WordWrap || MultiLine)
{
@ -1397,7 +1397,6 @@ void CGUIEditBox::inputChar(wchar_t c)
if (c != 0)
{
if (Text.size() < Max || Max == 0)
{
core::stringw s;
@ -1418,23 +1417,27 @@ void CGUIEditBox::inputChar(wchar_t c)
//check to see if we are at the end of the text
if ( (u32)CursorPos != Text.size())
{
s = Text.subString(0, CursorPos);
s.append(c);
if ( Text[CursorPos] == L'\n')
bool isEOL = (Text[CursorPos] == L'\n' ||Text[CursorPos] == L'\r' );
if (!isEOL || Text.size() < Max || Max == 0)
{
//just keep appending to the current line
//This follows the behavior of over gui libraries behaviors
s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
s = Text.subString(0, CursorPos);
s.append(c);
if ( isEOL )
{
//just keep appending to the current line
//This follows the behavior of other gui libraries behaviors
s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
}
else
{
//replace the next character
s.append( Text.subString(CursorPos + 1,Text.size() - CursorPos + 1));
}
Text = s;
++CursorPos;
}
else
{
//replace the next character
s.append( Text.subString(CursorPos + 1,Text.size() - CursorPos + 1));
}
Text = s;
++CursorPos;
}
else
else if (Text.size() < Max || Max == 0)
{
// add new character because we are at the end of the string
s = Text.subString(0, CursorPos);
@ -1444,7 +1447,7 @@ void CGUIEditBox::inputChar(wchar_t c)
++CursorPos;
}
}
else
else if (Text.size() < Max || Max == 0)
{
// add new character
s = Text.subString(0, CursorPos);

View File

@ -75,7 +75,7 @@ COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFil
ContextManager->generateSurface();
ContextManager->generateContext();
ExposedData = ContextManager->getContext();
ContextManager->activateContext(ExposedData);
ContextManager->activateContext(ExposedData, false);
}
COGLES2Driver::~COGLES2Driver()
@ -426,7 +426,7 @@ COGLES2Driver::~COGLES2Driver()
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
if (ContextManager)
ContextManager->activateContext(videoData);
ContextManager->activateContext(videoData, true);
clearBuffers(clearFlag, clearColor, clearDepth, clearStencil);

View File

@ -47,7 +47,7 @@ COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params, io::IFil
ContextManager->generateSurface();
ContextManager->generateContext();
ExposedData = ContextManager->getContext();
ContextManager->activateContext(ExposedData);
ContextManager->activateContext(ExposedData, false);
windowSize = params.WindowSize;
@ -206,7 +206,7 @@ bool COGLES1Driver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth,
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
if (ContextManager)
ContextManager->activateContext(videoData);
ContextManager->activateContext(videoData, true);
clearBuffers(clearFlag, clearColor, clearDepth, clearStencil);

View File

@ -72,7 +72,7 @@ bool COpenGLDriver::initDriver()
ContextManager->generateSurface();
ContextManager->generateContext();
ExposedData = ContextManager->getContext();
ContextManager->activateContext(ExposedData);
ContextManager->activateContext(ExposedData, false);
genericDriverInit();
@ -288,7 +288,7 @@ bool COpenGLDriver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth,
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
if (ContextManager)
ContextManager->activateContext(videoData);
ContextManager->activateContext(videoData, true);
#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
if ( DeviceType == EIDT_SDL )
@ -3584,11 +3584,8 @@ void COpenGLDriver::draw3DLine(const core::vector3df& start,
//! Removes a texture from the texture cache and deletes it, freeing lot of memory.
void COpenGLDriver::removeTexture(ITexture* texture)
{
if (texture)
{
CacheHandler->getTextureCache().remove(texture);
CNullDriver::removeTexture(texture);
}
CacheHandler->getTextureCache().remove(texture);
CNullDriver::removeTexture(texture);
}
//! Check if the driver supports creating textures with the given color format

View File

@ -179,7 +179,7 @@ bool CWGLManager::initialize(const SIrrlichtCreationParameters& params, const SE
CurrentContext.OpenGLWin32.HRc = hrc;
CurrentContext.OpenGLWin32.HWnd = temporary_wnd;
if (!activateContext(CurrentContext))
if (!activateContext(CurrentContext, false))
{
os::Printer::log("Cannot activate a temporary GL rendering context.", ELL_ERROR);
wglDeleteContext(hrc);
@ -438,7 +438,7 @@ const SExposedVideoData& CWGLManager::getContext() const
return CurrentContext;
}
bool CWGLManager::activateContext(const SExposedVideoData& videoData)
bool CWGLManager::activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero)
{
if (videoData.OpenGLWin32.HWnd && videoData.OpenGLWin32.HDc && videoData.OpenGLWin32.HRc)
{
@ -449,6 +449,15 @@ bool CWGLManager::activateContext(const SExposedVideoData& videoData)
}
CurrentContext=videoData;
}
else if (!restorePrimaryOnZero && !videoData.OpenGLWin32.HDc && !videoData.OpenGLWin32.HRc)
{
if (!wglMakeCurrent((HDC)0, (HGLRC)0))
{
os::Printer::log("Render Context reset failed.");
return false;
}
CurrentContext = videoData;
}
// set back to main context
else if (!videoData.OpenGLWin32.HWnd && CurrentContext.OpenGLWin32.HDc != PrimaryContext.OpenGLWin32.HDc)
{

View File

@ -53,7 +53,7 @@ namespace video
virtual const SExposedVideoData& getContext() const _IRR_OVERRIDE_;
//! Change render context, disable old and activate new defined by videoData
virtual bool activateContext(const SExposedVideoData& videoData) _IRR_OVERRIDE_;
virtual bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero) _IRR_OVERRIDE_;
// Swap buffers.
virtual bool swapBuffers() _IRR_OVERRIDE_;