summaryrefslogtreecommitdiffstats
path: root/opengl/libagl2/src/state.cpp
diff options
context:
space:
mode:
authorDavid Li <davidxli@google.com>2011-03-01 16:54:04 -0800
committerDavid Li <davidxli@google.com>2011-03-08 17:41:29 -0800
commitaf94ceb5df8c7ee21d84a58caa5f632663d4e1b0 (patch)
treed4d71fbdd5d9119619d35a3a933f892a50124853 /opengl/libagl2/src/state.cpp
parentb57af729808cc33f470afaf266b857a3e91ca3e7 (diff)
downloadframeworks_base-af94ceb5df8c7ee21d84a58caa5f632663d4e1b0.zip
frameworks_base-af94ceb5df8c7ee21d84a58caa5f632663d4e1b0.tar.gz
frameworks_base-af94ceb5df8c7ee21d84a58caa5f632663d4e1b0.tar.bz2
Initial commit of libAgl2 using Pixelflinger2 in external/mesa3d
Somewhat functional, refer to README for details. Need to enable Android.mk to build. It builds libGLES_android.so, which needs to replace the one in system/lib/egl built by libagl. Change-Id: Iec3aaa8f3963a4185d81955cd24019eb0c4a5850 Signed-off-by: David Li <davidxli@google.com>
Diffstat (limited to 'opengl/libagl2/src/state.cpp')
-rw-r--r--opengl/libagl2/src/state.cpp129
1 files changed, 129 insertions, 0 deletions
diff --git a/opengl/libagl2/src/state.cpp b/opengl/libagl2/src/state.cpp
new file mode 100644
index 0000000..22e73fa
--- /dev/null
+++ b/opengl/libagl2/src/state.cpp
@@ -0,0 +1,129 @@
+#include "gles2context.h"
+
+GLES2Context::GLES2Context()
+{
+ memset(this, 0, sizeof *this);
+
+ assert((void *)&rasterizer == &rasterizer.interface);
+ InitializeGGLState(&rasterizer.interface);
+ iface = &rasterizer.interface;
+ printf("gl->rasterizer.PickScanLine(%p) = %p \n", &rasterizer.PickScanLine, rasterizer.PickScanLine);
+ assert(rasterizer.PickRaster);
+ assert(rasterizer.PickScanLine);
+
+ InitializeTextures();
+ InitializeVertices();
+}
+
+GLES2Context::~GLES2Context()
+{
+ UninitializeTextures();
+ UninitializeVertices();
+ UninitializeGGLState(&rasterizer.interface);
+}
+
+void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->BlendColor(ctx->iface, red, green, blue, alpha);
+}
+
+void glBlendEquation( GLenum mode )
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->BlendEquationSeparate(ctx->iface, mode, mode);
+}
+
+void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->BlendEquationSeparate(ctx->iface, modeRGB, modeAlpha);
+}
+
+void glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->BlendFuncSeparate(ctx->iface, sfactor, dfactor, sfactor, dfactor);
+}
+
+void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->BlendFuncSeparate(ctx->iface, srcRGB, dstRGB, srcAlpha, dstAlpha);
+}
+
+void glClear(GLbitfield mask)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->Clear(ctx->iface, mask);
+}
+
+void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->ClearColor(ctx->iface, red, green, blue, alpha);
+}
+
+void glClearDepthf(GLclampf depth)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->ClearDepthf(ctx->iface, depth);
+}
+
+void glClearStencil(GLint s)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->ClearStencil(ctx->iface, s);
+}
+
+void glCullFace(GLenum mode)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->CullFace(ctx->iface, mode);
+}
+
+void glDisable(GLenum cap)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->EnableDisable(ctx->iface, cap, false);
+}
+
+void glEnable(GLenum cap)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->EnableDisable(ctx->iface, cap, true);
+}
+
+void glFinish(void)
+{
+ // do nothing
+}
+
+void glFrontFace(GLenum mode)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+ ctx->iface->FrontFace(ctx->iface, mode);
+}
+
+void glFlush(void)
+{
+ // do nothing
+}
+
+void glHint(GLenum target, GLenum mode)
+{
+ // do nothing
+}
+
+void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+// LOGD("agl2: glScissor not implemented x=%d y=%d width=%d height=%d", x, y, width, height);
+ //CALL_GL_API(glScissor, x, y, width, height);
+}
+
+void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ GLES2_GET_CONST_CONTEXT(ctx);
+// LOGD("agl2: glViewport x=%d y=%d width=%d height=%d", x, y, width, height);
+ ctx->iface->Viewport(ctx->iface, x, y, width, height);
+}