• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "gles2context.h"
2 
GLES2Context()3 GLES2Context::GLES2Context()
4 {
5    memset(this, 0, sizeof *this);
6 
7    assert((void *)&rasterizer == &rasterizer.interface);
8    InitializeGGLState(&rasterizer.interface);
9    iface = &rasterizer.interface;
10    printf("gl->rasterizer.PickScanLine(%p) = %p \n", &rasterizer.PickScanLine, rasterizer.PickScanLine);
11    assert(rasterizer.PickRaster);
12    assert(rasterizer.PickScanLine);
13 
14    InitializeTextures();
15    InitializeVertices();
16 }
17 
~GLES2Context()18 GLES2Context::~GLES2Context()
19 {
20    UninitializeTextures();
21    UninitializeVertices();
22    UninitializeGGLState(&rasterizer.interface);
23 }
24 
glBlendColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)25 void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
26 {
27    GLES2_GET_CONST_CONTEXT(ctx);
28    ctx->iface->BlendColor(ctx->iface, red, green, blue, alpha);
29 }
30 
glBlendEquation(GLenum mode)31 void glBlendEquation( GLenum mode )
32 {
33    GLES2_GET_CONST_CONTEXT(ctx);
34    ctx->iface->BlendEquationSeparate(ctx->iface, mode, mode);
35 }
36 
glBlendEquationSeparate(GLenum modeRGB,GLenum modeAlpha)37 void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
38 {
39    GLES2_GET_CONST_CONTEXT(ctx);
40    ctx->iface->BlendEquationSeparate(ctx->iface, modeRGB, modeAlpha);
41 }
42 
glBlendFunc(GLenum sfactor,GLenum dfactor)43 void glBlendFunc(GLenum sfactor, GLenum dfactor)
44 {
45    GLES2_GET_CONST_CONTEXT(ctx);
46    ctx->iface->BlendFuncSeparate(ctx->iface, sfactor, dfactor, sfactor, dfactor);
47 }
48 
glBlendFuncSeparate(GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)49 void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
50 {
51    GLES2_GET_CONST_CONTEXT(ctx);
52    ctx->iface->BlendFuncSeparate(ctx->iface, srcRGB, dstRGB, srcAlpha, dstAlpha);
53 }
54 
glClear(GLbitfield mask)55 void glClear(GLbitfield mask)
56 {
57    GLES2_GET_CONST_CONTEXT(ctx);
58    ctx->iface->Clear(ctx->iface, mask);
59 }
60 
glClearColor(GLclampf red,GLclampf green,GLclampf blue,GLclampf alpha)61 void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
62 {
63    GLES2_GET_CONST_CONTEXT(ctx);
64    ctx->iface->ClearColor(ctx->iface, red, green, blue, alpha);
65 }
66 
glClearDepthf(GLclampf depth)67 void glClearDepthf(GLclampf depth)
68 {
69    GLES2_GET_CONST_CONTEXT(ctx);
70    ctx->iface->ClearDepthf(ctx->iface, depth);
71 }
72 
glClearStencil(GLint s)73 void glClearStencil(GLint s)
74 {
75    GLES2_GET_CONST_CONTEXT(ctx);
76    ctx->iface->ClearStencil(ctx->iface, s);
77 }
78 
glCullFace(GLenum mode)79 void glCullFace(GLenum mode)
80 {
81    GLES2_GET_CONST_CONTEXT(ctx);
82    ctx->iface->CullFace(ctx->iface, mode);
83 }
84 
glDisable(GLenum cap)85 void glDisable(GLenum cap)
86 {
87    GLES2_GET_CONST_CONTEXT(ctx);
88    ctx->iface->EnableDisable(ctx->iface, cap, false);
89 }
90 
glEnable(GLenum cap)91 void glEnable(GLenum cap)
92 {
93    GLES2_GET_CONST_CONTEXT(ctx);
94    ctx->iface->EnableDisable(ctx->iface, cap, true);
95 }
96 
glFinish(void)97 void glFinish(void)
98 {
99    // do nothing
100 }
101 
glFrontFace(GLenum mode)102 void glFrontFace(GLenum mode)
103 {
104    GLES2_GET_CONST_CONTEXT(ctx);
105    ctx->iface->FrontFace(ctx->iface, mode);
106 }
107 
glFlush(void)108 void glFlush(void)
109 {
110    // do nothing
111 }
112 
glHint(GLenum target,GLenum mode)113 void glHint(GLenum target, GLenum mode)
114 {
115    // do nothing
116 }
117 
glScissor(GLint x,GLint y,GLsizei width,GLsizei height)118 void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
119 {
120 //   LOGD("agl2: glScissor not implemented x=%d y=%d width=%d height=%d", x, y, width, height);
121    //CALL_GL_API(glScissor, x, y, width, height);
122 }
123 
glViewport(GLint x,GLint y,GLsizei width,GLsizei height)124 void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
125 {
126    GLES2_GET_CONST_CONTEXT(ctx);
127 //   LOGD("agl2: glViewport x=%d y=%d width=%d height=%d", x, y, width, height);
128    ctx->iface->Viewport(ctx->iface, x, y, width, height);
129 }
130