diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-17 14:24:46 +0000 |
---|---|---|
committer | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-17 14:24:46 +0000 |
commit | 16bab87a78cfaf6a4f334e1af910c46883f460af (patch) | |
tree | d3673b82876bca69b03b1eaf04d3f0fdc16ee622 /src/utils/mac | |
parent | 1dd17a133f4fa5c5a0c752e6b9a6f7af6f329fb8 (diff) |
Add GL context creation for X so that gm can run GPU on Linux.
http://codereview.appspot.com/4548047/
git-svn-id: http://skia.googlecode.com/svn/trunk@1343 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/mac')
-rw-r--r-- | src/utils/mac/SkEGLContext_mac.cpp | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/src/utils/mac/SkEGLContext_mac.cpp b/src/utils/mac/SkEGLContext_mac.cpp index 14ab14bc5d..e601f35617 100644 --- a/src/utils/mac/SkEGLContext_mac.cpp +++ b/src/utils/mac/SkEGLContext_mac.cpp @@ -1,59 +1,60 @@ #include "SkEGLContext.h" +//#include "SkTypes.h" #include <AGL/agl.h> -SkEGLContext::SkEGLContext() : fContext(NULL) { +SkEGLContext::SkEGLContext() : context(NULL) { } SkEGLContext::~SkEGLContext() { - if (fContext) { - aglDestroyContext((AGLContext)fContext); - } + if (this->context) { + aglDestroyContext(this->context); + } } bool SkEGLContext::init(int width, int height) { - GLint major, minor; - AGLContext ctx; + GLint major, minor; + AGLContext ctx; - aglGetVersion(&major, &minor); -// SkDebugf("---- agl version %d %d\n", major, minor); + aglGetVersion(&major, &minor); + //SkDebugf("---- agl version %d %d\n", major, minor); - const GLint pixelAttrs[] = { - AGL_RGBA, - AGL_STENCIL_SIZE, 8, + const GLint pixelAttrs[] = { + AGL_RGBA, + AGL_STENCIL_SIZE, 8, /* - AGL_SAMPLE_BUFFERS_ARB, 1, - AGL_MULTISAMPLE, - AGL_SAMPLES_ARB, 2, + 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); + 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); /* - static const GLint interval = 1; - aglSetInteger(ctx, AGL_SWAP_INTERVAL, &interval); + static const GLint interval = 1; + aglSetInteger(ctx, AGL_SWAP_INTERVAL, &interval); */ - aglSetCurrentContext(ctx); - fContext = (void*)ctx; + aglSetCurrentContext(ctx); + this->context = ctx; - // Now create our FBO render target + // Now create our FBO render target - GLuint fboID; - GLuint cbID; + 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); + 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); |