如何用假参数初始化glut? [英] How to initialize glut with fake parameters?
本文介绍了如何用假参数初始化glut?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用opengl,使用GLUT和GLEW库为某个应用程序创建一个插件。
I'm using opengl, using the GLUT and GLEW libraries to create a plugin for a certain application.
这个插件不是一个简单的int main (argc,argv)。所以我不能将这些值传递给glutInit()。
This plugin doesn't start with a simple int main(argc, argv). So i can't pass these values to glutInit().
我试过这样:
glutInit(0, NULL); <--- Crash
GLenum err = glewInit();
但是当我试图调用glutInit我可以重建那些params一些如何,所以它不会崩溃,仍然可以使用Glut库..
But i crashed when it tried to call the glutInit() function. Can i reconstruct those params some how, so that it won't crash and still be able to use the Glut library..??
推荐答案
您可以这样做:
#include <GL/freeglut.h>
int main()
{
char fakeParam[] = "fake";
char *fakeargv[] = { fakeParam, NULL };
int fakeargc = 1;
glutInit( &fakeargc, fakeargv );
//...
}
注意这是一个丑陋的黑客。
but take a note that it is an ugly hack.
这篇关于如何用假参数初始化glut?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文