Contents
What does a texture atlas in OpenGL mean?
This means that I have a texture atlas (i.e. spritesheet) which contains the textures for the tiles. For the sake of simplicity, let’s assume that I have a huge internal 2D array, containing the tileIDs and a lookup tablel/hasmap for the UV coords for each tile type. All the tiles have the same dimension (the texture AND the onscreen tiles).
How to make a big tilemap in OpenGL?
I want to be able to have a big tilemap (e.g. like Terraria, or an infinite procedural generated one), with only a handful of tiles on my screen. This means that I have a texture atlas (i.e. spritesheet) which contains the textures for the tiles.
How to do attributeless tile rendering in OpenGL?
Hoping on the train of attributeless rendering, I can pass a uniform or create a const array to hold the UV offsets of every tile type, and only pass at every camera move the updated tile type IDs to the shader (with a uniform?).
How to reduce the vertex count in OpenGL?
Either using triangle strips, or indices to reduce the vertex count, and use provoking vertices to correctly map the UV coordinates (this can be combined with attributeless rendering). The vertices are all fixed for the window, and only the textures change.
Which is the fastest way to draw tiles in OpenGL?
The fastest drawing occurs when drawing from video memory to video memory because the pixels don’t have to travel from the CPU to the video card. The best strategy for using tiles in OpenGL is to place a set of tiles in one texture map. For the widest compatibility you should make the texture map a power of 2.
Can you draw with OpenGL on a Mac?
OpenGL takes advantage of your Mac’s graphics accelerator, which makes drawing fast. Portability. Your OpenGL drawing code will run on Windows and Linux as well as Mac OS X. You can take your OpenGL knowledge and apply it to 3D games. The fastest way to draw 2D graphics with OpenGL is to use texture maps.