Pages

Wednesday, May 15, 2013

OpenGL 2.1 +.OBJ files

                                      <My land ahead>


I have been out of business for a long time, too long in fact, but I gathered all my strength and decided I still wont surrender , so I decided to take a few steps to continue with my project.

First thing I thought was I needed to improve my Opengl Skills, that involved:
  • Drooping my Opengl1.x skills ( forgetting all the immediate drawing stuff)
  • Start with at least Opengl 2.1 (vertex and fragment shaders, + working with VAOS)


I could have chosen Opengl 3.3 or even 4.3, but that would mean dropping support for a wide amount of persons including all the "vga integrated in the motherboard" + mac users, so Opengl 2.1 + shader model #120 was my target.

I started learning on "modern opengl tutorial sites" like:
  • http://www.opengl-tutorial.org/
  • http://ogldev.atspace.co.uk/index.html
  • http://arcsynthesis.org/gltut/
First dilemma I had  was which API could I use with Opengl, I could have used SDL, but that would mean switching to SDL2, then I had Glut, not for me!! finally I chose "GLFW": http://www.glfw.org/ which is basically a framework to use opengl + window management + keyboard + mouse input, everything simple and working on Linux /Windows /Mac OS/X isn't it nice?

So I went my way working on it until I had an idea about how to use basic functions, and made a simple class to load exported objects on "Wavefront .obj" format, the class is quite simple to use:

  • cobj myasset; //instance an object..
  • myasset.loadmodel("land.obj","map.tga"); //load the obj file + the texture
  • myasset.draw(MVP); //draws the object!
I think it's hard to make it easier to use ;) the result of my work:

                                   <Forgive me for the silly models!>

So I had an object loader, what now? I needed somewhere to place the models, that was my second dilemma: I have no artistic skill so how to make a map?...

-libnoise (http://libnoise.sourceforge.net/) came to rescue me.. again, I just recovered an old project I used to generate noise maps and made an exporter so I could write obj files with the noise map, that is basically an height map + a color map, after a few attempts I got it working, and I was able to load it into blender!!


 And, adding a model + a transparent sea texture I got the final result:

<back into the business again!>

I'm exhausted, but at the same time very happy, good things coming soon!