glWindowPos2i未在此范围中声明 [英] glWindowPos2i was not declared in this scope

查看:894
本文介绍了glWindowPos2i未在此范围中声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个OpenGL程序迁移到C ++。我有所有的库包括转换除了一个。在我的显示功能,我有这行(以显示文本在屏幕上):

  glWindowPos2i 

当我以.c运行程序或以.cpp运行程序时,在OSX。但我需要它在Linux上编译为.cpp。当我去编译它在那里,我得到这个错误:



错误:'glWindowPos2i未声明在此范围



我不知道这是一个缺少的库,或发生了什么。

解决方案

这是因为 glWindowPos__ (...)开始使用扩展: GL_ARB_window_pos 。它被集成到版本1.4的核心OpenGL中。



你很幸运在OS X上有一个支持OpenGL 2.1 / 3.2(更新版本)的盒子。在Linux中,情况有很大的不同。您必须使用GLX API在运行时加载 glWindowPos__(...)函数入口点(因为它们由显示驱动程序提供)。

要诚实地解决这个问题最简单的方法是整合 GLEW 库添加到用于非OS X定向构建的构建环境中。在Microsoft Windows中,您将遇到同样的问题,因为Windows只是随OpenGL 1.1库一起提供的 - 显示驱动程序在运行时扩展它就像在Linux。



GLEW将负责在Windows和Linux上加载OpenGL库不提供的函数入口点,并使整个过程变得无痛。只要记得在OS X上构建软件时禁用GLEW,这是没有必要的,如果你在OS X中链接到它,实际上会产生更多的问题。


I'm migrating an OpenGL program over to C++. I have all of the library includes transitioned except for one. In my display function, I have this line (to display text on the screen):

glWindowPos2i(5,5);

This works fine when I run the program as a .c or when I run it as a .cpp in OSX. But I need it to compile as a .cpp on Linux, also. When I go to compile it there, I get this error:

error: 'glWindowPos2i' was not declared in this scope

I can't figure out if this is a missing library or what is going on. Does anyone know what I need to do to get this line to compile?

解决方案

That is because glWindowPos__ (...) started life out as an extension: GL_ARB_window_pos. It was integrated into core OpenGL in version 1.4.

You are fortunate on OS X to have an implementation of OpenGL that supports OpenGL 2.1/3.2 (in newer versions) out-of-the-box. In Linux, the situation is much different. You have to use the GLX API to load the glWindowPos__ (...) function entry-points at run-time (because they are provided by the display driver).

The easiest way to solve this in all honesty would be to integrate the GLEW library into your build environment for non-OS X targeted builds. You will encounter this same problem in Microsoft Windows, because Windows only ships with OpenGL 1.1 libraries out-of-the-box - display drivers extend it at run-time just as in Linux.

GLEW will take care of loading the function entry-points that are not provided with the shipping OpenGL libraries on both Windows and Linux, and make the whole process painless. Just remember to disable GLEW when you build your software on OS X, it is not necessary and it actually creates more problems if you do link to it in OS X.

这篇关于glWindowPos2i未在此范围中声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆