mirror of
https://github.com/SFML/SFML.git
synced 2024-11-29 06:41:05 +08:00
Some minor modifications in RenderImage implementation
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1363 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
c237305f9b
commit
2e40f341ba
@ -200,7 +200,7 @@ bool RenderImageImplPBuffer::Activate(bool active)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// /see RenderImageImpl::UpdateTexture
|
/// /see RenderImageImpl::UpdateTexture
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderImageImplPBuffer::UpdateTexture(unsigned int textureId)
|
void RenderImageImplPBuffer::UpdateTexture(unsigned int textureId)
|
||||||
{
|
{
|
||||||
if (Activate(true))
|
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(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, myWidth, myHeight));
|
||||||
|
|
||||||
GLCheck(glBindTexture(GL_TEXTURE_2D, previous));
|
GLCheck(glBindTexture(GL_TEXTURE_2D, previous));
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -83,7 +83,7 @@ private :
|
|||||||
/// /see RenderImageImpl::UpdateTexture
|
/// /see RenderImageImpl::UpdateTexture
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual bool UpdateTexture(unsigned textureId);
|
virtual void UpdateTexture(unsigned textureId);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
|
@ -134,8 +134,9 @@ void RenderImage::Display()
|
|||||||
// Update the target image
|
// Update the target image
|
||||||
if (myRenderImage)
|
if (myRenderImage)
|
||||||
{
|
{
|
||||||
bool pixelsFlipped = myRenderImage->UpdateTexture(myImage.myTexture);
|
myRenderImage->UpdateTexture(myImage.myTexture);
|
||||||
myImage.myPixelsFlipped = pixelsFlipped;
|
|
||||||
|
myImage.myPixelsFlipped = true;
|
||||||
myImage.myArrayUpdated = false;
|
myImage.myArrayUpdated = false;
|
||||||
myImage.myTextureUpdated = true;
|
myImage.myTextureUpdated = true;
|
||||||
}
|
}
|
||||||
|
@ -74,10 +74,8 @@ public :
|
|||||||
///
|
///
|
||||||
/// \param textureId : OpenGL identifier of the target texture
|
/// \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
|
} // namespace priv
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <SFML/Graphics/RenderImageImplFBO.hpp>
|
#include <SFML/Graphics/RenderImageImplFBO.hpp>
|
||||||
#include <SFML/Graphics/Image.hpp>
|
#include <SFML/Graphics/Image.hpp>
|
||||||
#include <SFML/Graphics/GLCheck.hpp>
|
#include <SFML/Graphics/GLCheck.hpp>
|
||||||
#include <SFML/Window/Context.hpp>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
@ -41,8 +40,7 @@ namespace priv
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
RenderImageImplFBO::RenderImageImplFBO() :
|
RenderImageImplFBO::RenderImageImplFBO() :
|
||||||
myFrameBuffer(0),
|
myFrameBuffer(0),
|
||||||
myDepthBuffer(0),
|
myDepthBuffer(0)
|
||||||
myContext (NULL)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -66,9 +64,6 @@ RenderImageImplFBO::~RenderImageImplFBO()
|
|||||||
GLuint frameBuffer = static_cast<GLuint>(myFrameBuffer);
|
GLuint frameBuffer = static_cast<GLuint>(myFrameBuffer);
|
||||||
GLCheck(glDeleteFramebuffersEXT(1, &frameBuffer));
|
GLCheck(glDeleteFramebuffersEXT(1, &frameBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the context
|
|
||||||
delete myContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,13 +84,7 @@ bool RenderImageImplFBO::IsSupported()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer)
|
bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer)
|
||||||
{
|
{
|
||||||
// Create the context if not already done
|
// Create the framebuffer object
|
||||||
if (!myContext)
|
|
||||||
myContext = new Context;
|
|
||||||
|
|
||||||
// Create the framebuffer object if not already done
|
|
||||||
if (!myFrameBuffer)
|
|
||||||
{
|
|
||||||
GLuint frameBuffer = 0;
|
GLuint frameBuffer = 0;
|
||||||
GLCheck(glGenFramebuffersEXT(1, &frameBuffer));
|
GLCheck(glGenFramebuffersEXT(1, &frameBuffer));
|
||||||
myFrameBuffer = static_cast<unsigned int>(frameBuffer);
|
myFrameBuffer = static_cast<unsigned int>(frameBuffer);
|
||||||
@ -104,17 +93,9 @@ bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigne
|
|||||||
std::cerr << "Impossible to create render image (failed to create the frame buffer object)" << std::endl;
|
std::cerr << "Impossible to create render image (failed to create the frame buffer object)" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Bind the framebuffer
|
|
||||||
GLCheck(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFrameBuffer));
|
GLCheck(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, myFrameBuffer));
|
||||||
|
|
||||||
// Create the depth buffer
|
// Create the depth buffer if requested
|
||||||
if (myDepthBuffer)
|
|
||||||
{
|
|
||||||
GLuint depth = static_cast<GLuint>(myDepthBuffer);
|
|
||||||
GLCheck(glDeleteRenderbuffersEXT(1, &depth));
|
|
||||||
}
|
|
||||||
if (depthBuffer)
|
if (depthBuffer)
|
||||||
{
|
{
|
||||||
GLuint depth = 0;
|
GLuint depth = 0;
|
||||||
@ -150,8 +131,7 @@ bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigne
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderImageImplFBO::Activate(bool active)
|
bool RenderImageImplFBO::Activate(bool active)
|
||||||
{
|
{
|
||||||
if (myContext)
|
myContext.SetActive(active);
|
||||||
myContext->SetActive(active);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -159,10 +139,9 @@ bool RenderImageImplFBO::Activate(bool active)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// /see RenderImageImpl::UpdateTexture
|
/// /see RenderImageImpl::UpdateTexture
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderImageImplFBO::UpdateTexture(unsigned int)
|
void RenderImageImplFBO::UpdateTexture(unsigned int)
|
||||||
{
|
{
|
||||||
// Nothing to do: the FBO draws directly into the target image
|
// Nothing to do: the FBO draws directly into the target image
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -29,12 +29,11 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/RenderImageImpl.hpp>
|
#include <SFML/Graphics/RenderImageImpl.hpp>
|
||||||
|
#include <SFML/Window/Context.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
{
|
{
|
||||||
class Context;
|
|
||||||
|
|
||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -83,14 +82,14 @@ private :
|
|||||||
/// /see RenderImageImpl::UpdateTexture
|
/// /see RenderImageImpl::UpdateTexture
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual bool UpdateTexture(unsigned textureId);
|
virtual void UpdateTexture(unsigned textureId);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
unsigned int myFrameBuffer; ///< OpenGL frame buffer object
|
unsigned int myFrameBuffer; ///< OpenGL frame buffer object
|
||||||
unsigned int myDepthBuffer; ///< Optional depth buffer attached to the frame buffer
|
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
|
} // namespace priv
|
||||||
|
@ -191,7 +191,7 @@ bool RenderImageImplPBuffer::Activate(bool active)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// /see RenderImageImpl::UpdateTexture
|
/// /see RenderImageImpl::UpdateTexture
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderImageImplPBuffer::UpdateTexture(unsigned int textureId)
|
void RenderImageImplPBuffer::UpdateTexture(unsigned int textureId)
|
||||||
{
|
{
|
||||||
if (Activate(true))
|
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(glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, myWidth, myHeight));
|
||||||
|
|
||||||
GLCheck(glBindTexture(GL_TEXTURE_2D, previous));
|
GLCheck(glBindTexture(GL_TEXTURE_2D, previous));
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -82,7 +82,7 @@ private :
|
|||||||
/// /see RenderImageImpl::UpdateTexture
|
/// /see RenderImageImpl::UpdateTexture
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual bool UpdateTexture(unsigned textureId);
|
virtual void UpdateTexture(unsigned textureId);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
|
Loading…
Reference in New Issue
Block a user