4#include "gfx/Texture.h"
6using namespace System::Runtime::InteropServices;
8namespace XXSharpKmyGfx{
12 private ref class Texture {
14 bool managedResourceAttached =
false;
18 bool deleteAsCreator =
false;
19 System::String^ loadpath;
23 deleteAsCreator =
true;
26 Texture(System::String^ path, System::Guid guid,
int type,
bool srgb,
bool genmipmap, TEXTUREUSAGE usage,
bool compress, PREMULTIPLIEDTYPE premultiplied);
28 Texture(kmyGfx::Texture* t)
31 deleteAsCreator =
false;
35 Texture^ makeNewReference()
37 return gcnew Texture(obj);
45 void managedResourceAttach()
47 if (managedResourceAttached) {
48 DBGPRINTF(
"[warn] texture attached to multiple managed resource. (%s)", obj ? obj->getFileName() :
"nullobj");
50 managedResourceAttached =
true;
53 void managedResourceDetach()
55 if (!managedResourceAttached) {
56 DBGPRINTF(
"[warn] unattached texture was detached. (%s)", obj ? obj->getFileName() :
"nullobj");
58 managedResourceAttached =
false;
61 bool isEqual(XXSharpKmyGfx::Texture^ t)
71 if (deleteAsCreator) {
82 if (deleteAsCreator) {
92 return obj->getWidth();
98 return obj->getHeight();
104 return obj->getStoredWidth();
107 int getStoredHeight()
110 return obj->getStoredHeight();
113 void setMagFilter(TEXTUREFILTER f)
117 if (f == TEXTUREFILTER::kBILINEAR)obj->setMagFilter(kmyGfx::Texture::kFILTER_BILINEAR);
118 else obj->setMagFilter(kmyGfx::Texture::kFILTER_NEAREST);
121 void setMinFilter(TEXTUREFILTER f)
125 if (f == TEXTUREFILTER::kBILINEAR)obj->setMinFilter(kmyGfx::Texture::kFILTER_BILINEAR);
126 else obj->setMinFilter(kmyGfx::Texture::kFILTER_NEAREST);
129 void setWrap(WRAPTYPE f)
133 obj->setUWrap(f == WRAPTYPE::kCLAMP ? kmyGfx::WRAPTYPE::kWRAPTYPE_CLAMP : kmyGfx::WRAPTYPE::kWRAPTYPE_REPEAT);
134 obj->setVWrap(f == WRAPTYPE::kCLAMP ? kmyGfx::WRAPTYPE::kWRAPTYPE_CLAMP : kmyGfx::WRAPTYPE::kWRAPTYPE_REPEAT);
137 void setUWrap(WRAPTYPE f)
141 obj->setUWrap(f == WRAPTYPE::kCLAMP ? kmyGfx::WRAPTYPE::kWRAPTYPE_CLAMP : kmyGfx::WRAPTYPE::kWRAPTYPE_REPEAT);
144 void setVWrap(WRAPTYPE f)
148 obj->setVWrap(f == WRAPTYPE::kCLAMP ? kmyGfx::WRAPTYPE::kWRAPTYPE_CLAMP : kmyGfx::WRAPTYPE::kWRAPTYPE_REPEAT);
151 void setWWrap(WRAPTYPE f)
155 obj->setWWrap(f == WRAPTYPE::kCLAMP ? kmyGfx::WRAPTYPE::kWRAPTYPE_CLAMP : kmyGfx::WRAPTYPE::kWRAPTYPE_REPEAT);
158 void setAnisotropy(
float v)
160 if (obj)obj->setAnisotropy(v);
163 void setType(
int type)
165 if (obj)obj->setType((kmyGfx::TEXTURETYPE)type);
168 void setUsage(TEXTUREUSAGE usage)
170 if (obj)obj->setUsage((kmyGfx::TEXTUREUSAGE)usage);
173 void setCompress(
bool flg)
175 if (obj)obj->setCompress(flg);
178 void setPremultiplied(PREMULTIPLIEDTYPE premultiplied)
180 if (obj)obj->setPremultiplied((kmyGfx::PremultipliedType)premultiplied);
183 bool isReloadRequired() {
return obj ? obj->m_reloadRequired :
false; }
185 void renamePath(System::String^ path);
187 void create(
int width,
int height,
bool srgb,
int miplevel);
188 void create(
int width,
int height, TEXTUREFFORMAT format,
int miplevel);
189 void enableWrite() {
if (obj)obj->enableWrite(); }
190 void apply() {
if (obj)obj->apply(); }
191 void storeSubPixel2DDelay(
int x,
int y,
int w,
int h, array<UINT32>^ list, TEXTUREFFORMAT format,
int sx,
int sy,
int swidth,
int level);
192 void copyTexture2DDelay(
int dx,
int dy,
int dw,
int dh,
int dlevel,
int sx,
int sy,
int slevel, Texture^ src);
193 void storeSubPixel2D(
int x,
int y,
int w,
int h, array<UINT32>^ list, TEXTUREFFORMAT format,
int sx,
int sy,
int swidth,
int level);
194 void storeSubPixel2D(
int x,
int y,
int w,
int h, u8 *list, TEXTUREFFORMAT format,
int level);
195 static void getColor(System::String^ name, [System::Runtime::InteropServices::Out] array<UINT32>^% list,
int% width,
int% height);
197 static Texture^ load(System::String^ path,
bool srgb, TEXTURESHAPE shape, TEXTUREUSAGE usage);
199 static Texture^ load(System::IO::Stream^ stream,
bool srgb,
bool genmipmap, TEXTURESHAPE shape, TEXTUREUSAGE usage);
201 static array<System::String^>^ getLoadableFileList(System::String^ path);
203 static int getMaxTexture2DSize()
205 return kmyGfx::GfxDriver::getInstance()->getMaxTexture2DSize();
208 static void pushFindTextureBaseDirectory(String^ path);
209 static void popFindTextureBaseDirectory();
211 static int getTextureStoreJobSerial();
212 static bool textureStoreJobFinished(
int serial);
213 static void textureStoreJobDispatchAll();
214 static void textureStoreJobWaitQueuedJobFinished();
216 static void forceReloadFileTextures() {
217 kmyGfx::Texture::forceReloadFileTextures();
220 void getColor([System::Runtime::InteropServices::Out] array<UINT32>^% list,
int level);
222 System::String^ getFileName();
223 System::String^ getFilePath();
224 System::Guid getGuid();
225 void setGuid(System::Guid
id);
226 bool isSrgb() {
return obj?obj->isSrgb():
false; }
227 void setSrgb(
bool b) {
if(obj)obj->setSrgb(b); }
228 void setGenMipmap(
bool flg) {
if(obj)obj->setGenMipmap(flg); }
230 void addRef() {
if (obj)obj->addRef(); }
231 void removeRef() {
if (obj)obj->removeRef(); }
232 void reloadIfLoaded() {
if (obj)obj->reloadIfLoaded(); }
233 int getRef() {
return (obj ==
nullptr) ? -1000 : obj->getRefCount(); }
239 auto format = obj->getFormat();
243 return TEXTUREFFORMAT::kINVALID;
TEXTUREFFORMAT
Definition: GfxTypes.cs:43