27June2009

Blog Moved

Posted by legalize under: Administrivia.

After convincing me to use their site for a blog, XMission decided to remove all blog services about two years after offering them. So I have moved this blog to wordpress at the following URL:

http://legalizeadulthood.wordpress.com

All new blog entries will appear there. Eventually this URL will stop working. If I’m lucky they’ll map it with a redirect, but I wouldn’t hold my breath for that.

Comments Off 

29March2009

Angry White Dude on Borrin’ Orrin

Posted by legalize under: Politics.

Angry White Dude on Borrin’ Orrin. ’nuff said.

0 

26January2009

Why I’m a Libertarian and Glenn Beck is Not

Posted by legalize under: Politics.

A while back, cporter commented on my blog:

My only issue with voting Libertarian is its longtime identity with drug legalisation advocacy, and its public persona of anarchist-leanings. I feel that this makes a libertarian unelectable, and therefore a wasted vote.

Take a look at the collateral damage from the Drug War and tell me why prohibition such a good idea? Watch episode after episode of Gangland and tell me why prohibition is such a good idea? Drug prohibition is simply a failed policy. It always has been and always will be.

Ya know, recently the bankrupt economic policies of the Republicans have become so glaringly obvious that even Glenn Beck thinks he’s a libertarian. He’s not. No way in hell is he a libertarian, except a libertarian-of-the-moment or a libertarian-of-convenience-so-long-as-republicans-are-doing-something-stupid.

I’m a libertarian (and a Libertarian) because they stick to their principles and don’t pull their punches. They come right out and say the honest truth, and America could use a little more of that in their politics instead of endless “Slick Willie Syndrome” and “Bush Derangement Syndrome” tit-for-tat name calling and hatred that all too often passes for informed commentary in our political sphere.

Anyone can take a principled stand when its butterflies and lollipops all over the political landscape. The true measure of a man’s character is when he stands up for the things he believes in and knows to be right, even when they aren’t popular. Sure, standing up for the end of drug prohibition isn’t a popular stance, but its failure is glaringly obvious to anyone other than the blind. That’s the damned honest truth and its about time we faced up to it.

[Update: Dealing With Drug Violence in Mexico]

2 

19January2009

Direct3D Programming Tip #4: Check All HRESULTs

Posted by legalize under: Direct3D Programming Tips; DirectX; Programming.

Checking for errors is a good programming habit, but new programmers haven’t yet learned this habit. Most of the methods and functions you can call in Direct3D return an HRESULT, or a COM “handle to a result”, that indicates success or failure. Most of the time, your expectation is that these calls should succeed. This leads people to write “happy path” code that assumes that the call will succeed instead of verifying that it succeeded.

Use the FAILED and SUCCEEDED macros to turn an HRESULT into a boolean value that can be used in a conditional statement to determine the success or failure of any given HRESULT. Its not a good idea to compare the return value to specific failure codes because those failure codes may change and then your comparison logic will be wrong. The macros above tell you the general status of an HRESULT: success or failure.

Just as there are multiple failure codes that can be encoded in an HRESULT, there are also multiple success values. Comparing the result code to S_OK can fail for the same reasons that comparing the result code to a specific failure code can fail.

When programming in Direct3D, small errors early in the use of the device tend to manifest themselves as an incorrect rendering that’s only noticed much later after the source of the problem. If you check all your HRESULT values diligently, then you will be notified at the source of the problem and not later when the incorrect rendering is presented to the screen.

A failure to check the result codes of methods and functions is a common problem among beginning Direct3D programmers. It distracts them from the true source of the error. Checking the result codes diligently will keep you focused on the error when it occurs instead of having to backtrack in the debugger.

5 

11January2009

Direct3D Programming Tip #3: Use Smart Pointers

Posted by legalize under: Computers; Direct3D Programming Tips; DirectX; Programming.

Direct3D exposes functionality through COM interface pointers. Managing the reference counts on the obtained interfaces is a common problem for new Direct3D programmers. Managing the reference count on an interface becomes trivial if you use a smart pointer wrapper class, such as CComPtr<T> or boost::shared_ptr<T> and keep in mind the ownership policies established by the smart pointer class.

In addition to managing reference counts for you, smart pointers can make your code exception safe. When an exception is thrown, if an interface pointer is held within a CComPtr declared on the stack, then its destructor will be run when the stack is unwound. The destructor for CComPtr will call IUnknown::Release on any interface pointer it holds, thus cleaning up any locally obtained resources as the exception unwinds the stack to the nearest exception handler.

Read the rest of this entry »

5 

21December2008

Direct3D Programming Tip #2: Use the Documentation

Posted by legalize under: Computers; Direct3D Programming Tips; DirectX; Programming.

This is a programming tip? Well yeah, I’m sorry to report that often times its obvious from the questions people post that they either don’t know the documentation exists or they don’t use it. Personally, I don’t know how they can get anything done without the documentation. 3D graphics is hard! I put the shortcut to the documentation in my Quick Launch toolbar on the task bar:

  1. Click Start / Programs… and find the entry for the DirectX SDK.
  2. With the cursor over the DirectX SDK entry, right click to display the context menu and select Open
  3. While holding the Ctrl key, drag and drop the shortcut for the DirectX Documentation on the Quick Launch toolbar. A plus (+) sign should appear as you drop the shortcut to let you know that you’re making a copy of the shortcut and not moving it.

OK, now you’ve got the documentation at your fingertips ready to consult at any time. When I’m writing code that is talking directly to Direct3D interfaces, I usually leave the help browser open and just minimize it when I’m not using it. That way its only a quick Alt+TAB away while I’m coding.

Read the rest of this entry »

0 

21December2008

Refactoring: Finding Dead Code

Posted by legalize under: Computers; Programming; Refactoring.

There’s a “dead code” code smell mentioned in Refactoring. The refactoring is to delete the code. OK, easy enough to do. Over the years, I’ve identified a few handy ways of identifying the dead code laying around in your code base. That way you can ferret it all out at once and get rid of it. This specific example is for C++, but you can apply the techniques to any language.

Read the rest of this entry »

4 

1December2008

Application Installation and Patching Survey for Windows

Posted by legalize under: Computers; Programming; Windows Installer.

The Windows SDK blog is asking:

How should installation and patching work in future versions of Windows?

1 

26November2008

The Emperor Wears No Clothes

Posted by legalize under: Politics.

Here’s a sobering article by Michael Lewis about the financial bubble.

Yes, its long. Yes, it will piss you off when you read it.

Yes, it will cut through the veneer of bullshit being erected by the financial industry to claim they are not at fault for this fiasco.

Yes, you should be writing angry letters to Orrin Hatch (web site, contact) and Bob Bennett (web site, contact), your two bailout brethren, who voted to give these guys 700 billion of our hard-earned money, our children’s hard-earned money, our grandchildren’s hard-earned money and probably a few more generations after that, too.

Tell them how pissed off you are. Let them know that “politics as usual” with your money just isn’t acceptable anymore, no matter how much of a republican they claim to be.

0 

24November2008

White Paper about D3D WARP 10

Posted by legalize under: Computers; DirectX; Programming.

Andy Glaister at Microsoft has written a white paper about the Windows Advanced Rasterization Platform (WARP). For those of you interested in this new feature that appeared in the November 2008 DirectX SDK, check out this white paper as it is not included in the SDK.

0 

Browse

Calendar

July 2009
M T W T F S S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

Links