I'm trying to add a DirectX 11 renderer (not sure if that is even doable in a "simple" manner) to the Return To Castle Wolfenstein source code and I'm having some problems. I have a rendering class in a header that I included in the project, and whenever I include it in one of the RTCW files I get this error:
1>c:\program files (x86)\windows kits\8.1\include\um\directxmath.h(17): fatal error C1189: #error: DirectX Math requires C++
Now I am wondering what would be a way to use DirectX math functions/classes (and all DirectX classes actually) in a C project such as the RTCW code? Is it possible to change the entire project settings so it compiles as C++? I am using Visual Studio 2017.
This is my renderer class declaration in XD3D.h header:
#include <d3d11.h>
#include <DirectXMath.h>
#include "XGeomObject.h"
#include "XCamera.h"
using namespace DirectX;
#define GPA(d3dModule, func) GetProcAddress(d3dModule, func)
class XD3DRenderer
{
protected:
HMODULE m_XD3DModule;
ID3D11Device* m_pD3DDevice;
ID3D11DeviceContext* m_pDeviceContext;
IDXGISwapChain* m_pSwapChain;
ID3D11RenderTargetView* m_pRenderTargetView;
ID3D11Texture2D* m_pBackBuffer;
ID3D11Texture2D* m_pDepthStencilBuffer;
ID3D11DepthStencilState* m_pDepthStencilState;
ID3D11DepthStencilState* m_pDisabledDepthStencilState;
ID3D11RasterizerState* m_pRasterState;
ID3D11DepthStencilView* m_pDepthStencilView;
HWND m_wnd;
int m_screenWidth, m_screenHeight;
bool m_fullScreen;
D3DXMATRIX m_world, m_view, m_proj;
bool m_lightMapsOn;
public:
XD3DRenderer();
XD3DRenderer(HWND wnd, int screenwidth, int screenheight,bool fullscreen);
~XD3DRenderer();
ID3D11Device* GetD3DDevice() { return m_pD3DDevice; }
ID3D11DeviceContext* GetDeviceContext() { return m_pDeviceContext; }
bool LoadDriver();
bool CreateD3DDevice(HWND wnd, int screenwidth, int screenheight, bool fullscreen );
bool CreateRenderTargetView();
bool CreateDepthBuffer();
bool CreateDepthStencilView();
bool CreateDisabledDepthStencilState();
bool Setup();
bool ClearScene(const D3DXCOLOR& col);
bool Render(XGeomObject*, XCamera*);
bool ShowScene();
void TurnOnZBuffer();
void TurnOffZBuffer();
};
And I include it in the C project in the RTCW win_glimp.c file like this:
#include <assert.h>
#include "../renderer/tr_local.h"
#include "../qcommon/qcommon.h"
#include "resource.h"
#include "glw_win.h"
#include "win_local.h"
#include "../renderer/XD3D.h"
extern void WG_CheckHardwareGamma( void );
extern void WG_RestoreGamma( void );
... rest of win_glimp.c file omitted.