Path: blob/master/RSDKv5/RSDK/Graphics/DX9/DX9RenderDevice.hpp
1164 views
const auto _wapiShowCursor = ShowCursor;1const auto _wapiGetCursorPos = GetCursorPos;23class RenderDevice : public RenderDeviceBase4{5public:6struct WindowInfo {7union {8struct {9UINT width;10UINT height;11UINT refresh_rate;12};13D3DDISPLAYMODE internal;14} * displays;15D3DVIEWPORT9 viewport;16};17static WindowInfo displayInfo;1819static bool Init();20static void CopyFrameBuffer();21static void FlipScreen();22static void Release(bool32 isRefresh);2324static void RefreshWindow();25static void GetWindowSize(int32 *width, int32 *height);2627static void SetupImageTexture(int32 width, int32 height, uint8 *imagePixels);28static void SetupVideoTexture_YUV420(int32 width, int32 height, uint8 *yPlane, uint8 *uPlane, uint8 *vPlane, int32 strideY, int32 strideU,29int32 strideV);30static void SetupVideoTexture_YUV422(int32 width, int32 height, uint8 *yPlane, uint8 *uPlane, uint8 *vPlane, int32 strideY, int32 strideU,31int32 strideV);32static void SetupVideoTexture_YUV444(int32 width, int32 height, uint8 *yPlane, uint8 *uPlane, uint8 *vPlane, int32 strideY, int32 strideU,33int32 strideV);3435static bool ProcessEvents();3637static void InitFPSCap();38static bool CheckFPSCap();39static void UpdateFPSCap();4041static bool InitShaders();42static void LoadShader(const char *fileName, bool32 linear);4344inline static void ShowCursor(bool32 shown)45{46if (shown) {47while (_wapiShowCursor(true) < 0)48;49}50else {51while (_wapiShowCursor(false) >= 0)52;53}54}5556inline static bool GetCursorPos(Vector2 *pos)57{58POINT cursorPos{};59_wapiGetCursorPos(&cursorPos);60ScreenToClient(windowHandle, &cursorPos);61pos->x = cursorPos.x;62pos->y = cursorPos.y;63return true;64}6566static inline void SetWindowTitle()67{68#if _UNICODE69// shoddy workaround to get the title into wide chars in UNICODE mode70std::string str = RSDK::gameVerInfo.gameTitle;71std::wstring temp = std::wstring(str.begin(), str.end());72LPCWSTR gameTitle = temp.c_str();73#else74std::string str = RSDK::gameVerInfo.gameTitle;75LPCSTR gameTitle = str.c_str();76#endif7778SetWindowText(windowHandle, gameTitle);79}8081static HWND windowHandle;82static IDirect3DTexture9 *imageTexture;8384static IDirect3D9 *dx9Context;85static IDirect3DDevice9 *dx9Device;8687static UINT dxAdapter;88static int32 adapterCount;8990// WinMain args91static HINSTANCE hInstance;92static HINSTANCE hPrevInstance;93static INT nShowCmd;9495private:96static bool SetupRendering();97static void InitVertexBuffer();98static bool InitGraphicsAPI();99100static void GetDisplays();101102static void ProcessEvent(MSG msg);103static LRESULT CALLBACK WindowEventCallback(HWND hRecipient, UINT message, WPARAM wParam, LPARAM lParam);104105static bool useFrequency;106107static LARGE_INTEGER performanceCount, frequency, initialFrequency, curFrequency;108109static HDEVNOTIFY deviceNotif;110static PAINTSTRUCT Paint;111112static IDirect3DVertexDeclaration9 *dx9VertexDeclare;113static IDirect3DVertexBuffer9 *dx9VertexBuffer;114static IDirect3DTexture9 *screenTextures[SCREEN_COUNT];115static D3DVIEWPORT9 dx9ViewPort;116117static RECT monitorDisplayRect;118static GUID deviceIdentifier;119};120121struct ShaderEntry : public ShaderEntryBase {122IDirect3DVertexShader9 *vertexShaderObject;123IDirect3DPixelShader9 *pixelShaderObject;124};125126127