开发者

OpenGL and perspective vs polygon/model size

I've been mucking around in OpenGL on Android for a while and feel like I've been able to figure a lot of things out. I've been working from the book "Hello, Android!" and the Android port of the NeHe 3D world tutorial. The fun part is that both differ a bit in implementation, so piecing something together from both has been loads of fun. The thing is, the HA tutorial has you build a spinning cube and uses very large int values. The cube is basically 65536x65536. Shrinking these values shrinks the cube considerably. However, the NeHe port uses much smaller floats. The height of the little world is only 6.0, yet the perspective from the camera makes it look like you're about 1.0-2.0 units tall. I've compared and contrasted the two like mad to try and find out how this was done, but I've come up empty. I can tell that the NeHe code does not normal anything while the HA code does. It applies a glNormal3f function to take the larger values down to 1,0,0, for example, then builds with TRIANGLE_STRIP, which appears to be a quick way to pump a lot of geometry in a short time. Being an OpenGL newbie, I can't say for sure if this is why or if this just makes it easier to draw and apply textures later. It's probably unrelated, but the NeHe tutorial feeds the vertex/texture buffers in as GL_FLOAT while the HA feeds them as GL_FIXED. Changing the latter to the former results in a lot of ugly planing.

I've mucked around with the viewport and translatef (which as put me in the spinning cube), but I can't seem to fig开发者_Python百科ure out how each manages perspective vs the size of the polygons around it. Can anyone shed some light on this? Thanks.


I'm not sure what this HA tutorial is, but check if they're using the fixed-point versions (generally with a x suffix instead of f) of the various OpenGL ES functions. If so, remember that the OpenGL ES fixed-point format is S15.16, so 65536 maps to 1.0f or thereabouts.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜