blob: 7fb5562e5c0e4b2f889340988282c3a5917b19f2 [file] [log] [blame] [edit]
# HG changeset patch
# User Erik Ogenvik <erik@ogenvik.org>
# Date 1521740507 -3600
# Branch v0-8
# Node ID b7f846e6d8926f09080c4326f60cf6049ba5f5fc
# Parent a404dc83619fba5351a13bfdbab1fec12776d4ed
Use macros to handle changed Ogre::SharedPtr API.
diff --git a/cegui/include/CEGUI/RendererModules/Ogre/OgreMacros.h b/cegui/include/CEGUI/RendererModules/Ogre/OgreMacros.h
new file mode 100644
--- /dev/null
+++ b/cegui/include/CEGUI/RendererModules/Ogre/OgreMacros.h
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (C) 2018 Erik Ogenvik
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ ***************************************************************************/
+
+#ifndef _CEGUIOgreMacros_h_
+#define _CEGUIOgreMacros_h_
+
+#include <OgrePrerequisites.h>
+
+//New shared ptr API introduced in 1.10.1
+#if OGRE_VERSION >= 0x10A01
+#define OGRE_RESET(_sharedPtr) ((_sharedPtr).reset())
+#define OGRE_ISNULL(_sharedPtr) (!(_sharedPtr))
+#else
+#define OGRE_RESET(_sharedPtr) ((_sharedPtr).setNull())
+#define OGRE_ISNULL(_sharedPtr) ((_sharedPtr).isNull())
+#endif
+
+#endif //_CEGUIOgreMacros_h_
diff --git a/cegui/src/RendererModules/Ogre/CMakeLists.txt b/cegui/src/RendererModules/Ogre/CMakeLists.txt
--- a/cegui/src/RendererModules/Ogre/CMakeLists.txt
+++ b/cegui/src/RendererModules/Ogre/CMakeLists.txt
@@ -11,11 +11,5 @@
if (CEGUI_FOUND_OGRE_VERSION_MAJOR GREATER 0 AND CEGUI_FOUND_OGRE_VERSION_MINOR GREATER 10)
target_compile_features(${CEGUI_TARGET_NAME} PRIVATE cxx_std_11)
-
-target_compile_definitions(${CEGUI_TARGET_NAME}
- PRIVATE
- -DOGRE_VERSION_MAJOR=${CEGUI_FOUND_OGRE_VERSION_MAJOR}
- -DOGRE_VERSION_MINOR=${CEGUI_FOUND_OGRE_VERSION_MINOR}
- )
endif(CEGUI_FOUND_OGRE_VERSION_MAJOR GREATER 0 AND CEGUI_FOUND_OGRE_VERSION_MINOR GREATER 10)
diff --git a/cegui/src/RendererModules/Ogre/GeometryBuffer.cpp b/cegui/src/RendererModules/Ogre/GeometryBuffer.cpp
--- a/cegui/src/RendererModules/Ogre/GeometryBuffer.cpp
+++ b/cegui/src/RendererModules/Ogre/GeometryBuffer.cpp
@@ -26,6 +26,7 @@
***************************************************************************/
#include "CEGUI/RendererModules/Ogre/GeometryBuffer.h"
#include "CEGUI/RendererModules/Ogre/Texture.h"
+#include "CEGUI/RendererModules/Ogre/OgreMacros.h"
#include "CEGUI/Vertex.h"
#include "CEGUI/RenderEffect.h"
@@ -39,6 +40,8 @@
#include <OgreViewport.h>
#endif
+
+
// Start of CEGUI namespace section
namespace CEGUI
{
@@ -132,7 +135,7 @@
{
OGRE_DELETE rop.vertexData;
rop.vertexData = 0;
- vb.setNull();
+ OGRE_RESET(vb);
}
//----------------------------------------------------------------------------//
diff --git a/cegui/src/RendererModules/Ogre/Renderer.cpp b/cegui/src/RendererModules/Ogre/Renderer.cpp
--- a/cegui/src/RendererModules/Ogre/Renderer.cpp
+++ b/cegui/src/RendererModules/Ogre/Renderer.cpp
@@ -29,6 +29,7 @@
#include "CEGUI/RendererModules/Ogre/TextureTarget.h"
#include "CEGUI/RendererModules/Ogre/Texture.h"
#include "CEGUI/RendererModules/Ogre/WindowTarget.h"
+#include "CEGUI/RendererModules/Ogre/OgreMacros.h"
#include "CEGUI/GUIContext.h"
#include "CEGUI/Exceptions.h"
#include "CEGUI/System.h"
@@ -62,7 +63,7 @@
#include <OgreHlmsDatablock.h>
#endif
-#if OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 11
+#if OGRE_VERSION > 0x11000
#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM
#include <RTShaderSystem/OgreRTShaderConfig.h>
#endif
@@ -919,7 +920,7 @@
}
else// If no shader was compatible
{
- d_pimpl->d_vertexShader.setNull();
+ OGRE_RESET(d_pimpl->d_vertexShader);
CEGUI_THROW(RendererException(
"OgreRenderer::initialiseShaders: No supported syntax - "
"unable to compile '__cegui_internal_vs__'"));
@@ -970,8 +971,8 @@
}
else
{
- d_pimpl->d_vertexShader.setNull();
- d_pimpl->d_pixelShader.setNull();
+ OGRE_RESET(d_pimpl->d_vertexShader);
+ OGRE_RESET(d_pimpl->d_pixelShader);
CEGUI_THROW(RendererException(
"OgreRenderer::initialiseShaders: No supported syntax - "
@@ -1002,10 +1003,10 @@
if (d_pimpl->d_hlmsSamplerblock != NULL)
hlmsManager->destroySamplerblock(d_pimpl->d_hlmsSamplerblock);
#endif
- d_pimpl->d_pixelShaderParameters.setNull();
- d_pimpl->d_vertexShaderParameters.setNull();
- d_pimpl->d_pixelShader.setNull();
- d_pimpl->d_vertexShader.setNull();
+ OGRE_RESET(d_pimpl->d_pixelShaderParameters);
+ OGRE_RESET(d_pimpl->d_vertexShaderParameters);
+ OGRE_RESET(d_pimpl->d_pixelShader);
+ OGRE_RESET(d_pimpl->d_vertexShader);
}
//----------------------------------------------------------------------------//
diff --git a/cegui/src/RendererModules/Ogre/ResourceProvider.cpp b/cegui/src/RendererModules/Ogre/ResourceProvider.cpp
--- a/cegui/src/RendererModules/Ogre/ResourceProvider.cpp
+++ b/cegui/src/RendererModules/Ogre/ResourceProvider.cpp
@@ -27,6 +27,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#include "CEGUI/RendererModules/Ogre/ResourceProvider.h"
+#include "CEGUI/RendererModules/Ogre/OgreMacros.h"
#include "CEGUI/Exceptions.h"
#include <OgreArchiveManager.h>
@@ -59,7 +60,7 @@
Ogre::DataStreamPtr input = Ogre::ResourceGroupManager::getSingleton().
openResource(filename.c_str(), orpGroup.c_str());
- if (input.isNull())
+ if (OGRE_ISNULL(input))
CEGUI_THROW(InvalidRequestException(
"Unable to open resource file '" + filename +
"' in resource group '" + orpGroup + "'."));
diff --git a/cegui/src/RendererModules/Ogre/Texture.cpp b/cegui/src/RendererModules/Ogre/Texture.cpp
--- a/cegui/src/RendererModules/Ogre/Texture.cpp
+++ b/cegui/src/RendererModules/Ogre/Texture.cpp
@@ -25,6 +25,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#include "CEGUI/RendererModules/Ogre/Texture.h"
+#include "CEGUI/RendererModules/Ogre/OgreMacros.h"
#include "CEGUI/Exceptions.h"
#include "CEGUI/System.h"
#include "CEGUI/RendererModules/Ogre/ImageCodec.h"
@@ -105,7 +106,7 @@
createEmptyOgreTexture(Texture::PF_RGBA);
// throw exception if no texture was able to be created
- if (d_texture.isNull())
+ if (OGRE_ISNULL(d_texture))
CEGUI_THROW(RendererException(
"Failed to create Texture object with spcecified size."));
@@ -222,7 +223,7 @@
d_texture->getBuffer(0,0).get()->blitFromMemory(*pixelBox);
// throw exception if no texture was able to be created
- if (d_texture.isNull())
+ if (OGRE_ISNULL(d_texture))
CEGUI_THROW(RendererException(
"Failed to blit to Texture from memory."));
@@ -235,7 +236,7 @@
//----------------------------------------------------------------------------//
void OgreTexture::blitFromMemory(const void* sourceData, const Rectf& area)
{
- if (d_texture.isNull()) // TODO: exception?
+ if (OGRE_ISNULL(d_texture)) // TODO: exception?
return;
// NOTE: const_cast because Ogre takes pointer to non-const here. Rather
@@ -250,7 +251,7 @@
//----------------------------------------------------------------------------//
void OgreTexture::blitToMemory(void* targetData)
{
- if (d_texture.isNull()) // TODO: exception?
+ if (OGRE_ISNULL(d_texture)) // TODO: exception?
return;
Ogre::PixelBox pb(d_size.d_width, d_size.d_height,
@@ -261,10 +262,10 @@
//----------------------------------------------------------------------------//
void OgreTexture::freeOgreTexture()
{
- if (!d_texture.isNull() && !d_isLinked)
+ if (!OGRE_ISNULL(d_texture) && !d_isLinked)
Ogre::TextureManager::getSingleton().remove(d_texture->getHandle());
- d_texture.setNull();
+ OGRE_RESET(d_texture);
}
//----------------------------------------------------------------------------//
@@ -320,7 +321,7 @@
d_texture = texture;
d_isLinked = !take_ownership;
- if (!d_texture.isNull())
+ if (!OGRE_ISNULL(d_texture))
{
d_size.d_width = d_texture->getWidth();
d_size.d_height= d_texture->getHeight();