测量与正交剪切平面一起使用的屏幕的好方法

发布于 2024-11-26 09:02:12 字数 236 浏览 5 评论 0原文

嘿,我正在转换我的项目,以便它使用正交投影,因为我被告知它更简单且适合 2D 游戏。我真的不知道如何测量裁剪平面的屏幕参数。我可以对数字进行硬编码,但这会导致屏幕横向显示时拉伸。我什至不知道剪切平面是否应该固定在屏幕边缘,但情况似乎确实如此,因为我一直在尝试不同的数字,数字越大,绘制的形状越小。这让我假设我输入的数字只是轴的最末端。

我的假设正确吗?

避免拉伸的最佳方法是什么?

哪些命令最适合查找屏幕尺寸?

Hey I'm converting my project so that it uses orthographic projection because I've been told its simpler and ideal for 2D games. I don't know really know how I'm meant to measure the screen parameters for the clipping planes. I could hard code numbers but that would cause stretching when the screen is put into landscape. I don't even really know if the clipping planes are meant to be fixed to the edge of the screen but that appears to be the case because I've been trying different numbers and the larger the numbers the smaller the drawn shape gets. That leads me to assume that the numbers I'm putting in are just the extreme ends of the axis.

Are my assumptions correct?

What is the best way to avoid the stretching?

What commands are best for finding the size of the screen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反目相谮 2024-12-03 09:02:12

啊哈刚刚明白了 =)

刚刚意识到我的 onSurfaceChanged 方法如下所示:

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    GLU.gluOrtho2D(gl, -width, width , -height, height);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

gl.glViewPort 找到屏幕尺寸,经过一番播放后,我终于得到了一个中心对齐的图像,当使用该行更改方向时没有拉伸

GLU.gluOrtho2D(gl, -width, width , -height, height);

有人纠正我如果有更好的方法来实现这个=)

Ah Ha Just got it =)

Just realised that my onSurfaceChanged Method looks like this:

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    GLU.gluOrtho2D(gl, -width, width , -height, height);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

gl.glViewPort finds the screen size and after a bit of playing I finally got a centre aligned image with no stretching when orientation is changed using the line

GLU.gluOrtho2D(gl, -width, width , -height, height);

Someone correct me if there is a better way to implement this =)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文