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 > DS Textures and my quest for more knowledge (involves QUADS)

#60061 - LOst? - Sun Nov 06, 2005 8:18 pm

I have this little idea how to use a texture of 256x256 and reuse it over a cupple of 2D quads by just changing the UV coordinates. I don't even know how to save a texture or how to load it correctly.
glGenTextures(), glBindTexture(), and glTexImage2D() are some of the routines I know I have to call. But right now I have too little info on my hands. I have tried to find more info, but the only real info out there is "working the same as OpenGL". I don't know OpenGL. I don't even want to use 3D.

dovoto has been the best help so far. His little analog clock example made me a hero for a day. He knows most of these stuff I guess.

I want to add numbers to my working analog clock. 1 to 12, all being painted into a square texture. Then saved into C data. From here my guess it to apply the same texture to all the quads I have put out on the clock face, and then change the UV coordinates (which I still haven't understood yet). The hardest part will be to figire out how to change the color of the numbers to the same color of my clock face. If it somehow works the same as Direct3D, all I need to do is make the numbers white, and then change the vertex color. I promise you that I will try my best with the info I get from here. So any info is worth to me!

Also, if any of you want to give a link to a good texture conversation program. A program that can save with the alpha channel bit, so that I can have white pixels, and the black pixels to become transparent somehow.


Thank you for helping me in any way possible!
_________________
Exceptions are fun

#60133 - Extreme Coder - Mon Nov 07, 2005 11:41 am

I don't know about the texture conversion things, but I can help about tex coordinates. Let's take an example:

If you only want to take from 1,0 to 3,3, you could do the following:

Code:

glLoadIdentity();   // Reset The View
   
float tx=(1/tex_width);// The top left corner
float ty=(3/tex_height);//same here
   
float tx2=(0/tex_width);//bottom left corner
float ty2=(3/tex_height);//same here
   
glBindTexture(GL_TEXTURE_2D, texture[0]);

glBegin(GL_QUADS);
   glTexCoord2f( tx, ty); glVertex3f(0, 0, 0);
   glTexCoord2f(tx2, ty); glVertex3f(1, 0, 0);
   glTexCoord2f(tx2,ty2); glVertex3f(1,1, 0);
   glTexCoord2f( tx,ty2); glVertex3f( 0,1, 0);

   glEnd();
// You can change the vertex coordinates as you like


Hope that helped ;)

#60147 - LOst? - Mon Nov 07, 2005 5:14 pm

Yes. This is one step I needed to know. This will help me to get starting. Thanks!
_________________
Exceptions are fun