2015年3月5日 星期四

week02_測試OpenGL呂登祐

第2週

01.測試CodeBlocks的Open GL

1.open CodeBlocks
2.file > new project >Open GL Project >build and run

02.然後要寫今天的 GLUT

1.google: GLUT



2.google: freeGLUT >download the Download freeglut 2.8.1-1 for MinGW >解壓縮 > open CodeBlocks>file > new project



3.Open GL Project >複製libfreeglut.a(C:\Users\USER\Desktop\freeglut\lib) >改名libglut32




4.按確定(in the CodeBlocks) >finish >build and run





03.打5行程式碼




 #include <GL/glut.h>  ///呼叫GL/glut的功能

 int main(int argc, char **argv) ///main()的參數,也可寫成int main(int argc, char* argv[])

{
    glutInit(&argc, argv);
    glutCreateWindow("林周罵尬李拚了!");  ///開一個glut視窗(小駱駝命名法)
    glutMainLoop(); ///glut的主要迴圈,卡住用的
}



04.再加打5行程式碼

#include <GL/glut.h>  ///呼叫GL/glut的功能

void display() ///用來畫東西的顯示函式
{
    glutSolidTeapot(0.3); ///用glut畫一個實心的茶壺
    glFlush(); ///把他沖出去(從記憶體把東西叫出來)
}
int main(int argc, char **argv) ///main()的參數,也可寫成int main(int argc, char* argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("林周罵尬李拚了!");  ///開一個glut視窗(小駱駝命名法)
    glutDisplayFunc(display);
    glutMainLoop(); ///glut的主要迴圈,卡住用的
    return 0;
}



05.利用剛剛的程式碼搬到 visual c++ 環境


1.下載 freeGLUT >Download freeglut 2.8.1-1 for MSVC >解壓縮到桌面(目前捷徑:C:\Users\USER\Desktop\freeglut\lib) >開啟 visual c++ >file >New Project C++主控台 >確定 >下一步 >把其他選項取消掉 >選擇空專案 >完成 >專案>屬性(或直接Alt+F7) >連結器 >一般>其他程式庫連結 貼上C:\Users\USER\Desktop\freeglut\lib>
2.把freefult.dll放到專案中






沒有留言:

張貼留言