如何平移2D OpenGL ES的场景 [英] How to pan a 2D openGL ES scene

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

问题描述

我试着走动与iOS中使用的glTranslatef OGLES绘制的图像。我知道我可以使用UIPanGestureRecognizer平移量,但我不能确定如何适用三角洲的变量x和y。任何想法如何做到这一点还是知道一个更好的方式来平移图像中的OpenGL ES 1.1?

IM如何建立我的看法:

 的CGRect RECT = view.bounds;
glViewport(0,0,rect.size.width,rect.size.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0,rect.size.width,-rect.size.height,0,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


解决方案

 的CGRect RECT = view.bounds;
glViewport(0,0,rect.size.width,rect.size.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(XPAN,rect.size.width + XPAN,-rect.size.height + yPan,yPan,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

Im trying to move an image around drawn with OGLES using glTranslatef in iOS. I know i can get the amount panned using a UIPanGestureRecognizer, but am unsure how to apply the deltas to the x and y variables. Any ideas how to accomplish this or know of a better way to pan around an image in openGL ES 1.1?

How im setting up my view:

    CGRect rect = view.bounds;
glViewport(0, 0,rect.size.width,rect.size.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 
glOrthof( 0,rect.size.width,-rect.size.height, 0, -1, 1 ) ;  
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();    

解决方案

CGRect rect = view.bounds;
glViewport(0, 0,rect.size.width,rect.size.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 
glOrthof( xPan,rect.size.width + xPan,-rect.size.height + yPan, yPan, -1, 1 ) ;  
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); 

这篇关于如何平移2D OpenGL ES的场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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