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 > different texture size problems

#104273 - knight0fdragon - Wed Sep 27, 2006 5:30 pm

I am trying to use a texture that is not 128x128,but there seems to be a problem with this,

here is an example of a 128x128 and a 64x64

http://hyperclubbingfriends.yourfreewebspace.com/Knight0fDragon/image007.GIF

and here is snippets of my code

Code:

uint16 buf[64*64];
int LoadGLTextures()                           // Load PCX files And Convert To Textures
{
 
   for(int i = 0; i < 64*64; i+=3)
  {
    buf[i] = RGB15(31,0,0) | BIT(15);
    buf[i+1] = RGB15(0,31,0) | BIT(15);
    buf[i+2] = RGB15(0,0,31) | BIT(15);
 
  }
   glGenTextures(1, &texture[0]);
   glBindTexture(0, texture[0]);
   glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_64 , TEXTURE_SIZE_64, 0, TEXGEN_TEXCOORD, (uint8*)buf);


   return TRUE;
}



int DrawGLScene(void)
{
   //we are going to use floating point for the tutorial...keep in mind the DS has no
   //floating point hardware.  For real life use the built in fixed point types.
   //this is where the magic happens

  glPushMatrix();
  glLoadIdentity();                           // Reset The Current Modelview Matrix
   glTranslate3f32(-(1<<8),-1<<8,-(450));                  // Move Left 1.5 Units And Into The Screen 6.0
   for(v16 z = 0 << 12; z < (1 << 9); z+=(1 << 9))
  {
    for(v16 x = 0 << 12; x < (1 << 9); x+=(1 << 9))
    {
      glBindTexture(GL_TEXTURE_2D, texture[0]);

      glBegin(GL_QUADS);                  // Draw A Quad
        glTexCoord2f(0.0f, 1.0f);
        //glTexCoord2t16((0<<4), (0<<4));
        glVertex3v16(x           , z, 0);            // Top Left
         
        glTexCoord2f(1.0f, 1.0f);
        //glTexCoord2t16((0<<4), (1<<11));
        glVertex3v16(x           , z + (1 << 9)+1, 0);            // Top Right
         
        glTexCoord2f(1.0f, 0.0f);
        //glTexCoord2t16((1<<11), (1<<11));
        glVertex3v16(x + (1 << 9)+1, z + (1 << 9)+1, 0);            // Bottom Right
         
        glTexCoord2f(0.0f, 0.0f);
         //glTexCoord2t16((1<<11), (0<<4));
        glVertex3v16(x + (1 << 9)+1, z, 0);            // Bottom Left
       glEnd();

    }
  }

  glPopMatrix(1);
  swiWaitForVBlank();
      
   // flush to screen   
   glFlush();
   
  return TRUE;
}




_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#104413 - Payk - Thu Sep 28, 2006 9:21 pm

Hmh as far as i know you only can use texturesize which are a product of 2^x. 256x256 never worked for met. But you can use 64x128 or things like that. Not sure if t16 supports that but that texturepack macro can help. But t16 is fastest way....

#104684 - toa - Sun Oct 01, 2006 3:50 pm

If you'r using libnds's video GL wrapper straight out of the box, there is two things you have to know:

(1) x&y are flippet, so you have to rotate your images 90 degrees
(2) The version of glTexCoord2f you get from videoGL.h is hardcoded to 128x128 textures, so using any other sizes is going to give you all kinds of grief :-D

Perhaps this help?