• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // Context_gles_1_0.cpp: Implements the GLES1-specific parts of Context.
8 
9 #include "libANGLE/Context.h"
10 
11 #include "common/mathutil.h"
12 #include "common/utilities.h"
13 
14 #include "libANGLE/GLES1Renderer.h"
15 #include "libANGLE/queryconversions.h"
16 #include "libANGLE/queryutils.h"
17 
18 namespace gl
19 {
20 
clientActiveTexture(GLenum texture)21 void Context::clientActiveTexture(GLenum texture)
22 {
23     getMutableGLES1State()->setClientTextureUnit(texture - GL_TEXTURE0);
24     mStateCache.onGLES1ClientStateChange(this);
25 }
26 
colorPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)27 void Context::colorPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
28 {
29     // Note that we normalize data for UnsignedByte types. This is to match the behavior
30     // of current native GLES drivers.
31     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Color), size, type,
32                         type == VertexAttribType::UnsignedByte, stride, ptr);
33 }
34 
disableClientState(ClientVertexArrayType clientState)35 void Context::disableClientState(ClientVertexArrayType clientState)
36 {
37     getMutableGLES1State()->setClientStateEnabled(clientState, false);
38     disableVertexAttribArray(vertexArrayIndex(clientState));
39     mStateCache.onGLES1ClientStateChange(this);
40 }
41 
enableClientState(ClientVertexArrayType clientState)42 void Context::enableClientState(ClientVertexArrayType clientState)
43 {
44     getMutableGLES1State()->setClientStateEnabled(clientState, true);
45     enableVertexAttribArray(vertexArrayIndex(clientState));
46     mStateCache.onGLES1ClientStateChange(this);
47 }
48 
getFixedv(GLenum pname,GLfixed * params)49 void Context::getFixedv(GLenum pname, GLfixed *params)
50 {
51     GLenum nativeType;
52     unsigned int numParams = 0;
53 
54     getQueryParameterInfo(pname, &nativeType, &numParams);
55 
56     std::vector<GLfloat> paramsf(numParams, 0);
57     CastStateValues(this, nativeType, pname, numParams, paramsf.data());
58 
59     for (unsigned int i = 0; i < numParams; i++)
60     {
61         params[i] = ConvertFloatToFixed(paramsf[i]);
62     }
63 }
64 
getTexParameterxv(TextureType target,GLenum pname,GLfixed * params)65 void Context::getTexParameterxv(TextureType target, GLenum pname, GLfixed *params)
66 {
67     const Texture *const texture = getTextureByType(target);
68     QueryTexParameterxv(this, texture, pname, params);
69 }
70 
normalPointer(VertexAttribType type,GLsizei stride,const void * ptr)71 void Context::normalPointer(VertexAttribType type, GLsizei stride, const void *ptr)
72 {
73     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Normal), 3, type, GL_FALSE, stride,
74                         ptr);
75 }
76 
texCoordPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)77 void Context::texCoordPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
78 {
79     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::TextureCoord), size, type, GL_FALSE,
80                         stride, ptr);
81 }
82 
texParameterx(TextureType target,GLenum pname,GLfixed param)83 void Context::texParameterx(TextureType target, GLenum pname, GLfixed param)
84 {
85     Texture *const texture = getTextureByType(target);
86     SetTexParameterx(this, texture, pname, param);
87 }
88 
texParameterxv(TextureType target,GLenum pname,const GLfixed * params)89 void Context::texParameterxv(TextureType target, GLenum pname, const GLfixed *params)
90 {
91     Texture *const texture = getTextureByType(target);
92     SetTexParameterxv(this, texture, pname, params);
93 }
94 
vertexPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)95 void Context::vertexPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
96 {
97     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Vertex), size, type, GL_FALSE,
98                         stride, ptr);
99 }
100 
101 // GL_OES_draw_texture
drawTexf(float x,float y,float z,float width,float height)102 void Context::drawTexf(float x, float y, float z, float width, float height)
103 {
104     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), x, y, z, width, height);
105 }
106 
drawTexfv(const GLfloat * coords)107 void Context::drawTexfv(const GLfloat *coords)
108 {
109     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), coords[0], coords[1],
110                                 coords[2], coords[3], coords[4]);
111 }
112 
drawTexi(GLint x,GLint y,GLint z,GLint width,GLint height)113 void Context::drawTexi(GLint x, GLint y, GLint z, GLint width, GLint height)
114 {
115     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), static_cast<GLfloat>(x),
116                                 static_cast<GLfloat>(y), static_cast<GLfloat>(z),
117                                 static_cast<GLfloat>(width), static_cast<GLfloat>(height));
118 }
119 
drawTexiv(const GLint * coords)120 void Context::drawTexiv(const GLint *coords)
121 {
122     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(),
123                                 static_cast<GLfloat>(coords[0]), static_cast<GLfloat>(coords[1]),
124                                 static_cast<GLfloat>(coords[2]), static_cast<GLfloat>(coords[3]),
125                                 static_cast<GLfloat>(coords[4]));
126 }
127 
drawTexs(GLshort x,GLshort y,GLshort z,GLshort width,GLshort height)128 void Context::drawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
129 {
130     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), static_cast<GLfloat>(x),
131                                 static_cast<GLfloat>(y), static_cast<GLfloat>(z),
132                                 static_cast<GLfloat>(width), static_cast<GLfloat>(height));
133 }
134 
drawTexsv(const GLshort * coords)135 void Context::drawTexsv(const GLshort *coords)
136 {
137     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(),
138                                 static_cast<GLfloat>(coords[0]), static_cast<GLfloat>(coords[1]),
139                                 static_cast<GLfloat>(coords[2]), static_cast<GLfloat>(coords[3]),
140                                 static_cast<GLfloat>(coords[4]));
141 }
142 
drawTexx(GLfixed x,GLfixed y,GLfixed z,GLfixed width,GLfixed height)143 void Context::drawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
144 {
145     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(), ConvertFixedToFloat(x),
146                                 ConvertFixedToFloat(y), ConvertFixedToFloat(z),
147                                 ConvertFixedToFloat(width), ConvertFixedToFloat(height));
148 }
149 
drawTexxv(const GLfixed * coords)150 void Context::drawTexxv(const GLfixed *coords)
151 {
152     mGLES1Renderer->drawTexture(this, &mState, getMutableGLES1State(),
153                                 ConvertFixedToFloat(coords[0]), ConvertFixedToFloat(coords[1]),
154                                 ConvertFixedToFloat(coords[2]), ConvertFixedToFloat(coords[3]),
155                                 ConvertFixedToFloat(coords[4]));
156 }
157 
158 // GL_OES_matrix_palette
currentPaletteMatrix(GLuint matrixpaletteindex)159 void Context::currentPaletteMatrix(GLuint matrixpaletteindex)
160 {
161     UNIMPLEMENTED();
162 }
163 
loadPaletteFromModelViewMatrix()164 void Context::loadPaletteFromModelViewMatrix()
165 {
166     UNIMPLEMENTED();
167 }
168 
matrixIndexPointer(GLint size,GLenum type,GLsizei stride,const void * pointer)169 void Context::matrixIndexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
170 {
171     UNIMPLEMENTED();
172 }
173 
weightPointer(GLint size,GLenum type,GLsizei stride,const void * pointer)174 void Context::weightPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
175 {
176     UNIMPLEMENTED();
177 }
178 
179 // GL_OES_point_size_array
pointSizePointer(VertexAttribType type,GLsizei stride,const void * ptr)180 void Context::pointSizePointer(VertexAttribType type, GLsizei stride, const void *ptr)
181 {
182     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::PointSize), 1, type, GL_FALSE,
183                         stride, ptr);
184 }
185 
186 // GL_OES_query_matrix
queryMatrixx(GLfixed * mantissa,GLint * exponent)187 GLbitfield Context::queryMatrixx(GLfixed *mantissa, GLint *exponent)
188 {
189     UNIMPLEMENTED();
190     return 0;
191 }
192 
193 // GL_OES_texture_cube_map
getTexGenfv(GLenum coord,GLenum pname,GLfloat * params)194 void Context::getTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
195 {
196     UNIMPLEMENTED();
197 }
198 
getTexGeniv(GLenum coord,GLenum pname,GLint * params)199 void Context::getTexGeniv(GLenum coord, GLenum pname, GLint *params)
200 {
201     UNIMPLEMENTED();
202 }
203 
getTexGenxv(GLenum coord,GLenum pname,GLfixed * params)204 void Context::getTexGenxv(GLenum coord, GLenum pname, GLfixed *params)
205 {
206     UNIMPLEMENTED();
207 }
208 
texGenf(GLenum coord,GLenum pname,GLfloat param)209 void Context::texGenf(GLenum coord, GLenum pname, GLfloat param)
210 {
211     UNIMPLEMENTED();
212 }
213 
texGenfv(GLenum coord,GLenum pname,const GLfloat * params)214 void Context::texGenfv(GLenum coord, GLenum pname, const GLfloat *params)
215 {
216     UNIMPLEMENTED();
217 }
218 
texGeni(GLenum coord,GLenum pname,GLint param)219 void Context::texGeni(GLenum coord, GLenum pname, GLint param)
220 {
221     UNIMPLEMENTED();
222 }
223 
texGeniv(GLenum coord,GLenum pname,const GLint * params)224 void Context::texGeniv(GLenum coord, GLenum pname, const GLint *params)
225 {
226     UNIMPLEMENTED();
227 }
228 
texGenx(GLenum coord,GLenum pname,GLfixed param)229 void Context::texGenx(GLenum coord, GLenum pname, GLfixed param)
230 {
231     UNIMPLEMENTED();
232 }
233 
texGenxv(GLenum coord,GLenum pname,const GLint * params)234 void Context::texGenxv(GLenum coord, GLenum pname, const GLint *params)
235 {
236     UNIMPLEMENTED();
237 }
238 
vertexArrayIndex(ClientVertexArrayType type) const239 int Context::vertexArrayIndex(ClientVertexArrayType type) const
240 {
241     return GLES1Renderer::VertexArrayIndex(type, mState.gles1());
242 }
243 
244 // static
TexCoordArrayIndex(unsigned int unit)245 int Context::TexCoordArrayIndex(unsigned int unit)
246 {
247     return GLES1Renderer::TexCoordArrayIndex(unit);
248 }
249 }  // namespace gl
250