Jump to content

  • Log In with Google      Sign In   
  • Create Account


synopfab

Member Since 09 Nov 2011
Offline Last Active Nov 15 2011 02:53 PM
-----

Topics I've Started

Repeat texture with GLKit

09 November 2011 - 01:16 PM

Hi everybody,

I am using GLKit in order to show textures on my project. The code is like this :

-(void)setTextureImage:(UIImage *)image {
    NSError *error;
    texture = [GLKTextureLoader textureWithCGImage:image.CGImage options:nil error:&error];
    if (error) {
        NSLog(@"Error loading texture from image: %@",error);
    }
}

effect.texture2d0.envMode = GLKTextureEnvModeReplace;
        effect.texture2d0.target = GLKTextureTarget2D;
        effect.texture2d0.name = texture.name;

glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
        glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0, self.textureCoordinates);

Now I want to repeat this texture on a rectangle. Is there any way use GLKit for this behavior ?
I've tried to use opengl function in addition to the glkit ones, but it raises errors :

glEnable(GL_TEXTURE_2D);
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
        glBindTexture( GL_TEXTURE_2D, texture.name );

2011-11-09 20:10:28.614 ********[16309:207] GL ERROR: 0x0500
2011-11-09 20:10:30.840 ********[16309:207] Error loading texture from image: Error Domain=GLKTextureLoaderErrorDomain Code=8 "The operation couldn’t be completed. (GLKTextureLoaderErrorDomain error 8.)" UserInfo=0x68545c0 {GLKTextureLoaderGLErrorKey=1280, GLKTextureLoaderErrorKey=OpenGL error}

Thank you for your help,
Fabrice

PARTNERS