• 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
19 {
20 
FixedMatrixToMat4(const GLfixed * m)21 angle::Mat4 FixedMatrixToMat4(const GLfixed *m)
22 {
23     angle::Mat4 matrixAsFloat;
24     GLfloat *floatData = matrixAsFloat.data();
25 
26     for (int i = 0; i < 16; i++)
27     {
28         floatData[i] = gl::ConvertFixedToFloat(m[i]);
29     }
30 
31     return matrixAsFloat;
32 }
33 
34 }  // namespace
35 
36 namespace gl
37 {
38 
alphaFunc(AlphaTestFunc func,GLfloat ref)39 void Context::alphaFunc(AlphaTestFunc func, GLfloat ref)
40 {
41     mState.gles1().setAlphaFunc(func, ref);
42 }
43 
alphaFuncx(AlphaTestFunc func,GLfixed ref)44 void Context::alphaFuncx(AlphaTestFunc func, GLfixed ref)
45 {
46     mState.gles1().setAlphaFunc(func, ConvertFixedToFloat(ref));
47 }
48 
clearColorx(GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)49 void Context::clearColorx(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
50 {
51     mState.setColorClearValue(ConvertFixedToFloat(red), ConvertFixedToFloat(green),
52                               ConvertFixedToFloat(blue), ConvertFixedToFloat(alpha));
53 }
54 
clearDepthx(GLfixed depth)55 void Context::clearDepthx(GLfixed depth)
56 {
57     mState.setDepthClearValue(clamp01(ConvertFixedToFloat(depth)));
58 }
59 
clientActiveTexture(GLenum texture)60 void Context::clientActiveTexture(GLenum texture)
61 {
62     mState.gles1().setClientTextureUnit(texture - GL_TEXTURE0);
63     mStateCache.onGLES1ClientStateChange(this);
64 }
65 
clipPlanef(GLenum p,const GLfloat * eqn)66 void Context::clipPlanef(GLenum p, const GLfloat *eqn)
67 {
68     mState.gles1().setClipPlane(p - GL_CLIP_PLANE0, eqn);
69 }
70 
clipPlanex(GLenum plane,const GLfixed * equation)71 void Context::clipPlanex(GLenum plane, const GLfixed *equation)
72 {
73     const GLfloat equationf[4] = {
74         ConvertFixedToFloat(equation[0]),
75         ConvertFixedToFloat(equation[1]),
76         ConvertFixedToFloat(equation[2]),
77         ConvertFixedToFloat(equation[3]),
78     };
79 
80     mState.gles1().setClipPlane(plane - GL_CLIP_PLANE0, equationf);
81 }
82 
color4f(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)83 void Context::color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
84 {
85     mState.gles1().setCurrentColor({red, green, blue, alpha});
86 }
87 
color4ub(GLubyte red,GLubyte green,GLubyte blue,GLubyte alpha)88 void Context::color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
89 {
90     mState.gles1().setCurrentColor(
91         {normalizedToFloat<uint8_t>(red), normalizedToFloat<uint8_t>(green),
92          normalizedToFloat<uint8_t>(blue), normalizedToFloat<uint8_t>(alpha)});
93 }
94 
color4x(GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)95 void Context::color4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
96 {
97     mState.gles1().setCurrentColor({ConvertFixedToFloat(red), ConvertFixedToFloat(green),
98                                     ConvertFixedToFloat(blue), ConvertFixedToFloat(alpha)});
99 }
100 
colorPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)101 void Context::colorPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
102 {
103     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Color), size, type, GL_FALSE,
104                         stride, ptr);
105 }
106 
depthRangex(GLfixed n,GLfixed f)107 void Context::depthRangex(GLfixed n, GLfixed f)
108 {
109     mState.setDepthRange(clamp01(ConvertFixedToFloat(n)), clamp01(ConvertFixedToFloat(f)));
110 }
111 
disableClientState(ClientVertexArrayType clientState)112 void Context::disableClientState(ClientVertexArrayType clientState)
113 {
114     mState.gles1().setClientStateEnabled(clientState, false);
115     disableVertexAttribArray(vertexArrayIndex(clientState));
116     mStateCache.onGLES1ClientStateChange(this);
117 }
118 
enableClientState(ClientVertexArrayType clientState)119 void Context::enableClientState(ClientVertexArrayType clientState)
120 {
121     mState.gles1().setClientStateEnabled(clientState, true);
122     enableVertexAttribArray(vertexArrayIndex(clientState));
123     mStateCache.onGLES1ClientStateChange(this);
124 }
125 
fogf(GLenum pname,GLfloat param)126 void Context::fogf(GLenum pname, GLfloat param)
127 {
128     SetFogParameters(&mState.gles1(), pname, &param);
129 }
130 
fogfv(GLenum pname,const GLfloat * params)131 void Context::fogfv(GLenum pname, const GLfloat *params)
132 {
133     SetFogParameters(&mState.gles1(), pname, params);
134 }
135 
fogx(GLenum pname,GLfixed param)136 void Context::fogx(GLenum pname, GLfixed param)
137 {
138     if (GetFogParameterCount(pname) == 1)
139     {
140         GLfloat paramf = pname == GL_FOG_MODE ? ConvertToGLenum(param) : ConvertFixedToFloat(param);
141         fogf(pname, paramf);
142     }
143     else
144     {
145         UNREACHABLE();
146     }
147 }
148 
fogxv(GLenum pname,const GLfixed * params)149 void Context::fogxv(GLenum pname, const GLfixed *params)
150 {
151     int paramCount = GetFogParameterCount(pname);
152 
153     if (paramCount > 0)
154     {
155         GLfloat paramsf[4];
156         for (int i = 0; i < paramCount; i++)
157         {
158             paramsf[i] =
159                 pname == GL_FOG_MODE ? ConvertToGLenum(params[i]) : ConvertFixedToFloat(params[i]);
160         }
161         fogfv(pname, paramsf);
162     }
163     else
164     {
165         UNREACHABLE();
166     }
167 }
168 
frustumf(GLfloat l,GLfloat r,GLfloat b,GLfloat t,GLfloat n,GLfloat f)169 void Context::frustumf(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
170 {
171     mState.gles1().multMatrix(angle::Mat4::Frustum(l, r, b, t, n, f));
172 }
173 
frustumx(GLfixed l,GLfixed r,GLfixed b,GLfixed t,GLfixed n,GLfixed f)174 void Context::frustumx(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
175 {
176     mState.gles1().multMatrix(angle::Mat4::Frustum(ConvertFixedToFloat(l), ConvertFixedToFloat(r),
177                                                    ConvertFixedToFloat(b), ConvertFixedToFloat(t),
178                                                    ConvertFixedToFloat(n), ConvertFixedToFloat(f)));
179 }
180 
getClipPlanef(GLenum plane,GLfloat * equation)181 void Context::getClipPlanef(GLenum plane, GLfloat *equation)
182 {
183     mState.gles1().getClipPlane(plane - GL_CLIP_PLANE0, equation);
184 }
185 
getClipPlanex(GLenum plane,GLfixed * equation)186 void Context::getClipPlanex(GLenum plane, GLfixed *equation)
187 {
188     GLfloat equationf[4] = {};
189 
190     mState.gles1().getClipPlane(plane - GL_CLIP_PLANE0, equationf);
191 
192     for (int i = 0; i < 4; i++)
193     {
194         equation[i] = ConvertFloatToFixed(equationf[i]);
195     }
196 }
197 
getFixedv(GLenum pname,GLfixed * params)198 void Context::getFixedv(GLenum pname, GLfixed *params)
199 {
200     GLenum nativeType;
201     unsigned int numParams = 0;
202 
203     getQueryParameterInfo(pname, &nativeType, &numParams);
204 
205     std::vector<GLfloat> paramsf(numParams, 0);
206     CastStateValues(this, nativeType, pname, numParams, paramsf.data());
207 
208     for (unsigned int i = 0; i < numParams; i++)
209     {
210         params[i] = ConvertFloatToFixed(paramsf[i]);
211     }
212 }
213 
getLightfv(GLenum light,LightParameter pname,GLfloat * params)214 void Context::getLightfv(GLenum light, LightParameter pname, GLfloat *params)
215 {
216     GetLightParameters(&mState.gles1(), light, pname, params);
217 }
218 
getLightxv(GLenum light,LightParameter pname,GLfixed * params)219 void Context::getLightxv(GLenum light, LightParameter pname, GLfixed *params)
220 {
221     GLfloat paramsf[4];
222     getLightfv(light, pname, paramsf);
223 
224     for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
225     {
226         params[i] = ConvertFloatToFixed(paramsf[i]);
227     }
228 }
229 
getMaterialfv(GLenum face,MaterialParameter pname,GLfloat * params)230 void Context::getMaterialfv(GLenum face, MaterialParameter pname, GLfloat *params)
231 {
232     GetMaterialParameters(&mState.gles1(), face, pname, params);
233 }
234 
getMaterialxv(GLenum face,MaterialParameter pname,GLfixed * params)235 void Context::getMaterialxv(GLenum face, MaterialParameter pname, GLfixed *params)
236 {
237     GLfloat paramsf[4];
238     getMaterialfv(face, pname, paramsf);
239 
240     for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
241     {
242         params[i] = ConvertFloatToFixed(paramsf[i]);
243     }
244 }
245 
getTexEnvfv(TextureEnvTarget target,TextureEnvParameter pname,GLfloat * params)246 void Context::getTexEnvfv(TextureEnvTarget target, TextureEnvParameter pname, GLfloat *params)
247 {
248     GetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, params);
249 }
250 
getTexEnviv(TextureEnvTarget target,TextureEnvParameter pname,GLint * params)251 void Context::getTexEnviv(TextureEnvTarget target, TextureEnvParameter pname, GLint *params)
252 {
253     GLfloat paramsf[4];
254     GetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
255     ConvertTextureEnvToInt(pname, paramsf, params);
256 }
257 
getTexEnvxv(TextureEnvTarget target,TextureEnvParameter pname,GLfixed * params)258 void Context::getTexEnvxv(TextureEnvTarget target, TextureEnvParameter pname, GLfixed *params)
259 {
260     GLfloat paramsf[4];
261     GetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
262     ConvertTextureEnvToFixed(pname, paramsf, params);
263 }
264 
getTexParameterxv(TextureType target,GLenum pname,GLfixed * params)265 void Context::getTexParameterxv(TextureType target, GLenum pname, GLfixed *params)
266 {
267     const Texture *const texture = getTextureByType(target);
268     QueryTexParameterxv(this, texture, pname, params);
269 }
270 
lightModelf(GLenum pname,GLfloat param)271 void Context::lightModelf(GLenum pname, GLfloat param)
272 {
273     SetLightModelParameters(&mState.gles1(), pname, &param);
274 }
275 
lightModelfv(GLenum pname,const GLfloat * params)276 void Context::lightModelfv(GLenum pname, const GLfloat *params)
277 {
278     SetLightModelParameters(&mState.gles1(), pname, params);
279 }
280 
lightModelx(GLenum pname,GLfixed param)281 void Context::lightModelx(GLenum pname, GLfixed param)
282 {
283     lightModelf(pname, ConvertFixedToFloat(param));
284 }
285 
lightModelxv(GLenum pname,const GLfixed * param)286 void Context::lightModelxv(GLenum pname, const GLfixed *param)
287 {
288     GLfloat paramsf[4];
289 
290     for (unsigned int i = 0; i < GetLightModelParameterCount(pname); i++)
291     {
292         paramsf[i] = ConvertFixedToFloat(param[i]);
293     }
294 
295     lightModelfv(pname, paramsf);
296 }
297 
lightf(GLenum light,LightParameter pname,GLfloat param)298 void Context::lightf(GLenum light, LightParameter pname, GLfloat param)
299 {
300     SetLightParameters(&mState.gles1(), light, pname, &param);
301 }
302 
lightfv(GLenum light,LightParameter pname,const GLfloat * params)303 void Context::lightfv(GLenum light, LightParameter pname, const GLfloat *params)
304 {
305     SetLightParameters(&mState.gles1(), light, pname, params);
306 }
307 
lightx(GLenum light,LightParameter pname,GLfixed param)308 void Context::lightx(GLenum light, LightParameter pname, GLfixed param)
309 {
310     lightf(light, pname, ConvertFixedToFloat(param));
311 }
312 
lightxv(GLenum light,LightParameter pname,const GLfixed * params)313 void Context::lightxv(GLenum light, LightParameter pname, const GLfixed *params)
314 {
315     GLfloat paramsf[4];
316 
317     for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
318     {
319         paramsf[i] = ConvertFixedToFloat(params[i]);
320     }
321 
322     lightfv(light, pname, paramsf);
323 }
324 
lineWidthx(GLfixed width)325 void Context::lineWidthx(GLfixed width)
326 {
327     mState.setLineWidth(ConvertFixedToFloat(width));
328 }
329 
loadIdentity()330 void Context::loadIdentity()
331 {
332     mState.gles1().loadMatrix(angle::Mat4());
333 }
334 
loadMatrixf(const GLfloat * m)335 void Context::loadMatrixf(const GLfloat *m)
336 {
337     mState.gles1().loadMatrix(angle::Mat4(m));
338 }
339 
loadMatrixx(const GLfixed * m)340 void Context::loadMatrixx(const GLfixed *m)
341 {
342     mState.gles1().loadMatrix(FixedMatrixToMat4(m));
343 }
344 
logicOp(LogicalOperation opcodePacked)345 void Context::logicOp(LogicalOperation opcodePacked)
346 {
347     mState.gles1().setLogicOp(opcodePacked);
348 }
349 
materialf(GLenum face,MaterialParameter pname,GLfloat param)350 void Context::materialf(GLenum face, MaterialParameter pname, GLfloat param)
351 {
352     SetMaterialParameters(&mState.gles1(), face, pname, &param);
353 }
354 
materialfv(GLenum face,MaterialParameter pname,const GLfloat * params)355 void Context::materialfv(GLenum face, MaterialParameter pname, const GLfloat *params)
356 {
357     SetMaterialParameters(&mState.gles1(), face, pname, params);
358 }
359 
materialx(GLenum face,MaterialParameter pname,GLfixed param)360 void Context::materialx(GLenum face, MaterialParameter pname, GLfixed param)
361 {
362     materialf(face, pname, ConvertFixedToFloat(param));
363 }
364 
materialxv(GLenum face,MaterialParameter pname,const GLfixed * param)365 void Context::materialxv(GLenum face, MaterialParameter pname, const GLfixed *param)
366 {
367     GLfloat paramsf[4];
368 
369     for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
370     {
371         paramsf[i] = ConvertFixedToFloat(param[i]);
372     }
373 
374     materialfv(face, pname, paramsf);
375 }
376 
matrixMode(MatrixType mode)377 void Context::matrixMode(MatrixType mode)
378 {
379     mState.gles1().setMatrixMode(mode);
380 }
381 
multMatrixf(const GLfloat * m)382 void Context::multMatrixf(const GLfloat *m)
383 {
384     mState.gles1().multMatrix(angle::Mat4(m));
385 }
386 
multMatrixx(const GLfixed * m)387 void Context::multMatrixx(const GLfixed *m)
388 {
389     mState.gles1().multMatrix(FixedMatrixToMat4(m));
390 }
391 
multiTexCoord4f(GLenum target,GLfloat s,GLfloat t,GLfloat r,GLfloat q)392 void Context::multiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
393 {
394     unsigned int unit = target - GL_TEXTURE0;
395     ASSERT(target >= GL_TEXTURE0 && unit < getCaps().maxMultitextureUnits);
396     mState.gles1().setCurrentTextureCoords(unit, {s, t, r, q});
397 }
398 
multiTexCoord4x(GLenum target,GLfixed s,GLfixed t,GLfixed r,GLfixed q)399 void Context::multiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
400 {
401     unsigned int unit = target - GL_TEXTURE0;
402     ASSERT(target >= GL_TEXTURE0 && unit < getCaps().maxMultitextureUnits);
403     mState.gles1().setCurrentTextureCoords(unit, {ConvertFixedToFloat(s), ConvertFixedToFloat(t),
404                                                   ConvertFixedToFloat(r), ConvertFixedToFloat(q)});
405 }
406 
normal3f(GLfloat nx,GLfloat ny,GLfloat nz)407 void Context::normal3f(GLfloat nx, GLfloat ny, GLfloat nz)
408 {
409     mState.gles1().setCurrentNormal({nx, ny, nz});
410 }
411 
normal3x(GLfixed nx,GLfixed ny,GLfixed nz)412 void Context::normal3x(GLfixed nx, GLfixed ny, GLfixed nz)
413 {
414     mState.gles1().setCurrentNormal(
415         {ConvertFixedToFloat(nx), ConvertFixedToFloat(ny), ConvertFixedToFloat(nz)});
416 }
417 
normalPointer(VertexAttribType type,GLsizei stride,const void * ptr)418 void Context::normalPointer(VertexAttribType type, GLsizei stride, const void *ptr)
419 {
420     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Normal), 3, type, GL_FALSE, stride,
421                         ptr);
422 }
423 
orthof(GLfloat left,GLfloat right,GLfloat bottom,GLfloat top,GLfloat zNear,GLfloat zFar)424 void Context::orthof(GLfloat left,
425                      GLfloat right,
426                      GLfloat bottom,
427                      GLfloat top,
428                      GLfloat zNear,
429                      GLfloat zFar)
430 {
431     mState.gles1().multMatrix(angle::Mat4::Ortho(left, right, bottom, top, zNear, zFar));
432 }
433 
orthox(GLfixed l,GLfixed r,GLfixed b,GLfixed t,GLfixed n,GLfixed f)434 void Context::orthox(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
435 {
436     mState.gles1().multMatrix(angle::Mat4::Ortho(ConvertFixedToFloat(l), ConvertFixedToFloat(r),
437                                                  ConvertFixedToFloat(b), ConvertFixedToFloat(t),
438                                                  ConvertFixedToFloat(n), ConvertFixedToFloat(f)));
439 }
440 
pointParameterf(PointParameter pname,GLfloat param)441 void Context::pointParameterf(PointParameter pname, GLfloat param)
442 {
443     SetPointParameter(&mState.gles1(), pname, &param);
444 }
445 
pointParameterfv(PointParameter pname,const GLfloat * params)446 void Context::pointParameterfv(PointParameter pname, const GLfloat *params)
447 {
448     SetPointParameter(&mState.gles1(), pname, params);
449 }
450 
pointParameterx(PointParameter pname,GLfixed param)451 void Context::pointParameterx(PointParameter pname, GLfixed param)
452 {
453     GLfloat paramf = ConvertFixedToFloat(param);
454     SetPointParameter(&mState.gles1(), pname, &paramf);
455 }
456 
pointParameterxv(PointParameter pname,const GLfixed * params)457 void Context::pointParameterxv(PointParameter pname, const GLfixed *params)
458 {
459     GLfloat paramsf[4] = {};
460     for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
461     {
462         paramsf[i] = ConvertFixedToFloat(params[i]);
463     }
464     SetPointParameter(&mState.gles1(), pname, paramsf);
465 }
466 
pointSize(GLfloat size)467 void Context::pointSize(GLfloat size)
468 {
469     SetPointSize(&mState.gles1(), size);
470 }
471 
pointSizex(GLfixed size)472 void Context::pointSizex(GLfixed size)
473 {
474     SetPointSize(&mState.gles1(), ConvertFixedToFloat(size));
475 }
476 
polygonOffsetx(GLfixed factor,GLfixed units)477 void Context::polygonOffsetx(GLfixed factor, GLfixed units)
478 {
479     mState.setPolygonOffsetParams(ConvertFixedToFloat(factor), ConvertFixedToFloat(units));
480 }
481 
popMatrix()482 void Context::popMatrix()
483 {
484     mState.gles1().popMatrix();
485 }
486 
pushMatrix()487 void Context::pushMatrix()
488 {
489     mState.gles1().pushMatrix();
490 }
491 
rotatef(float angle,float x,float y,float z)492 void Context::rotatef(float angle, float x, float y, float z)
493 {
494     mState.gles1().multMatrix(angle::Mat4::Rotate(angle, angle::Vector3(x, y, z)));
495 }
496 
rotatex(GLfixed angle,GLfixed x,GLfixed y,GLfixed z)497 void Context::rotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
498 {
499     mState.gles1().multMatrix(angle::Mat4::Rotate(
500         ConvertFixedToFloat(angle),
501         angle::Vector3(ConvertFixedToFloat(x), ConvertFixedToFloat(y), ConvertFixedToFloat(z))));
502 }
503 
sampleCoveragex(GLclampx value,GLboolean invert)504 void Context::sampleCoveragex(GLclampx value, GLboolean invert)
505 {
506     GLclampf valuef = ConvertFixedToFloat(value);
507     mState.setSampleCoverageParams(clamp01(valuef), ConvertToBool(invert));
508 }
509 
scalef(float x,float y,float z)510 void Context::scalef(float x, float y, float z)
511 {
512     mState.gles1().multMatrix(angle::Mat4::Scale(angle::Vector3(x, y, z)));
513 }
514 
scalex(GLfixed x,GLfixed y,GLfixed z)515 void Context::scalex(GLfixed x, GLfixed y, GLfixed z)
516 {
517     mState.gles1().multMatrix(angle::Mat4::Scale(
518         angle::Vector3(ConvertFixedToFloat(x), ConvertFixedToFloat(y), ConvertFixedToFloat(z))));
519 }
520 
shadeModel(ShadingModel model)521 void Context::shadeModel(ShadingModel model)
522 {
523     mState.gles1().setShadeModel(model);
524 }
525 
texCoordPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)526 void Context::texCoordPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
527 {
528     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::TextureCoord), size, type, GL_FALSE,
529                         stride, ptr);
530 }
531 
texEnvf(TextureEnvTarget target,TextureEnvParameter pname,GLfloat param)532 void Context::texEnvf(TextureEnvTarget target, TextureEnvParameter pname, GLfloat param)
533 {
534     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, &param);
535 }
536 
texEnvfv(TextureEnvTarget target,TextureEnvParameter pname,const GLfloat * params)537 void Context::texEnvfv(TextureEnvTarget target, TextureEnvParameter pname, const GLfloat *params)
538 {
539     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, params);
540 }
541 
texEnvi(TextureEnvTarget target,TextureEnvParameter pname,GLint param)542 void Context::texEnvi(TextureEnvTarget target, TextureEnvParameter pname, GLint param)
543 {
544     GLfloat paramsf[4] = {};
545     ConvertTextureEnvFromInt(pname, &param, paramsf);
546     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
547 }
548 
texEnviv(TextureEnvTarget target,TextureEnvParameter pname,const GLint * params)549 void Context::texEnviv(TextureEnvTarget target, TextureEnvParameter pname, const GLint *params)
550 {
551     GLfloat paramsf[4] = {};
552     ConvertTextureEnvFromInt(pname, params, paramsf);
553     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
554 }
555 
texEnvx(TextureEnvTarget target,TextureEnvParameter pname,GLfixed param)556 void Context::texEnvx(TextureEnvTarget target, TextureEnvParameter pname, GLfixed param)
557 {
558     GLfloat paramsf[4] = {};
559     ConvertTextureEnvFromFixed(pname, &param, paramsf);
560     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
561 }
562 
texEnvxv(TextureEnvTarget target,TextureEnvParameter pname,const GLfixed * params)563 void Context::texEnvxv(TextureEnvTarget target, TextureEnvParameter pname, const GLfixed *params)
564 {
565     GLfloat paramsf[4] = {};
566     ConvertTextureEnvFromFixed(pname, params, paramsf);
567     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
568 }
569 
texParameterx(TextureType target,GLenum pname,GLfixed param)570 void Context::texParameterx(TextureType target, GLenum pname, GLfixed param)
571 {
572     Texture *const texture = getTextureByType(target);
573     SetTexParameterx(this, texture, pname, param);
574 }
575 
texParameterxv(TextureType target,GLenum pname,const GLfixed * params)576 void Context::texParameterxv(TextureType target, GLenum pname, const GLfixed *params)
577 {
578     Texture *const texture = getTextureByType(target);
579     SetTexParameterxv(this, texture, pname, params);
580 }
581 
translatef(float x,float y,float z)582 void Context::translatef(float x, float y, float z)
583 {
584     mState.gles1().multMatrix(angle::Mat4::Translate(angle::Vector3(x, y, z)));
585 }
586 
translatex(GLfixed x,GLfixed y,GLfixed z)587 void Context::translatex(GLfixed x, GLfixed y, GLfixed z)
588 {
589     mState.gles1().multMatrix(angle::Mat4::Translate(
590         angle::Vector3(ConvertFixedToFloat(x), ConvertFixedToFloat(y), ConvertFixedToFloat(z))));
591 }
592 
vertexPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)593 void Context::vertexPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
594 {
595     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Vertex), size, type, GL_FALSE,
596                         stride, ptr);
597 }
598 
599 // GL_OES_draw_texture
drawTexf(float x,float y,float z,float width,float height)600 void Context::drawTexf(float x, float y, float z, float width, float height)
601 {
602     mGLES1Renderer->drawTexture(this, &mState, x, y, z, width, height);
603 }
604 
drawTexfv(const GLfloat * coords)605 void Context::drawTexfv(const GLfloat *coords)
606 {
607     mGLES1Renderer->drawTexture(this, &mState, coords[0], coords[1], coords[2], coords[3],
608                                 coords[4]);
609 }
610 
drawTexi(GLint x,GLint y,GLint z,GLint width,GLint height)611 void Context::drawTexi(GLint x, GLint y, GLint z, GLint width, GLint height)
612 {
613     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(x), static_cast<GLfloat>(y),
614                                 static_cast<GLfloat>(z), static_cast<GLfloat>(width),
615                                 static_cast<GLfloat>(height));
616 }
617 
drawTexiv(const GLint * coords)618 void Context::drawTexiv(const GLint *coords)
619 {
620     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(coords[0]),
621                                 static_cast<GLfloat>(coords[1]), static_cast<GLfloat>(coords[2]),
622                                 static_cast<GLfloat>(coords[3]), static_cast<GLfloat>(coords[4]));
623 }
624 
drawTexs(GLshort x,GLshort y,GLshort z,GLshort width,GLshort height)625 void Context::drawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
626 {
627     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(x), static_cast<GLfloat>(y),
628                                 static_cast<GLfloat>(z), static_cast<GLfloat>(width),
629                                 static_cast<GLfloat>(height));
630 }
631 
drawTexsv(const GLshort * coords)632 void Context::drawTexsv(const GLshort *coords)
633 {
634     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(coords[0]),
635                                 static_cast<GLfloat>(coords[1]), static_cast<GLfloat>(coords[2]),
636                                 static_cast<GLfloat>(coords[3]), static_cast<GLfloat>(coords[4]));
637 }
638 
drawTexx(GLfixed x,GLfixed y,GLfixed z,GLfixed width,GLfixed height)639 void Context::drawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
640 {
641     mGLES1Renderer->drawTexture(this, &mState, ConvertFixedToFloat(x), ConvertFixedToFloat(y),
642                                 ConvertFixedToFloat(z), ConvertFixedToFloat(width),
643                                 ConvertFixedToFloat(height));
644 }
645 
drawTexxv(const GLfixed * coords)646 void Context::drawTexxv(const GLfixed *coords)
647 {
648     mGLES1Renderer->drawTexture(this, &mState, ConvertFixedToFloat(coords[0]),
649                                 ConvertFixedToFloat(coords[1]), ConvertFixedToFloat(coords[2]),
650                                 ConvertFixedToFloat(coords[3]), ConvertFixedToFloat(coords[4]));
651 }
652 
653 // GL_OES_matrix_palette
currentPaletteMatrix(GLuint matrixpaletteindex)654 void Context::currentPaletteMatrix(GLuint matrixpaletteindex)
655 {
656     UNIMPLEMENTED();
657 }
658 
loadPaletteFromModelViewMatrix()659 void Context::loadPaletteFromModelViewMatrix()
660 {
661     UNIMPLEMENTED();
662 }
663 
matrixIndexPointer(GLint size,GLenum type,GLsizei stride,const void * pointer)664 void Context::matrixIndexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
665 {
666     UNIMPLEMENTED();
667 }
668 
weightPointer(GLint size,GLenum type,GLsizei stride,const void * pointer)669 void Context::weightPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
670 {
671     UNIMPLEMENTED();
672 }
673 
674 // GL_OES_point_size_array
pointSizePointer(VertexAttribType type,GLsizei stride,const void * ptr)675 void Context::pointSizePointer(VertexAttribType type, GLsizei stride, const void *ptr)
676 {
677     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::PointSize), 1, type, GL_FALSE,
678                         stride, ptr);
679 }
680 
681 // GL_OES_query_matrix
queryMatrixx(GLfixed * mantissa,GLint * exponent)682 GLbitfield Context::queryMatrixx(GLfixed *mantissa, GLint *exponent)
683 {
684     UNIMPLEMENTED();
685     return 0;
686 }
687 
688 // GL_OES_texture_cube_map
getTexGenfv(GLenum coord,GLenum pname,GLfloat * params)689 void Context::getTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
690 {
691     UNIMPLEMENTED();
692 }
693 
getTexGeniv(GLenum coord,GLenum pname,GLint * params)694 void Context::getTexGeniv(GLenum coord, GLenum pname, GLint *params)
695 {
696     UNIMPLEMENTED();
697 }
698 
getTexGenxv(GLenum coord,GLenum pname,GLfixed * params)699 void Context::getTexGenxv(GLenum coord, GLenum pname, GLfixed *params)
700 {
701     UNIMPLEMENTED();
702 }
703 
texGenf(GLenum coord,GLenum pname,GLfloat param)704 void Context::texGenf(GLenum coord, GLenum pname, GLfloat param)
705 {
706     UNIMPLEMENTED();
707 }
708 
texGenfv(GLenum coord,GLenum pname,const GLfloat * params)709 void Context::texGenfv(GLenum coord, GLenum pname, const GLfloat *params)
710 {
711     UNIMPLEMENTED();
712 }
713 
texGeni(GLenum coord,GLenum pname,GLint param)714 void Context::texGeni(GLenum coord, GLenum pname, GLint param)
715 {
716     UNIMPLEMENTED();
717 }
718 
texGeniv(GLenum coord,GLenum pname,const GLint * params)719 void Context::texGeniv(GLenum coord, GLenum pname, const GLint *params)
720 {
721     UNIMPLEMENTED();
722 }
723 
texGenx(GLenum coord,GLenum pname,GLfixed param)724 void Context::texGenx(GLenum coord, GLenum pname, GLfixed param)
725 {
726     UNIMPLEMENTED();
727 }
728 
texGenxv(GLenum coord,GLenum pname,const GLint * params)729 void Context::texGenxv(GLenum coord, GLenum pname, const GLint *params)
730 {
731     UNIMPLEMENTED();
732 }
733 
vertexArrayIndex(ClientVertexArrayType type) const734 int Context::vertexArrayIndex(ClientVertexArrayType type) const
735 {
736     return GLES1Renderer::VertexArrayIndex(type, mState.gles1());
737 }
738 
739 // static
TexCoordArrayIndex(unsigned int unit)740 int Context::TexCoordArrayIndex(unsigned int unit)
741 {
742     return GLES1Renderer::TexCoordArrayIndex(unit);
743 }
744 }  // namespace gl
745