mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Direct3D11: Implement backface culling
This commit is contained in:
parent
bd4b8b8af2
commit
7338f69361
3 changed files with 17 additions and 12 deletions
|
@ -17,4 +17,5 @@
|
|||
* Changing server texture packs sometimes still retains textures from previous one
|
||||
* Crashes at startup when another process has exclusively acquired Direct3D9 device
|
||||
* Can't bind controls to mouse buttons
|
||||
* Does not work at all on 64 bit macOS
|
||||
* Does not work at all on 64 bit macOS
|
||||
* Making a gas block undeletable doesn't prevent placing blocks over it
|
|
@ -167,11 +167,6 @@ void Gfx_DisableMipmaps(void) {
|
|||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------State management----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
|
||||
|
||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||
}
|
||||
|
||||
void Gfx_SetFog(cc_bool enabled) {
|
||||
}
|
||||
|
||||
|
@ -489,7 +484,7 @@ void Gfx_DisableTextureOffset(void) {
|
|||
//---------------------------------------------------------Rasteriser-----------------------------------------------------
|
||||
//########################################################################################################################
|
||||
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-rasterizer-stage
|
||||
static ID3D11RasterizerState* rs_state;
|
||||
static ID3D11RasterizerState* rs_states[2];
|
||||
|
||||
static void RS_CreateRasterState(void) {
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_rasterizer_desc
|
||||
|
@ -498,22 +493,31 @@ static void RS_CreateRasterState(void) {
|
|||
desc.FillMode = D3D11_FILL_SOLID;
|
||||
desc.FrontCounterClockwise = true;
|
||||
desc.DepthClipEnable = true; // otherwise vertices/pixels beyond far plane are still wrongly rendered
|
||||
ID3D11Device_CreateRasterizerState(device, &desc, &rs_state);
|
||||
ID3D11Device_CreateRasterizerState(device, &desc, &rs_states[0]);
|
||||
|
||||
desc.CullMode = D3D11_CULL_BACK;
|
||||
ID3D11Device_CreateRasterizerState(device, &desc, &rs_states[1]);
|
||||
}
|
||||
|
||||
static void RS_UpdateViewport(void) {
|
||||
D3D11_VIEWPORT viewport;
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = WindowInfo.Width;
|
||||
viewport.Height = WindowInfo.Height;
|
||||
viewport.Width = max(WindowInfo.Width, 1);
|
||||
viewport.Height = max(WindowInfo.Height, 1);
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
ID3D11DeviceContext_RSSetViewports(context, 1, &viewport);
|
||||
}
|
||||
|
||||
static cc_bool cullingOn;
|
||||
static void RS_UpdateRasterState(void) {
|
||||
ID3D11DeviceContext_RSSetState(context, rs_state);
|
||||
ID3D11DeviceContext_RSSetState(context, rs_states[cullingOn]);
|
||||
}
|
||||
|
||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||
cullingOn = enabled;
|
||||
RS_UpdateRasterState();
|
||||
}
|
||||
|
||||
static void RS_Init(void) {
|
||||
|
|
|
@ -330,7 +330,7 @@ void Mutex_Unlock(void* handle) {
|
|||
struct WaitData {
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
int signalled;
|
||||
int signalled; /* For when Waitable_Signal is called before Waitable_Wait */
|
||||
};
|
||||
|
||||
void* Waitable_Create(void) {
|
||||
|
|
Loading…
Reference in a new issue