AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Opengl coords8/3/2023 ![]() ![]() libGDX does not translate the image data between the two (which would involve copying the image line by line), instead it simply copies the data as is. However, most image formats store the image data comparable to touch coordinates, which is y-down. The “problem” with this is that OpenGL expects the texture data to be in image coordinates, which is y-up. ![]() It is also possible to modify or create a pixmap by code, e.g. The texture can then be used to render to the screen. For example when loading a PNG image file to a texture, it is first decoded (uncompressed) to a Pixmap, which is the raw pixel data of the image, then it is copied to the GPU for use as texture. Pixmaps are commonly used to upload texture data. The camera.project and viewport.project methods can be used to convert world units to screen coordinates. In the majority of use-cases you don’t need this coordinate system a lot, if any, and it should be isolated from your game logic and its coordinate system. For example when calling glViewport, glScissor or manipulating a pixmap (see next). You typically use these coordinates to specify which portion of the screen to render onto. Converting between them is therefore quite easy: The only difference between touch and screen coordinates is that touch coordinates are y-down, while screen coordinates are y-up. Likewise, these are integers, they can’t be fractional. It is also used as indexer for an image in memory. This is OpenGL’s counterpart to touch coordinates that is: it is used to specify (index) a pixel of the (portion of the) physical screen. Dependence: device/resource/asset specific.Range: (0,0) (lower left corner) to ( ()-1, ()-1) (upper right corner).the camera.unproject or viewport.unproject method let’s you convert them to world coordinates (see below). ![]() You typically want to convert these coordinates as soon as possible to a more convenient coordinate system. Whenever working with mouse or touch coordinates, you’ll be using this coordinate system. You might even lean towards using these as your default/favorite, which you shouldn’t. If you’re familiar with canvas graphics or basic image editors, then you are probably already familiar with these coordinates. This coordinate system is based on the classic representation of the display, which is usually also closest to the device/OS specific implementation. Therefore these coordinates are always represented as integers, they can’t be fractional. Starts at the upper left pixel of the (application portion of the) physical screen and has the size of the (application portion of the) physical screens width and height in pixels.Įach coordinate is an index in the 2D array of this grid, representing a physical pixel on the screen.
0 Comments
Read More
Leave a Reply. |