第一節未到
今日上課內容:
註冊、認識 github.com
更改 profile 的照片
新增 GitHub 的專案倉庫(類似雲端,但對於程式設計來說可以做更多事情)
(之後上課做的內容、自己做的東西,都可以把 CodeBlocks專案放上去)
如何上傳檔案:
在 2020graphics專案倉庫Add file
Upload files(檔案,目錄) commit確認
將上課做的week03-1、2上傳 GitHub 囉!!!
![]() |
week03-1 week03-2 |
如何做單位圓:
基本做圓型
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,0);///yellow
glutSolidSphere(0.5, 30, 30);//實心圓球 (0.5是半徑)
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week03-circle");
glutDisplayFunc( display );
glutMainLoop();
}
--------------------------------------------------------------
進階做圓形:
#include <GL/glut.h>
#include <math.h> //有用到數學、記得加
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,0);///yellow
glBegin(GL_POLYGON);//開始畫圖
for( int i=0; i<30 ; i++){
float a = 3.1415926 * 2 /30 *i;
glVertex2f( 0.3 + 0.2*cos(a) , 0.6 + 0.2*sin(a));
}
//使用迴圈以及三角函數等分的方式去畫圓,迴圈、等分越多次,越圓。ex:只分三次就只會形成三角形。
glEnd();//結束
glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week03-circle");
glutDisplayFunc( display );
glutMainLoop();
}





沒有留言:
張貼留言