mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 10:55:57 -04:00
Add constructors from existing SDL2 objects
This commit is contained in:
parent
0557464b56
commit
25bbd97b3e
@ -30,6 +30,9 @@
|
||||
|
||||
namespace SDL2pp {
|
||||
|
||||
Renderer::Renderer(SDL_Renderer* renderer) : renderer_(renderer) {
|
||||
}
|
||||
|
||||
Renderer::Renderer(Window& window, int index, Uint32 flags) {
|
||||
if ((renderer_ = SDL_CreateRenderer(window.Get(), index, flags)) == nullptr)
|
||||
throw Exception("SDL_CreateRenderer failed");
|
||||
|
@ -51,6 +51,14 @@ private:
|
||||
SDL_Renderer* renderer_; ///< Contained SDL_Renderer structure
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct from existing SDL_Renderer structure
|
||||
///
|
||||
/// \param renderer Existing SDL_Renderer to manage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Renderer(SDL_Renderer* renderer);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create renderer
|
||||
///
|
||||
|
@ -148,16 +148,15 @@ public:
|
||||
const SDL_PixelFormat& GetFormat() const;
|
||||
};
|
||||
|
||||
private:
|
||||
public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create surface taking existing SDL_surface structure
|
||||
/// \brief Construct from existing SDL_Surface structure
|
||||
///
|
||||
/// \param surface Existing SDL_surface to manage
|
||||
/// \param surface Existing SDL_Surface to manage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Surface(SDL_Surface* surface);
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create RGB surface
|
||||
///
|
||||
|
@ -40,6 +40,9 @@
|
||||
|
||||
namespace SDL2pp {
|
||||
|
||||
Texture::Texture(SDL_Texture* texture) : texture_(texture) {
|
||||
}
|
||||
|
||||
Texture::Texture(Renderer& renderer, Uint32 format, int access, int w, int h) {
|
||||
if ((texture_ = SDL_CreateTexture(renderer.Get(), format, access, w, h)) == nullptr)
|
||||
throw Exception("SDL_CreateTexture failed");
|
||||
|
@ -172,6 +172,14 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct from existing SDL_Texture structure
|
||||
///
|
||||
/// \param texture Existing SDL_Texture to manage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Texture(SDL_Texture* texture);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create empty texture
|
||||
///
|
||||
|
@ -26,6 +26,9 @@
|
||||
|
||||
namespace SDL2pp {
|
||||
|
||||
Window::Window(SDL_Window* window) : window_(window) {
|
||||
}
|
||||
|
||||
Window::Window(const std::string& title, int x, int y, int w, int h, Uint32 flags) {
|
||||
if ((window_ = SDL_CreateWindow(title.c_str(), x, y, w, h, flags)) == nullptr)
|
||||
throw Exception("SDL_CreateWindow failed");
|
||||
|
@ -64,6 +64,14 @@ private:
|
||||
SDL_Window* window_; ///< Contained SDL2_Window structure
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct from existing SDL_Window structure
|
||||
///
|
||||
/// \param window Existing SDL_Window to manage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Window(SDL_Window* window);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create window with specified title and fimensions
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user