Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange black pixels on model
    text
    copied!<p>I tried to draw a model with 197 polygons but i have strange black pixels on it: </p> <p><a href="http://i.imagehost.org/0398/IMG_0172.png" rel="nofollow noreferrer">alt text http://i.imagehost.org/0398/IMG_0172.png</a></p> <p>When I run the code in the iPhone Simulator, it shows well without those black pixels, but on the device I have that problem.</p> <p>I set perspective:</p> <pre><code>const GLfloat zNear = 0.01, zFar = 1000.0, fieldOfView = 45.0; GLfloat size; glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0); CGRect rect = self.bounds; glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size / (rect.size.width / rect.size.height), zNear, zFar); glViewport(0, 0, rect.size.width, rect.size.height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(0.3f, 0.3f, 0.3f, 1.0f); glColor4f(0,0,0,0.5f); glEnable(GL_SMOOTH); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnableClientState(GL_VERTEX_ARRAY); </code></pre> <p>And draw (model vertices, indexes and normals store in global arrays.):</p> <pre><code>glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); [EAGLContext setCurrentContext:context]; glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glTranslatef(1.0, -9, -22); glVertexPointer(3, GL_FLOAT, 0, vertices); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, normals); glDrawElements(GL_TRIANGLES, 3*192, GL_UNSIGNED_BYTE, icosahedronFaces); glDisableClientState(GL_NORMAL_ARRAY); glTranslatef(-1.0, 9, 22); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; </code></pre>
 

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