Note that there are some explanatory texts on larger screens.

plurals
  1. POGLKit on iOS5: setting texture prevents other drawing
    primarykey
    data
    text
    <p>I am attempting to do some very simple 2D drawing with GLKit, including using a texture. However, if I load the texture, but don't even use it in the drawing, somehow it prevents the drawing from taking place!</p> <p>Here is my setup code:</p> <pre><code>-(void) setup { effect = [[GLKBaseEffect alloc] init]; // comment this out - drawing takes place texture = [GLKTextureLoader textureWithCGImage:[UIImage imageNamed: @"arrow.png"].CGImage options:nil error: nil]; if (texture) { effect.texture2d0.envMode = GLKTextureEnvModeReplace; effect.texture2d0.target = GLKTextureTarget2D; effect.texture2d0.name = texture.name; }; // end of comment this out... effect.transform.projectionMatrix = GLKMatrix4MakeOrtho(0.0, self.bounds.size.width, self.bounds.size.height, 0.0, 1, -1); } </code></pre> <p>Here is my drawing code:</p> <pre><code>- (void)drawRect:(CGRect)rect { GLKVector2 vertices[4]; GLKVector4 colors[4]; vertices[0] = GLKVector2Make(20.0, 30.0); vertices[1] = GLKVector2Make(120.0, 45.0); vertices[2] = GLKVector2Make(70.0, 88.0); vertices[3] = GLKVector2Make(20.0, 80.0); for(int i = 0; i &lt; 4; i++) { colors[i] = GLKVector4Make(0.3, 0.8, 0.5, 1.0); }; glClearColor(0.85, 0.05, 0.1, 1.0); glClear(GL_COLOR_BUFFER_BIT); [effect prepareToDraw]; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnableVertexAttribArray(GLKVertexAttribPosition); glEnableVertexAttribArray(GLKVertexAttribColor); glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLKVertexAttribColor, 4, GL_FLOAT, GL_FALSE, 0, colors); glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); glDisableVertexAttribArray(GLKVertexAttribPosition); glDisableVertexAttribArray(GLKVertexAttribColor); glDisable(GL_BLEND); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload