Saturday, March 30, 2013

[OpenGL] glShadeModel

[Reference] The OpenGL SuperBible


"The other shading model that can be specified with glShadeModel is GL_FLAT for flat shading. Flat
shading means that no shading calculations are performed on the interior of primitives. Generally,
with flat shading, the color of the primitive's interior is the color that was specified for the last
vertex. The only exception is for a GL_POLYGON primitive, in which case the color is that of the first
vertex."

使用 glShadeModel() 可設定三角形或多邊形內部顏色的著色方式,有二個可使用的參數 GL_SMOOTH 和 GL_FLAT。
GL_SMOOTH 將三角形或多邊形的各個頂點的顏色加以計算,於其內部漸層著色。
GL_FLAT只取用三角形或多邊形單一頂點的顏色作為其內部的顏色。在三角形取最後一點的顏色,多邊形則取用第一點的顏色。

Friday, March 29, 2013

[OpenGL] Lighting

[Reference] The OpenGL SuperBible
OpenGL 提供許多關於顏色、材質、光、影的功能。內容很多,慢慢添加。

從開燈開始:

01: glEnable(GL_LIGHTING);   //開燈


// Bright white light – full intensity RGB values
02: GLfloat ambientLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };

// Set light model to use ambient light specified by
// ambientLight[]
03: glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambientLight);


第 1 行開啟光源。

第 2 行設定環境(ambient)光源的顏色及強度。環境光是從各方向均勻照向物體的光源。 
4個參數依序為 RGBA。值域為 0~1,數值愈大則物體愈亮,預設值為(0.2, 0.2, 0.2, 1.0)(很暗)

第 3 行將環境光源的參數代入 OpenGL。

若未使用第 2, 3行則表示使用預設的環境光源參數。難怪,只開燈而未設定其他燈光參數時,物體變暗。因為這裏設定環境光源為白色,開燈後物體呈現灰色。

(再來, 設定材質, 或用 glColor )

Thursday, March 21, 2013

[OpenGL] Display List, Vertex Array, Vertex buffer object (VBO)

Reference: http://www.songho.ca/opengl/gl_vbo.html
Reference: http://www.gamedev.net/topic/487333-glgenbuffers-vs-glgenbuffersarb/

"Using vertex array can reduce the number of function calls and redundant usage of the shared vertices. However, the disadvantage of vertex array is that vertex array functions are in the client state and the data in the arrays must be re-sent to the server each time when it is referenced.
On the other hand, display list is server side function, so it does not suffer from overhead of data transfer. But, once a display list is compiled, the data in the display list cannot be modified.
Vertex buffer object (VBO) creates "buffer objects" for vertex attributes in high-performance memory on the server side and provides same access functions to reference the arrays, which are used in vertex arrays, such as glVertexPointer(), glNormalPointer(), glTexCoordPointer(), etc."

Vertex Array: 資料存放在 Client 端, 每次畫圖時要傳送至 Server 端。可修改資料內容。
Display List: 資料放在 Serve 端(執行較快)。但不可修改資料內容。若要修改, 則必須重建 Display List。
VBO:同時兼具 Vertex Array 和 Display List 的優點。資料放在 Server 端,而且可修改資料內容。

OpenGL 1.4 版(含)之前,VBO 是 OpenGL 延伸功能 (GL_ARB_vertex_buffer_object),相關函數名後面加有 ARB。

OpenGL 1.5 版(含)之後,VBO 是 OpenGL 內函功能,相關函數名後面不加 ARB。

Wednesday, March 6, 2013

Set Anyone (All users) radio button as default at Startmenu Dialog (InstallAWare)

1. At Dialog Editor, set Checked of [Anyone] radio button to "true"  and  [Only for me] to "false"
2. Creating Compressed Single Self-Installing EXE.
3. At Group Policy Wizard, use ALLUSERS=TRUE as command line parameter.
4. Create MSI from Group Policy Wizard.

Reference:
http://forums.installaware.com/viewtopic.php?f=2&t=3043


[Qt] 執行檔需要哪些 Dll?

 1. 使用 Qt  的 windeployqt.exe 工具 (在 C:\Qt\Qt5.14.1\5.14.1\msvc2017\bin\)。   a. 把執行檔 myProgram.exe 放在某個資料夾。   b. 在檔案總管這個資料夾按 Shift 和滑鼠右鍵,開啟 Po...