glutInit(argc, argv); glut初始化API
int main(int argc, char **argv){}
int argc 和 char **argv 傳遞 到 你的自定義函數(shù),再傳遞給 glutInit()。
----------------------------------------
自定義函數(shù):
void fun(int argc, char **argv,...){
glutInit(&argc, argv);
...
}
--------
int main(int argc, char **argv){
(void) fun(argc, argv,...);
...
}
這個函數(shù)用來初始化 GLUT 庫.這個函數(shù)從 main 函數(shù)獲取其兩個參數(shù).對應(yīng)main 函數(shù)的形式應(yīng)是:int main(int argc,char* argv[]);
在這個部分我們將在我們的程序里建立一個main函數(shù),這個main函數(shù)將完成必須的初始化和開啟事件處理循環(huán)。所有的GLUT函數(shù)都有g(shù)lut前綴并且那些完成一些初始化的函數(shù)有g(shù)lutInit前綴。你首先要做的是調(diào)用函數(shù)glutInit()。
Void glutInit(int*argc,char**argv);
參數(shù):
Argc:一個指針,指向從main()函數(shù)傳遞過來的沒更改的argc變量。
Argv:一個指針,指向從main()函數(shù)傳遞過來的沒更改的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"
總結(jié)
以上是生活随笔為你收集整理的glutInit(argc, argv); glut初始化API的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++中含义
- 下一篇: fprintf()中的stderr解析