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 > opengl 512X512 texture

#54592 - GPFerror - Tue Sep 20, 2005 6:28 pm

could someone post an example of displaying a 512X512 texture. I cant figure out what im doing wrong trying to update the examples from using an 128X128 texture.

thanks,
Troy(GPF)

#55217 - Ethos - Mon Sep 26, 2005 2:17 pm

Make sure you set banks A-D for textures for 512x512 (useless size imho)
_________________
Ethos' Homepage (Demos/NDS 3D Tutorial)

#55266 - dovoto - Tue Sep 27, 2005 6:14 am

My code may still have issues spanning the banks (although i seem to remember fixing it). Try manualy loading the texture into vram by setting the desired banks to VRAM_LCD, loading the graphics, then setting them back to texture. If that works then it likely is my texture code that is jacked up.
_________________
www.drunkencoders.com

#55323 - GPFerror - Tue Sep 27, 2005 7:15 pm

well here my code you can see I dont know much about 3d :(
I'v since address what I was attempting to do with the rotational background but for the help of others maybe someone can fix this code so it works :)

I just made a new pcx file of the included 128X128 and stretched it to 512X512 and renamed to drunkenlogo3.pcx

Code:
#include <nds.h>
#include <stdlib.h>
#include <malloc.h>
//needed to load pcx files
#include <nds/arm9/image.h>

#include "drunkenlogo3_pcx.h"

int main() {   
   
   int textureID;

   powerON(POWER_ALL);

   //set mode 0, enable BG0 and set it to 3D
   videoSetMode(MODE_0_3D);

   //irqs are nice
   irqInit();
   irqEnable(IRQ_VBLANK);

   //this should work the same as the normal gl call
   glViewPort(0,0,255,191);
   
   glClearColor(0,0,0);
   glClearDepth(0x7FFF);
   
   //vramSetBankA(VRAM_A_LCD); vramSetBankB(VRAM_B_LCD); vramSetBankC(VRAM_C_LCD); vramSetBankD(VRAM_D_LCD);
   vramSetBankA(VRAM_A_TEXTURE_SLOT0); vramSetBankB(VRAM_B_TEXTURE_SLOT1); vramSetBankC(VRAM_C_TEXTURE_SLOT2); vramSetBankD(VRAM_D_TEXTURE_SLOT3);
   sImage pcx;                //////////////(NEW) and different from nehe.

   //load our texture
   loadPCX((u8*)drunkenlogo3_pcx, &pcx);
   
   image8to16(&pcx);

   glGenTextures(1, &textureID);
   glBindTexture(0, textureID);
   glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_512, TEXTURE_SIZE_512, 0, TEXGEN_TEXCOORD, (u8*)pcx.data8);
   imageDestroy(&pcx);
    
   while(1) {
      glReset();
   
glMatrixMode (GL_MODELVIEW);

glPushMatrix ();

glLoadIdentity ();

glMatrixMode (GL_PROJECTION);

glPushMatrix ();

glLoadIdentity ();

      //not a real gl function and will likely change
      glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK);

      
      glBindTexture(0, textureID);

   
    //glBindTexture (GL_TEXTURE_2D, 13); /* bind to our texture, has id of 13 */

    glBegin (GL_QUADS);
    glEnable (GL_TEXTURE_2D); /* enable texture mapping */
glBegin (GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex3f (0.0, 0.0, 0.0);
glTexCoord2f (1.0, 0.0);
glVertex3f (10.0, 0.0, 0.0);
glTexCoord2f (1.0, 1.0);
glVertex3f (10.0, 10.0, 0.0);
glTexCoord2f (0.0, 1.0);
glVertex3f (0.0, 10.0, 0.0);
glEnd ();
    glEnd ();

   
glPopMatrix (0);

glMatrixMode (GL_MODELVIEW);

glPopMatrix (1);
         
      glFlush();


      swiWaitForVBlank();
   }

   return 0;
}//end main

#55324 - dovoto - Tue Sep 27, 2005 7:18 pm

oh..sorry, the float versions of glTexxxx are hardcoded to 128x128. Forgot about that.
_________________
www.drunkencoders.com

#55496 - GPFerror - Wed Sep 28, 2005 9:49 pm

dovoto wrote:
oh..sorry, the float versions of glTexxxx are hardcoded to 128x128. Forgot about that.


So does that mean I should use a differrent function or is a fix required in libnds?

thanks

#55504 - Ethos - Wed Sep 28, 2005 10:18 pm

The function i submitted glTexCoord2f32 should do the trick...only its a fixed point function....so just convert first
_________________
Ethos' Homepage (Demos/NDS 3D Tutorial)

#55649 - dovoto - Fri Sep 30, 2005 6:23 am

GPFerror wrote:
dovoto wrote:
oh..sorry, the float versions of glTexxxx are hardcoded to 128x128. Forgot about that.


So does that mean I should use a differrent function or is a fix required in libnds?

thanks

Use the fixed point version, but yes the float version will need to be fixed (which will make it even slower;)
_________________
www.drunkencoders.com