Tuesday, September 27, 2011

on BuffersObjects and hair pulling

So, tonight, I finally got the port of the second lesson to work. This was a tricky one. It has been a few days and I was getting some weirdly funny stuff going on in the last couple of days, that really brought to me the fact that I'm working with code wrapping around C native calls, and that OpenGL does NOT mess around!

Lesson 2 is about using VertexBufferObjects (or VBOs) to store the vertex information (position, colour, normal, etc etc) and then drawing the scene using those buffers. By moving the data to the VBOs, they are probably (depending on GFx driver) moved to the graphics card RAM, and hence, offer quite the speedup in terms or drawing. Also, as far as I can tell by looking at future parts of the tutorial, they would make life easier when importing in models generated from 3D modeling software, like Blender, which I think is inevitable if you ever need your game to include something other than triangles, cubes, teapots and chimps!

Getting the code to work however, was not really an easy thing. I am so far into the code right now, that when something goes wrong, I start to freak out and blame myself first. So I kept thinking it was probably the shaders from Lesson 1, or I had done something wrongly, but I guess it was just a case of too little sleep

Fast forward to tonight, when I've had a little bit better sleep than yesterday and a lot more time to pull my hair, and I've finally gotten the code to work. I also made sure I refactored it, and played around with it a little while, to make sure I got more confidence around it. I can now finally say, I know how to use VBOs coupled with shaders to get what I want onto the screen, at least, as far as what I want is a 2D polygon

Stay tuned till the next time when we tackle passing information to shaders whether varied or constant, which should demo how we can add custom colours and fog. Till then

No comments:

Post a Comment