mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa Format e LevelCount em Texture
This commit is contained in:
parent
540332d71c
commit
3c4a25e27e
@ -37,7 +37,7 @@ namespace xna {
|
||||
return texture2d;
|
||||
}
|
||||
|
||||
bool Texture2D::Initialize()
|
||||
void Texture2D::Initialize()
|
||||
{
|
||||
if (!m_device || !m_device->impl->_device) {
|
||||
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||
@ -62,7 +62,8 @@ namespace xna {
|
||||
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||
}
|
||||
|
||||
return true;
|
||||
surfaceFormat = DxHelpers::SurfaceFormatToXna(impl->dxDescription.Format);
|
||||
levelCount = static_cast<Int>(impl->dxShaderDescription.Texture2D.MipLevels);
|
||||
}
|
||||
|
||||
void setDefaultDesc(Texture2D::PlatformImplementation& impl) {
|
||||
@ -79,24 +80,24 @@ namespace xna {
|
||||
impl.dxShaderDescription.Texture2D.MostDetailedMip = 0;
|
||||
}
|
||||
|
||||
Texture2D::Texture2D() : GraphicsResource(nullptr) {
|
||||
Texture2D::Texture2D() : Texture(nullptr) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
setDefaultDesc(*impl);
|
||||
}
|
||||
|
||||
Texture2D::Texture2D(sptr<GraphicsDevice> const& device, size_t width, size_t height) : GraphicsResource(device) {
|
||||
Texture2D::Texture2D(sptr<GraphicsDevice> const& device, size_t width, size_t height) : Texture(device) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
setDefaultDesc(*impl);
|
||||
impl->dxDescription.Width = static_cast<UINT>(width);
|
||||
impl->dxDescription.Height = static_cast<UINT>(height);
|
||||
}
|
||||
|
||||
Texture2D::Texture2D(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||
Texture2D::Texture2D(sptr<GraphicsDevice> const& device) : Texture(device) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
setDefaultDesc(*impl);
|
||||
}
|
||||
|
||||
Texture2D::Texture2D(sptr<GraphicsDevice> const& device, size_t width, size_t height, size_t mipMap, SurfaceFormat format) : GraphicsResource(device)
|
||||
Texture2D::Texture2D(sptr<GraphicsDevice> const& device, size_t width, size_t height, size_t mipMap, SurfaceFormat format) : Texture(device)
|
||||
{
|
||||
impl = unew<PlatformImplementation>();
|
||||
setDefaultDesc(*impl);
|
||||
|
@ -202,6 +202,8 @@ namespace xna {
|
||||
using P_RasterizerState = sptr<RasterizerState>;
|
||||
using P_PresentationParameters = sptr<PresentationParameters>;
|
||||
using P_SamplerStateCollection = sptr<SamplerStateCollection>;
|
||||
using P_Texture = sptr<Texture>;
|
||||
using P_Texture2D = sptr<Texture2D>;
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,28 +5,41 @@
|
||||
#include "gresource.hpp"
|
||||
|
||||
namespace xna {
|
||||
class Texture {
|
||||
//Represents a texture resource.
|
||||
class Texture : public GraphicsResource {
|
||||
public:
|
||||
~Texture() {}
|
||||
Texture(P_GraphicsDevice const& graphicsDevice) : GraphicsResource(graphicsDevice) {}
|
||||
|
||||
virtual ~Texture() {}
|
||||
|
||||
//Gets the format of the texture data.
|
||||
constexpr SurfaceFormat Format() const { return surfaceFormat; }
|
||||
//Gets the number of texture levels in a multilevel texture.
|
||||
constexpr Int LevelCount() const { return levelCount; }
|
||||
|
||||
protected:
|
||||
SurfaceFormat surfaceFormat{SurfaceFormat::Color};
|
||||
Int levelCount{ 0 };
|
||||
};
|
||||
|
||||
class Texture2D : public Texture, public GraphicsResource {
|
||||
class Texture2D : public Texture {
|
||||
public:
|
||||
Texture2D();
|
||||
Texture2D(sptr<GraphicsDevice> const& device);
|
||||
Texture2D(sptr<GraphicsDevice> const& device, size_t width, size_t height);
|
||||
Texture2D(sptr<GraphicsDevice> const& device, size_t width, size_t height, size_t mipMap, SurfaceFormat format);
|
||||
Texture2D(P_GraphicsDevice const& device);
|
||||
Texture2D(P_GraphicsDevice const& device, size_t width, size_t height);
|
||||
Texture2D(P_GraphicsDevice const& device, size_t width, size_t height, size_t mipMap, SurfaceFormat format);
|
||||
~Texture2D() override;
|
||||
Int Width() const;
|
||||
Int Height() const;
|
||||
Rectangle Bounds() const;
|
||||
bool Initialize();
|
||||
void SetData(std::vector<Color> const& data, size_t startIndex = 0, size_t elementCount = 0);
|
||||
void SetData(std::vector<Uint> const& data, size_t startIndex = 0, size_t elementCount = 0);
|
||||
void SetData(std::vector<Byte> const& data, size_t startIndex = 0, size_t elementCount = 0);
|
||||
void SetData(Int level, Rectangle* rect, std::vector<Byte> const& data, size_t startIndex, size_t elementCount);
|
||||
static sptr<Texture2D> FromStream(GraphicsDevice& device, String const& fileName);
|
||||
static sptr<Texture2D> FromMemory(GraphicsDevice& device, std::vector<Byte> const& data);
|
||||
static P_Texture2D FromStream(GraphicsDevice& device, String const& fileName);
|
||||
static P_Texture2D FromMemory(GraphicsDevice& device, std::vector<Byte> const& data);
|
||||
|
||||
void Initialize();
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
@ -34,7 +47,7 @@ namespace xna {
|
||||
};
|
||||
|
||||
|
||||
using PTexture2D = sptr<Texture2D>;
|
||||
using PTexture2D = P_Texture2D;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user