Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

opengl es z-buffer issue (isometric tile map)


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 Lucky808   Members   -  Reputation: 139

Like
0Likes
Like

Posted 07 March 2013 - 08:20 PM

Hi all,

 

I'm having trouble to get z-buffer to work properly on my isometric tile map. (using glOrthof() projection)

I've created and bound a depth buffer and enabled it. however during rendering, it only seems to work properly when my player character is walking behind other objects on the map. however, whenever the character gets in front of an object, the overlapping part between character and object does show up, meaning the entire object gets rendered and my character gets cut off from where the overlapping starts.

I'm stuck with this problem for 3 days and couldn't figure out why. any help is much appreciated!

 

 



Sponsor:

#2 Seabolt   Members   -  Reputation: 451

Like
0Likes
Like

Posted 09 March 2013 - 03:33 PM

Have you enabled depth testing?


Perception is when one imagination clashes with another

#3 Lucky808   Members   -  Reputation: 139

Like
0Likes
Like

Posted 09 March 2013 - 09:30 PM

Yes I have.

 

here is how I initialized openGL. do you see any issues with them:

 

 

if (!depthRenderbuffer){

glGenRenderbuffersOES(1, &depthRenderbuffer);

glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);

glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT24_OES, framebufferWidth, framebufferHeight);

glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);

}

 

 

glViewport(0, 0, rect.size.width , rect.size.height);

    

 

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

 

glOrthof(0, rect.size.width, 0, rect.size.height, -1024, 1024);

 

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

 

 

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

glClearDepthf(1.0f);

glEnable(GL_DEPTH_TEST);

glDepthMask(GL_TRUE);

glDepthFunc(GL_LEQUAL);

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

 

glEnable(GL_ALPHA_TEST);

glAlphaFunc(GL_GREATER, 0);

 

glEnableClientState(GL_VERTEX_ARRAY);

glEnableClientState(GL_COLOR_ARRAY);

glEnable(GL_TEXTURE_2D);

glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glEnable(GL_BLEND);

 

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

 

Thanks.



#4 Seabolt   Members   -  Reputation: 451

Like
0Likes
Like

Posted 10 March 2013 - 09:02 AM

That setup looks fine enough to me. Have you been error checking? In OpenGL it's glGetError(), I'm not sure if there is an equivalent on OpenGL ES.


Perception is when one imagination clashes with another

#5 Lucky808   Members   -  Reputation: 139

Like
0Likes
Like

Posted 11 March 2013 - 08:19 PM

I tried glGetError() and got an error code 1280, which is GL_INVALID_ENUM. my understanding is that this code can be ignored, right?



#6 Seabolt   Members   -  Reputation: 451

Like
0Likes
Like

Posted 12 March 2013 - 08:18 AM

No way, that essentially means you're passing an invalid parameter to a function and it has no idea how to handle it. So instead, it does nothing.


Perception is when one imagination clashes with another

#7 Lucky808   Members   -  Reputation: 139

Like
0Likes
Like

Posted 13 March 2013 - 08:52 PM

i got it to work. it turned out that i had assigned the wrong z-values to tiles. how stupid of me.

thanks for the help though.



#8 Seabolt   Members   -  Reputation: 451

Like
0Likes
Like

Posted 14 March 2013 - 08:13 AM

No problem!


Perception is when one imagination clashes with another




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