Load and used some texture ? (3D gu)

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Poison_xtreamlua
Posts: 12
Joined: Fri Aug 10, 2007 2:03 am

Load and used some texture ? (3D gu)

Post by Poison_xtreamlua »

Hi there,

I'm programming a 3D homebrew (my first 3D homebrew :p) and I wonder if it's possible to load and use more than one texture, can we used 3 , 4 or 5 texture ? (I'm using this class to load texture : http://www.psp-programming.com/code/dok ... rt-lesson5 ), and if it's possible how ?

Should I do this :

Code: Select all

	texture1.LoadTGA("data/texture/intro.tga");
	texture1.Swizzle();

	texture2.LoadTGA("data/texture/intro.tga");
	texture2.Swizzle();

       //....some lines
	sceGuEnable(GU_TEXTURE_2D);

	sceGuTexMode(GU_PSM_8888, 0, 0, texture1.Swizzled());
	sceGuTexMode(GU_PSM_8888, 0, 0, texture2.Swizzled());
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
	sceGuTexFilter( GU_LINEAR, GU_LINEAR );
	sceGuTexScale( 1.0f, 1.0f );
	sceGuTexOffset( 0.0f, 0.0f );
Or should I do this :

Code: Select all

	texture1.LoadTGA("data/texture/intro.tga");
	texture1.Swizzle();

	texture2.LoadTGA("data/texture/intro.tga");
	texture2.Swizzle();

       //....some lines
	sceGuEnable(GU_TEXTURE_2D);

	sceGuTexMode(GU_PSM_8888, 0, 0, texture1.Swizzled());
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
	sceGuTexFilter( GU_LINEAR, GU_LINEAR );
	sceGuTexScale( 1.0f, 1.0f );
	sceGuTexOffset( 0.0f, 0.0f );

	sceGuTexMode(GU_PSM_8888, 0, 0, texture2.Swizzled());
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
	sceGuTexFilter( GU_LINEAR, GU_LINEAR );
	sceGuTexScale( 1.0f, 1.0f );
	sceGuTexOffset( 0.0f, 0.0f );
Thanks :)

NB : Is it possible to load a 512 *512 tga ? Because it seems to bug when I try to blit the texture,whereas when I load the same image but in 256 *256 it works perfectly ?

Thanks again
quadrizo
Posts: 21
Joined: Thu Aug 23, 2007 10:21 pm

Post by quadrizo »

of course you can use more than one texture

but it seems to me you confuse the loading and use

loading :

Code: Select all

   texture1.LoadTGA("data/texture/intro.tga");
   texture1.Swizzle(); 
and use:

Code: Select all

   sceGuEnable(GU_TEXTURE_2D);

   sceGuTexMode(GU_PSM_8888, 0, 0, texture1.Swizzled());
   sceGuTexImage(0, ..., (void*) texture1.data);
   sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
   sceGuTexFilter( GU_LINEAR, GU_LINEAR );
   sceGuTexScale( 1.0f, 1.0f );
   sceGuTexOffset( 0.0f, 0.0f );
...
   sceGuDrawArray(....
... 
  sceGuTexMode(GU_PSM_8888, 0, 0, texture2.Swizzled());
  sceGuTexImage(0, ..., (void*) texture2.data);
...
  sceGuDrawArray(....
sceGuTexFunc,sceGuTexMode,sceGuTexFilter,...are used to give parameters to apply to the texture

and size limits are 512x512.... maybe a bug in your code
jsharrad
Posts: 100
Joined: Thu Oct 20, 2005 3:06 am

Post by jsharrad »

First one is fine provided you don't want different filtering / other texture options for each texture.

Getting errors when loading a 512x512 texture or not displaying correctly is probably because you're trying to load the whole thing into vram and there isn't enough vram left over after setting up the depth, draw, and display buffers for a texture that size (1mb).

If you're using 32 bit framebuffers, you only have about 700k vram left over.
Poison_xtreamlua
Posts: 12
Joined: Fri Aug 10, 2007 2:03 am

Post by Poison_xtreamlua »

quadrizo -> Thanks , you have resolved one of my problem, I was programming with a wrong code ^^ .

jsharrad -> Thanks for those information :) , but how I know if I load textures in VRAM or in RAM ? And how to choose :p ?

Because RAM have an higher capacity than VRAM (I mean RAM is bigger than VRAM) ?

Thanks again ;)
Post Reply