1.上週作業互評、票選
2.清大學姊點陣畫法展演
2017年9月29日 星期五
2017年9月28日 星期四
Claire's Note #3
WEEK03
Topic:
- 上週作業互評、票選
- 程式技巧講解
- 3D Model
- Vertex Buffer/Vertex Array
A. 上週作業互評、票選
STEP 1: Open Moodle & Download Homeworks
STEP 2: Unzip & Choose 6 pictures
魏建新的第三週學習單
蒲立年的學習筆記 Week 03
HW1 編譯小小兵的程式:
Step 1:從moodle上下載學姐小小兵的程式(hw1.c/minion.txt)
Step 2:把minion.txt放到freeglut/bin資料夾裡
Step 3:開啟OpenGL專案,把學姐的程式碼複製貼上,並建立執行
完成!!
HW2
Step 1:從moodle上下載所需的檔案(足球模型、3D Explorer)
Step 2:安裝完3D Explorer並開啟,從3D Explorer開啟soccerball.obj
Step 3:儲存為.cpp
Step 4:選擇Sample APP
Step 5:由CodeBlocks開啟OpenGL專案建立執行,將不能編譯的部分隱藏
Step 6:在一次建立執行
完成!!
世弦 Week03
一、繪製小小兵
1.下載學姐的cpp 貼在上次的 glut 專案的main.cpp裡:
2. 並把minion.txt 放在 freeglut/bin 裡:
3. 並案F9執行:
二、 跑3D足球圖
1.下載 soccerball.obj 丟到3DExploration 並選存成 .cpp:
2 選sample app:
3. 丟到opengl 專案:
4. 執行:
肯尼斯的學習筆記 Week 3
學習學姐的程式
程式碼:
//Drawing funciton
void draw(void)
{
FILE *f;
float w, h, c;
float r, g, b;
float i, j, x, y;
//Background color
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
//Read pixel file
f = fopen("minion.txt", "r");
//Read width, height, channel
fscanf(f, "%f %f %f", &w, &h, &c);
//Set point size
glPointSize(10.0f);
//Begin drawing
glBegin(GL_POINTS);
for(i=0; i<w; i++){
for(j=0; j<h; j++){
//Read r, g, b
fscanf(f, "%f %f %f", &r, &g, &b);
//Geometric transformation
x = -(i-(w/2.0))/(w/2.0);
y = (j-(h/2.0))/(h/2.0);
//Draw(in python, read as bgr)
glColor3f(b/255.0, g/255.0, r/255.0);
glVertex3f(y, x, 0);
}
}
//End drawing
glEnd();
fclose(f);
//Draw order
glutSwapBuffers();
}
//Main program
int main(int argc, char **argv)
{
glutInit(&argc, argv);
//Simple buffer
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE| GLUT_DEPTH);
glutInitWindowPosition(50,25);
glutInitWindowSize(300, 300);
glutCreateWindow("minion");
//Call to the drawing function
glutDisplayFunc(draw);
glutMainLoop();
return 0;
}
*將minion.txt放進freeglut\bin中
建立3D圖案的程式
1. 下載3D Exploration並安裝
2. 上網任意下載一個3D圖形 (https://free3d.com/),並在3D Exploration中開啟
3. 再另存新檔為cpp Open GL code類型,下一部的Export Type要設成Sample APP
4. 開啟CodeBlocks建立OpenGL project,再將cpp檔加入
5. 嘗試執行程式,會發生錯誤
6. 刪掉老舊的程式
7. 再次執行就會成功了
訂閱:
文章 (Atom)