aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGLContext.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-06 19:54:37 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-06 19:54:37 +0000
commit675c5c4303f75581405b510537e2fccd69bd416f (patch)
tree06fc4456ad850434f03ddc9d6be5184bc116ff29 /src/gpu/SkGLContext.cpp
parent1607863b608b7db6c813228768ed5d72997bbc82 (diff)
Fix SkGLContext FBO setup for ES2
Review URL: http://codereview.appspot.com/5452058/ git-svn-id: http://skia.googlecode.com/svn/trunk@2812 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/SkGLContext.cpp')
-rw-r--r--src/gpu/SkGLContext.cpp44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/gpu/SkGLContext.cpp b/src/gpu/SkGLContext.cpp
index c50ee6ee1f..f6b7db89f9 100644
--- a/src/gpu/SkGLContext.cpp
+++ b/src/gpu/SkGLContext.cpp
@@ -24,28 +24,45 @@ bool SkGLContext::init(int width, int height) {
fGL = this->createGLContext();
if (fGL) {
+ // clear any existing GL erorrs
+ GrGLenum error;
+ do {
+ error = SK_GL(*this, GetError());
+ } while (GR_GL_NO_ERROR != error);
GrGLuint cbID;
GrGLuint dsID;
SK_GL(*this, GenFramebuffers(1, &fFBO));
SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, fFBO));
SK_GL(*this, GenRenderbuffers(1, &cbID));
SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, cbID));
- SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
- GR_GL_RGBA,
- width, height));
+ if (fGL->supportsES2()) {
+ SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+ GR_GL_RGBA8,
+ width, height));
+ } else {
+ SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+ GR_GL_RGBA,
+ width, height));
+ }
SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_RENDERBUFFER,
cbID));
SK_GL(*this, GenRenderbuffers(1, &dsID));
SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, dsID));
- SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
- GR_GL_DEPTH_STENCIL,
- width, height));
- SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
- GR_GL_DEPTH_ATTACHMENT,
- GR_GL_RENDERBUFFER,
- dsID));
+ if (fGL->supportsES2()) {
+ SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+ GR_GL_STENCIL_INDEX8,
+ width, height));
+ } else {
+ SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER,
+ GR_GL_DEPTH_STENCIL,
+ width, height));
+ SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
+ GR_GL_DEPTH_ATTACHMENT,
+ GR_GL_RENDERBUFFER,
+ dsID));
+ }
SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
GR_GL_RENDERBUFFER,
@@ -53,10 +70,13 @@ bool SkGLContext::init(int width, int height) {
SK_GL(*this, Viewport(0, 0, width, height));
SK_GL(*this, ClearStencil(0));
SK_GL(*this, Clear(GR_GL_STENCIL_BUFFER_BIT));
-
+
+ error = SK_GL(*this, GetError());
GrGLenum status =
SK_GL(*this, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
- if (GR_GL_FRAMEBUFFER_COMPLETE != status) {
+
+ if (GR_GL_FRAMEBUFFER_COMPLETE != status ||
+ GR_GL_NO_ERROR != error) {
fFBO = 0;
fGL->unref();
fGL = NULL;