November 10, 2009

BSP Rendering

Yeah. I think I'm doing something wrong. ... lol :-)

Update: well, the vertex data seems correct, at least. I'll need to check that I'm using the correct mesh definitions.

Update: the face data is also correct. So I'm probably doing something wrong when trying to use vertex arrays...

Update: figured out my problem. I was using the "firstVertex" value as if it were a byte offset into the vertices, when it was really saying "the n-th vertex". I.e. I had to multiply it with the size of a vertex to get the real offset in bytes. So now it's looking much better... except for the psychedelic colours. :-) That's not a mistake though. I'm just not using the textures yet.

PS. This tutorial is quite helpful if you're considering of trying this for yourself.

2 comments:

Unknown said...

What are you using for the rendering, JOGL, LWJGL, something else? Just curious as I've chosen JOGL myself and wondered if it's the 'right' thing to do ;-)

KrisDS said...

Right now it's only JOGL. I also have bindings for LWJGL and GL4Java though. Both are currently "broken" as I haven't updated them when I upgraded to Snow Leopard on my machine (basically, the native binaries are out of date). I'll fix LWJGL, but I think I'll throw out GL4Java. It doesn't work with nio.Buffer, which is a pain when playing with vertex arrays. You want to be able to address an array from a certain offset, and pass it around as just another array. I.e. in C: &array[offset] (note the address-of operator). Java arrays don't allow that, nio.Buffers do (slice operation). You also want to mix and match bytes, ints and floats in your array. Again, you need nio.Buffers.