mirror of https://github.com/axmolengine/axmol.git
40 lines
1.2 KiB
Objective-C
40 lines
1.2 KiB
Objective-C
#pragma once
|
|
|
|
#include "../Texture.h"
|
|
#include "DeviceMTL.h"
|
|
#import <Metal/Metal.h>
|
|
|
|
CC_BACKEND_BEGIN
|
|
|
|
class TextureMTL : public Texture
|
|
{
|
|
public:
|
|
TextureMTL(id<MTLDevice> mtlDevice, const TextureDescriptor& descriptor);
|
|
~TextureMTL();
|
|
|
|
virtual void updateData(uint8_t* data) override;
|
|
virtual void updateSubData(unsigned int xoffset, unsigned int yoffset, unsigned int width, unsigned int height, uint8_t* data) override;
|
|
|
|
virtual void updateSamplerDescriptor(const SamplerDescriptor &sampler) override;
|
|
|
|
inline id<MTLTexture> getMTLTexture() const { return _mtlTexture; }
|
|
inline id<MTLSamplerState> getMTLSamplerState() const { return _mtlSamplerState; }
|
|
|
|
private:
|
|
void createTexture(id<MTLDevice> mtlDevice, const TextureDescriptor& descriptor);
|
|
void createSampler(id<MTLDevice> mtlDevice, const SamplerDescriptor& descriptor);
|
|
|
|
MTLSamplerAddressMode _sAddressMode;
|
|
MTLSamplerAddressMode _tAddressMode;
|
|
MTLSamplerMinMagFilter _minFilter;
|
|
MTLSamplerMinMagFilter _magFilter;
|
|
MTLSamplerMipFilter _mipFilter;
|
|
|
|
id<MTLDevice> _mtlDevice = nil;
|
|
id<MTLTexture> _mtlTexture = nil;
|
|
id<MTLSamplerState> _mtlSamplerState = nil;
|
|
unsigned int _bytesPerRow = 0;
|
|
};
|
|
|
|
CC_BACKEND_END
|