Jump to content
  • Advertisement
Sign in to follow this  
Martin Perry

OpenGL iPhone 4 vs iPhone 5S - OpenGL not rendering

This topic is 2144 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by Sponji

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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 Edited by L. Spiro

Share this post


Link to post
Share on other sites
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 Edited by L. Spiro

Share this post


Link to post
Share on other sites

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]
Edited by Martin Perry

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!