mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 10:55:57 -04:00
Merge 5cf39322a6f84ddc919aca83562a08cea278f1f6 into b00d3b9eb98be4fa2eca7ae9d88f96d28796e4f0
This commit is contained in:
commit
b9cf7d0261
@ -51,6 +51,18 @@ Surface::Surface(void* pixels, int width, int height, int depth, int pitch, Uint
|
||||
throw Exception("SDL_CreateRGBSurfaceFrom");
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
Surface::Surface(Uint32 flags, int width, int height, int depth, Uint32 format) {
|
||||
if ((surface_ = SDL_CreateRGBSurfaceWithFormat(flags, width, height, depth, format)) == nullptr)
|
||||
throw Exception("SDL_CreateRGBSurfaceWithFormat");
|
||||
}
|
||||
|
||||
Surface::Surface(void* pixels, int width, int height, int depth, int pitch, Uint32 format) {
|
||||
if ((surface_ = SDL_CreateRGBSurfaceWithFormatFrom(pixels, width, height, depth, pitch, format)) == nullptr)
|
||||
throw Exception("SDL_CreateRGBSurfaceWithFormatFrom");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SDL2PP_WITH_IMAGE
|
||||
Surface::Surface(RWops& rwops) {
|
||||
if ((surface_ = IMG_Load_RW(rwops.Get(), 0)) == nullptr)
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <SDL_stdinc.h>
|
||||
#include <SDL_blendmode.h>
|
||||
#include <SDL_version.h>
|
||||
|
||||
#include <SDL2pp/Config.hh>
|
||||
#include <SDL2pp/Optional.hh>
|
||||
@ -210,6 +211,41 @@ public:
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface(void* pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create RGB surface with the given format
|
||||
///
|
||||
/// \param[in] flags Flags are obsolete and should be set to 0
|
||||
/// \param[in] width Width of the surface
|
||||
/// \param[in] height Height of the surface
|
||||
/// \param[in] depth Depth of the surface
|
||||
/// \param[in] format The pixel format of the surface
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://wiki.libsdl.org/SDL_CreateRGBSurfaceWithFormat
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface(Uint32 flags, int width, int height, int depth, Uint32 format);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create RGB surface with the given format from the given pixel data
|
||||
///
|
||||
/// \param[in] pixels The pixel data to create the surface from
|
||||
/// \param[in] width Width of the surface
|
||||
/// \param[in] height Height of the surface
|
||||
/// \param[in] depth Depth of the surface
|
||||
/// \param[in] pitch The length of a row of pixels in bytes
|
||||
/// \param[in] format The pixel format of the surface
|
||||
///
|
||||
/// \throws SDL2pp::Exception
|
||||
///
|
||||
/// \see https://wiki.libsdl.org/SDL_CreateRGBSurfaceWithFormat
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface(void* pixels, int width, int height, int depth, int pitch, Uint32 format);
|
||||
#endif
|
||||
|
||||
#ifdef SDL2PP_WITH_IMAGE
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -17,4 +17,15 @@ BEGIN_TEST(int, char*[])
|
||||
EXPECT_EQUAL(crate.GetHeight(), 32);
|
||||
EXPECT_EQUAL(crate.GetSize(), Point(32, 32));
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
{
|
||||
// Test create surface from pixel format
|
||||
Surface surface(0, 600, 300, 24, SDL_PIXELFORMAT_RGBA32);
|
||||
|
||||
EXPECT_EQUAL(surface.GetWidth(), 600);
|
||||
EXPECT_EQUAL(surface.GetHeight(), 300);
|
||||
EXPECT_EQUAL(surface.GetFormat(), SDL_PIXELFORMAT_RGBA32);
|
||||
}
|
||||
#endif
|
||||
END_TEST()
|
||||
|
Loading…
x
Reference in New Issue
Block a user