iPhone iOS5 querying OpenGL ES 2.0 pipeline objects if they are hidden in the view or not…“Occlusion”

元气小坏坏 提交于 2019-12-06 02:28:25

问题


EXT_occlusion_query_boolean is new with OS5.0,

it looks to me like not a single person on the entire internet has posted about these new extensions nor used this code....

so here they are set up properly...which is not documented anywhere as far as i can tell... you can imagine how they would go in your code from this little sudo code here:

import UIKit/UIKit.h

import GLKit/GLKit.h

import "GLProgram.h"

GLuint testBox,hasBeenTested,theParams;

//...

glGenQueriesEXT(1, &testBox);

glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, testBox);


//... draw an object .......

glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);

glGetQueryObjectuivEXT(testBox, GL_QUERY_RESULT_AVAILABLE_EXT, &hasBeenTested);

if (hasBeenTested) glGetQueryObjectuivEXT(testBox, GL_QUERY_RESULT_EXT, &theParams);

glDeleteQueriesEXT(1, &testBox);

if (!theParams)  object is hidden;  don't draw next time;

hopefully some here can use this code, i've tested it and it works, however, there appears to be a bug in GLKit, where if you use self.effect2 = [[GLKBaseEffect alloc] init]; type of GLKit code to render an object, rather than a normal GLES2.0 pipeline, the queries will fail to give you the correct answer... (never hidden) although i tested a pipeline object hiding a GLKBaseEffect object, (which fails) so it could be there is a bug just mixing the two types, if you go the other way, have a GLKBaseEffect object hide a pipeline object, it gives the correct answer, i did not test further yet.

so the question is, I bet i can go further with this and create collision detection in the vertex/fragment shader somehow... this code i found looks like a start... given these two pieces of sudo code, can someone get me closer to collision detection that just triggers when a "part" goes completely inside another part? a quicker easier/firststep could be to have the entire object hidden inside another object before a positive is triggered, this would be a great start, any ideas?

http://ucv.academia.edu/RhadamésCarmona/Papers/743483/Volume-Surface_Collision_Detection

来源:https://stackoverflow.com/questions/8598368/iphone-ios5-querying-opengl-es-2-0-pipeline-objects-if-they-are-hidden-in-the-vi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!