Leap second
January 3, 2006 on 2:14 am | In Computer, Linux | No CommentsLooking the syslog of my Linux box, I found the following entry:
Clock: inserting leap second 23:59:60 UTC
Setting raster position in OpenGL
December 1, 2005 on 2:18 am | In Computer, Graphics | No CommentsWhen writing an OpenGL application, there are many occasions you want to draw texts or pixels in a window. To do that, you need to set the current raster position in the window coordinates, and the following is a typical code to achive it:
void drawPixelsOnScreen(const int x, const int y)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, windowWidth, 0, windowHeight);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glRasterPos2i(x, y);
glDrawPixels(...);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
There are so many state changes involved in this code just to draw texts/pixels. However, I just found today that I can set the current raster position in the window coordinates with glWindowPos*() which is introduced in OpenGL 1.4. Then the above code will become:
void drawPixelsOnScreen(const int x, const int y)
{
glWindowPos2i(x, y);
glDrawPixels(...);
}
It’s much more simple. I should have known this earlier.
32bit pointers
November 15, 2005 on 10:16 am | In Computer | No CommentsWhen you’re writing low-level C/C++ code, sometimes you need to mark a pointer to a non-usable address to make debugging easier. Here are some of the possible markings I know of:
0xdeadbeef
0xfeedbabe
0xfeedface
There aren’t many words you can compose using a-f. I like the first one the most.
Update: The one I like the mose is 0xdeadbeef. 0xbadbeef and 0xbadbabe are not good examples because they don’t fill all bits.
Ken Perlin
October 20, 2005 on 3:56 pm | In School | No CommentsKen Perlin of Perlin noise fame came to the computer graphics class where I’m doing TA today. He talked about various stuff he’s worked on. You can look at his works by searching “perlin” at google and follow the top ranked link (this is what he said in class to get to his webpage).
Politics test
September 23, 2005 on 9:16 pm | In Politics | No CommentsI’ve taken a politics test. Here is my result:
| You are a Social Liberal (71% permissive) and an… Economic Liberal (38% permissive) You are best described as a:
Link: The Politics Test on Ok Cupid |
Swimming
September 21, 2005 on 11:51 pm | In General | 1 CommentAfter two years of break, I finally started going swimming again. A part of reasons I started again is that my LDL, a bad cholesterol, was over the optimal range when I took physical exam back in July. Since then I’ve been decreasing consumption of saturated fat, but obviously exercise is much better than diet. I try not to push my limit to swimming distance. I hope this strategy would work and swimming would be my life-long habit.
Assembly Code
September 10, 2005 on 9:06 am | In Computer | No CommentsI’ve been writing x86 assembly language code, and I’ve stumbled on a weird problem. When I run the code below on my Athlon box running debian sid, I get segmention fault. However, it runs fine on my old celeron box running debian sarge. If I define data in the data section, it runs on both machines. I tried assembling and linking this code using gcc by changing _start to main, and it worked. I have no idea why the code doesn’t run on my Athlon box. Could it be a bug in gas or ld?
.data
.text
.globl _start
_start:
movl $1, %eax # exit system call.
movl $0, %ebx # Exit code is 0.
int $0x80
ESR
September 10, 2005 on 1:15 am | In Computer | No CommentsEric S Raymond, a famous open source developer and advocate, got a job offer from Microsoft. As ESR says in his blog, it must be the funniest joke.
Car Battery
September 9, 2005 on 3:38 am | In Misc | 1 CommentI was going to school for a class on Tuesday. When I turned the ignition key, I heard weird clicking noise from the engine and my car didn’t fire up. Instantly I thought it must have been the battery that had gone bad, but at the same time I also suspected that it could be worse than that. To determine the severity of the problem, I came back to home and searched on the web about the noise. From the information I gathered, I concluded that just the battery had went bad. I also checked AAA membership benefits, but they just take my car to the closest service facility. So I turned to a custodian in my apartment and asked him to jump start my car. Fortunately he had a jumping wire and we connected each end of the wire to each car’s battery and I was finally able to start my car.
As a consequence of these events, I was in a situation to replace the battery as soon as possible. I wanted to go to Wal-Mart to buy a new battery and replace it by myself because I knew that batteries are cheaper there and it’s relatively easy to replace it, but my wife insisted on going to Pep Boys because if the engine stalled, no one would help us jump starting my car in the Wal-Mart parking lot. Finally I agreed with my wife’s idea and ended up going to Pep Boys. They charge only $7 for labor plus whatever the cost of a battery, so I asked them to replace it. While a mechanic was replacing the battery, he was struggling with getting the old one out for more than five minutes. Then he ended up replacing a connector to a new one. It was right to have a mechanic replace the battery.
It was a relly rough day, but I’m glad that I was not in a remote place when I had encountered the battery problem.
New Flat Panel
September 1, 2005 on 7:33 pm | In Computer | No CommentsI received a Dell UltraSharp 2001FP flat panel display. It’s an amazingly crisp and beautiful display. The screen is much bigger than my previous NEC monitor even though the increase in the size is just 1.1 inch because the size of an LCD palnel is measured only by the visible region, while a CRT monitor is measured by the diagonal length of the entire tube which includes invisible area. The resolution of the new LCD panel is 100 dpi which is 10 dpi less than the NEC monitor, thus I can use smaller fonts and they still look very nice. I also enabled sub-pixel rendering and fonts look even nicer. I really hope this LCD panel lasts very long.
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
