diff --git a/src/SFML/Graphics/Linux/RenderImageImplPBuffer.cpp b/src/SFML/Graphics/Linux/RenderImageImplPBuffer.cpp index 99219789..b945e70d 100644 --- a/src/SFML/Graphics/Linux/RenderImageImplPBuffer.cpp +++ b/src/SFML/Graphics/Linux/RenderImageImplPBuffer.cpp @@ -200,7 +200,7 @@ bool RenderImageImplPBuffer::Activate(bool active) //////////////////////////////////////////////////////////// /// /see RenderImageImpl::UpdateTexture //////////////////////////////////////////////////////////// -bool RenderImageImplPBuffer::UpdateTexture(unsigned int textureId) +void RenderImageImplPBuffer::UpdateTexture(unsigned int textureId) { if (Activate(true)) { @@ -215,11 +215,7 @@ bool RenderImageImplPBuffer::UpdateTexture(unsigned int textureId) GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, myWidth, myHeight)); GLCheck(glBindTexture(GL_TEXTURE_2D, previous)); - - return true; } - - return false; } } // namespace priv diff --git a/src/SFML/Graphics/Linux/RenderImageImplPBuffer.hpp b/src/SFML/Graphics/Linux/RenderImageImplPBuffer.hpp index 338259fc..06ef0727 100644 --- a/src/SFML/Graphics/Linux/RenderImageImplPBuffer.hpp +++ b/src/SFML/Graphics/Linux/RenderImageImplPBuffer.hpp @@ -29,11 +29,11 @@ // Headers //////////////////////////////////////////////////////////// #include -#include +#include #include #include - - + + namespace sf { namespace priv @@ -83,11 +83,11 @@ private : /// /see RenderImageImpl::UpdateTexture /// //////////////////////////////////////////////////////////// - virtual bool UpdateTexture(unsigned textureId); + virtual void UpdateTexture(unsigned textureId); //////////////////////////////////////////////////////////// // Member data - //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// ::Display* myDisplay; ///< Connection to the X display GLXPbuffer myPBuffer; ///< P-Buffer GLXContext myContext; ///< Associated OpenGL context diff --git a/src/SFML/Graphics/RenderImage.cpp b/src/SFML/Graphics/RenderImage.cpp index ba259764..3b91155d 100644 --- a/src/SFML/Graphics/RenderImage.cpp +++ b/src/SFML/Graphics/RenderImage.cpp @@ -134,9 +134,10 @@ void RenderImage::Display() // Update the target image if (myRenderImage) { - bool pixelsFlipped = myRenderImage->UpdateTexture(myImage.myTexture); - myImage.myPixelsFlipped = pixelsFlipped; - myImage.myArrayUpdated = false; + myRenderImage->UpdateTexture(myImage.myTexture); + + myImage.myPixelsFlipped = true; + myImage.myArrayUpdated = false; myImage.myTextureUpdated = true; } } diff --git a/src/SFML/Graphics/RenderImageImpl.hpp b/src/SFML/Graphics/RenderImageImpl.hpp index bf1a15f8..b0a9d987 100644 --- a/src/SFML/Graphics/RenderImageImpl.hpp +++ b/src/SFML/Graphics/RenderImageImpl.hpp @@ -74,10 +74,8 @@ public : /// /// \param textureId : OpenGL identifier of the target texture /// - /// \return True if the new pixels are flipped vertically - /// //////////////////////////////////////////////////////////// - virtual bool UpdateTexture(unsigned int textureId) = 0; + virtual void UpdateTexture(unsigned int textureId) = 0; }; } // namespace priv diff --git a/src/SFML/Graphics/RenderImageImplFBO.cpp b/src/SFML/Graphics/RenderImageImplFBO.cpp index c5ab6de9..d38bc072 100644 --- a/src/SFML/Graphics/RenderImageImplFBO.cpp +++ b/src/SFML/Graphics/RenderImageImplFBO.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include @@ -41,8 +40,7 @@ namespace priv //////////////////////////////////////////////////////////// RenderImageImplFBO::RenderImageImplFBO() : myFrameBuffer(0), -myDepthBuffer(0), -myContext (NULL) +myDepthBuffer(0) { } @@ -66,9 +64,6 @@ RenderImageImplFBO::~RenderImageImplFBO() GLuint frameBuffer = static_cast(myFrameBuffer); GLCheck(glDeleteFramebuffersEXT(1, &frameBuffer)); } - - // Destroy the context - delete myContext; } @@ -89,32 +84,18 @@ bool RenderImageImplFBO::IsSupported() //////////////////////////////////////////////////////////// bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer) { - // Create the context if not already done - if (!myContext) - myContext = new Context; - - // Create the framebuffer object if not already done + // Create the framebuffer object + GLuint frameBuffer = 0; + GLCheck(glGenFramebuffersEXT(1, &frameBuffer)); + myFrameBuffer = static_cast(frameBuffer); if (!myFrameBuffer) { - GLuint frameBuffer = 0; - GLCheck(glGenFramebuffersEXT(1, &frameBuffer)); - myFrameBuffer = static_cast(frameBuffer); - if (!myFrameBuffer) - { - std::cerr << "Impossible to create render image (failed to create the frame buffer object)" << std::endl; - return false; - } + std::cerr << "Impossible to create render image (failed to create the frame buffer object)" << std::endl; + return false; } - - // Bind the framebuffer GLCheck(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFrameBuffer)); - // Create the depth buffer - if (myDepthBuffer) - { - GLuint depth = static_cast(myDepthBuffer); - GLCheck(glDeleteRenderbuffersEXT(1, &depth)); - } + // Create the depth buffer if requested if (depthBuffer) { GLuint depth = 0; @@ -150,8 +131,7 @@ bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigne //////////////////////////////////////////////////////////// bool RenderImageImplFBO::Activate(bool active) { - if (myContext) - myContext->SetActive(active); + myContext.SetActive(active); return true; } @@ -159,10 +139,9 @@ bool RenderImageImplFBO::Activate(bool active) //////////////////////////////////////////////////////////// /// /see RenderImageImpl::UpdateTexture //////////////////////////////////////////////////////////// -bool RenderImageImplFBO::UpdateTexture(unsigned int) +void RenderImageImplFBO::UpdateTexture(unsigned int) { // Nothing to do: the FBO draws directly into the target image - return true; } } // namespace priv diff --git a/src/SFML/Graphics/RenderImageImplFBO.hpp b/src/SFML/Graphics/RenderImageImplFBO.hpp index 2529e293..d289f584 100644 --- a/src/SFML/Graphics/RenderImageImplFBO.hpp +++ b/src/SFML/Graphics/RenderImageImplFBO.hpp @@ -29,17 +29,16 @@ // Headers //////////////////////////////////////////////////////////// #include +#include namespace sf { -class Context; - namespace priv { //////////////////////////////////////////////////////////// /// Specialization of RenderImageImpl using the -/// FrameBuffer Object extension +/// Frame Buffer Object extension //////////////////////////////////////////////////////////// class RenderImageImplFBO : public RenderImageImpl { @@ -83,14 +82,14 @@ private : /// /see RenderImageImpl::UpdateTexture /// //////////////////////////////////////////////////////////// - virtual bool UpdateTexture(unsigned textureId); + virtual void UpdateTexture(unsigned textureId); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// unsigned int myFrameBuffer; ///< OpenGL frame buffer object unsigned int myDepthBuffer; ///< Optional depth buffer attached to the frame buffer - Context* myContext; ///< Needs a separate OpenGL context for not messing up the other ones + Context myContext; ///< Needs a separate OpenGL context for not messing up the other ones }; } // namespace priv diff --git a/src/SFML/Graphics/Win32/RenderImageImplPBuffer.cpp b/src/SFML/Graphics/Win32/RenderImageImplPBuffer.cpp index e3e7a60d..90f6b055 100644 --- a/src/SFML/Graphics/Win32/RenderImageImplPBuffer.cpp +++ b/src/SFML/Graphics/Win32/RenderImageImplPBuffer.cpp @@ -191,7 +191,7 @@ bool RenderImageImplPBuffer::Activate(bool active) //////////////////////////////////////////////////////////// /// /see RenderImageImpl::UpdateTexture //////////////////////////////////////////////////////////// -bool RenderImageImplPBuffer::UpdateTexture(unsigned int textureId) +void RenderImageImplPBuffer::UpdateTexture(unsigned int textureId) { if (Activate(true)) { @@ -206,11 +206,7 @@ bool RenderImageImplPBuffer::UpdateTexture(unsigned int textureId) GLCheck(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, myWidth, myHeight)); GLCheck(glBindTexture(GL_TEXTURE_2D, previous)); - - return true; } - - return false; } } // namespace priv diff --git a/src/SFML/Graphics/Win32/RenderImageImplPBuffer.hpp b/src/SFML/Graphics/Win32/RenderImageImplPBuffer.hpp index c6b1b6c6..b3e4ba22 100644 --- a/src/SFML/Graphics/Win32/RenderImageImplPBuffer.hpp +++ b/src/SFML/Graphics/Win32/RenderImageImplPBuffer.hpp @@ -82,7 +82,7 @@ private : /// /see RenderImageImpl::UpdateTexture /// //////////////////////////////////////////////////////////// - virtual bool UpdateTexture(unsigned textureId); + virtual void UpdateTexture(unsigned textureId); //////////////////////////////////////////////////////////// // Member data