opengl_driver.h文件中:

一. glutInit(argc, argv); glut初始化API

kernel.cu文件中:

一. glutInit(argc, argv); glut初始化API

 glutInit(int *argc, char **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"

相关文章: