DonAithnen (donaithnen) wrote,

  • Mood:

Stupid GL!

This is mostly just a rant about GL being annoying. However if any of the programmers out there happen to know/remember GL and/or general matrix math and have any bright ideas i certainly wouldn't mind hearing them.

I tried to get DirectX 9 working a few weeks ago, and i just couldn't get it to do anything with DevCpp. After giving up on that i decided to try doing something with OpenGL instead, since DevCpp comes with that already installed.

I used GL for graphics back in college and i still have the red book we used then, so i didn't think it would be too hard, and indeed it started out easy enough. I made a couple tanks and added controls so i could move the camera around to look at them from different angles.

So the first problem, which i'd been expecting, is that rotating and moving the camera are in relation to the world axis. As soon as you get the camera out of line of that it stops responding the way you would expect. I've been trying to find the equation for rotating a matrix about an arbitrary axis but haven't had much luck with that. The few webpages i've found suggest either using the DirectX function which does that (which i clearly can't) or something involving the use of the component Euler angles. Unfortunatly i have no idea what the best way to find the component Euler angles is, or how that would really help me figure out what x degrees to the left for an object at a random rotation was.

But anyways i finally gave up on the rotations, at least temporarily, and see if i could at least get translation working right. There should be a way to grab the camera's matrix so i could check the component parts to find out what's forward and what's up and etc. But if there is such a way i don't know what it is. So i figured that since i knew the rotations that went into it then i should just create a vector or two with the initial orientation of the camera and calculate it myself.

So i've written some matrix multiplication functions which should do the job, but i've now run into the most annoying problem. I can't find any bloody way to print error messages!

There's no text window, so i can't use printf. I seem to remember a way you could print messages to the debugger with Visual C++, but if DevCpp has that functionality i haven't figured it out yet. I figured that GL should have some way of printing text to the window, but it doesn't seem to. I tried looking at the font.c demo in the red book and that works fine as long as you're in ortho view, but as soon as i try it with gluPerspective it does nothing =P I could actually draw messages out letter by letter, but that would be a real pain.

The last and most perplexing problem i've run into recently is weird lighlting. I set up lights and material properties for the tanks and everything seemed to be working fine except for the specular aspect. I couldn't see any highlights on them, but i wasn't sure if that was just because they were made up of a few small flat polys or because the lighting was broken. So i tried drawing a sphere with glutSolidSphere. However as soon as i added that all the tanks turned a really dark grey that i can barely see unless i put them between the camera and the sphere. If i comment out that one line that draws the sphere then they all come back. It doesn't make any bloody sense =P


I kinda fixed one of the problems

I finally got the camera translation working properly. However in order to do so i had to write a debug function to print messages out to a file, which is just icky. It did help my figure out that one stupid mistake, but since i'm sure there will be more problems later i really wish i could figure out a better solution.

  • Rollerblading and (Not) Eating

    Since the 36 hour fasting last week seemed pretty easy i decided to try again with 48 hours, just because it seemed like a more even number. (And…

  • Recaps: Rollerblading

    Me heel turned out not to be as blistery as i thought, so i went rollerblading before trivia again last wednesday. It felt like i had a slightly…

  • Rollerblading

    I finally went rollerblading again yesterday afternoon, for the first time in over a year! I obviously couldn't rollerblade right after breaking my…

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.