Skip to content

Commit

Permalink
Fix Issue sprang#1: Paintings do not appear on the canvas in Release …
Browse files Browse the repository at this point in the history
…builds.
  • Loading branch information
sprang committed Nov 5, 2013
1 parent 2311434 commit dc98466
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Classes/WDGLUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

void WDGLBuildQuadForRect(CGRect rect, CGAffineTransform transform, GLuint *quadVAO, GLuint *quadVBO, BOOL stroke);
void WDGLBuildQuadForRect(CGRect rect, CGAffineTransform transform, GLuint *quadVAO, GLuint *quadVBO);
void WDGLRenderInRect(CGRect rect, CGAffineTransform transform);
30 changes: 8 additions & 22 deletions Classes/WDGLUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#import "WDGLUtilities.h"

void WDGLBuildQuadForRect(CGRect rect, CGAffineTransform transform, GLuint *quadVAO, GLuint *quadVBO, BOOL stroke)
void WDGLBuildQuadForRect(CGRect rect, CGAffineTransform transform, GLuint *quadVAO, GLuint *quadVBO)
{
CGPoint corners[4];

Expand All @@ -24,33 +24,19 @@ void WDGLBuildQuadForRect(CGRect rect, CGAffineTransform transform, GLuint *quad
corners[i] = CGPointApplyAffineTransform(corners[i], transform);
}

const GLfloat vertices[] = {
corners[0].x, corners[0].y, 0.0, 0.0,
corners[1].x, corners[1].y, 1.0, 0.0,
corners[3].x, corners[3].y, 0.0, 1.0,
corners[2].x, corners[2].y, 1.0, 1.0,
};

glGenVertexArraysOES(1, quadVAO);
glBindVertexArrayOES(*quadVAO);

// create, bind, and populate VBO
glGenBuffers(1, quadVBO);
glBindBuffer(GL_ARRAY_BUFFER, *quadVBO);

const GLfloat *vertices = NULL;

if (stroke) {
const GLfloat quadVertices[] = {
corners[0].x, corners[0].y, 0.0, 0.0,
corners[1].x, corners[1].y, 1.0, 0.0,
corners[2].x, corners[2].y, 1.0, 1.0,
corners[3].x, corners[3].y, 0.0, 1.0
};
vertices = quadVertices;
} else {
const GLfloat quadVertices[] = {
corners[0].x, corners[0].y, 0.0, 0.0,
corners[1].x, corners[1].y, 1.0, 0.0,
corners[3].x, corners[3].y, 0.0, 1.0,
corners[2].x, corners[2].y, 1.0, 1.0,
};
vertices = quadVertices;
}

glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 16, vertices, GL_STATIC_DRAW);

// set up attrib pointers
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDPainting.m
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ - (GLuint) quadVAO
if (!quadVAO_) {
[EAGLContext setCurrentContext:self.context];
CGRect bounds = CGRectMake(0, 0, self.width, self.height);
WDGLBuildQuadForRect(bounds, CGAffineTransformIdentity, &quadVAO_, &quadVBO_, NO);
WDGLBuildQuadForRect(bounds, CGAffineTransformIdentity, &quadVAO_, &quadVBO_);
}

return quadVAO_;
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDShadowQuad.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ - (void) blitWithScale:(float)scale

if (!CGRectEqualToRect(rect, lastRect)) {
[self freeBuffers];
WDGLBuildQuadForRect(rect, CGAffineTransformIdentity, &vao_, &vbo_, NO);
WDGLBuildQuadForRect(rect, CGAffineTransformIdentity, &vao_, &vbo_);
}

// Bind the texture to be used
Expand Down

0 comments on commit dc98466

Please sign in to comment.