OpenGL的理解 [英] Understanding OpenGL

查看:122
本文介绍了OpenGL的理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对OpenGL的一些基本点/问题,而不是所有涉及code,但概念也是如此。我将不胜感激,如果你能回答,确认或扩大对其中任何一个。我警告你,有些人可能很幼稚,所以请多多包涵。


  1. 据我了解,OpenGL是一个标准,而不是一个软件。例如,'得到'的OpenGL实际上涉及得到一个它不一定有第三方实现必须由Khronos的认可。


  2. 的OpenGL通常指的GL工具(GLU)和GL公用事业工具包(GLUT)的结合。他们有方法开头 GLU 过剩,RESP。与基本的OpenGL的方法,与简单的 GL ,都是由那些让显卡驱动程序,即NVIDIA?

  3. 开始实施
  4. 我认为过剩方法是特定于操作系统的帮手,例如 glutKeyboardFunc()有是,国米preT键盘。所以,如果我想要一个更强大的替代的方式来跨preT键盘输入,我只想用的OS API。 OpenGL的本身纯粹是大约图形,但过剩的这样的事情,因为显卡并不多没有实时人类的控制。


  5. 在我看来,那 GLU 方法可以等同于调用了一系列低级 GL 方法。一个例子我想引用是 glOrtho() gluPerspective()。他们似乎对我有工作类似的方法,但计算的角度可能更复杂,所以 gluPerspective()是方便,但可能只是解决一些 GL 方法。


  6. 我研究使用freeglut在大学基本的OpenGL和我一直具有使用OpenGL的骨灰级的方式这一愿景,只使用低级别的方法。我不知道这是否是太傻太天真想法,但有写的OpenGL的专业的方式,来获得其最大的功能?就像,presumably,游戏开发者不会使用 glutPostRedisplay()例如,对不对?这似乎太容易和方便,喜欢它隐藏了很多是怎么回事的。我怀疑这也是对C ++如此,因为GLUT回调是在命名空间的方法不友善(正如我在其他问题见过)。



解决方案

  

\\ 1.据我了解,OpenGL是一个标准,而不是一个软件。例如,'让'的OpenGL实际上涉及得到一个
  第三方实现这并不一定必须
  由Khronos的认可。


确实


  

\\ 2的OpenGL通常指的GL工具(GLU)和GL公用事业工具包(GLUT)的结合。他们有方法开头
   GLU 过剩,RESP。与基本的OpenGL方法,即开始
  用简单的 GL ,都是由那些让显卡驱动程序实现的,
  即NVIDIA?


没有。 OpenGL是刚刚与 GL ... 开始的功能。其他一切(GLU,GLUT)的第三方库,而不是OpenGL的覆盖。


  

\\ 3.我认为过剩方法是特定于操作系统的帮手,例如 glutKeyboardFunc()有是,国米preT键盘。所以,如果我
  想要一个更强大的替代的方式来跨preT键盘输入,我
  将只使用OS API。 OpenGL的本身纯粹是大约图形,但
  过剩有这样的事情,因为显卡没有太大的不
  实时人类的控制。


正确的。 GLUT是一个很小的框架,所以用别的东西强烈推荐。


  

\\ 4.在我看来, GLU 方法可以等同于调用了一系列低级 GL 方法。一个例子我想引用
  为 glOrtho() gluPerspective()


我想你指的 gluOrtho2D 但是,是的,你是正确的。 glOrtho 是一个真正的OpenGL-1的功能。在某种程度上, gluOrtho2D 是最没用的功能不断之一:

 无效gluOrtho2D(GLfloat左,右GLfloat,GLfloat底部,顶部GLfloat)
{
    glOrtho(左,右,底,顶,-1,1);
}


  

他们似乎对我也有类似的
  工作,但计算透视的方式可能会更复杂,因此
   gluPerspective()是方便,但可能只是解决一些
   GL 方法。


再次右键,但它其实很简单:

  GLU prespective(GLfloat视野,GLfloat方面,GLfloat近,远GLfloat)
{
    GLfloat一个= 0.5 * ATAN(FOV);
    glFrustum(-a *近,一*近,-a *近/方面,*近/方面,近,远);
}

用OpenGL-3核心开始,整个矩阵操作的东西已被删除。在重要的应用程序是没有多大用处的,因为你自己管理的矩阵反正。


  

\\ 5.我已经研究了使用在大学freeglut基本的OpenGL和我一直具有使用OpenGL的骨灰级的方式这一愿景,用
  只有低级别的方法。我不知道这是否是太傻太天真
  心想,但有写的OpenGL的专业的方式,来获得
  其最大的功能?就像,presumably,游戏开发商
  不会使用 glutPostRedisplay()例如,对吧?


是的,这是可能的,大多数游戏引擎确实做所有繁重的工作自理。
有libSDL,其中也涵盖了OpenGL的。我个人preFER GLFW或做自己的东西,确实如此。然而,这并没有改变一个使用OpenGL本身的方式。但是,这只是基础设施,它的大多只是写样板code。作为一个初学者,你只能获得不使用既定的框架很少。如果你的程序使用了大量的GUI窗口小部件,然后使用Qt或GTK的,其内嵌的OpenGL小部件是一个合理的选择。

然而,一些项目是非常硬派,并实现与OpenGL的整个GUI,太。 Blender是最极端的例子,我喜欢它。


  

这似乎太容易和方便,喜欢它隐藏了很多是怎么回事的。一世
  怀疑这也是对C ++如此,因为GLUT回调是不友善
  在命名空间的方法(如我在其他问题见过)。


GLUT回调与命名空间好吗(一个命名空间只是一个C ++编译时间的事情)。但是,什么是不可能的是通过类的实例方法为GLUT / C回调。

I have some fundamental points/questions about OpenGL, not all involving code but concepts as well. I would be grateful if you could answer, affirm or expand on any of them. I warn you, some might be naive, so please bear with me.

  1. I understand that OpenGL is just a standard, as opposed to a piece of software. For example, 'getting' OpenGL actually involves getting a third-party implementation which doesn't necessarily have to be endorsed by Khronos.

  2. OpenGL usually refers to the combination of the GL utilities (GLU) and the GL utilities toolkit (GLUT). They have methods beginning with glu and glut, resp. and the 'basic' OpenGL methods, that begin with simply gl, are implemented by those that make graphics drivers, i.e. NVIDIA?

  3. I assume that glut methods are OS-specific helpers, for example glutKeyboardFunc() has to be, to interpret the keyboard. So if I wanted a more powerful alternative way to interpret keyboard input, I would just use the OS API. OpenGL itself is purely about graphics, but glut has this sort of thing since graphics is not much without real-time human control.

  4. It seems to me that glu methods may be identical to calling a series of lower-level gl methods. One example I would like to quote is glOrtho() and gluPerspective(). They seem to me to have similar ways of working, but calculating perspective may be more complex, so gluPerspective() is for convenience, but might just resolve to some gl methods.

  5. I have studied basic OpenGL using freeglut at university, and I keep having this vision of a 'hardcore' way of using OpenGL, using only low-level methods. I don't know if this is a totally naive thought, but is there a 'professional' way of writing OpenGL, to get out its maximum functionality? Like, presumably, game developers wouldn't use glutPostRedisplay() for example, right? It seems too easy and convenient, like it hides a lot of what is going on. I suspect this is also true for C++ since GLUT callbacks aren't friendly with methods in namespaces (as I've seen in other questions).

解决方案

\ 1. I understand that OpenGL is just a standard, as opposed to a piece of software. For example, 'getting' OpenGL actually involves getting a third-party implementation which doesn't necessarily have to be endorsed by Khronos.

Indeed.

\ 2. OpenGL usually refers to the combination of the GL utilities (GLU) and the GL utilities toolkit (GLUT). They have methods beginning with glu and glut, resp. and the 'basic' OpenGL methods, that begin with simply gl, are implemented by those that make graphics drivers, i.e. NVIDIA?

No. OpenGL is just the functions beginning with gl…. Everything else (GLU, GLUT) are third party libraries, not covered by OpenGL.

\ 3. I assume that glut methods are OS-specific helpers, for example glutKeyboardFunc() has to be, to interpret the keyboard. So if I wanted a more powerful alternative way to interpret keyboard input, I would just use the OS API. OpenGL itself is purely about graphics, but glut has this sort of thing since graphics is not much without real-time human control.

Correct. GLUT is a very minimal framework, so using something else is strongly recommended.

\ 4. It seems to me that glu methods may be identical to calling a series of lower-level gl methods. One example I would like to quote is glOrtho() and gluPerspective().

I think you refer to gluOrtho2D but yes, you're correct. glOrtho is a true OpenGL-1 function. In some way, gluOrtho2D is one of the most useless functions ever:

void gluOrtho2D(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top)
{
    glOrtho(left, right, bottom, top, -1, 1);
}

They seem to me to have similar ways of working, but calculating perspective may be more complex, so gluPerspective() is for convenience, but might just resolve to some gl methods.

Right again, but it's actually quite simple:

gluPrespective(GLfloat fov, GLfloat aspect, GLfloat near, GLfloat far)
{
    GLfloat a = 0.5 * atan(fov);
    glFrustum(-a*near, a*near, -a*near/aspect, a*near/aspect, near, far);
}

Starting with OpenGL-3 core, the whole matrix manipulation stuff has been removed. In any serious application it's of little use, since you'll manage the matrices yourself anyway.

\ 5. I have studied basic OpenGL using freeglut at university, and I keep having this vision of a 'hardcore' way of using OpenGL, using only low-level methods. I don't know if this is a totally naive thought, but is there a 'professional' way of writing OpenGL, to get out its maximum functionality? Like, presumably, game developers wouldn't use glutPostRedisplay() for example, right?

Yes this is possible and most game engines indeed do all the grunt work themself. There is libSDL, which also covers OpenGL. Personally I prefer GLFW or doing the stuff myself, indeed. However this does not change the way one uses OpenGL itself. But this is just infrastructure, and it's mostly just writing boilerplate code. As a beginner you gain only very little by not using an established framework. If your program makes heavy use of GUI widgets, then using Qt or GTK, with its embedded OpenGL widget is a reasonable choice.

However some projects are very hardcore, and implement the whole GUI with OpenGL, too. Blender is the most extreme example, and I love it.

It seems too easy and convenient, like it hides a lot of what is going on. I suspect this is also true for C++ since GLUT callbacks aren't friendly with methods in namespaces (as I've seen in other questions).

GLUT callbacks are okay with namespaces (a namespace is just a C++ compilation time thing). But what's not possible is passing class instance methods as GLUT/C callbacks.

这篇关于OpenGL的理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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