07 7月 2010

little practice of two viewports

Practice of "Try this" in Red-Book chapter 3.

Target: 
Modify an existing program so that an object is drawn twice, in different Viewports.

Answer:
void reshape (int w, int h)
{
   glClear (GL_COLOR_BUFFER_BIT);
   glColor3f (1.0, 1.0, 1.0);
   
   glViewport (0, 0, (GLsizei) w/2, (GLsizei) h);
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity (); 
   gluLookAt (0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
   glScalef (1.0, 2.0, 1.0);      /* modeling transformation */ 
   glutWireCube (1.0);

   glViewport ((GLsizei) w/2, 0, (GLsizei) w/2, (GLsizei) h);
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity (); 
   gluLookAt (0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
   glScalef (1.0, 2.0, 1.0);      /* modeling transformation */ 
   glutWireCube (1.0);

    glFlush ();
}

Another amazing OpenGL project.

Again, after a hard and tired study, an amazing project will appear on my monitor, let me stick here and can't speak out how shock I felt.


This OpenGL project is made by Nate Robins. I knew this project from the so-called Red-book of OpenGL programming, OpenGL programming guide 7th edition.


How beautiful tool to demo some basic theories of OpenGL APIs, like transformation and lighting.



If you like OpenGL, just go to download and try it.
maybe you'll pronounce a voice of "WoW"..like I did few minutes ago.  :P

error: VS2005 MSVCR80D.dll

This isn't first time I run into this error: "can't find msvcr80d.dll" when I try to use the simple C code from books' author.
In the past, I only knew that came from IDE's version difference. But haven't tried to solve it. ( I use Visual studio 2005 )

I found the good solutions for this issue.   /* Original Post */

One of solutions I used and have proved it to be workable:
=> Change the project's location from FAT disk to NTFS.  

(Thanks the biggest NB company Q gave me a old enough NB with FAT disk.. :(  )

other solutions from the original website are as below but NOT be verified yet!!!
1.)  project properties-->manifest tool-->input and output-->Embed manifest--> choose NO.--> rebuild.
2.) manifest tool-->General Item-->Use Fat32 work-around-->YES.-->rebuild.

28 6月 2010

how to enable/disable drivers that with identical friendly names.

I am assigned to join a OEM project recently.
Target platform has 4 chips driven by same drivers.
So, all labels in the driver that we can check using Device Manager are almost identical.


How can I write a program to enable/disable those drivers without manual mouse control?


Answer is to use the devcon.exe from Windows Driver Development Kit (WDK) from: http://support.microsoft.com/kb/311272/zh-tw


In my case, the few different items between four drivers is the "Device Instance Path".
For example, 
PCI\VEN_1AF2&DEV_A001&SUBSYS_A0011AF2&REV_00\
4&2D325CF4&0&00E3
PCI\VEN_1AF2&DEV_A001&SUBSYS_A0011AF2&REV_00\
4&30419C1C&0&00E5


Checking the "Hardware IDs" and "Device Instance IDs" chapters in "WDK documentation",
you will find some definitions about which part called hardware ID and instance ID.
At the same time, type "devcon.exe help enable" in the cmd.exe to look how to use devcon.


Finally, in my case:
I use "devcon.exe enable @*00e3" (or use disable) to control driver with the batch file.


PS. this tool is only workable in Windows enrivonment, not under pure DOS.

19 6月 2010

something had remembered

也許是最近開始push自己紀錄生活 所以花比較多的時間看別人的blog、網路上的文章
想著這邊 那邊的差異

很多東西 剛看到的瞬間忍不住點頭 或心頭裡有句 "對 我也是這麼想的.."
可能記性不好吧 許多諸如此類的文字 感動 都無法一直記在腦裡

早上賴床時在想 如果每個人都有個習慣 把自己感動的片段文字記錄下來
也許50 100篇Blog 可以很快的讓人知道 你我的相似度

生活、職場、朋友間 有太多應付 或表面的東西 心裡偶而覺得 一種米養百種人
從認識到了解 從了解到認識 或許網路的抽想空間 可以顛倒一些既有的生活方式


昨晚睡覺前 本期商周網站的一篇 當超業好?還是主管好? 有這麼一段:

16 6月 2010

comparing is necessary

不管是最近的代工案子、或是無意間逛到的good blog
都深深覺得comparison不是壞事
有比較才知道自己的不足 看過別人的好 學起來 才會更好...

接觸到部門以外的事務 才知道其實我們還是很有一套制度的
免強可以算是比上不足比下有餘吧
雖然產品走向、銷售方面還有很大進步空間 但至少哪個phase該做到哪些事情
也都沒少過
嗯...我們算挺扎實的

接觸到真正好的blog 才知道什麼樣的版面讓人舒服閱讀 雖然沒有標準的逗點符號
仍然可以這麼棒
排版、照片、內容、流暢的敘述 都可以在這個棒球blog看到

模仿了他的blog寫法 不加逗點 挺有趣的
雖然還是沒啥料 只是寫下心情

25 5月 2010

SOP to Create Sample Programs of ICG

照著自己規劃的進度, 緩慢的進行ICG Study...
一段時間只唸內容文字,剛剛要Create Appendix A的Sample Program to Trace Code,
竟忘了最簡單的SOP, 有點Shock, 果然生疏不得
為避免將時間浪費在重複的錯誤中 寫一篇簡單的SOP給將來的自己

Target: Interactive Computer Graphics, A top-down approach with OpenGL (Forth Edition)
  1. Pre-set VS2005 Environment for GLUT.
  2. Create a Win32 Console App.
  3. In Wizard:
    Application Type-->Console Application
    Additional Options-->"Precompiled Header"
  4. After generating a buildable project, 將project_name.cpp的內容, 除了最上方的
    #include "stdafx.h"外,
    都用
    Angel's source codes to override.
  5. 最後視情況加上一些function需要include的library,
    例如:rand()需要額外增加 "#include <>stdlib.h
    "在#include "stdafx.h"下方
  6. If no error when you build the solution, the sample program is Ready.
Let's trace codes.

[補充] : 要use Angel's c file直接取代default的"int _tmain(int argc, _TCHAR* argv[])", 要記得在Project Setting裡面, 指定Unicode Character Set.