glutInit(argc, argv); glut初始化API
int main(int argc, char **argv){}
int argc 和 char **argv 傳遞 到 你的自定義函數,再傳遞給 glutInit()。
----------------------------------------
自定義函數:
void fun(int argc, char **argv,...){
glutInit(&argc, argv);
...
}
--------
int main(int argc, char **argv){
(void) fun(argc, argv,...);
...
}
這個函數用來初始化 GLUT 庫.這個函數從 main 函數獲取其兩個參數.對應main 函數的形式應是:int main(int argc,char* argv[]);
在這個部分我們將在我們的程序里建立一個main函數,這個main函數將完成必須的初始化和開啟事件處理循環。所有的GLUT函數都有glut前綴并且那些完成一些初始化的函數有glutInit前綴。你首先要做的是調用函數glutInit()。
Void glutInit(int*argc,char**argv);
參數:
Argc:一個指針,指向從main()函數傳遞過來的沒更改的argc變量。
Argv:一個指針,指向從main()函數傳遞過來的沒更改的argv變量。
opengl論壇給出的解釋:
Re: What are argcp and argv in Glutinit function?
argv is a pointer to an array of nullterminated strings, and argc says how large this array is.
Ther are automatucally passed to you when you start you program and enter main(). argv[0] is a pointer to a string which holds the name of the executable file, including full path. argv[1] is the first argument you pass to you program when starting it, and so on.
Like this:
c:\test.exe hello world
Then argc=3
argv[0]="c:\test.exe"
argv[1]="hello"
argv[2]="world"
總結
以上是生活随笔為你收集整理的glutInit(argc, argv); glut初始化API的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++中含义
- 下一篇: fprintf()中的stderr解析