Updated the API documentation of the graphics module
sf::Image now uses GL_CLAMP_TO_EDGE instead of GL_CLAMP (removes black border when the image is smooth) git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1511 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
7d68f59a5a
commit
073e7864ef
24 changed files with 931 additions and 649 deletions
|
@ -34,8 +34,6 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check the last OpenGL error
|
||||
////////////////////////////////////////////////////////////
|
||||
void GLCheckError(const std::string& file, unsigned int line)
|
||||
{
|
||||
// Get the last error
|
||||
|
@ -108,8 +106,6 @@ void GLCheckError(const std::string& file, unsigned int line)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make sure that GLEW is initialized
|
||||
////////////////////////////////////////////////////////////
|
||||
void EnsureGlewInit()
|
||||
{
|
||||
|
|
|
@ -54,16 +54,16 @@ namespace priv
|
|||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check the last OpenGL error
|
||||
/// \brief Check the last OpenGL error
|
||||
///
|
||||
/// \param file : Source file where the call is located
|
||||
/// \param line : Line number of the source file where the call is located
|
||||
/// \param file Source file where the call is located
|
||||
/// \param line Line number of the source file where the call is located
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void GLCheckError(const std::string& file, unsigned int line);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make sure that GLEW is initialized
|
||||
/// \brief Make sure that GLEW is initialized
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void EnsureGlewInit();
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Image::Image() :
|
||||
myWidth (0),
|
||||
myHeight (0),
|
||||
|
@ -56,8 +54,6 @@ myPixelsFlipped (false)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Image::Image(const Image& copy) :
|
||||
Resource<Image>()
|
||||
|
@ -82,8 +78,6 @@ Resource<Image>()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Image::~Image()
|
||||
{
|
||||
|
@ -92,8 +86,6 @@ Image::~Image()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load the image from a file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::LoadFromFile(const std::string& filename)
|
||||
{
|
||||
|
@ -115,19 +107,17 @@ bool Image::LoadFromFile(const std::string& filename)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load the image from a file in memory
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::LoadFromMemory(const void* data, std::size_t sizeInBytes)
|
||||
bool Image::LoadFromMemory(const void* data, std::size_t size)
|
||||
{
|
||||
// Check parameters
|
||||
if (!data || (sizeInBytes == 0))
|
||||
if (!data || (size == 0))
|
||||
{
|
||||
Err() << "Failed to image font from memory, no data provided" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Let the image loader load the image into our pixel array
|
||||
bool success = priv::ImageLoader::GetInstance().LoadImageFromMemory(data, sizeInBytes, myPixels, myWidth, myHeight);
|
||||
bool success = priv::ImageLoader::GetInstance().LoadImageFromMemory(data, size, myPixels, myWidth, myHeight);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
@ -143,8 +133,6 @@ bool Image::LoadFromMemory(const void* data, std::size_t sizeInBytes)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load the image directly from an array of pixels
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::LoadFromPixels(unsigned int width, unsigned int height, const Uint8* data)
|
||||
{
|
||||
|
@ -178,8 +166,6 @@ bool Image::LoadFromPixels(unsigned int width, unsigned int height, const Uint8*
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save the content of the image to a file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::SaveToFile(const std::string& filename) const
|
||||
{
|
||||
|
@ -191,8 +177,6 @@ bool Image::SaveToFile(const std::string& filename) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create an empty image
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::Create(unsigned int width, unsigned int height, const Color& color)
|
||||
{
|
||||
|
@ -228,8 +212,6 @@ bool Image::Create(unsigned int width, unsigned int height, const Color& color)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create transparency mask from a specified colorkey
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::CreateMaskFromColor(const Color& color, Uint8 alpha)
|
||||
{
|
||||
|
@ -255,10 +237,6 @@ void Image::CreateMaskFromColor(const Color& color, Uint8 alpha)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Copy pixels from another image onto this one.
|
||||
/// This function does a slow pixel copy and should only
|
||||
/// be used at initialization time
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect, bool applyAlpha)
|
||||
{
|
||||
|
@ -345,9 +323,6 @@ void Image::Copy(const Image& source, unsigned int destX, unsigned int destY, co
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create the image from the current contents of the
|
||||
/// given window
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::CopyScreen(RenderWindow& window, const IntRect& sourceRect)
|
||||
{
|
||||
|
@ -397,8 +372,6 @@ bool Image::CopyScreen(RenderWindow& window, const IntRect& sourceRect)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the color of a pixel
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::SetPixel(unsigned int x, unsigned int y, const Color& color)
|
||||
{
|
||||
|
@ -417,8 +390,6 @@ void Image::SetPixel(unsigned int x, unsigned int y, const Color& color)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a pixel from the image
|
||||
////////////////////////////////////////////////////////////
|
||||
Color Image::GetPixel(unsigned int x, unsigned int y) const
|
||||
{
|
||||
|
@ -432,10 +403,6 @@ Color Image::GetPixel(unsigned int x, unsigned int y) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a read-only pointer to the array of pixels (RGBA 8 bits integers components)
|
||||
/// Array size is GetWidth() x GetHeight() x 4
|
||||
/// This pointer becomes invalid if you reload or resize the image
|
||||
////////////////////////////////////////////////////////////
|
||||
const Uint8* Image::GetPixelsPtr() const
|
||||
{
|
||||
|
@ -454,8 +421,6 @@ const Uint8* Image::GetPixelsPtr() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Update the whole image from an array of pixels
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::UpdatePixels(const Uint8* pixels)
|
||||
{
|
||||
|
@ -473,8 +438,6 @@ void Image::UpdatePixels(const Uint8* pixels)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Update a sub-rectangle of the image from an array of pixels
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::UpdatePixels(const Uint8* pixels, const IntRect& rectangle)
|
||||
{
|
||||
|
@ -495,8 +458,6 @@ void Image::UpdatePixels(const Uint8* pixels, const IntRect& rectangle)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Bind the image for rendering
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::Bind() const
|
||||
{
|
||||
|
@ -508,8 +469,6 @@ void Image::Bind() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Enable or disable image smoothing filter
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::SetSmooth(bool smooth)
|
||||
{
|
||||
|
@ -532,8 +491,6 @@ void Image::SetSmooth(bool smooth)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the width of the image
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Image::GetWidth() const
|
||||
{
|
||||
|
@ -541,8 +498,6 @@ unsigned int Image::GetWidth() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the height of the image
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Image::GetHeight() const
|
||||
{
|
||||
|
@ -550,8 +505,6 @@ unsigned int Image::GetHeight() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Tells whether the smooth filtering is enabled or not
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::IsSmooth() const
|
||||
{
|
||||
|
@ -559,9 +512,6 @@ bool Image::IsSmooth() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Convert a subrect expressed in pixels, into float
|
||||
/// texture coordinates
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect Image::GetTexCoords(const IntRect& rect) const
|
||||
{
|
||||
|
@ -592,8 +542,6 @@ FloatRect Image::GetTexCoords(const IntRect& rect) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the maximum image size according to hardware support
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Image::GetMaximumSize()
|
||||
{
|
||||
|
@ -605,7 +553,25 @@ unsigned int Image::GetMaximumSize()
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a valid image size according to hardware support
|
||||
Image& Image::operator =(const Image& other)
|
||||
{
|
||||
Image temp(other);
|
||||
|
||||
std::swap(myWidth, temp.myWidth);
|
||||
std::swap(myHeight, temp.myHeight);
|
||||
std::swap(myTextureWidth, temp.myTextureWidth);
|
||||
std::swap(myTextureHeight, temp.myTextureHeight);
|
||||
std::swap(myTexture, temp.myTexture);
|
||||
std::swap(myIsSmooth, temp.myIsSmooth);
|
||||
std::swap(myArrayUpdated, temp.myArrayUpdated);
|
||||
std::swap(myTextureUpdated, temp.myTextureUpdated);
|
||||
std::swap(myPixelsFlipped, temp.myPixelsFlipped);
|
||||
std::swap(myPixels, temp.myPixels);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Image::GetValidSize(unsigned int size)
|
||||
{
|
||||
|
@ -629,30 +595,6 @@ unsigned int Image::GetValidSize(unsigned int size)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Assignment operator
|
||||
////////////////////////////////////////////////////////////
|
||||
Image& Image::operator =(const Image& other)
|
||||
{
|
||||
Image temp(other);
|
||||
|
||||
std::swap(myWidth, temp.myWidth);
|
||||
std::swap(myHeight, temp.myHeight);
|
||||
std::swap(myTextureWidth, temp.myTextureWidth);
|
||||
std::swap(myTextureHeight, temp.myTextureHeight);
|
||||
std::swap(myTexture, temp.myTexture);
|
||||
std::swap(myIsSmooth, temp.myIsSmooth);
|
||||
std::swap(myArrayUpdated, temp.myArrayUpdated);
|
||||
std::swap(myTextureUpdated, temp.myTextureUpdated);
|
||||
std::swap(myPixelsFlipped, temp.myPixelsFlipped);
|
||||
std::swap(myPixels, temp.myPixels);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create the OpenGL texture
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Image::CreateTexture()
|
||||
{
|
||||
|
@ -688,8 +630,8 @@ bool Image::CreateTexture()
|
|||
GLCheck(glGetIntegerv(GL_TEXTURE_BINDING_2D, &previous));
|
||||
GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture));
|
||||
GLCheck(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, myTextureWidth, myTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL));
|
||||
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));
|
||||
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));
|
||||
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
|
||||
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
|
||||
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
|
||||
GLCheck(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, myIsSmooth ? GL_LINEAR : GL_NEAREST));
|
||||
GLCheck(glBindTexture(GL_TEXTURE_2D, previous));
|
||||
|
@ -700,9 +642,6 @@ bool Image::CreateTexture()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make sure the texture in video memory is updated with the
|
||||
/// array of pixels
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::EnsureTextureUpdate() const
|
||||
{
|
||||
|
@ -726,9 +665,6 @@ void Image::EnsureTextureUpdate() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make sure the array of pixels is updated with the
|
||||
/// texture in video memory
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::EnsureArrayUpdate() const
|
||||
{
|
||||
|
@ -787,8 +723,6 @@ void Image::EnsureArrayUpdate() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Make sure that the image is ready to be used
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::Use() const
|
||||
{
|
||||
|
@ -796,8 +730,6 @@ void Image::Use() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Reset the image attributes
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::Reset()
|
||||
{
|
||||
|
@ -816,8 +748,6 @@ void Image::Reset()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destroy the OpenGL texture
|
||||
////////////////////////////////////////////////////////////
|
||||
void Image::DestroyTexture()
|
||||
{
|
||||
|
|
|
@ -42,8 +42,6 @@ extern "C"
|
|||
|
||||
namespace
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Error callback for PNG writing
|
||||
////////////////////////////////////////////////////////////
|
||||
void PngErrorHandler(png_structp png, png_const_charp message)
|
||||
{
|
||||
|
@ -58,8 +56,6 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the unique instance of the class
|
||||
////////////////////////////////////////////////////////////
|
||||
ImageLoader& ImageLoader::GetInstance()
|
||||
{
|
||||
static ImageLoader Instance;
|
||||
|
@ -68,8 +64,6 @@ ImageLoader& ImageLoader::GetInstance()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
ImageLoader::ImageLoader()
|
||||
{
|
||||
|
@ -77,8 +71,6 @@ ImageLoader::ImageLoader()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
ImageLoader::~ImageLoader()
|
||||
{
|
||||
|
@ -86,8 +78,6 @@ ImageLoader::~ImageLoader()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load pixels from an image file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool ImageLoader::LoadImageFromFile(const std::string& filename, std::vector<Uint8>& pixels, unsigned int& width, unsigned int& height)
|
||||
{
|
||||
|
@ -124,18 +114,15 @@ bool ImageLoader::LoadImageFromFile(const std::string& filename, std::vector<Uin
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load pixels from an image file in memory
|
||||
////////////////////////////////////////////////////////////
|
||||
bool ImageLoader::LoadImageFromMemory(const void* data, std::size_t sizeInBytes, std::vector<Uint8>& pixels, unsigned int& width, unsigned int& height)
|
||||
bool ImageLoader::LoadImageFromMemory(const void* data, std::size_t size, std::vector<Uint8>& pixels, unsigned int& width, unsigned int& height)
|
||||
{
|
||||
// Clear the array (just in case)
|
||||
pixels.clear();
|
||||
|
||||
// Load the image and get a pointer to the pixels in memory
|
||||
const unsigned char* buffer = static_cast<const unsigned char*>(data);
|
||||
int size = static_cast<int>(sizeInBytes);
|
||||
int imgWidth, imgHeight, imgChannels;
|
||||
unsigned char* ptr = SOIL_load_image_from_memory(buffer, size, &imgWidth, &imgHeight, &imgChannels, SOIL_LOAD_RGBA);
|
||||
const unsigned char* buffer = static_cast<const unsigned char*>(data);
|
||||
unsigned char* ptr = SOIL_load_image_from_memory(buffer, static_cast<int>(size), &imgWidth, &imgHeight, &imgChannels, SOIL_LOAD_RGBA);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
|
@ -162,8 +149,6 @@ bool ImageLoader::LoadImageFromMemory(const void* data, std::size_t sizeInBytes,
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save pixels to an image file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool ImageLoader::SaveImageToFile(const std::string& filename, const std::vector<Uint8>& pixels, unsigned int width, unsigned int height)
|
||||
{
|
||||
|
@ -200,8 +185,6 @@ bool ImageLoader::SaveImageToFile(const std::string& filename, const std::vector
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save a JPG image file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool ImageLoader::WriteJpg(const std::string& filename, const std::vector<Uint8>& pixels, unsigned int width, unsigned int height)
|
||||
{
|
||||
|
@ -259,8 +242,6 @@ bool ImageLoader::WriteJpg(const std::string& filename, const std::vector<Uint8>
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save a PNG image file
|
||||
////////////////////////////////////////////////////////////
|
||||
bool ImageLoader::WritePng(const std::string& filename, const std::vector<Uint8>& pixels, unsigned int width, unsigned int height)
|
||||
{
|
||||
|
|
|
@ -38,15 +38,15 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// ImageLoader load and save images from files ;
|
||||
/// Supported formats are : bmp, dds, jpg, png, tga, psd
|
||||
/// \brief Load/save image files
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class ImageLoader : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the unique instance of the class
|
||||
/// \brief Get the unique instance of the class
|
||||
///
|
||||
/// \return Reference to the ImageLoader instance
|
||||
///
|
||||
|
@ -54,12 +54,12 @@ public :
|
|||
static ImageLoader& GetInstance();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load pixels from an image file
|
||||
/// \brief Load an image from a file on disk
|
||||
///
|
||||
/// \param filename : Path of image file to load
|
||||
/// \param pixels : Array of pixels to fill with loaded image
|
||||
/// \param width : Width of loaded image, in pixels
|
||||
/// \param height : Height of loaded image, in pixels
|
||||
/// \param filename Path of image file to load
|
||||
/// \param pixels Array of pixels to fill with loaded image
|
||||
/// \param width Width of loaded image, in pixels
|
||||
/// \param height Height of loaded image, in pixels
|
||||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
|
@ -67,26 +67,26 @@ public :
|
|||
bool LoadImageFromFile(const std::string& filename, std::vector<Uint8>& pixels, unsigned int& width, unsigned int& height);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Load pixels from an image file in memory
|
||||
/// \brief Load an image from a file inn memory
|
||||
///
|
||||
/// \param data : Pointer to the file data in memory
|
||||
/// \param sizeInBytes : Size of the data to load, in bytes
|
||||
/// \param pixels : Array of pixels to fill with loaded image
|
||||
/// \param width : Width of loaded image, in pixels
|
||||
/// \param height : Height of loaded image, in pixels
|
||||
/// \param data Pointer to the file data in memory
|
||||
/// \param size Size of the data to load, in bytes
|
||||
/// \param pixels Array of pixels to fill with loaded image
|
||||
/// \param width Width of loaded image, in pixels
|
||||
/// \param height Height of loaded image, in pixels
|
||||
///
|
||||
/// \return True if loading was successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadImageFromMemory(const void* data, std::size_t sizeInBytes, std::vector<Uint8>& pixels, unsigned int& width, unsigned int& height);
|
||||
bool LoadImageFromMemory(const void* data, std::size_t size, std::vector<Uint8>& pixels, unsigned int& width, unsigned int& height);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save pixels to an image file
|
||||
/// \bref Save an array of pixels as an image file
|
||||
///
|
||||
/// \param filename : Path of image file to save
|
||||
/// \param pixels : Array of pixels to save to image
|
||||
/// \param width : Width of image to save, in pixels
|
||||
/// \param height : Height of image to save, in pixels
|
||||
/// \param filename Path of image file to save
|
||||
/// \param pixels Array of pixels to save to image
|
||||
/// \param width Width of image to save, in pixels
|
||||
/// \param height Height of image to save, in pixels
|
||||
///
|
||||
/// \return True if saving was successful
|
||||
///
|
||||
|
@ -96,24 +96,24 @@ public :
|
|||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
ImageLoader();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
~ImageLoader();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save a JPG image file
|
||||
/// \brief Save an image file in JPEG format
|
||||
///
|
||||
/// \param filename : Path of image file to save
|
||||
/// \param pixels : Array of pixels to save to image
|
||||
/// \param width : Width of image to save, in pixels
|
||||
/// \param height : Height of image to save, in pixels
|
||||
/// \param filename Path of image file to save
|
||||
/// \param pixels Array of pixels to save to image
|
||||
/// \param width Width of image to save, in pixels
|
||||
/// \param height Height of image to save, in pixels
|
||||
///
|
||||
/// \return True if saving was successful
|
||||
///
|
||||
|
@ -121,12 +121,12 @@ private :
|
|||
bool WriteJpg(const std::string& filename, const std::vector<Uint8>& pixels, unsigned int width, unsigned int height);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save a PNG image file
|
||||
/// \brief Save an image file in PNG format
|
||||
///
|
||||
/// \param filename : Path of image file to save
|
||||
/// \param pixels : Array of pixels to save to image
|
||||
/// \param width : Width of image to save, in pixels
|
||||
/// \param height : Height of image to save, in pixels
|
||||
/// \param filename Path of image file to save
|
||||
/// \param pixels Array of pixels to save to image
|
||||
/// \param width Width of image to save, in pixels
|
||||
/// \param height Height of image to save, in pixels
|
||||
///
|
||||
/// \return True if saving was successful
|
||||
///
|
||||
|
|
|
@ -36,8 +36,6 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplPBuffer::RenderImageImplPBuffer() :
|
||||
myPBuffer(NULL),
|
||||
myContext(NULL),
|
||||
|
@ -48,8 +46,6 @@ myHeight (0)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplPBuffer::~RenderImageImplPBuffer()
|
||||
{
|
||||
|
@ -67,8 +63,6 @@ RenderImageImplPBuffer::~RenderImageImplPBuffer()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports P-Buffer or not
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplPBuffer::IsSupported()
|
||||
{
|
||||
|
@ -79,8 +73,6 @@ bool RenderImageImplPBuffer::IsSupported()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Create
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplPBuffer::Create(unsigned int width, unsigned int height, unsigned int, bool depthBuffer)
|
||||
{
|
||||
|
@ -168,8 +160,6 @@ bool RenderImageImplPBuffer::Create(unsigned int width, unsigned int height, uns
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Activate
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplPBuffer::Activate(bool active)
|
||||
{
|
||||
|
@ -197,8 +187,6 @@ bool RenderImageImplPBuffer::Activate(bool active)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::UpdateTexture
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderImageImplPBuffer::UpdateTexture(unsigned int textureId)
|
||||
{
|
||||
|
|
|
@ -39,26 +39,27 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Specialization of RenderImageImpl using GLX P-Buffers
|
||||
/// \brief Specialization of RenderImageImpl using GLX P-Buffers
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class RenderImageImplPBuffer : public RenderImageImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplPBuffer();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
~RenderImageImplPBuffer();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports P-Buffer or not
|
||||
/// \brief Check whether the system supports P-Buffer or not
|
||||
///
|
||||
/// \return True if P-Buffer render images are supported
|
||||
///
|
||||
|
@ -68,19 +69,32 @@ public :
|
|||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Create
|
||||
/// \brief Create the render image implementation
|
||||
///
|
||||
/// \param width Width of the image to render to
|
||||
/// \param height Height of the image to render to
|
||||
/// \param textureId OpenGL texture identifier of the target image
|
||||
/// \param depthBuffer Is a depth buffer requested?
|
||||
///
|
||||
/// \return True if creation has been successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Activate
|
||||
/// \brief Activate or deactivate the render image for rendering
|
||||
///
|
||||
/// \param active True to activate, false to deactivate
|
||||
///
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::UpdateTexture
|
||||
/// \brief Update the pixels of the target texture
|
||||
///
|
||||
/// \param textureId OpenGL identifier of the target texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void UpdateTexture(unsigned textureId);
|
||||
|
|
|
@ -33,11 +33,9 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImpl::~RenderImageImpl()
|
||||
{
|
||||
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
|
|
@ -36,25 +36,26 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Abstract base class for render-image implementations
|
||||
/// \brief Abstract base class for render-image implementations
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class RenderImageImpl : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual ~RenderImageImpl();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create the render image
|
||||
/// \brief Create the render image implementation
|
||||
///
|
||||
/// \param width : Width of the image to render to
|
||||
/// \param height : Height of the image to render to
|
||||
/// \param textureId : OpenGL texture identifier of the target image
|
||||
/// \param depthBuffer : Do you want a depth buffer attached ?
|
||||
/// \param width Width of the image to render to
|
||||
/// \param height Height of the image to render to
|
||||
/// \param textureId OpenGL texture identifier of the target image
|
||||
/// \param depthBuffer Is a depth buffer requested?
|
||||
///
|
||||
/// \return True if creation has been successful
|
||||
///
|
||||
|
@ -62,17 +63,19 @@ public :
|
|||
virtual bool Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Activate / deactivate the render image for rendering
|
||||
/// \brief Activate or deactivate the render image for rendering
|
||||
///
|
||||
/// \param active : True to activate, false to deactivate
|
||||
/// \param active True to activate, false to deactivate
|
||||
///
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Update the pixels of the target texture
|
||||
/// \brief Update the pixels of the target texture
|
||||
///
|
||||
/// \param textureId : OpenGL identifier of the target texture
|
||||
/// \param textureId OpenGL identifier of the target texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void UpdateTexture(unsigned int textureId) = 0;
|
||||
|
|
|
@ -36,8 +36,6 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplFBO::RenderImageImplFBO() :
|
||||
myFrameBuffer(0),
|
||||
myDepthBuffer(0)
|
||||
|
@ -46,8 +44,6 @@ myDepthBuffer(0)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplFBO::~RenderImageImplFBO()
|
||||
{
|
||||
|
@ -67,8 +63,6 @@ RenderImageImplFBO::~RenderImageImplFBO()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports FBOs or not
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplFBO::IsSupported()
|
||||
{
|
||||
|
@ -79,8 +73,6 @@ bool RenderImageImplFBO::IsSupported()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Create
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer)
|
||||
{
|
||||
|
@ -126,8 +118,6 @@ bool RenderImageImplFBO::Create(unsigned int width, unsigned int height, unsigne
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Activate
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplFBO::Activate(bool active)
|
||||
{
|
||||
|
@ -136,12 +126,10 @@ bool RenderImageImplFBO::Activate(bool active)
|
|||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::UpdateTexture
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderImageImplFBO::UpdateTexture(unsigned int)
|
||||
{
|
||||
// Nothing to do: the FBO draws directly into the target image
|
||||
// Nothing to do: the FBO draws directly to the target image
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
|
|
@ -37,27 +37,28 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Specialization of RenderImageImpl using the
|
||||
/// Frame Buffer Object extension
|
||||
/// \brief Specialization of RenderImageImpl using the
|
||||
/// Frame Buffer Object OpenGL extension
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class RenderImageImplFBO : public RenderImageImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplFBO();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
~RenderImageImplFBO();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports FBOs or not
|
||||
/// \brief Check whether the system supports FBOs or not
|
||||
///
|
||||
/// \return True if FBO render images are supported
|
||||
///
|
||||
|
@ -67,19 +68,32 @@ public :
|
|||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Create
|
||||
/// \brief Create the render image implementation
|
||||
///
|
||||
/// \param width Width of the image to render to
|
||||
/// \param height Height of the image to render to
|
||||
/// \param textureId OpenGL texture identifier of the target image
|
||||
/// \param depthBuffer Is a depth buffer requested?
|
||||
///
|
||||
/// \return True if creation has been successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Activate
|
||||
/// \brief Activate or deactivate the render image for rendering
|
||||
///
|
||||
/// \param active True to activate, false to deactivate
|
||||
///
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::UpdateTexture
|
||||
/// \brief Update the pixels of the target texture
|
||||
///
|
||||
/// \param textureId OpenGL identifier of the target texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void UpdateTexture(unsigned textureId);
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape::Shape() :
|
||||
myOutline (0.f),
|
||||
myIsFillEnabled (true),
|
||||
|
@ -46,8 +44,6 @@ myIsCompiled (false)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Add a point to the shape
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::AddPoint(float x, float y, const Color& color, const Color& outlineColor)
|
||||
{
|
||||
|
@ -55,8 +51,6 @@ void Shape::AddPoint(float x, float y, const Color& color, const Color& outlineC
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Add a point to the shape
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::AddPoint(const Vector2f& position, const Color& color, const Color& outlineColor)
|
||||
{
|
||||
|
@ -65,8 +59,6 @@ void Shape::AddPoint(const Vector2f& position, const Color& color, const Color&
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the number of points composing the shape
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Shape::GetPointsCount() const
|
||||
{
|
||||
|
@ -74,9 +66,6 @@ unsigned int Shape::GetPointsCount() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Enable or disable filling the shape.
|
||||
/// Fill is enabled by default
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::EnableFill(bool enable)
|
||||
{
|
||||
|
@ -84,9 +73,6 @@ void Shape::EnableFill(bool enable)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Enable or disable drawing the shape outline.
|
||||
/// Outline is enabled by default
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::EnableOutline(bool enable)
|
||||
{
|
||||
|
@ -94,8 +80,6 @@ void Shape::EnableOutline(bool enable)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the position of a point
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::SetPointPosition(unsigned int index, const Vector2f& position)
|
||||
{
|
||||
|
@ -104,8 +88,6 @@ void Shape::SetPointPosition(unsigned int index, const Vector2f& position)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the position of a point
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::SetPointPosition(unsigned int index, float x, float y)
|
||||
{
|
||||
|
@ -113,8 +95,6 @@ void Shape::SetPointPosition(unsigned int index, float x, float y)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the color of a point
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::SetPointColor(unsigned int index, const Color& color)
|
||||
{
|
||||
|
@ -124,17 +104,13 @@ void Shape::SetPointColor(unsigned int index, const Color& color)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the outline color of a point
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::SetPointOutlineColor(unsigned int index, const Color& outlineColor)
|
||||
void Shape::SetPointOutlineColor(unsigned int index, const Color& color)
|
||||
{
|
||||
myPoints[index + 1].OutlineCol = outlineColor;
|
||||
myPoints[index + 1].OutlineCol = color;
|
||||
myIsCompiled = false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the width of the shape outline
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::SetOutlineWidth(float width)
|
||||
{
|
||||
|
@ -142,8 +118,6 @@ void Shape::SetOutlineWidth(float width)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the position of a point
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vector2f& Shape::GetPointPosition(unsigned int index) const
|
||||
{
|
||||
|
@ -151,8 +125,6 @@ const Vector2f& Shape::GetPointPosition(unsigned int index) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the color of a point
|
||||
////////////////////////////////////////////////////////////
|
||||
const Color& Shape::GetPointColor(unsigned int index) const
|
||||
{
|
||||
|
@ -160,8 +132,6 @@ const Color& Shape::GetPointColor(unsigned int index) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the outline color of a point
|
||||
////////////////////////////////////////////////////////////
|
||||
const Color& Shape::GetPointOutlineColor(unsigned int index) const
|
||||
{
|
||||
|
@ -169,8 +139,6 @@ const Color& Shape::GetPointOutlineColor(unsigned int index) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the width of the shape outline
|
||||
////////////////////////////////////////////////////////////
|
||||
float Shape::GetOutlineWidth() const
|
||||
{
|
||||
|
@ -178,8 +146,6 @@ float Shape::GetOutlineWidth() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a shape made of a single line
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape Shape::Line(float p1x, float p1y, float p2x, float p2y, float thickness, const Color& color, float outline, const Color& outlineColor)
|
||||
{
|
||||
|
@ -190,8 +156,6 @@ Shape Shape::Line(float p1x, float p1y, float p2x, float p2y, float thickness, c
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a shape made of a single line (use vectors)
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape Shape::Line(const Vector2f& p1, const Vector2f& p2, float thickness, const Color& color, float outline, const Color& outlineColor)
|
||||
{
|
||||
|
@ -215,8 +179,6 @@ Shape Shape::Line(const Vector2f& p1, const Vector2f& p2, float thickness, const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a shape made of a single rectangle
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape Shape::Rectangle(float left, float top, float width, float height, const Color& color, float outline, const Color& outlineColor)
|
||||
{
|
||||
|
@ -235,8 +197,6 @@ Shape Shape::Rectangle(float left, float top, float width, float height, const C
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a shape made of a single rectangle
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape Shape::Rectangle(const FloatRect& rectangle, const Color& color, float outline, const Color& outlineColor)
|
||||
{
|
||||
|
@ -244,8 +204,6 @@ Shape Shape::Rectangle(const FloatRect& rectangle, const Color& color, float out
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a shape made of a single circle
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape Shape::Circle(float x, float y, float radius, const Color& color, float outline, const Color& outlineColor)
|
||||
{
|
||||
|
@ -253,8 +211,6 @@ Shape Shape::Circle(float x, float y, float radius, const Color& color, float ou
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create a shape made of a single circle (use vectors)
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape Shape::Circle(const Vector2f& center, float radius, const Color& color, float outline, const Color& outlineColor)
|
||||
{
|
||||
|
@ -278,8 +234,6 @@ Shape Shape::Circle(const Vector2f& center, float radius, const Color& color, fl
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see Drawable::Render
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::Render(RenderTarget&, Renderer& renderer) const
|
||||
{
|
||||
|
@ -357,8 +311,6 @@ void Shape::Render(RenderTarget&, Renderer& renderer) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Compile the shape : compute its center and its outline
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::Compile()
|
||||
{
|
||||
|
@ -408,8 +360,6 @@ void Shape::Compile()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Compute the normal of a given 2D segment
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Shape::ComputeNormal(const Vector2f& p1, const Vector2f& p2, Vector2f& normal)
|
||||
{
|
||||
|
@ -427,8 +377,6 @@ bool Shape::ComputeNormal(const Vector2f& p1, const Vector2f& p2, Vector2f& norm
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor for Point
|
||||
////////////////////////////////////////////////////////////
|
||||
Shape::Point::Point(const Vector2f& position, const Color& color, const Color& outlineColor) :
|
||||
Position (position),
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Sprite::Sprite() :
|
||||
mySubRect (0, 0, 1, 1),
|
||||
myIsFlippedX(false),
|
||||
|
@ -45,8 +43,6 @@ myIsFlippedY(false)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct the sprite from a source image
|
||||
////////////////////////////////////////////////////////////
|
||||
Sprite::Sprite(const Image& image, const Vector2f& position, const Vector2f& scale, float rotation, const Color& color) :
|
||||
Drawable (position, scale, rotation, color),
|
||||
|
@ -58,8 +54,6 @@ myIsFlippedY(false)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the image of the sprite
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sprite::SetImage(const Image& image, bool adjustToNewSize)
|
||||
{
|
||||
|
@ -78,8 +72,6 @@ void Sprite::SetImage(const Image& image, bool adjustToNewSize)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the sub-rectangle of the sprite inside the source image
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sprite::SetSubRect(const IntRect& rectangle)
|
||||
{
|
||||
|
@ -87,9 +79,6 @@ void Sprite::SetSubRect(const IntRect& rectangle)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Resize the sprite (by changing its scale factors) (take 2 values).
|
||||
/// The default size is defined by the subrect
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sprite::Resize(float width, float height)
|
||||
{
|
||||
|
@ -98,9 +87,6 @@ void Sprite::Resize(float width, float height)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Resize the object (by changing its scale factors) (take a 2D vector)
|
||||
/// The default size is defined by the subrect
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sprite::Resize(const Vector2f& size)
|
||||
{
|
||||
|
@ -108,8 +94,6 @@ void Sprite::Resize(const Vector2f& size)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Flip the sprite horizontally
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sprite::FlipX(bool flipped)
|
||||
{
|
||||
|
@ -117,8 +101,6 @@ void Sprite::FlipX(bool flipped)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Flip the sprite vertically
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sprite::FlipY(bool flipped)
|
||||
{
|
||||
|
@ -126,8 +108,6 @@ void Sprite::FlipY(bool flipped)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the source image of the sprite
|
||||
////////////////////////////////////////////////////////////
|
||||
const Image* Sprite::GetImage() const
|
||||
{
|
||||
|
@ -135,8 +115,6 @@ const Image* Sprite::GetImage() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the sub-rectangle of the sprite inside the source image
|
||||
////////////////////////////////////////////////////////////
|
||||
const IntRect& Sprite::GetSubRect() const
|
||||
{
|
||||
|
@ -144,8 +122,6 @@ const IntRect& Sprite::GetSubRect() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the sprite size
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f Sprite::GetSize() const
|
||||
{
|
||||
|
@ -153,9 +129,6 @@ Vector2f Sprite::GetSize() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the color of a given pixel in the sprite
|
||||
/// (point is in local coordinates)
|
||||
////////////////////////////////////////////////////////////
|
||||
Color Sprite::GetPixel(unsigned int x, unsigned int y) const
|
||||
{
|
||||
|
@ -176,8 +149,6 @@ Color Sprite::GetPixel(unsigned int x, unsigned int y) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see Drawable::Render
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sprite::Render(RenderTarget&, Renderer& renderer) const
|
||||
{
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
Text::Text() :
|
||||
myFont (&Font::GetDefaultFont()),
|
||||
myCharacterSize(30),
|
||||
|
@ -45,8 +43,6 @@ myRectUpdated (true)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct the string from any kind of text
|
||||
////////////////////////////////////////////////////////////
|
||||
Text::Text(const String& string, const Font& font, unsigned int characterSize) :
|
||||
myFont (&font),
|
||||
|
@ -58,8 +54,6 @@ myRectUpdated (true)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the text (from any kind of string)
|
||||
////////////////////////////////////////////////////////////
|
||||
void Text::SetString(const String& string)
|
||||
{
|
||||
|
@ -68,8 +62,6 @@ void Text::SetString(const String& string)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the font of the string
|
||||
////////////////////////////////////////////////////////////
|
||||
void Text::SetFont(const Font& font)
|
||||
{
|
||||
|
@ -81,8 +73,6 @@ void Text::SetFont(const Font& font)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the base size for the characters.
|
||||
////////////////////////////////////////////////////////////
|
||||
void Text::SetCharacterSize(unsigned int size)
|
||||
{
|
||||
|
@ -94,9 +84,6 @@ void Text::SetCharacterSize(unsigned int size)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Set the style of the text
|
||||
/// The default style is Regular
|
||||
////////////////////////////////////////////////////////////
|
||||
void Text::SetStyle(unsigned long style)
|
||||
{
|
||||
|
@ -108,8 +95,6 @@ void Text::SetStyle(unsigned long style)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the text (the returned text can be converted implicitely to any kind of string)
|
||||
////////////////////////////////////////////////////////////
|
||||
const String& Text::GetString() const
|
||||
{
|
||||
|
@ -117,8 +102,6 @@ const String& Text::GetString() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the font used by the string
|
||||
////////////////////////////////////////////////////////////
|
||||
const Font& Text::GetFont() const
|
||||
{
|
||||
|
@ -126,8 +109,6 @@ const Font& Text::GetFont() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the base size of characters
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int Text::GetCharacterSize() const
|
||||
{
|
||||
|
@ -135,8 +116,6 @@ unsigned int Text::GetCharacterSize() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the style of the text
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned long Text::GetStyle() const
|
||||
{
|
||||
|
@ -144,10 +123,6 @@ unsigned long Text::GetStyle() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Return the visual position of the Index-th character of the string,
|
||||
/// in coordinates relative to the string
|
||||
/// (note : translation, center, rotation and scale are not applied)
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f Text::GetCharacterPos(std::size_t index) const
|
||||
{
|
||||
|
@ -192,8 +167,6 @@ Vector2f Text::GetCharacterPos(std::size_t index) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the string rectangle on screen
|
||||
////////////////////////////////////////////////////////////
|
||||
FloatRect Text::GetRect() const
|
||||
{
|
||||
|
@ -209,8 +182,6 @@ FloatRect Text::GetRect() const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see Drawable::Render
|
||||
////////////////////////////////////////////////////////////
|
||||
void Text::Render(RenderTarget&, Renderer& renderer) const
|
||||
{
|
||||
|
@ -316,8 +287,6 @@ void Text::Render(RenderTarget&, Renderer& renderer) const
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Recompute the bounding rectangle of the text
|
||||
////////////////////////////////////////////////////////////
|
||||
void Text::UpdateRect() const
|
||||
{
|
||||
|
|
|
@ -36,8 +36,6 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplPBuffer::RenderImageImplPBuffer() :
|
||||
myPBuffer (NULL),
|
||||
myDeviceContext(NULL),
|
||||
|
@ -49,15 +47,11 @@ myHeight (0)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplPBuffer::~RenderImageImplPBuffer()
|
||||
{
|
||||
if (myContext)
|
||||
{
|
||||
wglDeleteContext(myContext);
|
||||
}
|
||||
|
||||
if (myPBuffer && myDeviceContext)
|
||||
{
|
||||
|
@ -71,8 +65,6 @@ RenderImageImplPBuffer::~RenderImageImplPBuffer()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports P-Buffer or not
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplPBuffer::IsSupported()
|
||||
{
|
||||
|
@ -83,8 +75,6 @@ bool RenderImageImplPBuffer::IsSupported()
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Create
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplPBuffer::Create(unsigned int width, unsigned int height, unsigned int, bool depthBuffer)
|
||||
{
|
||||
|
@ -159,8 +149,6 @@ bool RenderImageImplPBuffer::Create(unsigned int width, unsigned int height, uns
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Activate
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImageImplPBuffer::Activate(bool active)
|
||||
{
|
||||
|
@ -188,8 +176,6 @@ bool RenderImageImplPBuffer::Activate(bool active)
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::UpdateTexture
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderImageImplPBuffer::UpdateTexture(unsigned int textureId)
|
||||
{
|
||||
|
|
|
@ -38,26 +38,27 @@ namespace sf
|
|||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Specialization of RenderImageImpl using WGL P-Buffers
|
||||
/// \brief Specialization of RenderImageImpl using WGL P-Buffers
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class RenderImageImplPBuffer : public RenderImageImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImageImplPBuffer();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
~RenderImageImplPBuffer();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports P-Buffer or not
|
||||
/// \brief Check whether the system supports P-Buffer or not
|
||||
///
|
||||
/// \return True if P-Buffer render images are supported
|
||||
///
|
||||
|
@ -67,19 +68,32 @@ public :
|
|||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Create
|
||||
/// \brief Create the render image implementation
|
||||
///
|
||||
/// \param width Width of the image to render to
|
||||
/// \param height Height of the image to render to
|
||||
/// \param textureId OpenGL texture identifier of the target image
|
||||
/// \param depthBuffer Is a depth buffer requested?
|
||||
///
|
||||
/// \return True if creation has been successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::Activate
|
||||
/// \brief Activate or deactivate the render image for rendering
|
||||
///
|
||||
/// \param active True to activate, false to deactivate
|
||||
///
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderImageImpl::UpdateTexture
|
||||
/// \brief Update the pixels of the target texture
|
||||
///
|
||||
/// \param textureId OpenGL identifier of the target texture
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void UpdateTexture(unsigned textureId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue