mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-11 16:49:27 +01:00
glstate: Support glBlendColor
This commit is contained in:
1 parent
41e5a5f367
commit
f4278247ed
1 file changed
+26
-4
+26
-4
@@ -12,7 +12,11 @@
|
||||
#endif
|
||||
#endif
|
||||
#include <functional>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
// OpenGL state cache. Should convert all code to use this instead of directly calling glEnable etc,
|
||||
// as GL state changes can be expensive on some hardware.
|
||||
class OpenGLState
|
||||
{
|
||||
private:
|
||||
@@ -56,7 +60,7 @@ private:
|
||||
class SavedState1_##func { \
|
||||
p1type p1; \
|
||||
public: \
|
||||
SavedState1_##func() : p1(p1def) {}; \
|
||||
SavedState1_##func() : p1(p1def) {}; \
|
||||
void set(p1type newp1) { \
|
||||
if(newp1 != p1) { \
|
||||
p1 = newp1; \
|
||||
@@ -73,7 +77,7 @@ private:
|
||||
p1type p1; \
|
||||
p2type p2; \
|
||||
public: \
|
||||
SavedState2_##func() : p1(p1def), p2(p2def) {}; \
|
||||
SavedState2_##func() : p1(p1def), p2(p2def) {}; \
|
||||
inline void set(p1type newp1, p2type newp2) { \
|
||||
if(newp1 != p1 || newp2 != p2) { \
|
||||
p1 = newp1; \
|
||||
@@ -86,10 +90,26 @@ private:
|
||||
} \
|
||||
}
|
||||
|
||||
#define STATEFLOAT4(func, def) \
|
||||
class SavedState4_##func { \
|
||||
float p[4]; \
|
||||
public: \
|
||||
SavedState4_##func() { \
|
||||
for (int i = 0; i < 4; i++) {p[i] = def;} \
|
||||
}; \
|
||||
inline void set(const float v[4]) { \
|
||||
if(memcmp(p,v,sizeof(float)*4)) { \
|
||||
memcpy(p,v,sizeof(float)*4); \
|
||||
func(p[0], p[1], p[2], p[3]); \
|
||||
} \
|
||||
} \
|
||||
inline void restore() { \
|
||||
func(p[0], p[1], p[2], p[3]); \
|
||||
} \
|
||||
}
|
||||
|
||||
bool initialized;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
OpenGLState() : initialized(false) {}
|
||||
void Initialize();
|
||||
@@ -98,6 +118,7 @@ public:
|
||||
BoolState<GL_BLEND, false> blend;
|
||||
STATE2(glBlendFunc, GLenum, GLenum, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) blendFunc;
|
||||
STATE1(glBlendEquation, GLenum, GL_FUNC_ADD) blendEquation;
|
||||
STATEFLOAT4(glBlendColor, 1.0f) blendColor;
|
||||
|
||||
BoolState<GL_CULL_FACE, false> cullFace;
|
||||
STATE1(glCullFace, GLenum, GL_FRONT) cullFaceMode;
|
||||
@@ -105,6 +126,7 @@ public:
|
||||
BoolState<GL_DEPTH_TEST, false> depthTest;
|
||||
STATE1(glDepthFunc, GLenum, GL_LESS) depthFunc;
|
||||
STATE2(glDepthRangef, float, float, 0.f, 1.f) depthRange;
|
||||
|
||||
};
|
||||
|
||||
#undef STATE1
|
||||
|
||||
Reference in new issue
Block a user