Posts

Getting Started with Python

Reading and analyzing data from a text file: My gentle introduction to writing a Python script.  A script I needed to read in a log file and extract all inkjet printhead temperature values in Celcius recorded for the duration of the print run. Very simple.

Using FLTK in Visual Studio

Image
Note: for configuring FLTK in Linux environments, please refer to this post . 1. Download and extract FLTK For this particular install I used an old Visual Studio 2003 .NET version. Get the zipped file from the download section of Bill Spitzak's FLTK site. Unzip the file and place it somewhere suitable such as C:\fltk-1.1.10-source.

Getting Started with OpenGL for Windows

Image
For setting up OpenGL in Ubuntu Linux, please see this post , otherwise for Windows / Visual Studio environments, please use these following instructions: 1. Download the latest Windows drivers As stated on the OpenGLs wiki page , OpenGL more or less comes with the Windows operating system. You will need to ensure your PC has the latest drivers for your graphics hardware, however. Without these drivers, you will probably default to the software version of OpenGL 1.1 which is considerably slower.

The Big Three in C++

Constructor, destructors and assignment operators There is a rule of thumb in C++ that if a class defines a destructor, constructor and copy assignment operator - then it should explicitly define these and not rely on their default implementation. Why do we need them? In the example below, the absence of an explicit copy constructor will simply make an exact copy of the class and you end up with two classes pointing to the same memory address - not what you want.  When you delete the array pointer in one class for example, the other class will be pointing to memory to which you have no idea as what it contains. Consider the following example class which is used to house an array of integers plus its size. It is written in such a way as to guarantee a crash: [code language="cpp"] #include ,algorithm> class Array { private: int size; int* vals; public: ~Array(); Array( int s, int* v ); }; Array::~Array() { delete vals; vals = NULL; ...

Converting IEEE 754 Floating Point into Binary

This post explains how to convert floating point numbers to binary numbers in the IEEE 754 format.  A good link on the subject of IEEE 754 conversion exists at Thomas Finleys website . For this post I will stick with the IEEE 754 single precision binary floating-point format: binary32. See this other posting for C++, Java and Python implementations for converting between the binary and decimal formats.

A First Stab at boost::bind

Boost::bind is “able to bind any argument to a specific value or route input arguments into arbitrary positions.” It's a means of converting a function into an object that can be copied around and called at a later point, deferred callbacks for example.

Avoiding Memory Leaks using Boost Libraries

Using boost::scoped_array When we want to dynamically allocate an array of objects for some purpose, the C++ programming language offers us the new and delete operators that are intended to replace the traditional malloc() and free() subroutines that are part of the standard library :