Sunday, September 28, 2008

code::blocks and OpenGL

Last time I used OpenGL was in a University project. By that time, I had to connect using telnet (and xterm, I think, but I barely remember) to a SUN sparc station running probably Solaris. I remember it was really exciting being able to view those simple 3D models on the screen and running in real time!

Lately I was reading some DirectX 10 and sudendly I was wondering what happened to OpenGL? Did It die? Is it there any develoment going on? Surprisingly I found that these libraries are alive and well. It's been used in several platforms including the iPhone so ... you can imagine the future of a technology installed in more than 5 million of devices! (Also, this library is used in both PS 3 and wii (add some other million).

After this brief introduction I decided to build a program under linux, c++ and OpenGL. The IDE of choice Code::Blocks. I used this IDE to build an embedded application so I recommend it. It runs really well with no complains.

One cool thing I found is that Code::Blocks already includes templates to create OpenGL applications using GLUT or using OpenGL with direct access to the X windows libraries.

Now, let's go to the practice. Select File->New->Project. This will pop up the following screen:

OpenGL Library with X-windows access:

OpenGL project is straightforward. You only have to follow the wizard. The project will be ready and you will be able to run it immediately:

As you can see, the wizard is clear and people from code::blocks really did a great job! Below, you can see the simple program running. After finishing the wizard, I just hit F9, and Voila!

OpenGL Library using GLUT:

In order yo have GLUT libraries (and of course, the code::blocks template) you will have to install the following packages:

Installing libxxf86vm from synaptics package Manager

freeglut3 being selected in Synaptics Manager

Please note I have installed the freeglut version of GLUT. You can see in the screen above the following message: "This package has been replaced by freeglut3'. Hmm, It looks like there are some restrictions in the GLUT license. (and glut seem to be out of date).

With these packages installed you can run code::blocks and go through the GLUT wizard.

First step is to let code::blocks where is GLUT installed. Usually all installed libraries in Linux are located in /usr.

Follow the wizard to create your project. Finish it and hit F9. Again, you will be able to see this cool screen: solid and wireframe models.

And .. that's all by now.

ps. I also suggest using SDL (Simple DirectMedia Layer). This library controls also Audio and Keyboard. You should install the following libraries in order to have SDL applications working:

Wednesday, September 24, 2008

Web Browser memory comparison

That title may sound more detailed than it is. I just want to compare memory allocation from 3 popular web browsers I have installed on my machine: Internet explorer 6 (a little out of date), Mozilla Firefox 3.02 and Google chrome 0.2.
All of them ran under the same machine (Windows XP professional). In order to be fair, same web pages were loaded, chosen randomly: (A local news paper) (facebook? what's that?)

I have to say before comparing those applications that Internet Explorer was the slowest browser followed by Firefox. The fastest one, chrome, but I have to say that I just installed it so there are no historic information, cookies, plugins, etc.
Facebook did not run flawlessly in chrome, if you can verify, try to send a feedback. The "Send Feedback" link does not work in Chrome.
Aestheticaly (although I think is somewhat subjective) Chrome has a best GUI, it's clean and simple. Unfortunatelly, Firefox is the ugliest one (I think this is because its relationship with Linux. I love linux, but it's ugly).

Now let's see what Task Manager has to say:

The two screens above show the number of processes and memory used by the applications:

Chrome: 21,620k
Chrome: 28,588k
Chrome: 16,136k
Chrome: 21,140k
explorer: 31,044k
explorer: 32,664k
firefox: 56,952k

4 processes for Chrome? hm there's something to explain here .... Indeed, Google created a booklet to explain us, the mortals, why this memory eater software does what it does: [chrome]. Do you think they need to explain us that? Maybe I am wrong so I encourage you to post your opinions. Chrome will open a 20mb process for each page you want to visit. Anyway my system didn't seem to complain about that.

I didn't want to add Internet Explorer because this version is not Tab Based but I will keep it just as a comparison.

Firefox looks just better when checking the memory allocated for that process. It's smaller than Internet Explorer and there's a lot difference with Chrome (is it ok if I sum 21mb+28mb+26mb+21? It looks like a lot of memory).

Now, I will close each application:

This is the performance before closing.

After closing Chrome
After closing i.e.
After closing Firefox
Chrome PF Usage: 1.17 - 1.10 = 0.06GB
i.e. PF Usage: 1.10 - 1.06 = 0.04GB
Firefox PF Usage 1.06 - 1.01 = 0.05GB
You can also check the Total Commit Charge (That is, the virual memory used by the processes)

From these numbers I can say that Chrome uses more memory than the other two applications and, therefore it may slow your computer if you don't have enough phyisical memory. Maybe this can be a trade off between program stability and memory consumption. As you will know after reading the booklet, separate processes won't crash the whole browsing experience. Only the tab implicated may fail.

Finally I have to add that both Firefox and Internet Explorer crashes in my system about one time a week (not that bad).

p.s. Visiting Chrome home page I found that the latest version available is BETA although About box in my machine doesn't even mention that:, Official Build 1583.

Comments and corrections are welcome.