mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
Direct3D11: Use dummy 1x1 white texture instead of default transparent black texture, when Gfx_BindTexture is called with nil texture ID
This commit is contained in:
parent
cb0cbf4cb7
commit
1010953830
@ -27,6 +27,8 @@ static const GUID guid_IXDGIDevice = { 0x54ec77fa, 0x1377, 0x44e6, { 0x8c, 0
|
|||||||
|
|
||||||
static int gfx_format = -1, depthBits; // TODO implement depthBits?? for ZNear calc
|
static int gfx_format = -1, depthBits; // TODO implement depthBits?? for ZNear calc
|
||||||
static UINT gfx_stride;
|
static UINT gfx_stride;
|
||||||
|
static GfxResourceID white_square;
|
||||||
|
|
||||||
static ID3D11Device* device;
|
static ID3D11Device* device;
|
||||||
static ID3D11DeviceContext* context;
|
static ID3D11DeviceContext* context;
|
||||||
static IDXGIDevice1* dxgi_device;
|
static IDXGIDevice1* dxgi_device;
|
||||||
@ -124,6 +126,7 @@ static void Gfx_FreeState(void) {
|
|||||||
|
|
||||||
FreeDefaultResources();
|
FreeDefaultResources();
|
||||||
FreePipeline();
|
FreePipeline();
|
||||||
|
Gfx_DeleteTexture(&white_square);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Gfx_RestoreState(void) {
|
static void Gfx_RestoreState(void) {
|
||||||
@ -133,6 +136,12 @@ static void Gfx_RestoreState(void) {
|
|||||||
InitDefaultResources();
|
InitDefaultResources();
|
||||||
gfx_format = -1;
|
gfx_format = -1;
|
||||||
InitPipeline();
|
InitPipeline();
|
||||||
|
|
||||||
|
/* 1x1 dummy white texture */
|
||||||
|
struct Bitmap bmp;
|
||||||
|
BitmapCol pixels[1] = { BITMAPCOL_WHITE };
|
||||||
|
Bitmap_Init(bmp, 1, 1, pixels);
|
||||||
|
Gfx_RecreateTexture(&white_square, &bmp, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -768,6 +777,9 @@ void Gfx_SetAlphaTest(cc_bool enabled) {
|
|||||||
void Gfx_SetAlphaArgBlend(cc_bool enabled) { }
|
void Gfx_SetAlphaArgBlend(cc_bool enabled) { }
|
||||||
|
|
||||||
void Gfx_BindTexture(GfxResourceID texId) {
|
void Gfx_BindTexture(GfxResourceID texId) {
|
||||||
|
/* defasult texture is otherwise transparent black */
|
||||||
|
if (!texId) texId = white_square;
|
||||||
|
|
||||||
ID3D11ShaderResourceView* view = (ID3D11ShaderResourceView*)texId;
|
ID3D11ShaderResourceView* view = (ID3D11ShaderResourceView*)texId;
|
||||||
ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &view);
|
ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &view);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user