Transforms and colors
Doing some progress… There’s a fun part in this OpenGL nonsense… figuring out an API and getting stuff to work with it is like rediscovering 3d graphics and fast forwarding 10 years of learning!
First of all, got transforms to work:
First with glm, then I wanted to bring in my own matrix library, since I was worried about the right-hand/left-hand stuff of OpenGL/DirectX, and the negative Z…
The funny thing… I just dumped my functions in and they worked first try… Which is weird, everything I understood regarding OpenGL says this shouldn’t work, so why is it working?! From what I understand, the matrixes should at least be transposed before going in OpenGL (considering they’re generated for D3D). Of course, there shouldn’t be much difference between both APIs if we use shaders, since the operations done are math, not API-transforms, but I should need at least to negate the Z… Unless I’m seeing this wrong, and the whole “right-hand” thing of OpenGL is not imposed at an API level, it’s just the way most libraries are done in OpenGL, and in the end, the Z output of the vertex shader on OpenGL should be a [0..1] number, in which case all of my code should work…
Now, if that also applies to texture coordinates (coordinate origin is different on the APIs), I’d be a happy man…
If someone has an explanation for what I’m seeing, I’d appreciate it, since my own argument doesn’t convince me…
Also added colors to the triangle:
For this, I have two buffers (one for positions, one for colors), although I think I know how I’d do this with just one (still have to test it though), since that’s the way I usually do it on D3D… I actually like this way of doing things (and that’s how I initially did it on D3D), but there used to be a performance hit because of this (probably due to cache hits)… Nowadays, since most cards are fill-rate bound, and not vertex-transform bound, I doubt it’s such a big hit…
Finally, tested the Z-buffer, which worked perfectly first try!
Isn’t it wonderful you came to a game development blog to see a guy learning OpenGL? It looks very professional, no?
At the current rate, I think I’ll probably be able to start the actual game porting to OpenGL in 4 or 5 days…
Now listening to “Alpha Noir” by “Moonspell”
Link of the Day: When this goes up, everyone in the world has probably seen this, but it came out today as of the time of the writing… And since I’m such a huge fan, this really got me psyched!
Comment
You must be logged in to post a comment.