Note that there are some explanatory texts on larger screens.

plurals
  1. POGLKit & adding tints to textures
    primarykey
    data
    text
    <p>I am having issue with tinting a PNG image with GLKit.</p> <p>I have a white PNG image that I load into the application and then use it to create a texture:</p> <pre><code>UIImage *image = [ UIImage imageNamed:@"brushImage" ]; NSError *error = nil; texture_m = [[ GLKTextureLoader textureWithCGImage:image.CGImage options:nil error:&amp;error] retain ]; if (error) { NSLog(@"Error loading texture from image: %@",error); } </code></pre> <p>the texture is created with no errors.</p> <p>however when I want to render the texture with blend activated the colour seems to be ignored and I get a white image. I had no issues when I was doing this in OpenGL1 were the image would pick up the colour that was defined in <code>glColor4f()</code>. Here is my render code:</p> <pre><code>-(void)render{ if (texture_m != nil) { effect_m.texture2d0.enabled = GL_TRUE; effect_m.texture2d0.envMode = GLKTextureEnvModeReplace; effect_m.texture2d0.target = GLKTextureTarget2D; effect_m.texture2d0.name = texture_m.name; } [effect_m prepareToDraw]; glClear(GL_COLOR_BUFFER_BIT); GLfloat squareVertices[] = { 50, 50, 150, 50, 50, 150, 150, 150 }; GLfloat squareTexture[] = { 0, 0, 1, 0, 0, 1, 1, 1 }; glColor4f( 1, 0, 0, 1 ); glEnableVertexAttribArray(GLKVertexAttribPosition); glEnableVertexAttribArray(GLKVertexAttribTexCoord0); glEnable(GL_BLEND); glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, 0, squareVertices); glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0, squareTexture ); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisable(GL_BLEND); glDisableVertexAttribArray(GLKVertexAttribPosition); glDisableVertexAttribArray(GLKVertexAttribTexCoord0); } </code></pre> <p>Could anybody help to solve this issue Thanks</p> <p>Reza</p>
    singulars
    1. This table or related slice is empty.
    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.
    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