feat: major engine overhaul - scene demo with lighting, sphere, ground
- Scene Demo: cube + sphere + ground plane with proper lighting - Audio: XAudio2 dynamic loading + WAV playback - Physics: expanded collision system - Renderer: improved pipeline with materials - UI: extended widget system - VisualScript: enhanced serializer + block interactions - ASM: optimized math/memory/profiling routines - Window: mouse input + scroll support
This commit is contained in:
1 parent
2653926d85
commit
0669d102ce
35 files changed
+1844
-314
No files matched your search
@@ -6,6 +6,32 @@
|
||||
|
||||
#pragma comment(lib, "windowscodecs.lib")
|
||||
|
||||
// 为 MinGW 提供 COM 助手宏(MSVC 已内联提供)
|
||||
#ifndef _MSC_VER
|
||||
#define ID3D11ShaderResourceView_Release(p) (p)->lpVtbl->Release(p)
|
||||
#define ID3D11Texture2D_Release(p) (p)->lpVtbl->Release(p)
|
||||
#define ID3D11Device_CreateTexture2D(p,a,b,c) (p)->lpVtbl->CreateTexture2D(p,a,b,c)
|
||||
#define ID3D11Device_CreateShaderResourceView(p,a,b,c) (p)->lpVtbl->CreateShaderResourceView(p,a,b,c)
|
||||
#define ID3D11DeviceContext_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
|
||||
#define ID3D11DeviceContext_PSSetShaderResources(p,a,b,c) (p)->lpVtbl->PSSetShaderResources(p,a,b,c)
|
||||
#define ID3D11DeviceContext_PSSetSamplers(p,a,b,c) (p)->lpVtbl->PSSetSamplers(p,a,b,c)
|
||||
#define ID3D11Device_CreateSamplerState(p,a,b) (p)->lpVtbl->CreateSamplerState(p,a,b)
|
||||
|
||||
#define IWICBitmapDecoder_GetFrame(p,a,b) (p)->lpVtbl->GetFrame(p,a,b)
|
||||
#define IWICBitmapFrameDecode_GetSize(p,a,b) (p)->lpVtbl->GetSize(p,a,b)
|
||||
#define IWICImagingFactory_CreateFormatConverter(p,a) (p)->lpVtbl->CreateFormatConverter(p,a)
|
||||
#define IWICFormatConverter_Initialize(p,a,b,c,d,e,f) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f)
|
||||
#define IWICFormatConverter_CopyPixels(p,a,b,c,d) (p)->lpVtbl->CopyPixels(p,a,b,c,d)
|
||||
#define IWICFormatConverter_Release(p) (p)->lpVtbl->Release(p)
|
||||
#define IWICBitmapFrameDecode_Release(p) (p)->lpVtbl->Release(p)
|
||||
#define IWICImagingFactory_CreateDecoderFromFilename(p,a,b,c,d,e) (p)->lpVtbl->CreateDecoderFromFilename(p,a,b,c,d,e)
|
||||
#define IWICBitmapDecoder_Release(p) (p)->lpVtbl->Release(p)
|
||||
#define IWICImagingFactory_CreateStream(p,a) (p)->lpVtbl->CreateStream(p,a)
|
||||
#define IWICStream_InitializeFromMemory(p,a,b) (p)->lpVtbl->InitializeFromMemory(p,a,b)
|
||||
#define IWICImagingFactory_CreateDecoderFromStream(p,a,b,c,d) (p)->lpVtbl->CreateDecoderFromStream(p,a,b,c,d)
|
||||
#define IWICStream_Release(p) (p)->lpVtbl->Release(p)
|
||||
#endif
|
||||
|
||||
static IWICImagingFactory* wic_factory = NULL;
|
||||
|
||||
static HRESULT ensure_wic(void) {
|
||||
@@ -183,6 +209,23 @@ Texture* texture_create_checkerboard(ID3D11Device* device, uint32_t size, uint32
|
||||
|
||||
void texture_bind(Texture* texture, ID3D11DeviceContext* ctx, uint32_t slot) {
|
||||
if (!texture || !texture->srv) return;
|
||||
ID3D11DeviceContext_PSSetShaderResources(ctx, slot, 1, &texture->srv);
|
||||
ID3D11DeviceContext_PSSetSamplers(ctx, slot, 1, &(ID3D11SamplerState*){NULL});
|
||||
static ID3D11SamplerState* default_sampler = NULL;
|
||||
if (!default_sampler) {
|
||||
ID3D11Device* device = NULL;
|
||||
ctx->lpVtbl->GetDevice(ctx, &device);
|
||||
if (device) {
|
||||
D3D11_SAMPLER_DESC sd = {0};
|
||||
sd.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
sd.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sd.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sd.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
sd.MinLOD = 0;
|
||||
sd.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
device->lpVtbl->CreateSamplerState(device, &sd, &default_sampler);
|
||||
device->lpVtbl->Release(device);
|
||||
}
|
||||
}
|
||||
ctx->lpVtbl->PSSetShaderResources(ctx, slot, 1, &texture->srv);
|
||||
ctx->lpVtbl->PSSetSamplers(ctx, slot, 1, &default_sampler);
|
||||
}
|
||||
Reference in new issue
Block a user