From 16bab87a78cfaf6a4f334e1af910c46883f460af Mon Sep 17 00:00:00 2001 From: "bungeman@google.com" Date: Tue, 17 May 2011 14:24:46 +0000 Subject: 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 --- src/utils/mac/SkEGLContext_mac.cpp | 73 +++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 36 deletions(-) (limited to 'src/utils/mac') 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 -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); -- cgit v1.2.3