soledad penadés
repeat 4[fd 100 rt 90]

Archive for the ‘linux’ Category

20080112 My first opengl program in Linux!

SDL and OpenGL playing nicely under linux

I had my first look at SDL some years ago, when Wing Extrem from Wildbits told me about a library which could work either in Windows or Linux and was very nice for making games. I remember that I managed to compile the .lib for visual studio but didn't manage to go much further.

Since then, I have been finding lots of projects which use SDL as their base, which makes them really portable across platforms, and I decided to have a more in-depth look at it this time, since there's no point in fighting the masses :-)

So I was toying with some tutorials, specially Sol's Graphics for beginners tutorials and the Me and Mark Publishing SDL and OpenGL tutorial and wondered if it would be possible to get the same main.cpp compiled and working on our ubuntu computer…

I had absolutely no idea of how to get something compiled with SDL and OpenGL in linux; the last time I tried to compile a demo for linux it ended up being a frustrating experience which almost caused me a trauma, so I was slightly scared of trying it again. But I decided to go ahead since it was just a plain .cpp file!

Googled a bit and found an straightforward way of compiling:

gcc main.cpp -o main.o `sdl-config –cflags –libs` -lGL -lGLU

If that's not ridiculously simple you tell me what it is. In Mac, for being able to get a [Cocoa] window, you need to prepare a tedious series of files and Objective C wrappers, just for being able to open a window and having decent event processing. Thanks god the nice people from SDL provide some XCode templates for getting started!

Immediate conclusion: apparently it's easier to develop OpenGL stuff in Linux than in Mac, unless there's some hidden automagic going on without my knowledge.

Of course there are a couple of minor details; because this is a computer which acts primarily as a file server, we have never bothered to make OpenGL work and all that, and as a consequence, it doesn't have hardware acceleration. This forced me to comment out the multisampling part, or I would get a Couldn't find matching GLX visual error message each time I tried to execute the program. It's also reporting that polygon stipple is being done by software rendering, but at least it does it.

This has left me wondering why there's not more people making demos for linux. I still need to find out how it would work with more complicated code bases and things like cmake, but it looks as truly doable now that I managed to get my first program working. Hmmm…

Sources

Should you want to fully experience the 0xFF00FF background plus a randomly noise-texturized rotating triangle, simply compile this little file and let yourself carried away :-)

20071231 Ubuntu and normal people

I have been speaking to some non-technical-at-all people recently about Ubuntu and its philosophy (and about the Linux and open source philosophy in general).

And I'm amazed at how enthusiastic they get about it!. They are really interested in the completely different approach that Linux takes; and instead of focusing in its technical merits (which is where discussions about Linux normally end up), they want to know more about who did it, why did they decide to give it for free, how can it have reached as far as Africa, what does Ubuntu mean, and if they are protected against code thieves.

Even more, they are truly surprised that Microsoft has allowed Linux to become what it is nowadays. And it's somehow shocking to see how what normally is a fuck micro$oft! attitude, becomes a fear of the uncertain terror attitude in non techie people. It looks as if they believe that we should ask for permission before doing anything in our computers or with our data!

I guess that's the ground which makes dead easy for our governments to sign up for exclusive contracts with Microsoft - if they are the owners of IT, what else are we to do?.

So if you want to promote Linux, do not focus only on how technically bad is Windows and how good is Linux, but give some clear background and speak about its philosophy in terms that everybody can understand - it makes a big difference.

Which terms?

There's no use in speaking about freedom of use and freedom of this and that (like the typical free as in beer vs free as in free speech comparison) - I personally didn't get the idea of debian until a few years ago, after having been bombarded by debianits about debian's philosophy for years too. I always thought they were bored and had chosen debian as their dissertation topic, a little bit like speakers at London's Speakers' Corner.

It's better to explain that linux lowers the entry barrier to computers, enabling people with limited resources to access the computing world, get a good knowledge about it and even contribute back if they can. And it is a nice story, which is not something that we are used to hear usually. They will get hooked by the sense of community which permeates the whole thing, because there are names and faces: Linus did this, Richard did that, that and that, then Amaya did something else, etc. We are not talking about a big ghostly corporation taking control of your hardware, but about the work of thousands of people helping you because they want.

After that, you can focus on technical differences, like better use of resources, stability, security, etc, but that's really secondary for them, because they normally don't appreciate performance differences and don't solve their IT problems either; in fact, it is you which has to deal with windows, windows virus, windows not wanting to update, windows having to be defragmented, windows complaining about authenticity, non valid operations and programs which close themselves, etc, etc.

OK, but did it really work? (with an skepticism tone)

Yes! I'll write about it later on, or maybe next year! :-)

Happy 2008 and don't drink too much!

20061215 How to set up the web server for working in a team

There are lots of urban legends around the intrincate complexities of setting up a web server in order to allow more than just one person to work with it. In fact, there are lots of bad habits, unfortunately very well established, like the "make your files writable == chmod 777 rule" which are just plainly Very Bad Ideas, and are also consequences of not understanding how things work.

So how do things work?

The main goal is to be able to add and modify files in the web server, regardless of which user does it. And the solution is just a combination of appropiate permissions and groups:

  1. Identify which user is executing apache in your server. For example, in an ubuntu machine it is usually www-data.
  2. Identify which users need to be able to read, write and delete files and directories inside the web root. For example, there could be a couple of users called foo and bar. Both need to be able to change files in the server, whether they were created first by them or not.
  3. Add foo and bar to the www-data group.
  4. For fixing possible glitches with permissions, do this:
  1. sudo chgrp -R www-data /var/www # change all the files' group to www-data
  2. sudo chmod g+w -R /var/www # allow people in the group to write to the files
  3. sudo chmod g+s -R /var/www # set the group id bit, so newly created files and folders inside the folders will inherit the group id of their container

Now, with this set up, everybody in the www-data group can modify stuff in /var/www, and newly created files will belong to the www-data group. And, of course, apache will be able to read and modify those files, so all should work nicely.

The only problem you can find is that when new files are created or copied they don't get the write permission for its group. A solution could just be to do a chmod g+w right after creating it (that's what I'm doing currently); advanced solutions will involve modifying the mask used to deal with files in the user profile.

Conclussion

As you see, this is a very easy process - it just requires a bit of attention to detail when setting up the server, and saves lots of headaches later. It is mostly useful for people with a dedicated server, or with an in-house machine, like the ubuntu box we have, where we can modify permissions, ownerships, groups, etc, at our will.
If you are in a shared hosting solution, I hope your hosting sets up things properly, so you will be able to avoid most of the cases where you need to do a chmod 777 in order to have apache writing stuff to folders that you, as a user, created. It is not that difficult, as you see!

Unfortunately most of the times they set things like this:

  1. apache is in its own group: apache
  2. user accounts are in their own group: foo
  3. stuff created by users, and the very folder for the user files, do not have the GID bit

So apache can read stuff which users upload, but it can't modify or write to those folders because apache and the user are in different groups. And the traditional solution is to give permissions to everybody. Which, if you have attacks like this one, may allow the attacker to modify the whole hosted tree, which proves that using chmod 777 systematically is a Very Bad Idea.

20061209 XSL with PHP in Ubuntu

XSL support in php5 is deactivated by default. Go to Synaptic Package Manager and search for php5-xsl. Mark the package for installation, apply the changes and once it's finished, don't forget to restart the server!

sudo /usr/sbin/apache2 -k restart
More XSL stories later on… time to experiment :)

20061011 Ubuntu and the demoscene

I was planning on writing this but trace was faster and posted some details on the wrong place - i.e. pouet's bbs, which has generated a lot of sceptic comments to say the least! Anyway here's a brief summary of what Mark Shuttleworth, the man behind Ubuntu, suggested past Saturday at Sundown 2006:

He basically offered the demoscene a new exposure channel so that we can get more people interested about it; this new channel would consist in replacing the usual boring boot screens with something a bit more funnier: a little intro!

While it looked quite cool it also was somehow vague and imprecise, as it happens always that someone gets such kind of ideas in new fields. But Mark explained that they weren't going to let developers/demosceners go in the wild, but instead work with them to define and provide a basic framework for exposing the available functionalities during boot. That framework may be extended and improved in the future, using the experience gained in previous versions, as any people with common sense can expect. So first versions would maybe just allow for software rendering but future ones could take care of any available hardware for accelerated graphics, for example.

On the other hand, he obviously agreed that there would be official intros, which would have the look and feel of the pertinent ubuntu distribution, but there would be open room for including lots of other contributions so that every person which installs ubuntu can choose which one does he like more. Even have a random one each time they boot… As he said, it means millions of people are booting ubuntu everyday. That's millions of hits for the demoscene. If this is not a way of promoting it in real geeky environments - and not the usual art & design environments which most coders feel annoyed at the mere thinking of, just stop reading this, go away.

There was also some more talk about how to implement it; the model that I understood they were proposing was simply to ask developers to create something which would get passed from time to time the current loading percentage, so that they could update the demo accordingly, just in case they wanted to show a "timeline" and not only a single nice effect, etc.

And there was also some discussion on how to add more scener content to places like the login screen - like some scenerish effect running in background while the computer is awaiting for a user to log in.

After Mark's presentation, Navis, Smash and xWize were talking for a good while with Mark but I don't know why I felt a sudden shyness attack and preferred to watch them and wonder what were they talking about :D
So maybe if they read this, they can provide us with the ultimate details.

In any case Mark said if anybody is interested, just drop him an email, I think he said mark at ubuntu.com.

I hope this helps a bit on the confusion which has been generated because of not having a record of the chat. I personally find this idea quite interesting, although I am not sure of being able to contribute until some kind of framework is there, but I'll try to keep updated on this topic.