Entries from August 2008 ↓
August 31st, 2008 — Nerdy Stuff
I’m currently planning on a career in games programming and was looking for some beginners’ tutorials in OpenGL using C++ and found a goodun over at code project. It’s a 3 part tutorial, and as I’m writing this the first two parts have been posted, complete with code and Visual Studio project files. As a relative beginner with C++ and a complete beginner with OpenGL I’ve found this fairly easy to follow. The code is pretty well commented, and the tutorial itself explains things clearly and doesn’t take too much for granted aside from a basic knowledge of programming/C++.
A trap for young players, there was a slight error in the code from the first part that caused the program to not shut down and stay in memory after the window had closed. Nobody else seemed to have this problem, and it could have just been me being difficult and using Vista. Nonetheless, if the code for part 1 hasn’t been updated, the fix is in the comments below part 1. Basically the main application loop did not clear the message queue with each iteration, only taking the first message. From what I’ve read on the issue this means that the WM_QUIT message sent from PostQuitMessage() is never received. This is because PostQuitMessage(0) sets a flag on the message queue which tells it to return a WM_QUIT message if the queue is empty. Obviously if the queue is never cleared, this message is never returned when the queue is queried for the next message.
If you have any problems with this, feel free to contact me. Happy coding!
August 18th, 2008 — Nerdy Stuff
Have you ever had one of those moments when you realise that something you held as a fundamental law of the universe doesn’t work the way you thought it did? Well I have, today in fact, while writing a batch script that needed to be aware of leap years. Multiple choice question (I promise it’s relevant), which of the following is a leap year: a) 1700 b)1900 c)both ‘a’ and ‘b’ d)none of the above. Correct answer: d). That’s right, it turns out that being evenly divisible by 4 isn’t enough to qualify as a leap year.
So, now that I’ve dropped that bombshell, who wants to know how to pick a leap year every time without embarassing yourself? Those of you with your hands raised can lower them and simply keep reading, because I’ll fill you in now. In plain English, a leap year occurs when the year is evenly divisible by 400, OR if the year is evenly divisible by 4 but NOT 100. Put another way, a leap year occurs every four years as you’d expect, except for the beginning of a new century, where a leap year only occurs if that year is evenly divisibly by 400 (e.g. 1600, 2000 etc.). A nice way to show this process is with the aid of a spiffy flow chart referenced in the about.com article I found today.
For those of you who might need to code this, the wiki article on leap years has pseudocode and C-style code examples of the algorithm. Furthermore, for those of you who might need to check leap years in a batch script, here’s a simple batch script to do so. In its current form, the script is called with the year you’re checking as the first and only argument, printing an answer in plain english before finishing.
@echo off
SET _year=%1
SET _bLeapYear=is not
::Check if the year is evenly divisible by 400
SET /a _modYear=%_year% / 400
SET /a _modYear=%_modYear% * 400
If %_modYear%==%_year% SET _bLeapYear=is
If %_modYear%==%_year% GOTO END
::Check if the year is evenly divisible by 4
SET /a _modYear=%_year% / 4
SET /a _modYear=%_modYear% * 4
If NOT %_modYear%==%_year% GOTO END
::Check if the year is evenly divisible by 100
SET /a _modYear=%_year% / 100
SET /a _modYear=%_modYear% * 100
If NOT %_modYear%==%_year% SET _bLeapYear=is
:END
echo %_year% %_bLeapYear% a leap year
As you might have noticed, I’m substituting the modulus operation found in most algorithms (including the ones on the wiki article) with a division followed by a multiplication. This is simply because batch scripts don’t have a modulus operator. For the mathematically curious, this works because we’re using integer arithmetic. For example, in a batch script, 2003 ÷ 4 = 500. As you can see, there is no remainder in the result. Furthermore, there is no rounding. This means that a ÷ b * b will only equal a when a is evenly divisible by b, or, a mod b = 0.
And there you have it, more than you probably wanted to know about leap years.
August 12th, 2008 — Nerdy Stuff
After my last post I might have left some thinking that the world of Quickr is all roses. Sadly this isn’t the case, as Quickr has a ways to go before I would consider it polished enough for prime time.
An example of an area where Quickr could improve is its “inclusion” of the Dojo toolkit. You’d think that ‘including Dojo’ woud mean that developers have access to it when customising Quickr. Not in my experience. I’ve spent hours trying to make a simple AJAX call with dojo on a Quickr page to no avail (if I’m doing something silly, let me know). After some digging around, it appears that the full framework’s there alright, but the version that’s referenced and used by Quickr appears to be a modified version that doesn’t offer all of Dojo’s core functionality. Include the full toolkit yourself and you run into more problems because Dojo is already running, and the second instance doesn’t seem to initialise. Life shouldn’t be this difficult.
Another example of where Quickr hasn’t quite hit the mark is the included wiki template. From a conceptual point of view, I’d go so far as to say it’s barely a wiki at all when compared to the likes of wikipedia. My biggest gripe with it would be the layout for wiki articles. Whenever you go to the home page for a wiki, it lists each page, with subsequent edits cascading below it like responses to a forum post. I don’t know where this design comes from, and I don’t know how this constitutes a wiki.
Finally, one of the most astounding omissions from a software house I’ve ever seen. The updates don’t have an installer. That’s right, in order to update Quickr, you have to manually copy and paste the new files into the system subject to the instructions in the MS Word document provided. I’m sorry, but that’s just pathetic. To IBM’s credit, it looks like the hotfix 19 will come with an installer, however, it’s hotfix 19. There should have been an installer with hotfix 1.
Well, now that I’ve bitched about Quickr after singing its praises, I hope I’ve offered a somewhat balanced view of it after my limited experience with it. Please note I’m fairly new to the world of Lotus, and even more new to the world of Quickr, so if I’ve gotten it all wrong, don’t be afraid to let me know. For those of you who want to see some more negatives, check out The Open Sourcerer’s opinion.
August 5th, 2008 — Nerdy Stuff
After spending the last few days looking into Lotus Quickr, I’ve developed a sense of restrained excitement at what the product can do. I’ll admit upfront that I wasn’t too impressed with Quickr or the accompanying Snapps templates when I began looking at them. I was starting to get the impression that this was an IBM branded blog/wiki combination with a few half-hearted apps thrown on top. I was wrong.
A senior consultant at work pointed me at a redbook for QuickPlace (Quickr’s predecessor) today and it has opened my eyes. For a start, it was nice to see some documentation on the features that make it more than an expensive blogging solution. Examples include the Lotusscript and Java hooks that allow you to build applications on top of the Quickr framework, and the ability to automatically trigger C DLLs in response to Quickr events. So it turns out Quickr is more than an uninspired blogging solution, it’s a collaboration framework that happens to give you blogs and wikis out of the box. I’m now working on a custom 8.1 theme for my company and hope to turn it into a full blown template (application) soon. Wish me luck.
August 4th, 2008 — Blog
Yes, I’m weak, I know. I’ve officially suspended working on my own, custom site. It was just too much work to get a back end that I’d be happy with in the time I have available, especially now that I’ve got new priorities. So, welcome to my wordpress blog. I know, it’s using a *gasp* generic theme, but I only set this up minutes ago. The fight hasn’t completely left me, one thing I am committed to doing in the near future is porting my theme to wordpress as much as possible so that it still feels like home.
So. What does this move mean to you, the nobody that reads the crap I publish? More posts! Now that I’m not focussing “web time” on developing a site, I should be posting much more often about the other crap I’m trying to do in my life… lucky you. To add to the ease of posting, there are numerous options that make posting from my iPhone even easier, so there’s now no excuse for a lack of content.
Now, I’m off to finish setting up, and then maybe sneak in another episode of Dexter before bed. He’s so dreamy…