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

本文介绍了OpenGL应用程序中GLUT库的初始化过程。通过调用glutInit函数并传递main函数的参数argc和argv,可以实现GLUT库的正确初始化。文章详细解释了argc和argv的作用及其在启动程序时的具体表现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

opengl_driver.h文件中:

kernel.cu文件中:

 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"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值