iPhone 4 vs iPhone 5S - OpenGL not rendering

Started by
7 comments, last by Martin Perry 10 years, 4 months ago

have problem with my OpenGL ES 2.0 app on iPhone 5S. On iPhone 4, all is running just fine. But when I run my app on 5S, I got missing geometry and frame capture is messaging error on this:


GL_CHECK( glDrawElements(this->primitiveType, this->perObjectVertices * primitiveCount, GL_UNSIGNED_SHORT, 0) );

Line should be perfectly valid, it runs without this problem on 4 and 4S. But on 5S I am getting


GL_INVALID_OPERATION 

Also, in emulator is all just fine, only on physical device is graphics missing

Advertisement

Sounds like an earlier error causes it to fail, like the vertex buffer not being set or something like that. Do you have the same iOS version on both phones?

No.. first one is iOS 5 and second one iOS 7... every gl call in my code is encapsulated with GL_CHECK, and it fails on glDrawElements, not before. Even Xcode GL debugger is logging error at the same gl call and not before during binds etc.

Have you tried commenting code out to find what causes the error? Maybe you forgot to disable vertex attributes after the previous draw call? It could be something like that and the other device just ignores it.

Derp

I have one universal render class... other primitives render just fine. Problem is only with one of them. So from my point ot view, it must be something during VB/IB filling, but according to openGL, there are no prior errors before glDrawElements

http://www.khronos.org/opengles/sdk/docs/man3/xhtml/glDrawElements.xml


GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped.
GL_INVALID_OPERATION is generated if transform feedback is active and not paused.



L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Interesting, I have read this manual (http://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml), and there is no word about this error.

However, I cant see any problem relating to this description. What can cause this ?

That is for OpenGL ES 2.0, mine is for OpenGL ES 3.0. glDrawPrimitives() can’t throw GL_INVALID_OPERATION in OpenGL ES 2.0, hence your problem.

I have updated my quote section. See if either applies to your case.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Well.. thats the strange thing. I am using OpenGL ES 2.0. I know, that 5S has ES 3.0, but I never include ES 3.0 headers.

I have tried to comment out only glDrawElements for that one particular graphics object and there are no more errors (obviously, object is nor rendered). I also compared content of VB / IB with the one on iPhone 4, where all is correct, and they are the same.

My IB has 30 elements (uint32 or uint16.. error in both cases)

My VB has 20 vertices, each of size 48 bytes (12 * sizeof(float))

My Pixel Shader only read texture


precision mediump float;

varying vec2 vTexCoord;

uniform sampler2D guiBgTetxure;
void main()
{    
    gl_FragColor += texture2D(guiBgTetxure, vTexCoord);
}

My Vertex Shader:


precision mediump float;



attribute vec4 POSITION;
attribute vec2 TEXCOORD0;
attribute vec2 TEXCOORD1;
attribute vec2 TEXCOORD2;
attribute vec2 TEXCOORD3;

uniform int stateIndex[64];

varying vec2 vTexCoord;


void main()
{            
    gl_Position = vec4(POSITION.xyz, 1.0);

    int index = stateIndex[int(POSITION.w)];

    if (index == -1)
    {
        gl_Position = vec4(0,0,0,0);
        index = 0;
    }

    if (index == 0) vTexCoord = TEXCOORD0;    
    else if (index == 1) vTexCoord = TEXCOORD1;    
    else if (index == 2) vTexCoord = TEXCOORD2;    
    else if (index == 3) vTexCoord = TEXCOORD3;    
 
}

-------

-------

EDIT:

If I do this


GL_CHECK( glDrawElements(this->primitiveType, 0, GL_UNSIGNED_INT, 0) );

error is gone... but naturally so the geometry

EDIT 2

Here is my glCall history in scene. On #15, there is an error


#0 glClearColor(0.0000000, 0.0588235, 0.3333333, 1.0000000)
#1 glClearDepthf(0.0000000)
#2 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
#3 glBindFramebuffer(GL_FRAMEBUFFER, 1)
#4 glEnable(GL_BLEND)
#5 glUseProgram(47)
#6 glActiveTexture(GL_TEXTURE0)
#7 glBindTexture(GL_TEXTURE_2D, 25)
#8 glUniform1i(guiBgTetxure, 0)
#9 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
#10 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
#11 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
#12 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
#13 glBindVertexArray(1)
#14 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 39)
#15 glDrawElements(GL_TRIANGLES, 30, GL_UNSIGNED_INT, nullptr)
#16 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)
#17 glBindVertexArray(0)
#18 glUseProgram(0)
#19 glDisable(GL_BLEND)
#20 glBindRenderbuffer(GL_RENDERBUFFER, 1)
#21 ["Context 1" presentRenderbuffer:GL_RENDERBUFFER]

This topic is closed to new replies.

Advertisement