+ 2

Loading textures from a Texture atlas [ OpenGL / C++ ]

I wanted to know how can I load an array of textures by passing in a texture atlas to a function using C++ and OpenGL if u know how, can u give me the code EDIT: I am using the stb_image loader library for my program

28th Jul 2018, 2:13 PM
Light
Light - avatar
1 Answer
+ 2
do it with texture coordinates. If you know the width and height of your texture atlas and all the textures in it are the same width and height, you can just do 1/atlas_width. so if you were texturing a quad, the top left corner's UV would be (1/atlas_width, 1/atlas_height). the lower right UV would be (2*(1/atlas_width), 2*(1/atlas_height)) from there you just multiply by the X,Y index of each texture. so the third along and second down would be (3*(1/atlas_width), 2*(1/atlas_height)).
5th Aug 2018, 7:01 AM
Aidan Haddon-Wright
Aidan Haddon-Wright - avatar