Tuesday, July 28, 2009

Sunday, July 26, 2009

Local "DOS" against the NVidia Linux driver

Because of a bug, I found out that looping on glClear causes very painful results with the NVidia Linux driver. It makes the desktop unusable, updating only every 2 seconds, and no events will reach any program. Only way to get out of it is to switch to a tty, then events seem to be transmitted, and the program will be exited. X crashed once when I switched to a tty, tho. Try out on your own risk.

EDIT: Warning: Seems that I didn't fix the bug in the program, so I got into the same situation again (however, my program runs a few gl statements in between every glClear) and the machine became so unresponsive that I couldn't even switch to a tty (had no second computer to ssh in with, that would likely have solved it). I repeat, run it at your own risk.

Here's a test-case:
#include <sdl.h>
#include <gl.h>

int main(int argc, char *argv[])
{
SDL_Surface *screen;
int i = 0;

SDL_Init(SDL_INIT_VIDEO);

screen = SDL_SetVideoMode( 640, 480, 0, SDL_OPENGL | SDL_GL_DOUBLEBUFFER );

glMatrixMode(GL_MODELVIEW);

while (1)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
SDL_Quit();

return 0;
}

Note that I am running a rather old version of the NVidia Linux driver, 173.14.09, they could very well have fixed this in newer versions.

Definition of brainlessness

1. glClear
2. glLoadIdentity
3. Switch to ortho projection
4. glClear
5. glLoadIdentity
6. Render everything
7. Swap buffers
8. Restore to viewport that was before switching to ortho
9. Swap buffers

Tuesday, July 14, 2009

Pocoproject

I stumbled upon this today, while looking for a platform-independent library to handle zip files:

http://pocoproject.org/

It appears to have quite a few more things that would be handy, like an XML DOM implementation, crypto routines (there must be hashing algos in there, right? I want those!), threading library and network programming.

I'll take a look on this, but it's possible that I will use it in a long-time project of mine: Nightfall, a free RTS game. See http://nightfall-rts.org/.

I'm currently using SDL and SDL_net for threading and networking, respectively, and I have my own tiny XML library (as I didn't want to drag in extra dependencies). SDL threading is not very advanced, and SDL_net doesn't support ipv6. The small XML library is quite limited.

Sunday, July 12, 2009

PHP and fgets()

In an attempt to mimic behaviour of fgets in C, it appears that PHP defines the $length argument as the number of characters - 1 that should be read.
The length argument to fgets in C includes the '\0', but PHP really has no reason to care about that issue.

Friday, July 10, 2009

Best slogan ever

http://www.fckeditor.net/: "FCKEditor - The text editor for Internet"

"Look, ma, I'm editing the Internet!"