MCPcopy Create free account
hub / github.com/MyGUI/mygui / createManual

Method createManual

Platforms/DirectX/DirectXPlatform/src/MyGUI_DirectXTexture.cpp:39–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 }
38
39 void DirectXTexture::createManual(int _width, int _height, TextureUsage _usage, PixelFormat _format)
40 {
41 destroy();
42
43 mInternalUsage = 0;
44 mInternalFormat = D3DFMT_UNKNOWN;
45
46 mSize.set(_width, _height);
47 mTextureUsage = _usage;
48 mPixelFormat = _format;
49 mInternalPool = D3DPOOL_MANAGED;
50
51 if (mTextureUsage == TextureUsage::RenderTarget)
52 {
53 mInternalUsage |= D3DUSAGE_RENDERTARGET;
54 mInternalPool = D3DPOOL_DEFAULT;
55 }
56 else if (mTextureUsage == TextureUsage::Dynamic)
57 mInternalUsage |= D3DUSAGE_DYNAMIC;
58 else if (mTextureUsage == TextureUsage::Stream)
59 mInternalUsage |= D3DUSAGE_DYNAMIC;
60
61 if (mPixelFormat == PixelFormat::R8G8B8A8)
62 {
63 mInternalFormat = D3DFMT_A8R8G8B8;
64 mNumElemBytes = 4;
65 }
66 else if (mPixelFormat == PixelFormat::R8G8B8)
67 {
68 mInternalFormat = D3DFMT_R8G8B8;
69 mNumElemBytes = 3;
70 }
71 else if (mPixelFormat == PixelFormat::L8A8)
72 {
73 mInternalFormat = D3DFMT_A8L8;
74 mNumElemBytes = 2;
75 }
76 else if (mPixelFormat == PixelFormat::L8)
77 {
78 mInternalFormat = D3DFMT_L8;
79 mNumElemBytes = 1;
80 }
81 else
82 {
83 MYGUI_PLATFORM_EXCEPT("Creating texture with unknown pixel formal.");
84 }
85
86 HRESULT result = mpD3DDevice->CreateTexture(
87 mSize.width,
88 mSize.height,
89 1,
90 mInternalUsage,
91 mInternalFormat,
92 mInternalPool,
93 &mpTexture,
94 nullptr);
95 if (FAILED(result))
96 {

Callers

nothing calls this directly

Calls 1

setMethod · 0.45

Tested by

no test coverage detected