Direct3D Tutorial (2007)

•August 10, 2009 • Leave a Comment

Just some notes that I wrote in 2007 for my Direct3D shader kick start. I need to say the tutorial is already a bit out dated. I kept it here for my reference only. Please do not follow it if you are a newbie. :)

//———————————————————–
/* Author: Son Hua */
/* Date: 30/05/2007 */
/* How to create an empty template project for Direct3D programming */

If you’re a newbie in Direct3D programming, and if you’re looking for a step-by-step guide to create a framework project to use for your Direct3D programming homework, then this is for you! :D

First of all, you need to:
1. Install DirectX SDK
2. Install Microsoft Visual Studio 2005, with Platform SDK (which includes winmm.lib and comclt.lib, which is used by the common framework in DirectX SDK sample directory).

Visual Studio 2005 configuration:
You will have to do some settings for VS2k5 to automatically find header files and library files (.h, .lib) of Direct3D (d3d9.h, d3d9.lib or something like that).

Tools -> Options, go to Project and Solutions node, select VC++ Directories
Choose following items from the combo box on right top of the window:
Include directories –> Add the path to the Include directory in DirectX SDK installation folder.
e.g. $(DXSDK_DIR)Include
Library directories (.lib) –> Add the path to the Lib directory in DirectX SDK installation folder.
e.g. $(DXSDK_DIR)Lib\x86

Another approach is that you can set these options in Project Properties of a particular project, but then you will need to repeat this work every time you create a new Direct3D project from scratch. So do it once in the VS2k5 settings instead.

So that’s it.
Then you can copy the source files in the Common folder of DirectX SDK Samples into your project, modify any #pragma comment (lib, “…”) if needed (to refer to your necessary library, e.g. d3dx9.lib, d3dx9d.lib). Define any necessary constant if needed.

#pragma comment(lib, “d3d9.lib”) –> Link to d3d9.lib (static lib) when compile. You also can declare it in Project Properties instead using #pragma.

error LNK: 2019: unresolved symbols –> means that some static lib are missing. (Header files are included, but no execution code (inside the static libs) is found as the libs are missing). Using #pragma comment(lib, “…”) to link to more libs if needed.

Python SGMLParser and HTMLParser

•August 8, 2009 • Leave a Comment

Recently I started to make a small program that can help me pull out interesting parts of my often visiting news website. The program is written in Python 2.5 and I have derived my parser from HTMLParser in htmllib module.

However, the SGMLParser and HTMLParser are not perfect. It does not handle the “ ” entity reference and the character reference “&#val;” where val is greater than 255. So when I print out the literal data to the HTTP response, these characters are replaced with a strange question mark character like this (�).

Fortunately, it is not hard to fix this issue. Just override the entity_def table to add new entity references, and override the convert_charref and convert_codepoint function to handle character reference. Below is my fix.

#----------------------------------------------------------------
# Definition of entities -- derived classes may override
# Default SGML and HTML parser do not handle   entity reference.
# It is handled here.
entitydefs = \
{'lt': '', 'amp': '&', 'quot': '"', 'apos': '\'',
# custom entity ref handler
'nbsp': ' '
}

# Default SGML parser does not handle charref where the character value is greater than 255.
# It is handled here.
def convert_charref(self, name):
"""Convert character reference, may be overridden."""
try:
n = int(name)
except ValueError:
return
#if not 0 <= n <= 255:
#    return
return self.convert_codepoint(n)

def convert_codepoint(self, codepoint):
return unichr(codepoint) # unicode version of chr

Then everything is fine. :)

10,000 lines of code

•July 30, 2009 • Leave a Comment

An up coming challenge.

Did not pass two questions

•June 9, 2009 • Leave a Comment

I didn’t pass Database and Network. In deep depress at the moment. What’s going on? What is the main reason for this failure? Time! Yes, I didn’t totally pay attention to this module. Next semester, more time should be reserved to study this again! Life still goes on. Try your best and you will not regret that.

Daily News

•June 8, 2009 • Leave a Comment

Daily News

•June 4, 2009 • Leave a Comment
  1. GPU-accelerated WiFi password cracking goes mainstream
  2. Hierarchical Image Space Radiosity for Interactive Global Illumination (Eurographics 2009)
  3. Seadragon Mobile (iPhone app from Microsoft) uses iPhone GPU acceleration for large image browsing and zooming.
  4. Deferred Shading tutorial and implementation.
  5. Deferred Lighting (Light PrePass) in CryEngine 3.

Experience from CS6240

•April 22, 2009 • Leave a Comment

I’ve been trying out my best efforts in this CS6240 course project although I did not have a lot of time. I felt quite satisfied with my presentation preparation but it seems not running well when I present the work to the professor. No matter how I try, he kept asking me about those questions that I think it is really trivial to the way I’m doing the project. I’ve no idea what is going wrong. I’ve been working hard, and I don’t want to get a bad grade. But anyway, before you blame others, you need to look back at yourself. I drew out a couple of things after this project:
1. Do not try to reimplement other’s method, unless you are asked to do so in an assignment. Use your own method, even though it’s not so good. But it shows how independent you are from defining the problem, find an algorithm to solve, and evaluate the result.
2. Do not start your project too late that you suffer from the pressure of being late in the project deadline. It prevents your creativity.
3. You need to determine what you want to solve from the beginning. Do not try out a method and after that run tests to see how far this method can work, or how many tests it can handle. Instead, design a method that address a specific problem that you know well, and make the algorithm to address and solve that problem in the end. My experience: I implemented a method to transfer the style. However, I didn’t address any specific styles like water color, oil, pastel. I complete the implementation and then test what it can handle. This is not good for research (the professor told me that). Instead, address something like water color, and design your method to transfer good water color instead. This is far more better.

Finally, sometimes you get wrong, but do not give up. This failure is a good experience to a better work in the future. So do not blame the others, first blame myself and learn from it. The world is always interesting to learn about.  :)

Tile Studio, a very nice tool for pixel artists

•April 5, 2009 • Leave a Comment

I revisit Tile Studio again today after knowing about it a few years ago. Not many updates since then but I like the way this tool helps pixel artists, especially newbies, to draw more easily. Tiles of different size can be created side by side and then animation can be synthesized using key frames. Colors can be selected in a range to ease the shading. The darken/lighten tool make the lighting process, in case you do it manually, more easier. Darker and brighter colors are selected automatically. Last but not least, a small preview window at the bottom right shows how your tile looks when placing it on the map. A must-use tool for indie game developers.

Ubuntu Shortcuts

•March 28, 2009 • Leave a Comment

Ctrl + Alt + F1 = Switch to the first virtual terminal
Ctrl + Alt + F2(F3)(F4)(F5)(F6) = Select the different virtual terminals
Ctrl + Alt + F7 = Switch to current terminal session with X (e.g., go back to Gnome from terminal)

(from http://ubuntuforums.org/showthread.php?t=50794)

Alt-Ctrl-L Locks the screen.

Alt-F1 opens the Applications menu, then use the arrow keys to navigate the submenus.

Alt-F2 opens the Run Application dialog box.

Alt-F3 opens the Deskbar Applet (F3 opens the search bar at the bottom of the window).

Alt-F4 closes the current window.

Alt-F5 unmaximizes the current window (if it’s maximized, of course).

Alt-F7, followed by arrow keys or mouse movement, adjusts the current window’s position.

Alt-F8 resizes the current window.

Alt-F9 minimizes the current window.

Alt-F10 maximizes the current window.

Alt-spacebar opens the window menu.

Alt-Tab moves between open windows.

Ctrl-Alt-Tab moves between open panels on the desktop.

Ctrl-W closes the current window.

Ctrl-Q closes the current application.

Here are some keyboard shortcuts for working in the Terminal window:

Ctrl-C kills the current process.

Ctrl-Z sends the current process to the background.

Ctrl-D logs you out.

Ctrl-R finds the last command matching the entered letters.

Tab followed by entered letters lists the available commands beginning with those letters.

Ctrl-U deletes the current line.

Ctrl-K deletes from the cursor right.

Ctrl-W deletes the word before the cursor.

Ctrl-L clears the terminal output.

Shift-Insert pastes the contents of the clipboard.

Alt-F moves forward one word.

Alt-B moves backward one word.

(From Ubuntu Unleashed, http://www.ubuntu-unleashed.com/2008/02/list-of-ubuntu-keyboard-shortcuts.html)

[November 12, 2008] Ngày 12 tháng 11 năm 2008 :D

•November 12, 2008 • 3 Comments

Hôm nay thứ tư, ngày 12 tháng 11 năm 2008. Một ngày bình thường, tối về nhà sớm hơn 2 ông trong nhà, ở trường làm việc rồi, về nhà được nghỉ ngơi nên buồn buồn lôi cái blog ra update. ^^

Kể ra thì còn một tháng nữa thi JLPT3 rồi, mà giờ này còn 3 bài chưa học T_T, chưa luyện nghe, chưa làm sample test, chưa ôn hết ngữ pháp :( (, đã vậy cuối tháng còn ham hố theo mấy đứa trong lab wa Kuching chơi 3 ngày nữa. Lần này gan ớn luôn rồi, thi JLPT3 mà tèo coi như tốn mấy trăm k tiền đăng kí. :( ( Giờ chỉ ước, đi chơi về khỏi học bài mà tự nhiên thi đậu thì thiệt là khoái :) )

Dạo này ở Sing không buồn cũng không dzui. Ngày lại ngày, công việc một đống, mỗi ngày đem ra gặm một miếng, khi nào gần hết đống đó tự nhiên lòi ra một đống khác, làm suốt ngày mà không được nghỉ :( ( Mau mau qua tháng 12 cho con nhờ, mau mau tới Tết cho con nhờ, sẽ về nhà chơi, sẽ được nghỉ nửa tháng :) )

Hết tháng 12 năm nay coi như xong vụ tiếng Nhật đi, năm sau sẽ polish tiếng Tàu của mình lên cái nữa. Sẽ cố gắng cho cái english tiến thêm tí nữa, degrade quá rồi :(

Hè hè, phải đi tắm rồi. Đói bụng quá nữa. Đi tắm rồi đi nấu mì ăn :) )

Viết blog xong tự nhiên thấy yêu đời gớm. :) )