开发者

OpenGL light direction reversed while drawing into a framebuffer texture

I've got an iPhone (OpenGL ES 1.1) app that does some rendering into textures. I'm setting up a framebuffer object and using glFramebufferTexture2D to attach the texture to it.

Everything works fine except that the light directions are reversed when drawing into this framebuffer object. I'm specifying light directions like this:

float theDirection[4] = { x, y, z, 0 }
glLightf( lightIndex, GL_POSITION, theDirection )

When rendering without the framebuffer object, all my light directions are correct. When rendering with the framebuffer object, I have to negate theDirection f开发者_Python百科or things to look the same.

As a side note, the light directions are also reversed (with or without a framebuffer object) when I'm running on an iPhone 3G with iOS 3.2. If I'm running on an iPhone or iPad on 4.x, the light directions are not reversed.

Any ideas?


Strangely, the solution here was to enable GL_CULL_FACE. If GL_CULL_FACE is disabled in a MonoTouch project using OpenGL ES 1.1, then the GL lighting direction (for a directional GL_LIGHT0) will be negated on some of the devices or OS versions, I'm not sure which.

xcode-based C++ projects do not have this problem. OpenGL ES 1.1 xcode projects light consistently across all devices and OS versions that I've tested regardless of your GL_CULL_FACE setting.

As compared to the result of identical GL code in a C++ xcode project (which is consistent across devices regardless of GL_CULL_FACE), here are the devices that I see inverted lighting happening on in MonoTouch:

  • iPad running iOS 4.2.1
  • iOS simulator running iOS 4.2
  • iPhone4 running iOS 4.2.1

The lighting is correct on my iPhone 3G running iOS 3.1.2.

I posted a bug report to Novell: https://bugzilla.novell.com/show_bug.cgi?id=679896

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜