2018-11-15 23:31:39 +00:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
#ifndef W9XDIRECT3D_H
|
|
|
|
#define W9XDIRECT3D_H
|
|
|
|
|
2010-09-25 17:35:19 +00:00
|
|
|
#define MAX_SHADER_TEXTURES 8
|
|
|
|
|
2010-09-25 15:46:12 +00:00
|
|
|
#include <d3d9.h>
|
2010-09-25 17:35:19 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2011-03-20 22:21:12 +00:00
|
|
|
#include "cgFunctions.h"
|
2011-12-10 14:21:37 +00:00
|
|
|
#include "CD3DCG.h"
|
2011-02-24 00:26:42 +00:00
|
|
|
|
2010-09-25 15:46:12 +00:00
|
|
|
#include "render.h"
|
|
|
|
#include "wsnes9x.h"
|
|
|
|
#include "IS9xDisplayOutput.h"
|
|
|
|
|
2011-03-05 23:48:54 +00:00
|
|
|
#define FVF_COORDS_TEX D3DFVF_XYZ | D3DFVF_TEX1
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
typedef struct _VERTEX {
|
|
|
|
float x, y, z;
|
|
|
|
float tx, ty;
|
2011-12-10 14:21:37 +00:00
|
|
|
float lutx, luty;
|
2010-09-25 15:46:12 +00:00
|
|
|
_VERTEX() {}
|
2011-12-10 14:21:37 +00:00
|
|
|
_VERTEX(float x,float y,float z,float tx,float ty,float lutx, float luty) {
|
|
|
|
this->x=x;this->y=y;this->z=z;this->tx=tx;this->ty=ty;this->lutx=lutx;this->luty=luty;
|
2010-09-25 15:46:12 +00:00
|
|
|
}
|
|
|
|
} VERTEX; //our custom vertex with a constuctor for easier assignment
|
|
|
|
|
2018-08-07 14:03:41 +00:00
|
|
|
enum current_d3d_shader_type { D3D_SHADER_NONE, D3D_SHADER_CG };
|
2011-02-24 00:26:42 +00:00
|
|
|
|
2010-09-25 15:46:12 +00:00
|
|
|
class CDirect3D: public IS9xDisplayOutput
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
bool init_done; //has initialize been called?
|
|
|
|
LPDIRECT3D9 pD3D;
|
|
|
|
LPDIRECT3DDEVICE9 pDevice;
|
|
|
|
LPDIRECT3DTEXTURE9 drawSurface; //the texture used for all drawing operations
|
|
|
|
|
|
|
|
LPDIRECT3DVERTEXBUFFER9 vertexBuffer;
|
|
|
|
D3DPRESENT_PARAMETERS dPresentParams;
|
2010-09-25 17:35:19 +00:00
|
|
|
unsigned int filterScale; //the current maximum filter scale (at least 2)
|
2010-09-25 15:46:12 +00:00
|
|
|
unsigned int afterRenderWidth, afterRenderHeight; //dimensions after filter has been applied
|
|
|
|
unsigned int quadTextureSize; //size of the texture (only multiples of 2)
|
|
|
|
bool fullscreen; //are we currently displaying in fullscreen mode
|
|
|
|
|
2011-12-10 14:21:37 +00:00
|
|
|
VERTEX vertexStream[4]; //the 4 vertices that make up our display rectangle
|
|
|
|
|
|
|
|
static const D3DVERTEXELEMENT9 vertexElems[4];
|
|
|
|
LPDIRECT3DVERTEXDECLARATION9 vertexDeclaration;
|
2010-09-25 15:46:12 +00:00
|
|
|
|
2010-09-25 17:35:19 +00:00
|
|
|
LPDIRECT3DTEXTURE9 rubyLUT[MAX_SHADER_TEXTURES];
|
2011-02-24 00:26:42 +00:00
|
|
|
CGcontext cgContext;
|
|
|
|
current_d3d_shader_type shader_type;
|
2011-03-20 22:21:12 +00:00
|
|
|
bool cgAvailable;
|
2011-03-05 23:48:54 +00:00
|
|
|
|
2011-12-10 14:21:37 +00:00
|
|
|
CD3DCG *cgShader;
|
|
|
|
|
2010-09-25 17:35:19 +00:00
|
|
|
float shaderTimer;
|
|
|
|
int shaderTimeStart;
|
|
|
|
int shaderTimeElapsed;
|
2011-05-11 19:39:06 +00:00
|
|
|
int frameCount;
|
2010-09-25 17:35:19 +00:00
|
|
|
|
2010-09-25 15:46:12 +00:00
|
|
|
bool BlankTexture(LPDIRECT3DTEXTURE9 texture);
|
|
|
|
void CreateDrawSurface();
|
|
|
|
void DestroyDrawSurface();
|
2010-09-25 17:35:19 +00:00
|
|
|
bool ChangeDrawSurfaceSize(unsigned int scale);
|
2011-03-05 23:48:54 +00:00
|
|
|
void SetViewport();
|
2010-09-25 15:46:12 +00:00
|
|
|
void SetupVertices();
|
|
|
|
bool ResetDevice();
|
2011-12-10 14:21:37 +00:00
|
|
|
void SetFiltering();
|
2010-09-25 17:35:19 +00:00
|
|
|
bool SetShader(const TCHAR *file);
|
2011-03-04 01:11:36 +00:00
|
|
|
void checkForCgError(const char *situation);
|
2011-02-24 00:26:42 +00:00
|
|
|
bool SetShaderCG(const TCHAR *file);
|
2019-05-20 19:13:32 +00:00
|
|
|
void Clear();
|
2010-09-25 15:46:12 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CDirect3D();
|
|
|
|
~CDirect3D();
|
|
|
|
bool Initialize(HWND hWnd);
|
|
|
|
void DeInitialize();
|
|
|
|
void Render(SSurface Src);
|
|
|
|
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight);
|
|
|
|
bool ApplyDisplayChanges(void);
|
|
|
|
bool SetFullscreen(bool fullscreen);
|
|
|
|
void SetSnes9xColorFormat();
|
|
|
|
void EnumModes(std::vector<dMode> *modeVector);
|
|
|
|
};
|
|
|
|
|
2010-09-25 17:35:19 +00:00
|
|
|
#endif
|