1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
// Copyright (C) 2015 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "COpenGLCacheHandler.h"
#ifdef _IRR_COMPILE_WITH_OPENGL_
#include "COpenGLDriver.h"
namespace irr
{
namespace video
{
/* COpenGLCacheHandler */
COpenGLCacheHandler::COpenGLCacheHandler(COpenGLDriver* driver) :
COpenGLCoreCacheHandler<COpenGLDriver, COpenGLTexture>(driver), AlphaMode(GL_ALWAYS), AlphaRef(0.f), AlphaTest(false),
MatrixMode(GL_MODELVIEW), ClientActiveTexture(GL_TEXTURE0), ClientStateVertex(false),
ClientStateNormal(false), ClientStateColor(false), ClientStateTexCoord0(false)
{
// Initial OpenGL values from specification.
glAlphaFunc(AlphaMode, AlphaRef);
glDisable(GL_ALPHA_TEST);
glMatrixMode(MatrixMode);
Driver->irrGlClientActiveTexture(ClientActiveTexture);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
COpenGLCacheHandler::~COpenGLCacheHandler()
{
}
void COpenGLCacheHandler::setAlphaFunc(GLenum mode, GLclampf ref)
{
if (AlphaMode != mode || AlphaRef != ref)
{
glAlphaFunc(mode, ref);
AlphaMode = mode;
AlphaRef = ref;
}
}
void COpenGLCacheHandler::setAlphaTest(bool enable)
{
if (AlphaTest != enable)
{
if (enable)
glEnable(GL_ALPHA_TEST);
else
glDisable(GL_ALPHA_TEST);
AlphaTest = enable;
}
}
void COpenGLCacheHandler::setClientState(bool vertex, bool normal, bool color, bool texCoord0)
{
if (ClientStateVertex != vertex)
{
if (vertex)
glEnableClientState(GL_VERTEX_ARRAY);
else
glDisableClientState(GL_VERTEX_ARRAY);
ClientStateVertex = vertex;
}
if (ClientStateNormal != normal)
{
if (normal)
glEnableClientState(GL_NORMAL_ARRAY);
else
glDisableClientState(GL_NORMAL_ARRAY);
ClientStateNormal = normal;
}
if (ClientStateColor != color)
{
if (color)
glEnableClientState(GL_COLOR_ARRAY);
else
glDisableClientState(GL_COLOR_ARRAY);
ClientStateColor = color;
}
if (ClientStateTexCoord0 != texCoord0)
{
setClientActiveTexture(GL_TEXTURE0_ARB);
if (texCoord0)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
else
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
ClientStateTexCoord0 = texCoord0;
}
}
void COpenGLCacheHandler::setMatrixMode(GLenum mode)
{
if (MatrixMode != mode)
{
glMatrixMode(mode);
MatrixMode = mode;
}
}
void COpenGLCacheHandler::setClientActiveTexture(GLenum texture)
{
if (ClientActiveTexture != texture)
{
Driver->irrGlClientActiveTexture(texture);
ClientActiveTexture = texture;
}
}
} // end namespace
} // end namespace
#endif // _IRR_COMPILE_WITH_OPENGL_
|