Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had a problem like this and the work arround was loading the texture without the glktextureloader.</p> <p>Here some code for loading the texture without the GLKtextureLoader:</p> <pre><code>bool lPowerOfTwo = false; UIImage *image = [UIImage imageNamed:@"texture.png"]; GLuint width = CGImageGetWidth(image.CGImage); GLuint height = CGImageGetHeight(image.CGImage); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); void *imageData = malloc( height * width * 4 ); CGContextRef context = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); CGColorSpaceRelease( colorSpace ); CGContextClearRect( context, CGRectMake( 0, 0, width, height ) ); CGRect bounds=CGRectMake( 0, 0, width, height ); CGContextScaleCTM(context, 1, -1); bounds.size.height = bounds.size.height*-1; CGContextDrawImage(context, bounds, image.CGImage); GLuint lTextId; glGenTextures(1, &amp;lTextId); glBindTexture(GL_TEXTURE_2D, lTextId); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); if(!lPowerOfTwo) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glGenerateMipmap(GL_TEXTURE_2D); }else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); } CGContextRelease(context); free(imageData); </code></pre> <p>The lTextId variable has the opengl Texture Id.</p> <p>Note: if the texture dimension is not power of two, the texture will be shown black if the GL_TEXTURE_WRAP_S and _T are not set to GL_GLAMP_TO_EDGE</p>
 

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