使用SiftGPU遇到问题:freeglut ERROR: Function <glutDestroyWindow> called without first calling 'glutInit'.

1.问题:

        最近在配置SiftGPU(参见高翔博士的博客-SLAM拾萃(3):siftGPU)时遇到一个关于freeglut的问题:freeglut ERROR: Function <glutDestroyWindow> called without first calling 'glutInit'.

问题截图

2.分析:

       我看了下SiftGPU的源代码,在src/SiftGPU/LiteWindow.h中有调用glutDestroyWindow函数,但是在调用glutDestroyWindow之前已经调用了glutinit函数,和上面的错误描述有矛盾;

我暂时也不明白为什么会报这种错误。。。

3.解决办法:

        在google上找了很久,找到一个解决办法:

在调用glutDestroyWindow之前再调用一次glutinit,只不过glutinit的两个参数设为空值。

//修改前
virtual ~LiteWindow()    {  if(glut_id > 0)  glutDestroyWindow(glut_id); }
//修改后
virtual ~LiteWindow()   
    {  
        if(glut_id > 0) 
        {
            //添加以下三行,调用glutinit(),解决问题:freeglut ERROR: Function <glutDestroyWindow> called without first calling 'glutInit'.
            int argc = 0;
            char** argv;
            glutInit(&argc, argv); 
            glutDestroyWindow(glut_id);
        } 
    }
然后,问题就解决啦~

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值