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 > loading texure by kosfs

#114518 - Xgame - Mon Jan 08, 2007 6:09 pm

I whold like to load pcx texture by kosfs, but I prefer to use loadPCX(..). Can I do that or must I use a loader based on stdio funcion?

#114521 - GPFerror - Mon Jan 08, 2007 6:51 pm

you should be able to.
something like this

Code:
FILE * pFile;
int lSize;
char* pcx_file;
sImage pcx;
  if ((pFile = fopen("test.pcx","rb")) == NULL){ fprintf(stderr, "Error opening file\n");}
else
{
  fseek (pFile , 0 , SEEK_END);
  lSize = ftell (pFile);
  rewind (pFile);
 pcx_file= (char*) malloc (lSize);
fread (pcx_file,1,lSize,pFile);
fclose(pFile);
loadPCX((u8*)pcx_file, &pcx);
}


this should work with any filesytem that uses stdio functions.

Troy(GPF)
http://gpf.dcemu.co.uk

#114627 - Xgame - Tue Jan 09, 2007 4:52 pm

thank you but model don't "put"texture; . I can't put texture or color over this model and I can't explain why. Model is black and for do that screenshoot i put behind a color quad. I tryed to put "glLoadIdentity() before drawing it, but nothing change. [Images not permitted - Click here to view it] screenshot is done with ensata(nintendo ds official emulator) and is perfect like in ds.

#114698 - HyperHacker - Wed Jan 10, 2007 5:58 am

So, no matter what you do, your model remains black and textureless? Keep in mind polygon colours tend to be more of a tint for the textures; for example, if you have a grass texture on a yellow polygon, you get yellowish grass. On pure black polygons your texture won't appear at all.
_________________
I'm a PSP hacker now, but I still <3 DS.

#114738 - Xgame - Wed Jan 10, 2007 3:39 pm

but I can't put color in model. if i use glColor3f nothing happen. I just put color over model using glMaterialf. I think texture is really loaded because I can view it's size.

#114744 - Vich - Wed Jan 10, 2007 4:33 pm

Maybe you have to add a light to the scene?

#114746 - Xgame - Wed Jan 10, 2007 4:37 pm

no, i tryed but it didn't work

#114747 - Vich - Wed Jan 10, 2007 4:52 pm

Maybe there's something with the material settings?
I have these in my app at the moment:
Quote:

//need to set up some material properties since DS does not have them set by default
glMaterialf(GL_AMBIENT, RGB15(16,16,16));
glMaterialf(GL_DIFFUSE, RGB15(16,16,16));
glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));
glMaterialf(GL_EMISSION, RGB15(16,16,16));


Is the object still black when you don't enable the texture?

#114799 - HyperHacker - Wed Jan 10, 2007 9:05 pm

You were able to colour that quad behind it, so colour works. I suggest you disable everything else (materials, textures, etc), and if colour works then, turn them back on one at a time until it doesn't.
_________________
I'm a PSP hacker now, but I still <3 DS.

#114914 - Xgame - Thu Jan 11, 2007 3:46 pm

Vich wrote:
Maybe there's something with the material settings?
I have these in my app at the moment:
Quote:

//need to set up some material properties since DS does not have them set by default
glMaterialf(GL_AMBIENT, RGB15(16,16,16));
glMaterialf(GL_DIFFUSE, RGB15(16,16,16));
glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));
glMaterialf(GL_EMISSION, RGB15(16,16,16));


Is the object still black when you don't enable the texture?

after doing that I put color in model. I can't really understand why it don't work, as HyperHacker said I'll tray to remove a lot of 3d stuff.
EDIT
i removed glNormal3f by drawing and colors now works, but texture dose not

#114916 - silent_code - Thu Jan 11, 2007 4:10 pm

using glcolor works with textures, but you won't be able to light anything. to use lighting you need to set a material and *not* use glcolor.

#114918 - Vich - Thu Jan 11, 2007 4:43 pm

silent_code wrote:
using glcolor works with textures, but you won't be able to light anything. to use lighting you need to set a material and *not* use glcolor.


Is it possible to first draw 3D in perspective mode with materials and lighting and then load identity matrices, disable lighting, start orthogonal projection and draw quads with a glColor?
_________________
[project website] [personal website]

#114921 - Xgame - Thu Jan 11, 2007 5:31 pm

I loaded the texture over model, but is there still a problem: texcoords are horrible wrong! look at the picture [Images not permitted - Click here to view it]

#115392 - Payk - Mon Jan 15, 2007 8:07 pm

Well, as i already told you:
You need to toggle ST coords and invert one:

Code:

newS=Texturesize-T
newT=S


That should help. I dont know which model you used but for md2 it helped alot! (thanx to webez at this point...i was totaly frustated after hours testing...)

#115475 - Xgame - Tue Jan 16, 2007 9:04 am

I solved, the model was bugged(with other models work, but with the yoshi's one not!)

#116335 - Payk - Wed Jan 24, 2007 3:13 pm

XGame.
It really depends.
Milkshape does export texture coordinates on another way then 3DS-MAX does. And worst is when loading a md2 you can know if its that way or the other way. Thats why i renamed all models made with milkshape to mdm. So when over giving a filename to the loading function it just checks the last ucased letter to see how to load it. That works fine for me.


Code:
for (I = 0; I < Models[num].header.num_tris; ++I){
   for (j = 0; j < 3; ++j){
      if(texturereverse){
         s = (float)Models[num].texcoords[Models[num].triangles[I].st[j]].s / Models[num].header.skinwidth;
         t = (float)Models[num].texcoords[Models[num].triangles[I].st[j]].t / Models[num].header.skinheight;
         Models[num].texcoords[Models[num].triangles[I].st[j]].s=floattot16(float(s)*widthheight);
         Models[num].texcoords[Models[num].triangles[I].st[j]].t=floattot16(float(1-t)*widthheight);
      }

      if(!texturereverse){
         s = (float)Models[num].texcoords[Models[num].triangles[I].st[j]].s / Models[num].header.skinwidth;
         t = (float)Models[num].texcoords[Models[num].triangles[I].st[j]].t / Models[num].header.skinheight;
         Models[num].texcoords[Models[num].triangles[I].st[j]].s=floattot16(float(s)*widthheight);
         Models[num].texcoords[Models[num].triangles[I].st[j]].t=floattot16(float(t)*widthheight);
      }
   
   }
}


So if its a milkshape md2 texturereverse should be false.
If it was made with quake modeler or 3d studio max it has to be true value.