| David Li | aa1f54d | 2011-03-01 16:54:04 -0800 | [diff] [blame] | 1 | #include "gles2context.h" | 
|  | 2 |  | 
|  | 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 |  | 
|  | 18 | GLES2Context::~GLES2Context() | 
|  | 19 | { | 
|  | 20 | UninitializeTextures(); | 
|  | 21 | UninitializeVertices(); | 
|  | 22 | UninitializeGGLState(&rasterizer.interface); | 
|  | 23 | } | 
|  | 24 |  | 
|  | 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 |  | 
|  | 31 | void glBlendEquation( GLenum mode ) | 
|  | 32 | { | 
|  | 33 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 34 | ctx->iface->BlendEquationSeparate(ctx->iface, mode, mode); | 
|  | 35 | } | 
|  | 36 |  | 
|  | 37 | void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) | 
|  | 38 | { | 
|  | 39 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 40 | ctx->iface->BlendEquationSeparate(ctx->iface, modeRGB, modeAlpha); | 
|  | 41 | } | 
|  | 42 |  | 
|  | 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 |  | 
|  | 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 |  | 
|  | 55 | void glClear(GLbitfield mask) | 
|  | 56 | { | 
|  | 57 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 58 | ctx->iface->Clear(ctx->iface, mask); | 
|  | 59 | } | 
|  | 60 |  | 
|  | 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 |  | 
|  | 67 | void glClearDepthf(GLclampf depth) | 
|  | 68 | { | 
|  | 69 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 70 | ctx->iface->ClearDepthf(ctx->iface, depth); | 
|  | 71 | } | 
|  | 72 |  | 
|  | 73 | void glClearStencil(GLint s) | 
|  | 74 | { | 
|  | 75 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 76 | ctx->iface->ClearStencil(ctx->iface, s); | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | void glCullFace(GLenum mode) | 
|  | 80 | { | 
|  | 81 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 82 | ctx->iface->CullFace(ctx->iface, mode); | 
|  | 83 | } | 
|  | 84 |  | 
|  | 85 | void glDisable(GLenum cap) | 
|  | 86 | { | 
|  | 87 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 88 | ctx->iface->EnableDisable(ctx->iface, cap, false); | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | void glEnable(GLenum cap) | 
|  | 92 | { | 
|  | 93 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 94 | ctx->iface->EnableDisable(ctx->iface, cap, true); | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | void glFinish(void) | 
|  | 98 | { | 
|  | 99 | // do nothing | 
|  | 100 | } | 
|  | 101 |  | 
|  | 102 | void glFrontFace(GLenum mode) | 
|  | 103 | { | 
|  | 104 | GLES2_GET_CONST_CONTEXT(ctx); | 
|  | 105 | ctx->iface->FrontFace(ctx->iface, mode); | 
|  | 106 | } | 
|  | 107 |  | 
|  | 108 | void glFlush(void) | 
|  | 109 | { | 
|  | 110 | // do nothing | 
|  | 111 | } | 
|  | 112 |  | 
|  | 113 | void glHint(GLenum target, GLenum mode) | 
|  | 114 | { | 
|  | 115 | // do nothing | 
|  | 116 | } | 
|  | 117 |  | 
|  | 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 |  | 
|  | 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 | } |