opengl - Placing multiple images on a 3D surface -


if place texture on surface of 3d object, example cube, use vertices of cube describe placement of texture.

but if want place multiple separate images on same flat surface? or suppose 1 image, don't want appear @ edges of surface, vertices are, rather somewhere small , in middle of surface. want actual images chosen , placed dynamically @ runtime, otherwise condense them offline single texture.

i have approach want seek advice whether there better method, or if acceptable:

my guess create multiple separate 2d quads (with depth of 0), each texture associated them , placed on them (they of course texture atlas different texture coordinates).

then, transform these quads such appear on surface of 3d object, such cube. of course i'd have maintain matrix hierarchy these quads transformed appropriately whenever cube transformed, such appear attached cube.

while isn't hard, new texturing , know if normal practice this.

but if want place multiple separate images on same flat surface?

use multiple textures, maybe each own set of textuer coordinates. opengl implementation offer number of textuer units. each of them can supply different texture.

glactivetexture(gl_texture_0 + i); glbindtexture(…); gluniform1i(texturesampler[i], i); // texturesampler[i] contains sampler uniform location of bound program. 

or suppose 1 image, don't want appear @ edges of surface, vertices are, rather somewhere small , in middle of surface.

that's gl_clamp… texture wrap modes use.

gltexparameteri(gl_texture_wrap_{s,t,r}, gl_clamp[_to_{edge,border}]); 

with specify texture coordinates @ vertices outside [0, 1] interval, instead of repeating image show 1 time, edge pixels repeated. if make edge pixels transparent, it's if there no image there.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -