[Interest] [OT] Re: OpenGL weirdness

Guido Seifert wargand at gmx.de
Sat Aug 16 13:27:09 CEST 2014


> Very. In my case apitrace helped track down the broken matrix but it's still a 
> painful process, especially if you're new to the topic.

Terrible what can go wrong... with no idea why. Yesterday I coded my first 
deferred lighting OpenGL ES 2.0 program. Problem was... Only the first light was
rendered. Strange, I would have expected the last one... overwriting the first
light passes, but only the first one? I played for hrs with glBlendFunc and its
parameters...Nothing. Did I set glClear wrongly? Buffers correctly initialized? I 
just could not find the bug. Internet search... not too much detailed info on the 
deferred techniques...at least if compared with the forward rendering methods. 
Most books on OpenGL handle only the 'Hello World' triangle. As soon as it gets 
interesting: This technique is beyond the scope of this book. I really came to 
think this means: 'I don't understand this technique myself'. 

So... my light passes... everything looked exactly as it should... I even copy/pasted 
code snippets, which were supposed to work... Nothing...

Well... code snippets... The most important parts were left out. Perhaps because they
are obvious for experienced OpenGL developers. I am far from experienced and enjoy
delving into this for me relatively new area.

So, what was the problem? I did not set glDepthFunc(GL_EQUAL) and with the default 
glDepthFunc(GL_LESS), the second and following passes were not drawn, since pixels with
exactly the same depth were already drawn in the first pass. 

Very funny... after I found the problem, I was able to find plenty of sites explaining
this. But if you are new and don't even know there is something you should look after....

But hey at least I never drew the black cube on a black background... never happened to me*.

Guido











*... my cube and background were always green. ;-)



More information about the Interest mailing list