A (very simple) SDL Program

Filed under: Tutorials and HOWTOs by Hari
Posted at 18:10 IST (last updated: Wed, Jul 16, 2008 @ 20:43 IST)
Simple DirectMedia Layer (libSDL) is a cross-platform low-level graphics API that can be used to develop games on Linux. At present I find that it's one of the easiest among all the low-level APIs I've encountered to get a hang of and start programming.

Mind you, my first SDL program is very basic (as can be expected), but I guess many programmers will find that this is actually what is required to get you started on more involved graphics and game programming using SDL. I'm still playing with it a bit, but once I get around to creating a few simple programs with SDL it would be easy to build upon it.

Compared to the monstrosity that is DirectX (and which takes ages for you to understand something just to display a blank screen) SDL is a cakewalk. Python programmers will be interested in pygame.

Here's a very basic C++ program I wrote which just loads a PNG image (requires libsdl_image library as well as libsdl) and displays it in a window until the user presses the button 'Q'. It takes a while to poke around the documentation to understand the first few steps, but once you do that it's really easy. Those who've gone through any DirectX tutorial will realize that a similar program to display a bitmap or image using DirectX would require much more code.

For what it's worth, here it is:
#include <SDL/SDL.h>
#include <SDL/SDL_keyboard.h>
#include <SDL/SDL_keysym.h>
#include <SDL/SDL_image.h>
#include <iostream>

SDL_Surface* screen;

int main () { if ( SDL_Init (SDL_INIT_VIDEO) != 0) { std::cerr << "Cannot initialize SDL"; return -1; } atexit (SDL_Quit); screen = SDL_SetVideoMode (640, 480, 16, SDL_HWSURFACE); if (screen == NULL) { std::cerr << "Unable to set video mode"; return -1; } SDL_Surface* img = IMG_Load ("sdl_test.png"); SDL_Surface* img_format = SDL_DisplayFormat (img); SDL_FreeSurface (img); SDL_BlitSurface (img_format, NULL, screen, NULL); SDL_Flip (screen); SDL_FreeSurface(img_format); SDL_Event event;

while (1) { while (SDL_PollEvent (&event)) { switch (event.type) { case SDL_KEYUP: if (event.key.keysym.sym == 'q') exit (0); break; case SDL_QUIT: exit (0); } } } }

Commending ATI

Filed under: Software and Technology by Hari
Posted at 08:53 IST (last updated: Wed, Oct 29, 2008 @ 22:34 IST)
I have often criticized hardware manufacturers in the past for poor Linux driver support. In particular ATI's support for its video cards had been extremely poor in the not-too-recent past. However, all that is a thing of history now. I recently downloaded the latest version of the ATI proprietary driver and felt a bit apprehensive about how it would work, considering that I had the latest version of xorg and that I hadn't tried installing the ATI driver for a long time now.

What really impresses me is the improvements they've made over a period of time. Their latest driver supports all versions of Xorg upto version 7.0. The distro-independent graphical installer (which also has an option to create distro-specific package for the driver) works like a charm and the fact that there's very little manual tweaking now required to get 3d acceleration to work is something that comes as a great relief. And the fact that the installation of this driver no longer removes the older X configuration which assures that you can still use X and remove fglrx if things go bad. This is really something great. The other great thing about the installer is that it can also work in the command line without X as it comes with a ncurses interface too.

I managed to get version 8.26 installed on Debian etch. Obviously a couple of reboots are required for the 3d acceleration to be fully functional. Once for running aticonfig which creates the relevant ATI device section in xorg.conf and another for the fglrx module to load successfully thus enabling 3d acceleration. I don't know a way around the reboot since trying to insert the kernel module manually didn't work for me the first time.

To make sure that 3d acceleration is enabled after installation run fglrxinfo from a terminal. You should get this kind of message:
display: :0.0  screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: RADEON 9600 Generic
OpenGL version string: 2.0.5879 (8.26.18)
All in all, this has prompted me to make a blog post about Linux after a long, long time. More coming up! Watch this space. :)

Staff at TheAdminZone.com forums

Filed under: Life and Leisure by Hari
Posted at 20:12 IST (last updated: Wed, Jul 16, 2008 @ 20:15 IST)
I've just been appointed as a senior staff member at TheAdminZone forums. :)

Being appointed a moderator of a community of forum administrators is a special feeling. Hope I can do a good job of it now.

My articles at TheAdminZone forums

Filed under: Internet and Blogging by Hari
Posted at 20:35 IST (last updated: Thu, Oct 30, 2008 @ 08:12 IST)
I've not exactly been blogging actively, but I've been writing a few community articles on TheAdminZone forums. Mostly they're about community building and forum posting. Here they are:

How to leave a community or stop posting at a forum
Small community admin tips, tricks and solutions
Framing community rules - a guide

Update (more articles):

Influencing community behaviour by your leadership
Effective use of emoticons to handle online communication
The case against SEO - why social marketing is better for small communities

Feel free to leave your thoughts and comments. :)

Nearly a month and no post

Filed under: Bits and Bytes by Hari
Posted at 11:38 IST (last updated: Wed, Jul 16, 2008 @ 20:30 IST)
Almost a month has gone by and there has been no new post here. That's because I have been busy with my forum LiteraryForums.org. After converting to vBulletin (which is a great forum software, by the way) I have had a lot of other work to do.

I've now gone into a kind of non-technical phase. I'm still using Linux, but I am at a point where I'm more worried about what I do with the OS rather than be worried about the OS itself. Which means no more Debian or Slackware rants from me for a while. ;) A few people here might have also noticed that I no longer post on many forums like I used to in the past in line with my new policy online. In particular the biggest forum I used to visit regularly, LinuxQuestions.org, is no longer in my daily radar.

I had also written a couple of articles but I was not satisfied with the results and they remain as drafts. It seems that writing comes in patches and when you're with the flow of blogging, you tend to blog more freely. A month after a break from blogging, it's hard to get the engines moving again. There seems so little to blog about whereas when you're in the stream you write on almost anything under the sun effortlessly.

I should come back with the next category in the Top 50 Linux apps list soon. Otherwise the list might well remain unfinished.

Velu Naicker

Filed under: Artwork/Portraits/Caricatures by Hari
Posted at 18:47 IST (last updated: Fri, May 29, 2009 @ 21:24 IST)
Ok. A special cartoon corner. I was recently talking about my cartoon corner with my friends and one of them asked me if I could render Velu Naicker. This is the main character from the famous Tamil movie, Nayagan (1987) played by the renowned actor Kamal Haasan. For those who don't know what I'm talking about, here's the Wikipedia page for Nayagan.

So, here's my rendering of Velu Naicker in cartoon form! Enjoy...

Velu Naicker