Fri Mar 15, 2019 12:13 pm
setting the function to GL_NEVER means it will always fail, ie show everything,
So you need one of the other functions for testing which are the same as used by stencil
GL_NEVER
GL_LESS
GL_EQUAL
GL_LEQUAL
GL_GREATER
GL_NOTEQUAL
GL_GEQUAL
GL_ALWAYS
Try GL_LEQUAL
But to actually get depth functions to work you need to have a depth buffer, and thats set up when you get an EGL config, so you should also have a depth buffer enabled in your EGL config which may look something like this
static const EGLint attribute_list[] =
{
// these 1st 4, let us define the size of our colour components and from that the size of a pixel.
// In this case 32bits made up of 8xR, 8xG,8xB and 8xA
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SAMPLE_BUFFERS,1, // if you want anti alias at a slight fps cost, it won't make a huge difference on a 2D system
EGL_SAMPLES, 4, //keep these 2 lines
// These lines set up some basic internal features that help with depth sorting
EGL_DEPTH_SIZE, 8,
// These lines tell EGL how the surface is made up.
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_NONE
};
I usually set up my OpenGL states like this
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDepthMask(TRUE);
glDepthRangef(0.0f, 1.0f);
glClearDepthf(1.0f);
you may also need to consider
glCullFace(GL_BACK);
as it can make it look like things behind things are being seen
Btw, OpenGLES1.1 is basically outdated now, it does still work of course, but much better to move to OpenGLES2.0 when you get a grip on what that static pipeline is doing.. A lot of things like depth sorting work the same way so you're not losing anything by starting with 1.1
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/