gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Repeating a texture

#59692 - TomschikSimon - Thu Nov 03, 2005 2:12 pm

Is there a possibility to repeat a texture if the tex-coords are bigger than the texture. The texture is now displayed once correctly and after this I only see stripes till the end of the polygon.

#59719 - Freakker - Thu Nov 03, 2005 7:10 pm

I don't have experience programming 3D on the DS, but in OpenGL, if you use a value over 1 in glTexCoord the texture repeats itself(if you were to put 2, it would display twice, etc...)

#59720 - dovoto - Thu Nov 03, 2005 7:23 pm

Yes,
You need to specify this when you generate the texture (you could do it manualy also but i have provided no easy way to do this). There is example code in the examples folder (nds/graphics/3d/nehe/lesson 10).

Code:
glGenTextures(1, &texture[0]);
   glBindTexture(0, texture[0]);
   glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD | GL_TEXTURE_WRAP_S | GL_TEXTURE_WRAP_T, pcx.data8);


you will notice the wrap flags are added..you can also add vertical and horizontal flip flags
Code:
#define GL_TEXTURE_FLIP_S (1 << 18)
#define GL_TEXTURE_FLIP_T (1 << 19)

_________________
www.drunkencoders.com

#59722 - mike260 - Thu Nov 03, 2005 7:25 pm

TomschikSimon wrote:
Is there a possibility to repeat a texture if the tex-coords are bigger than the texture. The texture is now displayed once correctly and after this I only see stripes till the end of the polygon.


Try using GL_TEXTURE_WRAP_S|GL_TEXTURE_WRAP_T for the 'param' argument to glTexImage2D.
_________________
"Ever tried? Ever failed? No matter. Try Again. Fail again. Fail better."
-- Samuel Beckett

#59811 - TomschikSimon - Fri Nov 04, 2005 6:22 am

Thank you. Now it looks perfectly. I've seen these two defines earlier in the videoGL.h file, but I didn't know where to place them.