简体   繁体   English

如何处理不同的设备尺寸

[英]How to handle different device sizes

I know how to handle screen sizes, but it is quite a different matter when using OpenGL ES. 我知道如何处理屏幕尺寸,但使用OpenGL ES时则完全不同。 The thing is that normally I would just get the size of the screen in pixels and using the numbers given I would align items to be displayed. 事情是,通常我只是以像素为单位获得屏幕的大小,并使用给定的数字我将对齐要显示的项目。

But, as I mentioned before, in OpenGL ES it is quite different. 但是,正如我之前提到的,在OpenGL ES中它是完全不同的。 I want to draw a simple grid on the screen, but I want all the squares on all the devices to be the same size. 我想在屏幕上绘制一个简单的网格,但我希望所有设备上的所有正方形都是相同的大小。 That means that with bigger screens I would have more columns and rows instead of bigger squares. 这意味着,对于更大的屏幕,我会有更多的列和行而不是更大的方块。 So the real question is how to convert screen size in pixels into OpenGL vertex system. 所以真正的问题是如何将像素的屏幕尺寸转换为OpenGL顶点系统。

Actually, I was very stupid when asking this. 实际上,在问这个问题时我非常愚蠢。 After a bit of experimenting it turned out that the size of the squares of the grid will stay of the same size, because of the way opengl es vertices work. 经过一些实验后发现,网格的正方形大小将保持相同的大小,因为opengl es顶点的工作方式。 On bigger devices is the size the same as on smaller ones, because the scale stays the same, only the corner indices change accordingly. 在较大的设备上,尺寸与较小的设备相同,因为尺度保持不变,只有角落指数相应地改变。

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

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