The website of Lei Chen

Sunshine and rain of a developer

Archive for the ‘Uncategorized’ Category

DirectX 10 DrawText Disable Depth Buffer. Here’s how to fix it.

Posted by hide1713 on July 6, 2009

DrawText() is a bitch. It changes device state silently.  You have to use a spirit to save the states before you draw it and reset depth buffer after you draw the text.


void cGraphicsLayer::DrawTextString(int x, int y,
 D3DXCOLOR color, const TCHAR* strOutput)
{
 m_pFontSprite->Begin(D3DX10_SPRITE_SAVE_STATE);
 RECT rect = {x, y, m_rcScreenRect.right, m_rcScreenRect.bottom};

 m_pFont->DrawText(m_pFontSprite, strOutput, -1, &rect, DT_LEFT|DT_NOCLIP , color);
 m_pFontSprite->End();
}

Here’s how to recover the depth buffer. You need to keep your DepthStencilState and set it with OMSetDepthStencilState


void cGraphicsLayer::ResetDepthBuffer()
{
 m_pDevice->OMSetDepthStencilState(m_pDepthStencilState, 1);
}

Good luck

Posted in Uncategorized | Leave a Comment »

System 6 Forever

Posted by hide1713 on June 28, 2009

sys6_1sys6_2

System 6 (also referred to as System Software 6) is a graphical user interface-based operating system for Macintosh computers. It was released in 1988 by Apple Computer and was part of the Mac OS line of operating systems. System 6 was shipped with various Macintosh computers until it was succeeded by System 7 in 1991. The boxed version of System 6 cost 49 USD when introduced.[1] System 6 is classed as a monolithic operating system. It featured an improved MultiFinder, which allowed for co-operative multitasking. The last version of System 6 was released in 1991.

Why system 6?

Macintosh Operating System 6 is probably the nicest operating system ever made. Nowadays it’s considered ancient (development stopped somewhere in 1991) but it’s far from backward and with the use of the proper vintage software you can be just as productive on a System 6 machine as you’d be on a modern Mac. System 6 runs on most older Macintosh computers with 68000, 68020 and 68030 processors. Some of these Machines are also able to run later versions of the Mac OS up to 7.55 and 7.61, but the lower-end models, most notably the so called Compact Macs, the Mac Plus, the SE and the Classic, and the lowend 68020’s, the Mac II and the LC, are better off running System 6. They will be a lot faster with System 6 than with System 7. The reason behind this is the fact that System 6 is not only a lot more compact (it has less features and therefore less code to crunch), but also because System 6 was written in assembly code instead of the high level language C. Assembly code is a bit lower level and because of that a bit closer to the hardware of the machine, making it a lot more responsive.

Read some more system 6 advocacy here

Link System 6 Heven

Posted in Uncategorized | Leave a Comment »

Will it blend? Iphone

Posted by hide1713 on June 18, 2009

They blend almost everything which that be put in to the blender

Posted in Uncategorized | Leave a Comment »

Use Python To Convert ASCII to UTF-16

Posted by hide1713 on June 17, 2009

Such an easy thing. But I took 1 hours to figure out.

import codecs
f=open(“wall.obj”,’r')
txt = f.read()
print txt
f.close()

of = codecs.open(“uwall.obj”,’w',’utf-16′)
of.write(txt)
of.close()

Posted in Uncategorized | Leave a Comment »

How to use C++ Sleep() function under Windows

Posted by hide1713 on May 28, 2009

If you want to sleep 1 second in your program, you should do the following thing

1. #include <windows.h>

2. DWORD dwMillseconds=1000;

3. Sleep(doMillseconds);

Posted in Uncategorized | Leave a Comment »

Good Writing Tips

Posted by hide1713 on May 1, 2009

I discovered this good writing tips in Randy Pausch’s website. He is the professor that I respect most. The paper is written by  Marc H. Raibert at January 1985 and the key ideas in this paper remain true today.

The full version of the paper can be found here. It is not very long, so you can read it within 10 minutes. I promise that it is worth your time to read it.  Here are the outlines of this paper

  • You must want to produce good writing.
  • You must have confidence that you can produce good writing.
  • Good writing is bad writing that was rewritten.
  • Spill the beans right away.
  • Don’t be a slave to your prose.
  • Outlining helps to get unstuck.
  • Husband your readers.
  • Trust your readers.

Posted in Uncategorized | Leave a Comment »

Test Post by ScribeFire

Posted by hide1713 on April 13, 2009

ScribeFire is a offline blog client in Firefox.

17 Again Movie Trailer – Zac Efron

Posted in Uncategorized | Leave a Comment »

Gnome Blogger Test

Posted by hide1713 on April 13, 2009

This is a test post of Gnome Blogger

Features:

* Clean interface doesn’t get in the way of what you’re writing

* WYSIWYG styled text support

* Entries can be written gradually over the course of a day, popping gnome blog open and closed as you have thoughts to jot down and then posting at the end of the day

* Operates as a panel object/applet or a standalone application

* Supports many different kinds of blogs

* New Spell checking

* New Drag and drop images into your blog entry (if your blog supports it)

Posted in Uncategorized | Leave a Comment »

Smart method to protect your email address from spam

Posted by hide1713 on April 4, 2009

Recent research shows that the old approach “somebody at yahoo dot com” can not protect you from spam.  Well. I have a good suggestion here

python -c “import base64; print base64.decodestring(‘aGlkZTE3MTNAZ21haWwuY29t\n’)”

This approach might raise the bar. However, eventually, spammer would calculate all base 64 string in a page

Posted in Uncategorized | Leave a Comment »

Responsible Behavior

Posted by hide1713 on March 30, 2009

Posted in Uncategorized | Leave a Comment »