2018年6月23日 星期六

Week02_潘羽哲

         主要是要了解argc和argv這兩個函式。
(1)打開OpenGL專案,匯入檔案freeglut


















可以得知
      argv是用來儲存在命令字元內輸入的參數
      argc是用來儲存我們輸入的參數有幾個
(2) freeglut-MinGW-3.0.0-1.mp的用法
     如下圖所示資料夾內的 freeglut -> bin -> freeglut.dll
(3)
將“ freeglut.dll”貼到GLUT專案資料夾-> bin -> Debug 內
  將路徑切換到GLUT專案 -> bin ->Debug 
輸入以下程式碼:
#include <stdio.h>
#include <GL/glut.h>///使用較高級的GLUT(OpenGL User Toolkit)
void display()
{
    glClear(GL_COLOR_BUFFER_BIT);///清畫面
    glutSolidTeapot(0.3);///大小為0.3的茶壺
    glutSwapBuffers();///交換double buffers來顯示畫出來的畫面
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);///初始Initialize你的glut參數設定
    glutInitDisplayMode(GLUT_DOUBLE);///顯示模式:double buffers
    glutCreateWindow("Week02 Hello World Triangle");///建立視窗
    glutDisplayFunc(display);///顯示函式display()用來畫圖的
    glutMainLoop();///主要的迴圈,用來控制程式

}
可叫出茶壺的圖形
加入下列程式碼可調整茶壺顏色:
1.
glColor3f(0,1,0);///RGB調整茶壺的Color
///Color3f 3表示3個參數,f表示float浮點數(0.0~1.0)

2.
glClearColor(198/255.0,128/255.0,192/255.0,1);///清背景顏色









沒有留言:

張貼留言