Simple application scenarios are as follows:
The user clicks on the screen, and a triangle is generated at the clicked position. The triangle of OpenGL ES is generated with three vertices, but the coordinate range of the vertices of OpenGL ES is [-1.0, 1.0]. There is a problem here. The location is mapped to the coordinates of OpenGL ES. In fact, the reason is very simple. It is to map the x-axis coordinates of the screen such as [0, 1080] to the range of [-1.0, 1.0]. There is a small problem here. If the screen is The size of 1080 * 1920, if you want to click on each position on the screen, you must map to OpenGL ES coordinates, because the x-axis and y-axis coordinates of OpenGL ES are both [- 1.0, 1.0], so if glViewport (0, 0, 1080, 1920), the range of orthogonal projection or perspective projection should be left = -ratio, right = ratio, bottom = -1, top = 1, where ratio = (float) width / height. The code is relatively simple, directly on the renderings and source code download link.
Download link:Click to open the link
Getting the geographic coordinates of the clicked point by tapping the screen with your finger is a common feature in real-world applications. Below, I will show you how to implement this feature. Bas...
Foreword This week encountered a troublesome thing, the company docked a foreigner customer requires a custom password interface style, but the password key data processing, and obtain the password ne...
Look at the code directly, there are comments. ...
We model the three-dimensional coordinates in OpenGL to convert two-dimensional coordinates is calledprojection, The two-dimensional coordinates on the screen into three-dimensional coordinate transfo...
Reference: https://zhidao.baidu.com/question/560324903.html The personal test code is given below For the sake of simplicity, the model view and projection are all unit arrays, and the viewport is tra...
OpenGL: Screen coordinates to the world coordinate (GLFW implementation) The first blog post (I am the porter of the network) Screen Coordinates to World Coordinates Existence problem Original link: h...
(This article is Learnopengl learning note, tutorial Chinese translation addresshttps://learnopengl-cn.github.io/(Alternate addresshttps://learnopengl-cn.readthedocs.io/zh/latest/), Written on 2022-04...
[OpenGL] Click the mouse to get the world coordinates Labels (space separated): OpenGL cause Because I am doing graphics-related design recently, it takes time for the mouse to interactively acquire t...
Map of the big plug-in company has a basic functionality that the floating range is the principle of achieving (of course they may have a more high implementation method, but I said this method is fea...