如何在 2D opengl es 场景中获得绝对平移
我有一个在 2d opengl es 1.1 中渲染的可平移/可缩放图像。缩放后,如何获得从图像左侧到可视区域左侧的绝对位置? 这是一张图片来澄清我的意思:
I have a pannable/zoomable image rendered in a 2d opengl es 1.1. After zooming, how can i get the absolute position from the left side of the image to the left side of my viewable area?
Heres an image to clarify what i mean:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我对 IOS 了解不多,但从逻辑上讲,根据原点在哪里以及图像如何绘制到屏幕上,您可以计算距图像 x 位置的距离。例如,如果您的原点位于屏幕的左上角 (0,0),并且您的图像是从左上角绘制的(例如 (-10, 0)),那么您的距离将只是绝对值图像的 x 位置(例如 10 个单位)。但是,如果您的原点位于中心,那么您必须考虑屏幕尺寸并减去宽度的一半来获得距离。这可能听起来令人困惑,但它应该只是基本的数学。
Well I don't know much about IOS, but logically speaking, depending on where the origin is and how your image is being drawn onto the screen, you could just calculate the distance from the x position of the image. For instance, if your origin is on the top left of the screen (0,0), and your image is being drawn from the top left (eg. (-10, 0)), then your distance would simply be the absolute value of the x position of your image (eg. 10 units). However, if your origin was lets say, at the center, then you would have to take the screen size into account and subtract half of the width to achieve the distance. It may sound confusing but it should just be basic math.