aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/mac
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-12-23 15:00:45 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2010-12-23 15:00:45 +0000
commit873cb1e23b64e4b2d11749352b626bcef204bdd7 (patch)
tree16749ff8667f669deb28a00bbb5a7ce6d8db8f0d /src/utils/mac
parent5b9cfd4d8809d6d55aaf047a6a8acc2de2f2eeb0 (diff)
add gpu to the default makefile
move skia-gpu files into skia/src/gpu git-svn-id: http://skia.googlecode.com/svn/trunk@653 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/mac')
-rw-r--r--src/utils/mac/SkEGLContext_mac.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/utils/mac/SkEGLContext_mac.cpp b/src/utils/mac/SkEGLContext_mac.cpp
new file mode 100644
index 0000000000..13bb5922ac
--- /dev/null
+++ b/src/utils/mac/SkEGLContext_mac.cpp
@@ -0,0 +1,65 @@
+#include "SkEGLContext.h"
+#include <AGL/agl.h>
+
+SkEGLContext::SkEGLContext() : fContext(NULL) {
+}
+
+SkEGLContext::~SkEGLContext() {
+ if (fContext) {
+ aglDestroyContext((AGLContext)fContext);
+ }
+}
+
+bool SkEGLContext::init(int width, int height) {
+ GLint major, minor;
+ AGLContext ctx;
+
+ aglGetVersion(&major, &minor);
+ SkDebugf("---- agl version %d %d\n", major, minor);
+
+ const GLint pixelAttrs[] = {
+ AGL_RGBA,
+ AGL_STENCIL_SIZE, 8,
+/*
+ AGL_SAMPLE_BUFFERS_ARB, 1,
+ AGL_MULTISAMPLE,
+ AGL_SAMPLES_ARB, 2,
+*/
+ AGL_ACCELERATED,
+ AGL_NONE
+ };
+ AGLPixelFormat format = aglChoosePixelFormat(NULL, 0, pixelAttrs);
+ //AGLPixelFormat format = aglCreatePixelFormat(pixelAttrs);
+ SkDebugf("----- agl format %p\n", format);
+ ctx = aglCreateContext(format, NULL);
+ SkDebugf("----- agl context %p\n", ctx);
+ aglDestroyPixelFormat(format);
+
+ SkDebugf("---- sizeof aglcontext %d\n", sizeof(AGLContext));
+/*
+ static const GLint interval = 1;
+ aglSetInteger(ctx, AGL_SWAP_INTERVAL, &interval);
+*/
+
+ aglSetCurrentContext(ctx);
+ fContext = (void*)ctx;
+
+ // Now create our FBO render target
+
+ GLuint fboID;
+ GLuint cbID;
+ GLuint dsID;
+ glGenFramebuffersEXT(1, &fboID);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
+ glGenRenderbuffers(1, &cbID);
+ glBindRenderbuffer(GL_RENDERBUFFER, cbID);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, width, height);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, cbID);
+ glGenRenderbuffers(1, &dsID);
+ glBindRenderbuffer(GL_RENDERBUFFER, dsID);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, dsID);
+
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ return GL_FRAMEBUFFER_COMPLETE == status;
+}