sweet dreams

For my last army service, I was ordered to Eschenbach SG near Rapperswil to help in an arsenal. It’s actually a long story, how it came to that. Compared to a regular service, it was very much relaxed. I could go home every night, which is quite nice, especially if you have a young family. So, every morning when I walked from the train station to the arsenal, I passed a carpenter which had a gorgeous beam bed on display. The beams had crack, and looked really old, but perfectly restored. It didn’t have a price tag, so I assumed it was expensive. And I was not in need of a new bed anyway, so I just remembered it, for when I would need one. That was three and a half years ago.

Our bed recently broke. No, it’s not because I grew so fat. People say, that the mattress and the slatted frame should be replaced after ten years. So it was almost in time. And now I remembered the bed frame from Eschenbach. They did not respond to my eMail, so I had a look around other stores and websites. I found out that these beam beds with cracks are trendy, and that they are mostly made of swamp oak. Finally I found what I was looking for at Möbel Riesen in Brunnen.

They didn’t accept BitCoin directly, so I had to convert the funds first. At the time, the excange rate on MtGox was a steady ten percent higher than with other exchanges. This was quite tempting, even though most people suspected liquidity problems behind the long delays since last summer. So I split the risk, and traded half through BitStamp, and the other half through mtgox. BitStamp was quick and reliable as always, while I still wait for the money from MtGox. Meanwhile MtGox filed for bankruptcy, and I might have to write that money off.

The bed frame arrived earlier than expected, while we had some trouble getting the mattresses and slatted frames in time. So we had to sleep in a funny arrangement for a few days. But now finally, everything is in place. The beams are actually quite heavy, adding up to about 250kg.

As I work in the development of the PointLine CAD, naturally, I was interested in a CAD drawing for the bed frame. The guy from Sprenger Möbel was very friendly, and sent me a jpg, telling me there are no CAD files, as he draws everything by hand.

accelerated ray tracer

In all the great online classes I attended over the last year, there was one topic missing. Finally I found an offering for a Computer Graphics class. After all, that’s the field I ‘ve been working in for the last five and a half years. The class is offered at edx.org and is from Berkley. It’s the first class I’m taking from edx, and the style of the class is comparable to coursera and udacity.

The first part of the class was concerned about OpenGL, and we implemented an interactive scene viewer. Although I didn’t work directly with regular OpenGL before, only with WebGL which is based on OpenGL ES, it was mostly repetition. But nonetheless it was good training for working with homogeneous coordinates and matrices with different orderings. For grading, we had to produce 12 screenshots from the same scene with different transformations. Once it was implemented I had only to change the order of some transformations to have all images correct.

The second part was concerned with ray tracing. Eventhough I was familiar with the basic concept, working with it was new to me. And in the class, we had to build a ray tracer from scratch.The theory sounded straight forward. But somehow I was not so lucky in implementing it. In every new part I made some silly mistake. I developed it not exemplary test driven, but with unit tests for every key part that I wanted to verify. With that in place I could usually find and correct the problem in time. For grading, we had to produce seven images. Continue reading “accelerated ray tracer”

cmake with MSVC

I have used cmake for a couple of years with my hobby projects, and I love it. It is a cross platform meta build system. Like with Qt, people tend to first think that “cross platform” is the main feature. But like with Qt it’s actually one great feature amongst many others. It brings so many advantages that I can’t even list them all here.  Since last week, we also use it for PointLine at work. While the process is straightforward on linux, there are some things worth mentioning when using it on Windows.

Finding External libraries

Cmake has lots of finder scripts for commonly used libraries, and they work great in most cases. But we want to have multiple versions of the same libraries side by side, and depending on the version of PointLine we develop for, use the appropriate versions of the libraries. To be precise, not just the libraries, but also the headers and debug symbols need to be present in different versions. And we want to be able to debug different versions of our product using different versions of the libraries, simultaneously on the same machine. Continue reading “cmake with MSVC”

Optimizing compile time of a large C++ project

The codebase of our PointLine CAD is certainly quite large. sloccount calculated roughly  770’000 lines of C++ code. I know, this is not a very good metric to describe a project, but it gives an idea. Over time the compile time steadily increased. Of course we also added a lot of new stuff to the product. We also used advanced techniques to reduce the risk of bugs, that have to be paid with compile time. But still, the increase was disproportionate. We mitigated it by using IncrediBuild. Just like distcc, it distributes the compilation load across different machines on the LAN. If I’m lucky, I get about 20 cores compiling for me.

About once a year, one of us does some compile time optimization and tunes the precompiled headers. I did so about three years ago, and then this week it was my turn again. Reading what I could find about precompiled headers on the internet and applying that, I could get only a small speedup, roughly 10%. So I cleaned up the physical structure of the codebase. Here are some things I performed: Continue reading “Optimizing compile time of a large C++ project”

OpenCL First Steps

There is an increasing noise about GPGPU computing and how much faster than CPU (even parallel) it is. If you didn’t hear about all that, GPGPU is about using the computer’s graphics card(s) to do general purpose computations. The key to the performance lies in the parallel architecture of these devices. From what I read, an average graphics card has 64 parallel units, but they are not as versatile as the CPU of which a typical PC these days has 4 cores. That means, if the task is well suited, it can boost performance significantly, but if not, it’s nothing more than a lot of wasted work.

So I wanted to see for myself. To get started I read the book “OpenCL Programming Guide“. It gave a good overview. But now it was time to give it a try.

Continue reading “OpenCL First Steps”

Rendering Text in WebGL

Just like OpenGL and most rendering engines that I know of, WebGL has no builtin support for text rendering. And on top of that, I can’t use the approach we use in PointLine at the moment. PointLine gets the outlines for the characters from the Windows GDI. So I was looking for something cross platform.

Searching on the internet there are two main approaches:

  1. Render the alphabet or the word in question to an image, and then use that image to texture some triangles.
  2. Trace the outlines of the characters and triangulate the polygons.

Although I prefer the second approach, I found an example of the first that looked simple enough on nehe. It was based on FreeType and for OpenGL.  I started converting it to WebGL, but it was not as easy as it looked. It makes heavy use of display lists which are not available in WebGL.

So I looked further, and found the FTGL library which is also based on FreeType. It sounded like just what I need, but for OpenGL. So, I extended the library to allow me to extract the triangles for processing in WebGL. I sent my patch to the FTGL developers and hope for inclusion.

Meanwhile I can render texts in WebGL with my modified version of FTGL …  of course it’s only so easy to do when using Wt::WGLWidget from the excellent witty library.

Here is my research prototype which now has text.

Here are the important parts of how it’s done with the modified libftgl:

Continue reading “Rendering Text in WebGL”

PointLineWeb research prototype

Google employees can spend 20% of their working time for their own projects. We at cubx (The CAD development department recently split from BORM) have now something similar. We get to spend every second friday afternoon for some projects of our own. The only restriction is that it has to do with computer graphics.

I chose a project that I had in mind for almost as long as I have been working for BORM. I wanted to run PointLine as a web service on a linux box. Wit the old core, that was so tightly tied to MFC, this would have been impossible. But the new unfinished core is designed to be platform independent. So, I took it as a base.

Some three years ago, I looked at vrml and x3d for the 3d in browser part. These standards didn’t have as broad support as I thought. You couldn’t do much without buying proprietary browser plugins. So I never made much progress on that. But then came WebGL. All mayor Browsers support it natively, and on top  of that, my favourite web application framework recently got a WebGl widget.

So far, my research prototype doesn’t do much, but I already learned a lot that I can also use in my everyday work. I gained a better understanding of rendering pipelines, learned about shaders and ray picking …

As a side project, I set up a jenkins continous integration server that compiles the project on ubuntu and windows after every commit. Additionally, I learned about CPack, so that the result of the jenkins build is a binary deb package ready to install.

You can see the web application as it progresses here:

http://webglcad.ulrichard.ch

Usually, I would also provide a link to the sources, but this is closed source, sorry…

Propagate deletion of C++ Objects

Last year, I spent some time rewriting internals of how groups are handled in our CAD software. Before that, groups were just to help with the selection of elements that belong together. The grouping was only one level deep, and the elements were organized flat on the document. All the calling functions had to uptate the relationships in the pointers and containers which were publicly available. This was a constant source of bugs and completely unsuitable for nested symbols that we wanted to import.

Continue reading “Propagate deletion of C++ Objects”