flycast/core/rend/dx9/dxcontext.h

64 lines
2.0 KiB
C
Raw Normal View History

2021-04-12 20:49:04 +00:00
/*
Copyright 2021 flyinghead
This file is part of Flycast.
Flycast is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Flycast is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#ifdef _WIN32
#include "types.h"
2021-04-12 20:49:04 +00:00
#include <windows.h>
#include <d3d9.h>
#include "imgui_impl_dx9.h"
#include "comptr.h"
#include "d3d_overlay.h"
#include "wsi/context.h"
2021-04-12 20:49:04 +00:00
class DXContext : public GraphicsContext
2021-04-12 20:49:04 +00:00
{
public:
bool init(bool keepCurrentWindow = false);
void term() override;
2021-04-12 20:49:04 +00:00
void EndImGuiFrame();
void Present();
const ComPtr<IDirect3D9>& getD3D() const { return pD3D; }
const ComPtr<IDirect3DDevice9>& getDevice() const { return pDevice; }
void resize() override;
void setOverlay(bool overlayOnly) { this->overlayOnly = overlayOnly; }
std::string getDriverName() override {
2021-04-12 20:49:04 +00:00
D3DADAPTER_IDENTIFIER9 id;
pD3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &id);
return std::string(id.Description);
}
std::string getDriverVersion() override {
2021-04-12 20:49:04 +00:00
D3DADAPTER_IDENTIFIER9 id;
pD3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &id);
return std::to_string(id.DriverVersion.HighPart >> 16) + "." + std::to_string((u16)id.DriverVersion.HighPart)
+ "." + std::to_string(id.DriverVersion.LowPart >> 16) + "." + std::to_string((u16)id.DriverVersion.LowPart);
}
private:
void resetDevice();
2021-04-12 20:49:04 +00:00
ComPtr<IDirect3D9> pD3D;
ComPtr<IDirect3DDevice9> pDevice;
D3DPRESENT_PARAMETERS d3dpp{};
bool overlayOnly = false;
D3DOverlay overlay;
2021-09-07 12:16:05 +00:00
bool swapOnVSync = false;
2021-04-12 20:49:04 +00:00
};
extern DXContext theDXContext;
#endif