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 17:35:19 +00:00
|
|
|
|
|
|
|
#ifndef COPENGL_H
|
|
|
|
#define COPENGL_H
|
|
|
|
|
|
|
|
#include <windows.h>
|
2018-05-20 15:25:39 +00:00
|
|
|
#include "gl_core_3_1.h"
|
2011-03-20 22:21:12 +00:00
|
|
|
#include "cgFunctions.h"
|
2011-07-02 02:25:13 +00:00
|
|
|
#include "CGLCG.h"
|
2024-08-10 23:03:55 +00:00
|
|
|
#include "common/video/opengl/shaders/glsl.h"
|
2011-02-24 00:26:42 +00:00
|
|
|
|
2010-09-25 17:35:19 +00:00
|
|
|
#include "wglext.h"
|
|
|
|
#include "IS9xDisplayOutput.h"
|
|
|
|
|
2023-02-01 20:47:42 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2018-05-22 19:43:51 +00:00
|
|
|
enum current_ogl_shader_type { OGL_SHADER_NONE, OGL_SHADER_GLSL, OGL_SHADER_CG, OGL_SHADER_GLSL_OLD};
|
2011-02-24 00:26:42 +00:00
|
|
|
|
2010-09-25 17:35:19 +00: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-01-31 23:07:09 +00:00
|
|
|
TCHAR currentShaderFile[MAX_PATH];
|
2010-09-25 17:35:19 +00:00
|
|
|
|
2011-05-11 19:39:06 +00:00
|
|
|
int frameCount;
|
|
|
|
|
2010-09-25 17:35:19 +00:00
|
|
|
bool initDone;
|
|
|
|
bool fullscreen;
|
2018-05-22 19:27:40 +00:00
|
|
|
unsigned int outTextureWidth;
|
|
|
|
unsigned int outTextureHeight;
|
2010-09-25 17:35:19 +00:00
|
|
|
unsigned int afterRenderWidth, afterRenderHeight;
|
|
|
|
|
|
|
|
bool shaderFunctionsLoaded;
|
|
|
|
|
|
|
|
bool pboFunctionsLoaded;
|
|
|
|
|
2011-02-24 00:26:42 +00:00
|
|
|
CGcontext cgContext;
|
|
|
|
CGprogram cgVertexProgram, cgFragmentProgram;
|
|
|
|
current_ogl_shader_type shader_type;
|
2011-03-20 22:21:12 +00:00
|
|
|
bool cgAvailable;
|
2011-02-24 00:26:42 +00:00
|
|
|
|
2011-07-02 02:25:13 +00:00
|
|
|
CGLCG *cgShader;
|
2018-05-20 17:48:38 +00:00
|
|
|
GLSLShader *glslShader;
|
2011-07-02 02:25:13 +00:00
|
|
|
|
2010-09-25 17:35:19 +00:00
|
|
|
GLuint shaderProgram;
|
|
|
|
GLuint vertexShader;
|
|
|
|
GLuint fragmentShader;
|
|
|
|
|
|
|
|
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
|
|
|
|
|
2011-02-24 00:26:42 +00:00
|
|
|
bool SetShaders(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 SetShadersCG(const TCHAR *file);
|
|
|
|
bool SetShadersGLSL(const TCHAR *glslFileName);
|
2018-05-22 19:43:51 +00:00
|
|
|
bool SetShadersGLSL_OLD(const TCHAR *glslFileName);
|
2010-09-25 17:35:19 +00:00
|
|
|
bool LoadShaderFunctions();
|
|
|
|
bool LoadPBOFunctions();
|
2018-05-22 19:27:40 +00:00
|
|
|
void CreateDrawSurface(unsigned int width, unsigned int height);
|
2010-09-25 17:35:19 +00:00
|
|
|
void DestroyDrawSurface(void);
|
2018-05-22 19:27:40 +00:00
|
|
|
bool ChangeDrawSurfaceSize(unsigned int width, unsigned int height);
|
2010-09-25 17:35:19 +00:00
|
|
|
void SetupVertices();
|
2019-02-19 22:57:42 +00:00
|
|
|
bool ShaderAvailable();
|
2018-05-20 17:48:38 +00:00
|
|
|
bool NPOTAvailable();
|
2010-09-25 17:35:19 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
COpenGL();
|
|
|
|
~COpenGL();
|
2023-03-11 20:49:10 +00:00
|
|
|
bool Initialize(HWND hWnd) override;
|
|
|
|
void DeInitialize() override;
|
|
|
|
void Render(SSurface Src) override;
|
|
|
|
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight) override;
|
|
|
|
bool ApplyDisplayChanges(void) override;
|
|
|
|
bool SetFullscreen(bool fullscreen) override;
|
|
|
|
void SetSnes9xColorFormat(void) override;
|
|
|
|
void EnumModes(std::vector<dMode> *modeVector) override;
|
2019-03-05 20:25:50 +00:00
|
|
|
void SetSwapInterval(int frames);
|
2023-03-11 20:49:10 +00:00
|
|
|
std::vector<ShaderParam> *GetShaderParameters(void) override;
|
|
|
|
std::function<void(const char*)> GetShaderParametersSaveFunction() override;
|
2010-09-25 17:35:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|