Implement texture property getters

This commit is contained in:
Dmitry Marakasov 2014-11-25 23:41:54 +03:00
parent f5fa211cfe
commit a97d100372
2 changed files with 33 additions and 0 deletions

View File

@ -98,4 +98,32 @@ Texture::LockHandle Texture::Lock(const Rect& rect) {
return LockHandle(this, rect); return LockHandle(this, rect);
} }
Uint32 Texture::GetFormat() const {
Uint32 format;
if (SDL_QueryTexture(texture_, &format, nullptr, nullptr, nullptr) != 0)
throw Exception("SDL_QueryTexture failed");
return format;
}
int Texture::GetAccess() const {
int access;
if (SDL_QueryTexture(texture_, nullptr, &access, nullptr, nullptr) != 0)
throw Exception("SDL_QueryTexture failed");
return access;
}
int Texture::GetWidth() const {
int w;
if (SDL_QueryTexture(texture_, nullptr, nullptr, &w, nullptr) != 0)
throw Exception("SDL_QueryTexture failed");
return w;
}
int Texture::GetHeight() const {
int h;
if (SDL_QueryTexture(texture_, nullptr, nullptr, nullptr, &h) != 0)
throw Exception("SDL_QueryTexture failed");
return h;
}
} }

View File

@ -87,6 +87,11 @@ public:
void SetColorMod(Uint8 r = 255, Uint8 g = 255, Uint8 b = 255); void SetColorMod(Uint8 r = 255, Uint8 g = 255, Uint8 b = 255);
LockHandle Lock(const Rect& rect); LockHandle Lock(const Rect& rect);
Uint32 GetFormat() const;
int GetAccess() const;
int GetWidth() const;
int GetHeight() const;
}; };
} }