简体   繁体   English

像OpenGL中的游戏制造商一样以2D绘制顺序

[英]Draw order in 2D as in game maker in OpenGL

I have the following: 我有以下几点:

while(1){
  ...    
  object1.draw();
  object2.draw();
}

Of course the second object is drawn on first. 当然,第二个对象是第一个绘制的。 My question is if the object 1 can be drawn on the object 2 without changing the order in which they appear in the main loop. 我的问题是,是否可以将对象1绘制在对象2上而不改变它们在主循环中出现的顺序。

I can do something similar as the program game maker where the depth function is used? 我可以像使用深度功能的程序游戏开发商一样做些什么?

I use OpenGL without shaders. 我使用不带着色器的OpenGL。

I'm not familiar with Game Maker, but you can to use glFrustrum to achieve what you want in opengl. 我对Game Maker不熟悉,但是您可以使用glFrustrum在opengl中实现所需的功能。

https://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml https://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml

set the near and far clipping planes to 0, and 100 or some other arbitrarily large number. 将近和远裁剪平面设置为0,以及100或其他任意大数。 then when you draw them specify a z-value where the second z-value is less than, ie closer to the camera, than the first objects z-value. 然后在绘制它们时指定一个z值,其中第二个z值小于(即更靠近相机)比第一个对象的z值小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM