2012年3月10日 星期六

Homework 1 -Hi my old friend OpenGL


Back to 6 years before, I took a class in my school call "3D max Design"

which is my first time using CAD tool

still remember I were running in 256~512MB Pentium 3 computers which usually lag and freeze....
after that class I left opengl behind... 


主題介紹

What is OpenGL? Why Glut?
OpenGL (Open Graphics Library) is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics.
Glut is a free utility which support OpenGL. There are different version which can finish your project or start your program in different OS, including Win, Mac, Unix, Android system.






程式設計與寫作方法、執行結果呈現
助教您好,程式利用不同函式庫,如在您電腦上跑不動,請直接找我!!!!!
Homework requirement:
  build a 2D model structure

Extra Finish part (Version alpha1):

  - C struct

  - 3D model structure
  -  lighting
  - special effect + depth of field effect
  -  auto 360 rotate

  - swap cache
  - Multithread in CPU
  - allow manual window resize

  - F1 fullscreen, Esc to leave
                    
 Demo Video of Version alpha1
(Ram used <19MB CPU usage<1% GPU used 7% @ Core 160Mhz & Ram 250Mhz )
                                         useage including "camera recording"
     Code line: 508 Finished in 10, March (one week before deadline)
      OpenGL3.2, Intel Q9450, Vapor-X HD 4850, 2GB RAM(only use 2GB for testing)


Coming Version: alpha2 already coding for few days
- C++ class & C struct

-
Multithread  Highly Anti-aliasing
- free move camera
- Fully Error message

- Lock Framerate
- stable & less memory allocate (spend me too much time on it)


- Minimize CPU&GPU usage(not finish)


心得與討論
The hard part of the homework is the structure part specially the stairs one it's not easy to make it connection well with other part


Dev-c++ ERROR LIST(which i face in developing my homework):
Problem 1 - MinGW
    If Devc++ library including MinGW(default set in Devc++ after you install it with MinGW)
    which will make an error say can't find function in MinGW
    to fix this go to compiler options -> Directories -> Libraries delete everything on the list
    which Force devc++ serach library in default directory

Problem 2 - Fail to upgrade devc++
    To solve thisdownload glut-src and copy files to /lib, it works
   Other way to solve the problem is to uninstall and then remove Devc++ and it directory
   but be careful!!!!!all you path such as libraries may go wrong or gone after you reinstall!!!!

problem 3 - Linker ERROR & std error & GLUT_ATEXIT_HACK error  &  In function `_mingw_CRTStartup': Linker Error........

    made you you got these in front of everything
    #include <stdio.h>
    #include <stdlib.h>
    #include <Windows.h>
    #include <gl/gl.h>
    #include <gl/glu.h>
    #include <gl/glut.h>
    #define GLUT_DISABLE_ATEXIT_HACK

    Everytime when you start new project
    Go to Project -> Project Options -> Parameter -> linker
    both works for C or C++
    copy the bold text and paste them to linker,  a space must between each linker
    check the all *.a file path in your hard drive before you add it!!!
    if compiler shows "could not find -xxxxx" means you didn't have the library file,
    wrong word or in a wrong directory...
   
    below are poplar  library using in OPENGL program
    -lglaux -lmingw32 -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32
    -lole32  -loleaut32 -luuid -lodbc32 -lodbccp32 -lglut32 -lglu32 -lopengl32 -lm -lwinmm -lstdc++
   
   extra library
   -lglew32 -lglew32s
    lib/libglu32.a     lib/libglut.a     lib/libglut32.a     lib/libopengl32.a

    if you using GLM  library plz add these


    if you using QT  library  plz add these
 

    if you using QGLViewer library plz add these
 

    if you using freeglut library plz add these
    lib/libfreeglut.a

    if you using sfml library plz add these
    -lsfml-graphics -lsfml-window -lsfml-audio -lsfml-system

    if you using SDL plz add these
    -lSDLmain -lSDL -lSDL_image

   Download libraries
  
GLM  library  http://glm.g-truc.net/    http://glm.g-truc.net/glm.pdf  

    QT  library    http://qt-project.org
  freeglut library http://freeglut.sourceforge.net

Problem 4-   [Linker error] undefined reference to `Initialize(GL_Window*, Keys*)'  or    [Linker error] undefined reference to `Deinitialize()'
   This is maybe not missing a linker is missing Initialize or Deinitialize function, those fuction must be inside your main.cpp not only .h

Problem 5 - Code are right compiler show Multiple Definition
  delete all .a and .o file compile again

Problem 6 - Code are right compiler show build error 1
  solve: remove the project create a new project and add the old files back,
  include a wrong linker may cause this problem

Problem 7 - glut32.dll missing when excult .exe file
   a easy way is copy glut32.dll from glut-src(download from http://user.xmission.com/~nate/glut.html ) and paste to same directory under .exe,  you can find the missing dll here http://www.dll-files.com/

Problem 8 -  only  this error message " .drectve `-aligncomm:"___hexdig_D2A",5' unrecognized "
   Ignore it your .exe file already compile

Problem 9 - error message "The procedure entry point glRotatef could not be located in the dynamic link  library OPENGL.dll (无法定位程序输入点glRotatef与动态链接库oengl.dll) " when execute .exe
    Check your linker in project option Delete this in the linker list -lglut, /lib/libglut.a and replace it with  -lglut32 and /lib/libglut32.a

Thanks for Google
hope Devc++ will have update which latest version is 4.9.9.2 release 7 years before...... :-(

8 則留言:

  1. could you send me the snaps of printscreen for your errors?
    maybe i had met them before.
    or have you got some help from my-sent rar package?
    contact way: s981454

    回覆刪除
    回覆
    1. Hi and thank you for your kind word
      those error 99% of them already solve before i wrote them in this blog
      the reason of errors are comes when i using other libraries
      you sent me package???
      did u sent to my school mail?? my school mail is sucks can't receive any mail from student

      i already finish this homework for a while...
      not sure if i have time to make it better
      but before this Sunday i will update this blog
      Plz come again and let me know how you feel about my homework!!

      THX again

      刪除
    2. A nice work indeed! I feel that your work has gone beyond 961461.
      My 1st CG work is really shallow comparing with yours.
      Ye, I sent you a package, which contains some useful materials.

      刪除
  2. appreciate for your support and kind word to me and my classmate
    I will check your package
    my homework 2 almost finish (i call it version alpha2)
    but see if i finish other homework
    if i have time i will update it to alpha3
    :-)

    回覆刪除
  3. 恭喜入選優秀作業!快到去年3D全滅一周年祭了。提醒一句,key lib和你的獨有程式,不要上傳到portal!今日此物是你的,他日突然被別人拿走了,比如被你的TA。
    陳相淳學長的部落格能引起蘇xp長達半年的胡言亂語,我不知道今年會怎樣。
    http://cs314s961461.blogspot.com/
    不過,如果沒有涉及智慧知識產權,上傳到有bug的portal,無妨啦。

    回覆刪除
  4. 如果是我的話,我認為不應該利用3Dmax
    他是用3D max call obj 做室內物體
    其實可以更快, 只要你找對室內設計的軟件
    軟件的物件庫就包括了全部要有的物件
    而學長在材質和燈光上可以做得更好

    所以我HW1 HW2是主要以技術為主
    因為比模型的話只要用CAD軟件一畫出來加一些燈光處理就不用玩
    但作為資工系學生來講, 用CAD畫出不應該是我們要做的那部份
    那些是給設計系的人來做

    ps. portal的設計是如果你沒有上載助教是沒有辨法輸入分數
    也沒法證明是誰寫的

    回覆刪除
  5. 但你給我網址中的作業的確看到很用心
    1411B的助教不少我也認識
    謝謝你經驗的分享
    其實這個學校的助教不是全部都黑心的
    也有不少很好和優秀的
    請你也明白,找助教不容易
    助教沒什麼利益又受學校,老師,學生的氣
    一邊也要趕着改退回的論文(每個助教都一定退了不少次)
    也要改很難看的考卷

    某一門課到期中考前一個禮拜才找到
    因為剛開始助教跟本不會用某系統
    試了很久也不會

    我相信老師也得知這件事
    因為他會看每一個人的blog
    每一個人都有他在生活中不愉快的事

    另外一點是,我不妨告訢你
    HW2 比 Hw1 很多部份是近加和重新設計的
    如果拿到我的hw1,亂改連compile都不會成功

    很抱歉是,你一直以來要寄我的email我看了很多次都沒有收到.......

    回覆刪除
  6. 不是吧,你沒收到email?我回校再發一次。我是高中學的flash mx 2004和VB。

    “但作為資工系學生來講, 用CAD畫出不應該是我們要做的那部份,那些是給設計系的人來做”你說的太對了,一針見血,看王老師再要學生用CAD建模,比如sketchUP和blender。王老師不要再因為CAD設計不好看不美觀的原因罵學生了,好嗎?

    “HW2 比 Hw1 很多部份是近加和重新設計的。如果拿到我的hw1,亂改連compile都不會成功”好!大贊!去年我在1411b見到了陳學長的模組,所以提醒一句。

    我加一句,“不要do like陳學長,這是侵權。爲了媒體安全,用開源模組做試驗。”

    1411B助教,除了姜和胡,我都認識,還有專題生和1411A。爲了不讓學長們繼續被誤導被拉入美工深淵,最後發生意見不一,反目成仇,我很無奈。最後的意見不一,是由於3ds max,我沒法阻止蘇op繼續3DS。3ds讀檔頭文件早就有了。
    CG助教改程式和部落格的過程,你去看看,偷偷去,XD……

    你現在的狀態和我去年一樣,為助教說好話。我承認黃毅然老師的助教真的很好,很貼心,不干涉分數,不誤導學生。去年我聽到別人說蘇助教的xx話,還有前人對1411b的酸話,也是這樣的想法,“也許他很忙,他不喜歡人工智慧,更喜歡圖形圖像處理吧,他對我還真熱心呢,是個好人。”“他們很耐心的解答我的對圖形學的疑惑,雖然他們連計圖題目都看不懂。”你說的很對,如果是助教很苦的話,蘇o平去年的行為的目的是支開學生,拖延時間。
    我喜歡美術,擅長速寫,雕塑很爛,對CAD無能。我不是美術全能。王老師去年從4月一直罵我罵到6月8日,罵爲什麽不把貼圖弄好看,貼對位。我實力不夠,不會做單貼圖。不會做單貼圖,逼我罵我,我還是弄不出能讓王老師滿意的資深建模師美工級別的校園導覽系統。
    王老師在課堂上酸美工職業,抬高程式員的地位,我忍了,我的美工朋友如果聽到王老師的話估計會非常生氣。王老師卻讓學生做美工做的事,他知道我們建模有多辛苦嗎?建模占10分,還算做點名。。。GLM就隨意讓他的蘇助教在portal上亂扯淡,學生搞不出來就怪學生太蠢, 他真的看了portal和部落格?我覺得他沒有看,流量不對。他看了,卻沒有發現上面的所有學長都看出的錯誤,間接證明他沒有看991和992的portal和部落格。

    蘇o平胡言亂語,不負責任的拿出sketchUP+glm,我忍了。蘇o平對學生提出搞笑的寫程式的需求,忍了;pick selection mode是錯的(glPickMatrix(),看redbook pick&selection chapter),忍了;誇大GLM與貼圖,忍了。到最後還要把學生誤導去3ds,忍。我按照他的放在portal上的GLM提示去做,死路,7月1日去問他這件事,我被當垃圾一樣的趕出實驗室。助教資質都成問題,還不如像其他教授一樣不要助教,比如黃o然老師。

    當年你在多好。2011年5月18日,我知道這樣走不通,就我一個人,不能說服王老師和蘇o平,我是做2D動畫和手繪的,抗議無效,沒有人相信我,都擁去搞3D建模和貼圖,連讀模組的優化程式都寫不出來,建立出模型又有何用?1館模組面數3000多,真三國無雙6的典韋模組也是這個數量級,GLM 讀不進來,當然報錯。

    回覆刪除