Mesen-X/Windows/Renderer.h

100 lines
2.9 KiB
C
Raw Normal View History

#pragma once
#include "stdafx.h"
#include "../Core/IVideoDevice.h"
#include "../Core/IMessageManager.h"
2014-07-10 21:17:37 -04:00
#include "../Utilities/FolderUtilities.h"
#include "../Utilities/SimpleLock.h"
#include "../Utilities/Timer.h"
using namespace DirectX;
namespace DirectX {
class SpriteBatch;
class SpriteFont;
}
namespace NES {
class Renderer : public IVideoDevice, public IMessageManager
{
private:
HWND _hWnd = nullptr;
D3D_DRIVER_TYPE _driverType = D3D_DRIVER_TYPE_NULL;
D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_11_0;
ID3D11Device* _pd3dDevice = nullptr;
ID3D11Device1* _pd3dDevice1 = nullptr;
ID3D11DeviceContext* _pDeviceContext = nullptr;
ID3D11DeviceContext1* _pDeviceContext1 = nullptr;
IDXGISwapChain* _pSwapChain = nullptr;
ID3D11RenderTargetView* _pRenderTargetView = nullptr;
ID3D11DepthStencilState* _pDepthDisabledStencilState = nullptr;
ID3D11BlendState* _pAlphaEnableBlendingState = nullptr;
2014-06-23 16:38:01 -04:00
ID3D11SamplerState* _samplerState = nullptr;
ID3D11Texture2D* _pTexture = nullptr;
2015-07-23 23:16:31 -04:00
uint32_t* _videoRAM = nullptr;
bool _frameChanged = true;
uint16_t* _ppuOutputBuffer = nullptr;
uint16_t* _ppuOutputSecondaryBuffer = nullptr;
2014-07-10 21:17:37 -04:00
SimpleLock _frameLock;
bool _isHD = false;
Timer _fpsTimer;
uint32_t _frameCount = 0;
uint32_t _lastFrameCount = 0;
uint32_t _renderedFrameCount = 0;
uint32_t _lastRenderedFrameCount = 0;
uint32_t _currentFPS = 0;
uint32_t _currentRenderedFPS = 0;
2014-06-13 23:12:56 -04:00
2014-06-23 16:38:01 -04:00
unique_ptr<SpriteFont> _font;
unique_ptr<SpriteFont> _smallFont;
2014-06-23 16:38:01 -04:00
ID3D11Texture2D* _overlayTexture = nullptr;
2014-06-26 16:24:15 -04:00
byte* _overlayBuffer = nullptr;
unique_ptr<SpriteBatch> _spriteBatch;
//ID3D11PixelShader* _pixelShader = nullptr;
2014-06-23 16:38:01 -04:00
2015-07-23 23:16:31 -04:00
const uint32_t _bytesPerPixel = 4;
uint32_t _hdScreenWidth = 0;
uint32_t _hdScreenHeight = 0;
uint32_t _hdScreenBufferSize = 0;
HdPpuPixelInfo *_hdScreenTiles = nullptr;
HdPpuPixelInfo *_secondaryHdScreenTiles = nullptr;
list<shared_ptr<ToastInfo>> _toasts;
2015-07-23 23:16:31 -04:00
ID3D11ShaderResourceView* _toastTexture = nullptr;
2014-06-25 21:52:37 -04:00
2014-06-23 16:38:01 -04:00
HRESULT InitDevice();
void CleanupDevice();
2015-07-23 23:16:31 -04:00
void SetScreenSize();
ID3D11Texture2D* CreateTexture(uint32_t width, uint32_t height);
ID3D11ShaderResourceView* GetShaderResourceView(ID3D11Texture2D* texture);
void DrawNESScreen();
void DrawPauseScreen();
std::wstring WrapText(string text, SpriteFont* font, float maxLineWidth);
void DrawOutlinedString(string message, float x, float y, DirectX::FXMVECTOR color, float scale);
void DrawToasts();
void DrawToast(shared_ptr<ToastInfo> toast, int posIndex);
void RemoveOldToasts();
public:
2014-06-23 19:02:09 -04:00
Renderer(HWND hWnd);
~Renderer();
2014-06-23 16:38:01 -04:00
bool Render();
void DisplayMessage(string title, string message);
2015-07-21 18:18:20 -04:00
void UpdateFrame(void* frameBuffer);
void UpdateHdFrame(void *frameBuffer, HdPpuPixelInfo *screenTiles);
void DisplayToast(shared_ptr<ToastInfo> toast);
};
}