undefined reference to `gluPerspective‘ 解决方法

由于高版本的Opengl移除了gluPerspective函数,故需要自行编写该函数。
这里是一个由Copilot自动补全的gluPerspective函数,亲测可用。

void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
{
    GLdouble xmin, xmax, ymin, ymax;

    ymax = zNear * tan(fovy * 3.14159265 / 360.0);
    ymin = -ymax;
    xmin = ymin * aspect;
    xmax = ymax * aspect;

    glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}
  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
问题: undefined reference to `gluPerspective' 回答: 出现undefined reference to `gluPerspective'的错误可能有几种可能性。首先,gluPerspective函数的声明在GL/glu.h中,如果你使用的是mingW编译器,可能是因为在配置mingW时没有在环境变量中添加mingW中这个函数的链接库路径,导致gluPerspective只有声明没有reference。你可以尝试配置环境变量LIBRARY_PATH来解决这个问题。\[1\] 另外,如果你在高版本的OpenGL中使用gluPerspective函数,可能会出现undefined reference的错误,因为高版本的OpenGL已经移除了gluPerspective函数。在这种情况下,你需要自行编写gluPerspective函数。\[3\]我可以提供一个由Copilot自动补全的gluPerspective函数的示例代码,你可以尝试使用它来替代原来的gluPerspective函数。\[3\] 示例代码如下: ```cpp void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) { GLdouble xmin, xmax, ymin, ymax; ymax = zNear * tan(fovy * 3.14159265 / 360.0); ymin = -ymax; xmin = ymin * aspect; xmax = ymax * aspect; glFrustum(xmin, xmax, ymin, ymax, zNear, zFar); } ``` 请注意,这只是一个示例代码,你可能需要根据你的具体需求进行修改和适配。希望这能帮助你解决问题。 #### 引用[.reference_title] - *1* *2* [error: undefined reference to `gluPerspective@32‘ error: undefined reference to `gluLookAt@72‘ 的...](https://blog.csdn.net/Justice132/article/details/80653301)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [undefined reference to `gluPerspective解决方法](https://blog.csdn.net/qq_45434284/article/details/122203023)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wjh776a68

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值