1.week13-1_glm_gundam_keyboard_angleID_mouse_motion_angle
freeglut安裝
OpenCV安裝
重開CodeBlock,設定C-Setting的3個設定
--compiler的include要加入C:\OpenCV2.1\include
--linker的lib要加入C:\OpenCV2.1\lib
--linker設定,要加入cv210 cxcore210 highgui210
再把上周的week12-3_glm_gundam_keyboard_angleID_mouse_motion_angle拿來用
改檔名week13-1_glm_gundam_keyboard_angleID_mouse_motion_angle
開Notepad++改title成week13-1_glm_gundam_keyboard_angleID_mouse_motion_angle
把float angle=0;改成
"""cpp
float angle[20]={};
int angleID=0;
"""
2.week13-2_FILE_fopen_fprintf_fscanf 把week13-1複製整個目錄改目錄、檔案、Title名
要加FILE指標
"""cpp
#include <stdio.h>
FILE*fin=NULL;
FILE*fout=NULL;
"""
"""cpp
void motion(int x,int y){
angle[angleID]+=y-oldY;
oldX=x;
oldY=y;
glutPostRedisplay();
if(fout==NULL) fout=fopen("angle.txt","w+");
for(int i=0;i<20;i++){
printf("%.1f",angle[i]);
fprintf(fout,"%.1f",angle[i]);
}
printf("\n");
fprintf(fout,"\n");
}
"""
執行時,用mouse motion一邊改變角度,一邊大量產生角度值
小黑關掉後,可在目錄裡,看到angle.txt裡面就是剛剛印的一堆數值
小心,angle.txt裡面要有空格,不然就錯了。printf()及fprintf()要加"%.1f "
沒有留言:
張貼留言