Note that there are some explanatory texts on larger screens.

plurals
  1. POInconsistent artifacts when rendering textures in OpenGLES 2.0
    primarykey
    data
    text
    <p>I'm just trying to render some simple particles in OpenGLES 2.0 in the iPhone Simulator, and sometimes there are artifacts, and sometimes there aren't, it's almost like it's a coin flip when I try to run my code. The first image is what it should look like, the second image are the artifacts, notice the lines/banding at the bottom. Same image, same code, different results, it has me stumped:</p> <p><a href="http://i.imgur.com/C6LnoWj.png" rel="nofollow">http://i.imgur.com/C6LnoWj.png</a> &lt;-no artifacts</p> <p><a href="http://i.imgur.com/EBj26kG.png" rel="nofollow">http://i.imgur.com/EBj26kG.png</a> &lt;-artifacts</p> <p>Like I said, I have no idea where to begin, it's just a basic two triangle sprite with texture coordinates of (0,0), (0,1), (1,0), and (1,1). If you have any suggestions of what code I should post, I would appreciate it</p> <p>Edit:</p> <p>Here's my texture loading code.</p> <pre><code>CGImageRef image = [UIImage imageNamed:filename].CGImage; size_t width = CGImageGetWidth(image); size_t height = CGImageGetHeight(image); NSUInteger length = width*height*4; GLubyte *data = (GLubyte*)malloc(length*sizeof(GLubyte)); CGContextRef context = CGBitmapContextCreate(data, width, height, 8, width*4, CGImageGetColorSpace(image), kCGImageAlphaPremultipliedLast); CGContextTranslateCTM(context, 0, height); CGContextScaleCTM(context, 1.0, -1.0); CGContextDrawImage(context, CGRectMake(0, 0, width, height), image); CGContextRelease(context); GLuint texture; glGenTextures(1, &amp;texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); </code></pre> <p>I switched the malloc call to calloc based on the suggestion to zero out the memory first, and that seems to have fixed it.</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.
    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