19 12月 2010

美味代價


週末的晚上, 真適合看綜合台節目, 
無意間轉到這部:『美味代價』, 
感動之餘 一看就是一個半小時, 
現代化的工業加工食品, 真的很恐怖, 
外加那些肉品養殖的過程, 實在是怵目驚心。

不管是演員之一的Michael Pollan, 
推動 Levin's Law 的媽媽, 
或是可怕的孟山都種子公司, 
都提醒著我們去回過頭思考現在的生活, 
是否失去了那股原始的單純 與健康.

Google了相關資訊一個鐘頭, 
原來這是一部電影, 
原來令人欣賞的Pollan是紐約時報專欄作家, 也是柏克萊教授, 

這部影片一個成功的地方, 
就是在片尾清楚的標示著:
請至
有此連結 才能吸收許多相關資訊 以及思考著現在的生活。

07 12月 2010

Thank you ~ Microsoft.


一封email, 一場收穫良多的經驗分享會.
最近, 在Volume Rendering中轉不出成果來, 
雖然每天很多點子, 卻覺得應該先把作品做出來,
才踏實。

第一次到台灣微軟總部, 很開心, 
主題是Windows Phone7的開發者經驗分享, 
雖然自己只是個門外漢, 
抱著小夢想去聽聽, 看看...

馬來西亞的陳先生, 
講話很快的TimLee教授, 
G-Fly很會演說的大老闆, 
嚴肅有料的Ken, 
時尚, 人文, 溫和的北京老闆...

很多很棒的人, 
今天的我, 很榮幸, 很幸運! Thank you, MS.

23 11月 2010

Big Step, the Phong Shading.

事隔多年, 終於完成當初未完的作業 Homework #02.
也太弱, 之前設定的5天一篇的目標, 一下子又到了月底,
日子過很快, 繼續把握時間!


Results: 
Flat Shading

Gouraud Shading

Phong Shading


當初一直看課本的內容, 在想要怎麼implement "自行內插出每個pixel的normal vector", 
然後就一直做不出來...
可能是當時做影像處理的職業病吧, 壓根沒想到原來是在vertex shader按照最一般的example codes即可 = ="
這個作業真的可以學到很多東西 (假設在過程中跟我犯了一樣多的錯 >.< )

1. 第一個, 也是最久的一個問題, 為什麼Shader objects的result通通只有一個顏色?
The answer is the "color tracking" skill ( glEnable(GL_COLOR_MATERIAL), glColorMaterial() ).
因為 Enable Color Tracking, we have to assign new color before each glBegin().
經實驗證明, color tracking在每個glBegin and glEnd中, 不會發生效用. It should be:
for(int i=0;i< int(TRIobj->triangleList.size());i++)
{
  glColor3fv(TRIobj->triangleList[i].color);
  glBegin(GL_TRIANGLES);

  for(int j=0;j<3;j++){    
    glNormal3dv( TRIobj->triangleList[i].normal[j] );
    glVertex3dv( TRIobj->triangleList[i].vertex[j] );  // assign array form 
  }
  glEnd();
}

2. 過程中, 因為想要對shader objects debug, 所以卡在glUniformLocation()一段時間, 最後才發現, 一直get不到location的原因是:The value of input uniform variables can't be changed during the shader objects.

3. 惰性慫恿我不需三個Lights都Implement, 反正搞懂GLSL了阿!...幸好, 在coding 後方的Light時, 光線一直"透到前方平面"來, 讓我這門外漢以為還有Polygon的透明屬性沒有設定好, 又K了一陣子書, 結論是:因為座標轉換的觀念還不夠熟, 所以透光的效果其實是因為在打光前, 座標已經被轉換到前方平面來了.

回頭想想寫這份作業的過程, 以及手邊記錄著思考過程的手稿, 這些那些, 都是永遠的回憶.
不只跨越了當年的失落, 更在過程中, 發現了大量的網路資源, 高手們的Blog...
最後, 更被前輩們的網頁所感動, 既然要留下這些學習過程, 網頁編輯的功夫怎麼能省,
於是, 花了幾天靜下心來, 學習一些基本的HTML and CSS語法, 東湊西湊, 就是你所看的這些 :D

11 11月 2010

Unable to load DLL, 因為應用程式的並列設定不正確.

Platform:  Visual C# 2010
Target Library: DLL file that build by VC++ 2005.

工作上, 因為要在 Windows Form上使用舊有的native C++ DLL,
花了好一段時間解這個問題.

其中當然包括上網Google "因為應用程式的並列設定不正確"這個字串, 然後試了一些
可能有用 卻無效的方式.
後來發現要debug, 還是少用中文, 因為中文的Error Message是:

Unable to load DLL 'ECGAlgorithmWin32.dll': 因為應用程式的並列設定不正確,所以無法啟動。如需詳細資訊,請參閱應用程式事件記錄檔,或使用命令列工具 sxstrace.exe (Exception from HRESULT: 0x800736B1)
然而經由最後一段代碼, 查得英文的的Message是:
Unable to load DLL exception. This application has failed to start because the application configuration is incorrect ...
所以一直被"並列設定不正確"所誤導debug方向阿 T.T"

最終找到一個非常有用的MSDN BLOG,

22 10月 2010

'GL_BGR' : undeclared identifier

During the implementation of homework #02, I think it's better to be familiar to Picture Drawing and Texture Mapping first.


When I use the GL_BGR in "glDrawPixels()", it appear this compile error from VC++.


Solution is : 
try GL_BGR_EXT if it still dosnt work, you need to download updated GLext.h files from SGI or nVidia/ATi devloper relations. 
 by Silvermace in the GameDev Forum.

Why did we need to use GLext.h???  The OpenGL Website says:

Core API and Extension Header Files
Because extensions vary from platform to platform and driver to driver, OpenGL developers can't expect interfaces for all extensions to be defined in the standard gl.hglx.h, and wgl.h header files. Additional header files - glext.h,glxext.h, and wglext.h - are provided here
Why  did we need to use BGR instead of RGB ??
Because the actual storage format of each pixel in Windows system is BGR, not RGB.
Just a debug record.
 

Let's get the show on the road.

The course is still there...
The homework is still there... 
Some years went past, and I'm ready to try it again.


When fell over on graduate school, 
I didn't even know what "runtime", "callback function", and "instance" is..
So rookie on programming, that's my second year to the software world.


I believe I CAN.
----------------------------------------------------------------------------------------------------


The homework: You are required to do the following things in homework #1: 



  • Load a 3D model file of TRI format.
    Draw it in wireframe mode and view it in perspective view.
     
  • You should provide object rotation mode and camera rotation mode, and implement basic transformations such as rotation, translation, scaling and shear. 
  • The camera (eye) can be moved around and into the model. 
  • Clipping is required. Try to show the difference between clipping and non-clipping. 
  • ** You can not use functions gluPerspective and glFrustum !!  
And the course website is here, Interactive Computer Graphics in National Taiwan University.   


Final, I complete the homework again. This time I did that after reading some chapters of several books, instead of just copy one example code content of some Chinese book.


------------------------------------------------------------------------------------------------
Post this article after the due date of the homework this year may be more appropriate. 
Hope this helps some people that hesitate to or shy of asking questions to TAs.

05 10月 2010

[Extract] set up environment for OpenGL and GLUT on VC++ 2010 Express

Those steps are extracted from the good blog Here! and Here!, written by Nafee M Sadh's.
Write records here just for fear that if the original blog is removed someday.


Key Steps to create Win32 console application:

  • Select "Empty Project" in the wizard dialog.
  • In the Project Property, Configuration Properties  Linker  Input, Type “opengl32.lib;glu32.lib” in Additional Dependencies.
  • For above step, remember to select the "All configurations" to set the debug and release environment at the same time.

Key Step to set up GLUT environment:


  • Download the original GLUT library from Nate Robins’ site. (for my case, the zip package will generate one .h file, two .lib files, two .dll files after upzipped.) 
  • put the files as below: (VS2010) ( I copy these three lines form the original blog..)
    glut.h to the folder C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\gl\
    glut32.lib to the folder C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\
    glut32.dll to the folder C:\Windows\System32\
Try it, and don't forget to visit the original blog for more useful information. :P