Skip to main content

Posts

Showing posts from October, 2008

Queues with STL

In this project, I was requested to build an application to manage Queues (something like the ones you find when you want to view the latest Blockbuster movie). OK, It sounds simple, use a STL queue. Unfortunately, this is not the whole requirement. Being a graphical application, it requested to refresh the screen from time to time showing all the items in the queue. After some research I was not able to find a way to access elements inside the queue, only the Front and Back elements were accessible [if this is possible, let me know]. So, I had to take a look at other containers in STL in order to be able to get the functionality with good performance. I have selected 4 containers to accomplish this task : Queue (Only to measure it's performance), Lists, Vectors and Deques. All of them included members to work like Queues: - Queue: push(int), front(), pop() - List: push_back(int), front() and pop_front() - Vector: push_back(int), front() and erase(vector::begin()) - Deque: ...

code::blocks - OpenGL - SDL

After my previous post I decided to play with SDL and try to setup code::blocks with both OpenGL and SDL. I found it pretty simple (with code::blocks, so many things are easy, forget about gdb). Open your SDL project created previously, and set the link libraries as follow: (In case you are lost: project->Build Options->Linker Settings That's all, then you have to include the OpenGL headers or SDL headers: If you want to include only OpenGL files, you can do the following: #include <GL/gl.h> #include <GL/glu.h> SDL also includes a wrapper for OpenGL in the following file #include <SDL_opengl.h> Both should work with code generated by the Template. I have to stop here. If you need more information you can find several tutorials about SDL and OpenGL.