##### Ninja Library - Texture Function

# njSetTextureNum

Sets a texture number as the current texture

### FORMAT

`

  Sint32 njSetTextureNum( n )
  Uint32 n

`

### PARAMETER

  `n` | Texture number

### RETURN

  1 | Succeeded |
  -1 | Failed |

### DESCRIPTION

  Sets texture number n from the current texture list as the current texture.

  Subsequently, this remains the current texture until execution of `njSetTextureNum()` or `njSetTextureNumG()` function.

  About the texture number of the current texture
  As shown in the example below, when textures are created, texture numbers are sequentially allocated in the series 0, 1, 2, 3,... from the beginning of a NJS_TEXNAME structure which is set in the NJS_TEXLIST structure.
  NJS_TEXNAME texname[5];
  NJS_TEXLIST texlist={texname,5};
  /* Texture number 0 */
  njSetTextureNum(&texname[0],"file1.pvr",10,
  NJD_TEXATTR_TYPE_FILE |
  NJD_TEXATTR_GLOBALINDEX);
  /* Texture number 1 */
  njSetTextureNum(&texname[1],"file2.pvr",11,
  NJD_TEXATTR_TYPE_FILE |
  NJD_TEXATTR_GLOBALINDEX);
  /* Texture number 2 */
  njSetTextureNum(&texname[2],"file1.pvr",12,
  NJD_TEXATTR_TYPE_FILE |
  NJD_TEXATTR_GLOBALINDEX);
  /* Texture number 3 */
  njSetTextureNum(&texname[3],"file2.pvr",13,
  NJD_TEXATTR_TYPE_FILE |
  NJD_TEXATTR_GLOBALINDEX);
  /* Texture number 4 */
  njSetTextureNum(&texname[4],"file1.pvr",14,
  NJD_TEXATTR_TYPE_FILE |
  NJD_TEXATTR_GLOBALINDEX);

### EXAMPLE

      NJS_TEXNAME texname[2];
      NJS_TEXNAME texname2[2];
      NJS_TEXLIST texlist ={texname,2};
      NJS_TEXLIST texlist2 ={texname2,2};
      /* Prepare to load a total of 4 textures */
      NJS_TEXMEMLIST texmemlist[4];
      Sint8 *texbuf;
      njInitTexture(texmemlist,4);
      texbuf = syMalloc(0x20800);
      njInitTextureBuffer(texbuf,0x20000);
      njSetTextureName(&texname[0],"file1.pvr",0,NJD_TEXATTR_TYPE_FILE|
            NJD_TEXATTR_GLOBALINDEX);
      njSetTextureName(&texname[1],"file2.pvr",1,NJD_TEXATTR_TYPE_FILE|
            NJD_TEXATTR_GLOBALINDEX);
      njSetTextureName(&texname2[0],"file3.pvr",2,NJD_TEXATTR_TYPE_FILE|
            NJD_TEXATTR_GLOBALINDEX);
      njSetTextureName(&texname2[1],"file4.pvr",3,NJD_TEXATTR_TYPE_FILE|
            NJD_TEXATTR_GLOBALINDEX);
      /* Load texture */
      njLoadTexture(&texlist);
      /* Load texture */
      njLoadTexture(&texlist2);
      syFree(texbuf);
      /* Set current texture list as texlist */
      njSetTexture(&texlist);
      /* Set texture 0 from texlist as current texture file1.pvr */
      njSetTextureNum(0);
          :
      /* lit. Drawing texture using texture of file1.pvr */
          :
      /* Set texlist2 as current texture list */
      njSetTexture(&texlist2);
      /* Set texture 1 from texlist2 as current texture file4.pvr */
      njSetTextureNum(1);
          :
      /* lit. Drawing texture using texture of file4.pvr */
          :

### NOTE

  The specified texture must be present in texture memory. Refer to texture document for more details.

### REFERENCE

  `njSetTexture()
  njSetTextureNumG()
  `

njSetTextureNum

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999