Skip to content

Commit

Permalink
making kinc compile with MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
SunDaw committed Feb 11, 2024
1 parent e9c95ef commit 2ff2a24
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Backends/Audio2/WASAPI/Sources/kinc/backend/wasapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

// Windows 7
#define WINVER 0x0601
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0601

#define NOATOM
Expand Down Expand Up @@ -53,6 +56,7 @@
#include <AudioClient.h>
#include <mmdeviceapi.h>

#ifndef __MINGW32__
// MIDL_INTERFACE("1CB9AD4C-DBFA-4c32-B178-C2F568A703B2")
DEFINE_GUID(IID_IAudioClient, 0x1CB9AD4C, 0xDBFA, 0x4c32, 0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2);
// MIDL_INTERFACE("F294ACFC-3146-4483-A7BF-ADDCA7C260E2")
Expand All @@ -61,6 +65,7 @@ DEFINE_GUID(IID_IAudioRenderClient, 0xF294ACFC, 0x3146, 0x4483, 0xA7, 0xBF, 0xAD
DEFINE_GUID(IID_IMMDeviceEnumerator, 0xA95664D2, 0x9614, 0x4F35, 0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6);
// DECLSPEC_UUID("BCDE0395-E52F-467C-8E3D-C4579291692E")
DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E);
#endif

// based on the implementation in soloud and Microsoft sample code
static void (*volatile a2_callback)(kinc_a2_buffer_t *buffer, uint32_t samples, void *userdata) = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ IUnknown *kinc_winapp_internal_get_window(void);
#include <windows.graphics.directx.direct3d11.interop.h>
#endif

// MinGW workaround for missing defines
#ifndef D3D11_MIN_DEPTH
#define D3D11_MIN_DEPTH (0.0f)
#endif

#ifndef D3D11_MAX_DEPTH
#define D3D11_MAX_DEPTH (1.0f)
#endif

extern kinc_g4_pipeline_t *currentPipeline;
extern float currentBlendFactor[4];
extern bool needPipelineRebind;
Expand Down Expand Up @@ -876,6 +885,8 @@ void kinc_g4_set_texture_magnification_filter(kinc_g4_texture_unit_t unit, kinc_
case D3D11_FILTER_ANISOTROPIC:
d3d11filter = D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR;
break;
default:
break;
}
break;
case KINC_G4_TEXTURE_FILTER_LINEAR:
Expand All @@ -896,6 +907,8 @@ void kinc_g4_set_texture_magnification_filter(kinc_g4_texture_unit_t unit, kinc_
case D3D11_FILTER_ANISOTROPIC:
d3d11filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
break;
default:
break;
}
break;
case KINC_G4_TEXTURE_FILTER_ANISOTROPIC:
Expand Down Expand Up @@ -940,6 +953,8 @@ void kinc_g4_set_texture_minification_filter(kinc_g4_texture_unit_t unit, kinc_g
case D3D11_FILTER_ANISOTROPIC:
d3d11filter = D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR;
break;
default:
break;
}
break;
case KINC_G4_TEXTURE_FILTER_LINEAR:
Expand All @@ -961,11 +976,15 @@ void kinc_g4_set_texture_minification_filter(kinc_g4_texture_unit_t unit, kinc_g
case D3D11_FILTER_ANISOTROPIC:
d3d11filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
break;
default:
break;
}
break;
case KINC_G4_TEXTURE_FILTER_ANISOTROPIC:
d3d11filter = D3D11_FILTER_ANISOTROPIC;
break;
default:
break;
}

lastSamplers[unit.stages[KINC_G4_SHADER_TYPE_FRAGMENT]].Filter = d3d11filter;
Expand Down Expand Up @@ -1008,6 +1027,8 @@ void kinc_g4_set_texture_mipmap_filter(kinc_g4_texture_unit_t unit, kinc_g4_mipm
case D3D11_FILTER_ANISOTROPIC:
d3d11filter = D3D11_FILTER_ANISOTROPIC;
break;
default:
break;
}
break;
case KINC_G4_MIPMAP_FILTER_LINEAR:
Expand All @@ -1031,6 +1052,8 @@ void kinc_g4_set_texture_mipmap_filter(kinc_g4_texture_unit_t unit, kinc_g4_mipm
case D3D11_FILTER_ANISOTROPIC:
d3d11filter = D3D11_FILTER_ANISOTROPIC;
break;
default:
break;
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
uint32_t kinc_internal_hash_name(unsigned char *str) {
unsigned long hash = 5381;
int c;
while (c = *str++) {
while ((c = *str++)) {
hash = hash * 33 ^ c;
}
return hash;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Windows 7
#define WINVER 0x0601
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0601

#define NOATOM
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <kinc/graphics4/indexBuffer.h>
#include <kinc/graphics4/indexbuffer.h>

void kinc_g4_index_buffer_init(kinc_g4_index_buffer_t *buffer, int count, kinc_g4_index_buffer_format_t format, kinc_g4_usage_t usage) {
buffer->impl.count = count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ void kinc_g4_pipeline_compile(struct kinc_g4_pipeline *state) {
}
break;
}
default:
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static void initWindow(struct dx_window *window, int windowIndex) {
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
swapChainDesc.Windowed = true;

IDXGIFactory4 *dxgiFactory;
IDXGIFactory4 *dxgiFactory = NULL;
kinc_microsoft_affirm(CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory)));

kinc_microsoft_affirm(dxgiFactory->CreateSwapChain((IUnknown *)commandQueue, &swapChainDesc, &window->swapChain));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

// Windows 7
#define WINVER 0x0601
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0601

#define NOATOM
Expand Down
3 changes: 3 additions & 0 deletions Backends/System/Windows/Sources/kinc/backend/windowsunit.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Windows 7
#define WINVER 0x0601
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0601

#define NOATOM
Expand Down

0 comments on commit 2ff2a24

Please sign in to comment.