Code Blocks 茶壺 GLUT 程式碼
老師範例 ⏬
開啟Code Blocks > 輸入外掛標頭檔 #include <GL/glut.h>⏬
輸入茶壺的函式 glutSolidTeapot(大小參數); > 顯示圖形glutSwapBuffers();
輸入main函式 > 啟動顯示能力 + 3D深度
更改顏色函式 ( 需打在 glutSolidTeapot 之前 )⏬
glColor3f ( 255 , 0 , 0 ) ; //unsigned byte 格式 or
glColor3ub ( 0.5 , 1.0 , 0.2 ) // 3 個float格式
點線面色彩 GLUT 程式碼⏬
glVertex2f(1,0); //座標函式
彩色三角形
#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);
glColor3f(1.0,0.0,0.0);
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week03");
glutDisplayFunc(display);
glutMainLoop();
}

沒有留言:
張貼留言