Sunday, April 8, 2007

Textures

The network part of this project has reached a satisfactory stage to me, it will require some more work later on when we need to implement the event handler properly and possibly in game chat. So today I set about getting some texturing working, and see if I could implement it into our engine.

First of all, I did a Google hunt and found a couple of different websites and tutorials, notably the one listed below is quiet useful for information, which lead me to the next one.

Java Tips - Other API Tips

NeHe Java Ports

Now, the NeHe examples/tutorials are famous for being great and well documented OpenGL tutorials that a lot of develops use to learn different techniques when developing in OpenGL. It was a blessing to discover that someone had ported all of the NeHe tutorials into a working version using JOGL.

I downloaded and picked apart lesson06 and lesson09. Lesson06 was a simple 3D spinning cube that had a png textured on all of its faces, whilst lesson09 used a single star texture and had it duplicating and moving around the screen to reveal a cool pattern (Its purpose was to demonstrate how to move bitmaps around the screen). Below are pictures of both of the lessons after I had typed them into Netbeans and ran them.

Textured Cube Example


Spinning Stars Example

Whist looking at these example's I discovered that they used a bunch of utility classes that seem to be very robust and reusable. I spent a good couple of hours looking through all of them and getting an understanding of how they work. I was very impressed at the structure they used and how easy it is to create your own JOGL project using it. So after I got my head around it I started implementing the basic Display utilities and also all of the texturing utilities so we could make use of them also.

After playing around for a while, I've got it successfully implemented into our current project. Nothing has changed visually just yet, but I did find one issue that I quickly knocked out. The existing GLDisplay class I am making use of now used an FPSAnimator which has a few more options than the standard Animator. It was limiting the speed of the frames and also causing it run slower than expected (40 fps). I found this odd considering the lack of rendering and processing that was actually required of the program, usually we would get around 800 to 900 fps with visual sync off. So I replaced the FPSAnimator with a regular Animator and everything is normal again. I might switch back to the FPSAnimator later if we find a better use for it, but right now I don't think so. Anyway I didn't get around to actually make the engine use any textures yet, only because we need to get what we have so far working and I can replace the primitives that we use now with textures very easily when the time is right.

I've commited all the changes to the CVS and left a few notes for Pete to read over while I'm not around. The good thing about using a CVS is that you can comment all your code and leave notes around everywhere and or little tasks/jobs for your partner.

No comments: