Now that I am back in the world of full-time work, I have begun to think more seriously about my goals. One of my life goals, which I have recently decided are a superset of career goals, is to learn as much as possible. I have also decided that learning as much as possible is also a member of my set of career goals. To alleviate any confusion, I drew a Venn diagram summarising the situation.
As part of my new job, I am programming in C++ for a good part of each day. A consequence of this is that I am constantly learning new methods for writing and debugging C++ code, and programming in general. In an effort to document and share this knowledge, I’m going to start by telling you about
memset are two functions included in the C standard libraries.
memcpy is used to copy a block of memory from a source to a destination, and
memset is similarly used to set a block of memory to a particular value. While quite low level functions, these can both be very useful if speed is critical and you’re not working with higher level containers for whatever reason (yes, I know everyone says to use vectors if you’re not using straight C).
For the really geeky amongst you, here’s a pretty good article explaining some of the issues and approaches relating to floating point comparisons in C/C++.
On a side note, I’m almost done with my uni assignments for this semester. I’m hoping to post a few articles based on stuff I’ve encountered this semester once I get into exam period/holidays.
That is all.
If you’ve seen my last post, you’re aware that I’ve been playing with OpenGL and GLUT for a uni subject. As I like to straddle the OS fence and use a mixture of Windows Vista x64, Windows XP and Mac OS X 10.5, I like to have platform independent solutions to problems. The latest little issue I’ve come across regarding GLUT apps is that GLUT on the Mac has a different include. To include GLUT in a project for the mac, you must use the following:
In order to cut code that will compile successfully on either platform we can use optional includes with the
#endif preprocessor directives. Props to “kainjow” for providing this information in his/her forum post. Here’s how:
All this does is say “if we’re running on an Apple machine,
include GLUT/glut.h, otherwise
include GL/glut.h. Now to actually learn OpenGL/GLUT…
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!