2015-07-01 23:17:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
2014-06-12 21:48:04 -04:00
|
|
|
#include "stdafx.h"
|
2015-08-30 21:04:21 -04:00
|
|
|
#include "../Core/IRenderingDevice.h"
|
2014-07-06 19:54:47 -04:00
|
|
|
#include "../Core/IMessageManager.h"
|
2016-05-24 19:45:58 -04:00
|
|
|
#include "../Core/EmulationSettings.h"
|
2014-07-10 21:17:37 -04:00
|
|
|
#include "../Utilities/FolderUtilities.h"
|
|
|
|
#include "../Utilities/SimpleLock.h"
|
2015-07-14 21:51:39 -04:00
|
|
|
#include "../Utilities/Timer.h"
|
2014-06-12 21:48:04 -04:00
|
|
|
|
|
|
|
using namespace DirectX;
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
namespace DirectX {
|
|
|
|
class SpriteBatch;
|
|
|
|
class SpriteFont;
|
|
|
|
}
|
|
|
|
|
2014-06-12 21:48:04 -04:00
|
|
|
namespace NES {
|
2015-08-30 21:04:21 -04:00
|
|
|
class Renderer : public IRenderingDevice, public IMessageManager
|
2014-06-12 21:48:04 -04:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
HWND _hWnd = nullptr;
|
|
|
|
|
|
|
|
ID3D11Device* _pd3dDevice = nullptr;
|
2014-06-23 20:00:51 -04:00
|
|
|
ID3D11DeviceContext* _pDeviceContext = nullptr;
|
2014-06-12 21:48:04 -04:00
|
|
|
IDXGISwapChain* _pSwapChain = nullptr;
|
|
|
|
ID3D11RenderTargetView* _pRenderTargetView = nullptr;
|
2015-07-01 23:17:14 -04:00
|
|
|
ID3D11DepthStencilState* _pDepthDisabledStencilState = nullptr;
|
|
|
|
ID3D11BlendState* _pAlphaEnableBlendingState = nullptr;
|
|
|
|
|
2014-06-23 16:38:01 -04:00
|
|
|
ID3D11SamplerState* _samplerState = nullptr;
|
|
|
|
|
2016-05-22 14:43:07 -04:00
|
|
|
atomic<bool> _needFlip = false;
|
2016-05-22 11:14:01 -04:00
|
|
|
ID3D11Texture2D* _pTexture[2] = { nullptr,nullptr };
|
2016-01-12 19:42:28 -05:00
|
|
|
ID3D11Texture2D* _overlayTexture = nullptr;
|
2014-06-28 22:52:49 -04:00
|
|
|
|
|
|
|
bool _frameChanged = true;
|
2014-07-10 21:17:37 -04:00
|
|
|
SimpleLock _frameLock;
|
|
|
|
|
2016-05-24 19:45:58 -04:00
|
|
|
VideoResizeFilter _resizeFilter = VideoResizeFilter::NearestNeighbor;
|
|
|
|
|
2015-07-14 21:51:39 -04:00
|
|
|
Timer _fpsTimer;
|
|
|
|
uint32_t _lastFrameCount = 0;
|
2015-08-14 21:50:14 -04:00
|
|
|
uint32_t _renderedFrameCount = 0;
|
|
|
|
uint32_t _lastRenderedFrameCount = 0;
|
2015-07-14 21:51:39 -04:00
|
|
|
uint32_t _currentFPS = 0;
|
2015-08-14 21:50:14 -04:00
|
|
|
uint32_t _currentRenderedFPS = 0;
|
2014-06-13 23:12:56 -04:00
|
|
|
|
2014-06-23 16:38:01 -04:00
|
|
|
unique_ptr<SpriteFont> _font;
|
2016-02-11 18:34:55 -05:00
|
|
|
unique_ptr<SpriteFont> _largeFont;
|
2014-07-01 12:44:01 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
unique_ptr<SpriteBatch> _spriteBatch;
|
2014-06-23 16:38:01 -04:00
|
|
|
|
2015-07-23 23:16:31 -04:00
|
|
|
const uint32_t _bytesPerPixel = 4;
|
2016-01-05 21:28:38 -05:00
|
|
|
uint32_t _screenWidth = 0;
|
|
|
|
uint32_t _screenHeight = 0;
|
|
|
|
uint32_t _screenBufferSize = 0;
|
|
|
|
|
|
|
|
uint32_t _nesFrameHeight = 0;
|
|
|
|
uint32_t _nesFrameWidth = 0;
|
|
|
|
uint32_t _newFrameBufferSize = 0;
|
2014-06-12 21:48:04 -04:00
|
|
|
|
2016-01-31 00:41:33 -05:00
|
|
|
uint32_t _noUpdateCount = 0;
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
list<shared_ptr<ToastInfo>> _toasts;
|
2016-02-11 18:34:55 -05:00
|
|
|
//ID3D11ShaderResourceView* _toastTexture = nullptr;
|
2014-06-25 21:52:37 -04:00
|
|
|
|
2014-06-23 16:38:01 -04:00
|
|
|
HRESULT InitDevice();
|
|
|
|
void CleanupDevice();
|
2014-06-23 20:00:51 -04:00
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
void SetScreenSize(uint32_t width, uint32_t height);
|
2014-06-26 11:32:09 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
ID3D11Texture2D* CreateTexture(uint32_t width, uint32_t height);
|
2014-06-23 20:00:51 -04:00
|
|
|
ID3D11ShaderResourceView* GetShaderResourceView(ID3D11Texture2D* texture);
|
|
|
|
void DrawNESScreen();
|
|
|
|
void DrawPauseScreen();
|
2014-06-12 21:48:04 -04:00
|
|
|
|
2016-02-06 18:33:24 -05:00
|
|
|
std::wstring WrapText(string text, SpriteFont* font, float maxLineWidth, uint32_t &lineCount);
|
2016-02-19 13:05:04 -05:00
|
|
|
void DrawString(string message, float x, float y, DirectX::FXMVECTOR color, float scale, SpriteFont* font = nullptr);
|
|
|
|
void DrawString(std::wstring message, float x, float y, DirectX::FXMVECTOR color, float scale, SpriteFont* font = nullptr);
|
2014-07-09 21:11:02 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
void DrawToasts();
|
2016-02-06 18:33:24 -05:00
|
|
|
void DrawToast(shared_ptr<ToastInfo> toast, int &lastHeight);
|
2015-07-01 23:17:14 -04:00
|
|
|
void RemoveOldToasts();
|
2015-07-14 21:51:39 -04:00
|
|
|
|
2014-06-12 21:48:04 -04:00
|
|
|
public:
|
2014-06-23 19:02:09 -04:00
|
|
|
Renderer(HWND hWnd);
|
|
|
|
~Renderer();
|
2014-06-23 16:38:01 -04:00
|
|
|
|
2016-01-16 12:29:17 -05:00
|
|
|
void Reset();
|
2015-08-30 21:04:21 -04:00
|
|
|
void Render();
|
2015-07-11 08:27:22 -04:00
|
|
|
void DisplayMessage(string title, string message);
|
2015-07-01 23:17:14 -04:00
|
|
|
void DisplayToast(shared_ptr<ToastInfo> toast);
|
2015-08-30 21:04:21 -04:00
|
|
|
|
2016-01-05 21:28:38 -05:00
|
|
|
void UpdateFrame(void *frameBuffer, uint32_t width, uint32_t height);
|
2014-06-12 21:48:04 -04:00
|
|
|
};
|
|
|
|
}
|