GLEW会做什么,为什么我需要它? [英] What does GLEW do and why do I need it?

查看:75
本文介绍了GLEW会做什么,为什么我需要它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我已经知道为什么我需要GLEW了,但是只是到了一定程度.

Okay, so I already know why I need GLEW, but only up to a point.

如果我正在使用现代的OpenGL东西(可能从3.0版开始),并且/或者正在使用Core Profile,则需要GLEW,因为如果没有它,编译会产生错误,例如未声明glGenVertexArrays.

If I am using modern OpenGL stuff, probably from version 3.0 onwards, and/or am using the Core Profile, then GLEW is required as without it compilation produced error such as glGenVertexArrays was not declared.

因此GLEW可能会做一些后台工作,包括我们可能要使用的现代OpenGL函数.

So GLEW does a bit of background work including the modern OpenGL functions we would like to use, probably.

除此之外,它还有其他作用吗?另外,它是如何工作的.

Apart from that, does it do anything else? Also, how does it work.

例如,它是否可以改善跨平台编译? (例如,如果从Linux迁移到Windows或OS X,则需要对代码进行较少的修改?

As an example, does it improve cross-platform compilation? (Require less modifications to code if moving from Linux to Windows or OS X for example?

它是否还改善了图形硬件的跨平台性"?例如,假设我们有两台完全相同的计算机,包括OS.在一个系统上使用OpenGL 4.3命令编译程序.如果另一个系统具有仅支持OpenGL 3.3的图形卡或驱动程序,那么GLEW可以帮助您吗? (也许是为旧版本的OpenGL编译着色器吗?)

Does it also improved the "cross-platform-ness" of graphics hardware? For example, say we had two identical computers, including the OS. A program is compiled using OpenGL 4.3 commands on one system. If the other system has a graphics card or driver which only supports OpenGL 3.3, does GLEW help with that? (Compiling shaders for an older version of OpenGL, perhaps?)

所以您可能会看到我实际上并不知道GLEW的作用或作用方式.

So you can probably see I don't actually know what GLEW does or how it does it.

最后一点;有谁知道如何将GLEW与GLFW一起使用?我可能实际上将其作为一个单独的问题发布.

One last point; does anyone know how to use GLEW with GLFW? I might post that as a separate question actually.

推荐答案

GLEW不是必需的".您可以使用glcorearb.h标头,或类似的东西.但是,如果您链​​接某些功能-该功能必须存在于目标平台上,否则您的程序将无法启动. GLEW和其他工具正好可以解决该问题-您不是直接与GL函数链接,而是在初始化阶段之后获取函数指针.它使您可以在运行时检查存在哪些扩展以及可以使用哪些功能.

GLEW isn't 'required', as you put it. You could use glcorearb.h header, or anything like that. However, if you link with some function - it must exist on target platform, or your program wouldn't launch. GLEW and others are exactly to handle that - you're not linking with GL functions directly, but instead getting function pointers after initialization phase. It allows you to check at runtime which extensions are present and which functions may be used.

唯一可移植的功能是获取函数指针-它可能是wglGetProcAddress/glxGetProcAddress,并且与Apple OS类似.所以不,不是这样.但是,可用的GL扩展种类很多.

The only thing it helps with portability is getting function pointers - it may be wglGetProcAddress/glxGetProcAddress and it's analog for apple OSes. So no, it's not a case. However, the variety of available GL extensions is.

GLEW不需要使用您首选的GL初始化库的任何接触点-只需在创建GL上下文后调用glewInit.

GLEW requires no touch points with your preferred GL initialization library - just call glewInit after creating GL context.

这篇关于GLEW会做什么,为什么我需要它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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