2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2009-02-23 06:17:57 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
#ifndef _VERTEXSHADERCACHE_H_
|
|
|
|
#define _VERTEXSHADERCACHE_H_
|
|
|
|
|
2009-02-23 06:17:57 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2009-06-22 09:31:30 +00:00
|
|
|
#include "BPMemory.h"
|
2009-02-23 06:17:57 +00:00
|
|
|
#include "VertexShaderGen.h"
|
|
|
|
|
2011-01-29 20:16:51 +00:00
|
|
|
namespace OGL
|
|
|
|
{
|
|
|
|
|
2009-02-23 06:17:57 +00:00
|
|
|
struct VERTEXSHADER
|
|
|
|
{
|
|
|
|
VERTEXSHADER() : glprogid(0) {}
|
|
|
|
GLuint glprogid; // opengl program id
|
|
|
|
|
|
|
|
std::string strprog;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VertexShaderCache
|
|
|
|
{
|
|
|
|
struct VSCacheEntry
|
|
|
|
{
|
|
|
|
VERTEXSHADER shader;
|
2011-09-08 22:32:04 +00:00
|
|
|
VERTEXSHADERUIDSAFE safe_uid;
|
2011-09-29 21:32:05 +00:00
|
|
|
VSCacheEntry() {}
|
2009-02-23 06:17:57 +00:00
|
|
|
void Destroy() {
|
|
|
|
// printf("Destroying vs %i\n", shader.glprogid);
|
|
|
|
glDeleteProgramsARB(1, &shader.glprogid);
|
|
|
|
shader.glprogid = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<VERTEXSHADERUID, VSCacheEntry> VSCache;
|
|
|
|
|
|
|
|
static VSCache vshaders;
|
|
|
|
|
2011-09-29 21:32:05 +00:00
|
|
|
static VSCacheEntry* last_entry;
|
|
|
|
static VERTEXSHADERUID last_uid;
|
|
|
|
|
2009-09-26 12:39:12 +00:00
|
|
|
static GLuint CurrentShader;
|
|
|
|
static bool ShaderEnabled;
|
2009-03-01 00:57:39 +00:00
|
|
|
|
2009-02-23 06:17:57 +00:00
|
|
|
public:
|
|
|
|
static void Init();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2010-09-28 02:15:02 +00:00
|
|
|
static VERTEXSHADER* SetShader(u32 components);
|
2009-02-23 06:17:57 +00:00
|
|
|
static bool CompileVertexShader(VERTEXSHADER& ps, const char* pstrprogram);
|
2009-09-26 12:39:12 +00:00
|
|
|
|
|
|
|
static void SetCurrentShader(GLuint Shader);
|
|
|
|
static void DisableShader();
|
2010-06-05 00:01:18 +00:00
|
|
|
|
2009-02-23 06:17:57 +00:00
|
|
|
};
|
2011-12-01 03:00:21 +00:00
|
|
|
// GLSL Specific
|
|
|
|
void SetGLSLVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4);
|
|
|
|
void SetGLSLVSConstant4fv(unsigned int const_number, const float *f);
|
|
|
|
void SetMultiGLSLVSConstant4fv(unsigned int const_number, unsigned int count, const float *f);
|
|
|
|
void SetMultiGLSLVSConstant3fv(unsigned int const_number, unsigned int count, const float *f);
|
|
|
|
|
|
|
|
// CG Specific
|
|
|
|
void SetCGVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4);
|
|
|
|
void SetCGVSConstant4fv(unsigned int const_number, const float *f);
|
|
|
|
void SetMultiCGVSConstant4fv(unsigned int const_number, unsigned int count, const float *f);
|
|
|
|
void SetMultiCGVSConstant3fv(unsigned int const_number, unsigned int count, const float *f);
|
2011-01-29 20:16:51 +00:00
|
|
|
} // namespace OGL
|
|
|
|
|
2009-11-15 22:26:39 +00:00
|
|
|
#endif // _VERTEXSHADERCACHE_H_
|