Jump to content

  • Log In with Google      Sign In   
  • Create Account

Android orthographic interference glDrawArrays/glVertexAttribPointer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 30 March 2013 - 03:14 AM

This orthrographic image draws fine:

  glDisable(GL_DEPTH_TEST); 
    glUseProgram(g_program[ORTHO]); 
    glUniform1f(g_slots[ORTHO][WIDTH], (float)g_width); 
    glUniform1f(g_slots[ORTHO][HEIGHT], (float)g_height); 
    glUniform4f(g_slots[ORTHO][COLOR], 1, 1, 1, 1); 
    glEnableVertexAttribArray(g_slots[ORTHO][POSITION]); 
    glEnableVertexAttribArray(g_slots[ORTHO][TEXCOORD]); 
    glBindBuffer(GL_ARRAY_BUFFER, 0); 
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 
... 
  glVertexAttribPointer(g_slots[ORTHO][POSITION], 3, GL_FLOAT, GL_FALSE, sizeof(float)*5, &vertices[0]); 
    glVertexAttribPointer(g_slots[ORTHO][TEXCOORD], 2, GL_FLOAT, GL_FALSE, sizeof(float)*5, &vertices[3]); 
    glDrawArrays(GL_TRIANGLES, 0, 6); 
... 
    glEnable(GL_DEPTH_TEST);

 

But if I place this before it, it doesn't draw:

    glUseProgram(g_program[MODEL]); 
        ... 
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffers[frame]); 
    glVertexAttribPointer(g_slots[MODEL][TEXCOORD], 2, GL_FLOAT, GL_FALSE, sizeof(CVertexArray2), (void*)offsetof(CVertexArray2,texcoord));

        glUseProgram(g_program[BILLBOARD]); 
        ... 
        glVertexAttribPointer(g_slots[BILLBOARD][POSITION], 3, GL_FLOAT, GL_FALSE, sizeof(float)*5, &vertices[0]); 
        glVertexAttribPointer(g_slots[BILLBOARD][TEXCOORD], 2, GL_FLOAT, GL_FALSE, sizeof(float)*5, &vertices[3]); 
        glDrawArrays(GL_TRIANGLES, 0, 6);

 

If I get rid of the last glDrawArrays it draws, or if I remove glVertexAttribPointer(g_slots[MODEL][TEXCOORD]...

Any ideas why?

 


Sponsor:

#2 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 30 March 2013 - 07:02 PM

Here's what I broke the problem down to.

 

The ortho quad will draw if I comment any of these lines:

 

        glUseProgram(g_program[BILLBOARD]); 
        glEnableVertexAttribArray(g_slots[BILLBOARD][POSITION]); 
        glEnableVertexAttribArray(g_slots[BILLBOARD][TEXCOORD]); 
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glVertexAttribPointer(g_slots[BILLBOARD][POSITION], 3, GL_FLOAT, GL_FALSE, sizeof(float)*5, &vertices[0]); 
        glVertexAttribPointer(g_slots[BILLBOARD][TEXCOORD], 2, GL_FLOAT, GL_FALSE, sizeof(float)*5, &vertices[3]); 
        
        glDrawArrays(GL_TRIANGLES, 0, 6);

 

It has something to do with the texture because if I get rid of the texture in the billboard shaders, the ortho quad draws:

 

// billboard.frag

varying lowp vec2 TexCoordOut; 
uniform sampler2D Texture;

void main(void) 
{ 
  lowp vec2 TexCoord = vec2(0,0); 
    gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0) * texture2D(Texture, TexCoord); 
    //gl_FragColor = vec4(1,1,1,1); 
}

 

Vertex shader billboard.vert somehow effects the vertices of the ortho shader. The ortho quad only draws in the right part of the screen if I remove the line

 

    TexCoordOut = TexCoordIn;

attribute vec4 Position;
attribute vec2 TexCoordIn; 
varying vec2 TexCoordOut;

void main(void) 
{ 
    gl_Position = Position; 
    TexCoordOut = TexCoordIn; 
}


#3 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 31 March 2013 - 03:31 PM

And this works fine on iOS.

 

Reported a bug:

 

https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=53820



#4 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 31 March 2013 - 09:44 PM

https://code.google.com/p/android/issues/detail?id=53829&thanks=53829&ts=1364787874



#5 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 01 April 2013 - 12:19 AM

I can only think it might be memory corruption in another part of the program.



#6 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 02 April 2013 - 11:14 PM

No, this is not memory corruption. Definitely some bug in Galaxy Nexus or android.

 

I broke it down to the simplest example. Try this project (comment #5):

 

https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=53820



#7 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 03 April 2013 - 04:57 PM

Ugh, they're never going to reply to the issue. Android is such a piece of crap.



#8 invutil   Crossbones+   -  Reputation: 1932

Like
0Likes
Like

Posted 05 April 2013 - 06:31 PM

Fixed the problem by packing everything into VBO's. Inconvenient, especially for text, but it solved the problem.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS