我有一些关于 OpenGL 的基本观点/问题,不仅涉及代码,还涉及概念。如果您能回答、肯定或扩展其中任何一个,我将不胜感激。我警告你,有些人可能很幼稚,所以请多多包涵。
我知道 OpenGL 只是一个标准,而不是一个软件。例如,“获取”OpenGL 实际上涉及获取第三方实现,该实现不一定必须得到 Khronos 的认可。
OpenGL 通常指的是 GL 实用程序 (GLU) 和 GL 实用程序工具包 (GLUT) 的组合。它们有以 glu 和 glut 开头的方法,分别是。而以 gl 开头的“基本”OpenGL 方法是由那些制作图形驱动程序的公司实现的,例如 NVIDIA?
我假设 glut 方法是特定于操作系统的助手,例如 glutKeyboardFunc() 必须是,才能解释键盘。因此,如果我想要一种更强大的替代方法来解释键盘输入,我只会使用 OS API。 OpenGL 本身纯粹是关于图形的,但是 glut 有这种东西,因为图形没有多少没有实时的人工控制。
在我看来,glu 方法可能与调用一系列较低级别的 gl 方法相同。我想引用的一个例子是 glOrtho() 和 gluPerspective()。在我看来,它们的工作方式相似,但计算透视可能更复杂,所以 gluPerspective() 是为了方便,但可能只是解析为一些 gl 方法。
我在大学里使用 freeglut 学习了基本的 OpenGL,并且我一直有这种使用 OpenGL 的“硬核”方式的愿景,只使用低级方法。我不知道这是否是一个完全幼稚的想法,但是是否有一种“专业”的方式来编写 OpenGL,以发挥其最大的功能?比如,大概游戏开发者不会使用 glutPostRedisplay() 吧?这似乎太容易和方便了,就像它隐藏了很多正在发生的事情一样。我怀疑 C++ 也是如此,因为 GLUT 回调对命名空间中的方法不友好(正如我在其他问题中看到的那样)。
最佳答案
\ 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
gluandglut, resp. and the 'basic' OpenGL methods, that begin with simplygl, are implemented by those that make graphics drivers, i.e. NVIDIA?
没有。 OpenGL 只是以 gl… 开头的函数。其他所有内容(GLU、GLUT)都是第三方库,OpenGL 未涵盖。
\ 3. I assume that
glutmethods are OS-specific helpers, for exampleglutKeyboardFunc()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, butgluthas this sort of thing since graphics is not much without real-time human control.
正确。 GLUT 是一个非常小的框架,因此强烈建议使用其他框架。
\ 4. It seems to me that
glumethods may be identical to calling a series of lower-levelglmethods. One example I would like to quote isglOrtho()andgluPerspective().
我认为您指的是 gluOrtho2D 但是是的,您是正确的。 glOrtho 是一个真正的 OpenGL-1 函数。在某种程度上,gluOrtho2D 是有史以来最没用的函数之一:
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 someglmethods.
又对了,但其实很简单:
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);
}
从 OpenGL-3 核心开始,整个矩阵操作的东西都被删除了。在任何严肃的应用程序中,它都没有什么用处,因为无论如何您都将自己管理矩阵。
\ 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?
是的,这是可能的,而且大多数游戏引擎确实可以自己完成所有繁重的工作。 有 libSDL,它也涵盖了 OpenGL。事实上,我个人更喜欢 GLFW 或自己做这些事情。然而,这并没有改变人们使用 OpenGL 本身的方式。但这只是基础设施,主要是编写样板代码。作为初学者,如果不使用已建立的框架,您只会获得很少的 yield 。如果您的程序大量使用 GUI 小部件,那么使用 Qt 或 GTK 及其嵌入式 OpenGL 小部件是一个合理的选择。
但是有些项目非常硬核,并且也使用 OpenGL 实现了整个 GUI。 Blender 是最极端的例子,我喜欢它。
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 回调可以用于命名空间(命名空间只是 C++ 编译时的事情)。但是不可能将类实例方法作为 GLUT/C 回调传递。
关于c++ - 了解 OpenGL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7968748/
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
如何将send与+=一起使用?a=20;a.send"+=",10undefinedmethod`+='for20:Fixnuma=20;a+=10=>30 最佳答案 恐怕你不能。+=不是方法,而是语法糖。参见http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html它说Incommonwithmanyotherlanguages,Rubyhasasyntacticshortcut:a=a+2maybewrittenasa+=2.你能做的最好的事情是:
我对如何计算通过{%assignvar=0%}赋值的变量加一完全感到困惑。这应该是最简单的任务。到目前为止,这是我尝试过的:{%assignamount=0%}{%forvariantinproduct.variants%}{%assignamount=amount+1%}{%endfor%}Amount:{{amount}}结果总是0。也许我忽略了一些明显的东西。也许有更好的方法。我想要存档的只是获取运行的迭代次数。 最佳答案 因为{{incrementamount}}将输出您的变量值并且不会影响{%assign%}定义的变量,我
我有一个数组数组,想将元素附加到子数组。+=做我想做的,但我想了解为什么push不做。我期望的行为(并与+=一起工作):b=Array.new(3,[])b[0]+=["apple"]b[1]+=["orange"]b[2]+=["frog"]b=>[["苹果"],["橙子"],["Frog"]]通过推送,我将推送的元素附加到每个子数组(为什么?):a=Array.new(3,[])a[0].push("apple")a[1].push("orange")a[2].push("frog")a=>[[“苹果”、“橙子”、“Frog”]、[“苹果”、“橙子”、“Frog”]、[“苹果”、“
我经常将预配置的lambda插入可枚举的方法中,例如“map”、“select”等。但是“注入(inject)”的行为似乎有所不同。例如与mult4=lambda{|item|item*4}然后(5..10).map&mult4给我[20,24,28,32,36,40]但是,如果我制作一个2参数lambda用于像这样的注入(inject),multL=lambda{|product,n|product*n}我想说(5..10).inject(2)&multL因为“inject”有一个可选的单个初始值参数,但这给了我......irb(main):027:0>(5..10).inject
是否有self验证的问题列表。看着那个,我可以确定我知道。我应该复习一下。在学习的过程中,我列了一个这样的list,但它只包含我在某处听说过的项目。我需要一段时间才能找到新的东西。 最佳答案 以下是针对ruby和Rails的一些测试列表。证书名称:RubyonRails谁提供:oDeskIncorporation认证费用:免费网站:https://www.odesk.com/tests/985?pos=0证书名称:RubyonRails提供者:Techgig.com(TimesBusinessSolutionsLimited(T
有没有办法让Ruby能够做这样的事情?classPlane@moved=0@x=0defx+=(v)#thisiserror@x+=v@moved+=1enddefto_s"moved#{@moved}times,currentxis#{@x}"endendplane=Plane.newplane.x+=5plane.x+=10putsplane.to_s#moved2times,currentxis15 最佳答案 您不能在Ruby中覆盖复合赋值运算符。任务在内部处理。您应该覆盖+,而不是+=。plane.a+=b与plane.a=
我想覆盖store_accessor的getter。可以查到here.代码在这里:#Fileactiverecord/lib/active_record/store.rb,line74defstore_accessor(store_attribute,*keys)keys=keys.flatten_store_accessors_module.module_evaldokeys.eachdo|key|define_method("#{key}=")do|value|write_store_attribute(store_attribute,key,value)enddefine_met
出于某种原因,heroku尝试要求dm-sqlite-adapter,即使它应该在这里使用Postgres。请注意,这发生在我打开任何URL时-而不是在gitpush本身期间。我构建了一个默认的Facebook应用程序。gem文件:source:gemcuttergem"foreman"gem"sinatra"gem"mogli"gem"json"gem"httparty"gem"thin"gem"data_mapper"gem"heroku"group:productiondogem"pg"gem"dm-postgres-adapter"endgroup:development,:t
我是Ruby和这个网站的新手。下面两个函数是不同的,一个在函数外修改变量,一个不修改。defm1(x)x我想确保我理解正确-当调用m1时,对str的引用被复制并传递给将其视为x的函数。运算符当调用m2时,对str的引用被复制并传递给将其视为x的函数。运算符+创建一个新字符串,赋值x=x+"4"只是将x重定向到新字符串,而原始str变量保持不变。对吧?谢谢 最佳答案 String#+::str+other_str→new_strConcatenation—ReturnsanewStringcontainingother_strconc