2018-11-16 00:31:39 +01: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 19:35:19 +02:00
|
|
|
|
|
|
|
#ifndef COPENGL_H
|
|
|
|
#define COPENGL_H
|
|
|
|
|
|
|
|
#include <windows.h>
|
2018-05-20 17:25:39 +02:00
|
|
|
#include "gl_core_3_1.h"
|
2011-03-20 23:21:12 +01:00
|
|
|
#include "cgFunctions.h"
|
2011-07-02 04:25:13 +02:00
|
|
|
#include "CGLCG.h"
|
2018-05-20 19:48:38 +02:00
|
|
|
#include "../shaders/glsl.h"
|
2011-02-24 01:26:42 +01:00
|
|
|
|
2010-09-25 19:35:19 +02:00
|
|
|
#include "wglext.h"
|
|
|
|
#include "IS9xDisplayOutput.h"
|
|
|
|
|
2023-02-01 21:47:42 +01:00
|
|
|
#include <functional>
|
|
|
|
|
2018-05-22 21:43:51 +02:00
|
|
|
enum current_ogl_shader_type { OGL_SHADER_NONE, OGL_SHADER_GLSL, OGL_SHADER_CG, OGL_SHADER_GLSL_OLD};
|
2011-02-24 01:26:42 +01:00
|
|
|
|
2010-09-25 19:35:19 +02:00
|
|
|
class COpenGL : public IS9xDisplayOutput
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
HDC hDC;
|
|
|
|
HGLRC hRC;
|
|
|
|
HWND hWnd;
|
|
|
|
GLuint drawTexture;
|
|
|
|
GLuint drawBuffer;
|
|
|
|
GLfloat vertices[8];
|
|
|
|
GLfloat texcoords[8];
|
|
|
|
unsigned char * noPboBuffer;
|
2019-02-01 00:07:09 +01:00
|
|
|
TCHAR currentShaderFile[MAX_PATH];
|
2010-09-25 19:35:19 +02:00
|
|
|
|
2011-05-11 21:39:06 +02:00
|
|
|
int frameCount;
|
|
|
|
|
2010-09-25 19:35:19 +02:00
|
|
|
bool initDone;
|
|
|
|
bool fullscreen;
|
2018-05-22 21:27:40 +02:00
|
|
|
unsigned int outTextureWidth;
|
|
|
|
unsigned int outTextureHeight;
|
2010-09-25 19:35:19 +02:00
|
|
|
unsigned int afterRenderWidth, afterRenderHeight;
|
|
|
|
|
|
|
|
bool shaderFunctionsLoaded;
|
|
|
|
|
|
|
|
bool pboFunctionsLoaded;
|
|
|
|
|
2011-02-24 01:26:42 +01:00
|
|
|
CGcontext cgContext;
|
|
|
|
CGprogram cgVertexProgram, cgFragmentProgram;
|
|
|
|
current_ogl_shader_type shader_type;
|
2011-03-20 23:21:12 +01:00
|
|
|
bool cgAvailable;
|
2011-02-24 01:26:42 +01:00
|
|
|
|
2011-07-02 04:25:13 +02:00
|
|
|
CGLCG *cgShader;
|
2018-05-20 19:48:38 +02:00
|
|
|
GLSLShader *glslShader;
|
2011-07-02 04:25:13 +02:00
|
|
|
|
2010-09-25 19:35:19 +02:00
|
|
|
GLuint shaderProgram;
|
|
|
|
GLuint vertexShader;
|
|
|
|
GLuint fragmentShader;
|
|
|
|
|
|
|
|
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
|
|
|
|
|
2011-02-24 01:26:42 +01:00
|
|
|
bool SetShaders(const TCHAR *file);
|
2011-03-04 02:11:36 +01:00
|
|
|
void checkForCgError(const char *situation);
|
2011-02-24 01:26:42 +01:00
|
|
|
bool SetShadersCG(const TCHAR *file);
|
|
|
|
bool SetShadersGLSL(const TCHAR *glslFileName);
|
2018-05-22 21:43:51 +02:00
|
|
|
bool SetShadersGLSL_OLD(const TCHAR *glslFileName);
|
2010-09-25 19:35:19 +02:00
|
|
|
bool LoadShaderFunctions();
|
|
|
|
bool LoadPBOFunctions();
|
2018-05-22 21:27:40 +02:00
|
|
|
void CreateDrawSurface(unsigned int width, unsigned int height);
|
2010-09-25 19:35:19 +02:00
|
|
|
void DestroyDrawSurface(void);
|
2018-05-22 21:27:40 +02:00
|
|
|
bool ChangeDrawSurfaceSize(unsigned int width, unsigned int height);
|
2010-09-25 19:35:19 +02:00
|
|
|
void SetupVertices();
|
2019-02-19 23:57:42 +01:00
|
|
|
bool ShaderAvailable();
|
2018-05-20 19:48:38 +02:00
|
|
|
bool NPOTAvailable();
|
2010-09-25 19:35:19 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
COpenGL();
|
|
|
|
~COpenGL();
|
|
|
|
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);
|
2019-03-05 21:25:50 +01:00
|
|
|
void EnumModes(std::vector<dMode> *modeVector);
|
|
|
|
void SetSwapInterval(int frames);
|
2023-02-01 21:47:42 +01:00
|
|
|
std::vector<GLSLParam> *GetShaderParameters(void);
|
|
|
|
std::function<void(const char*)> GetShaderParametersSaveFunction();
|
2010-09-25 19:35:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|