Textures not appearing

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

Moderators: cheriff, TyRaNiD

Post Reply
masterlodi
Posts: 11
Joined: Sat Mar 04, 2006 9:35 pm

Textures not appearing

Post by masterlodi »

I'm trying to texture a cube with a 24-bit bitmap and it doesn't seem to work.

I've loaded the 24-bit image file fine but when the cube is rendered, there are no textures. What am I doing wrong?

Code: Select all

sceGuTexMode(GU_PSM_8888,0,0,0);
sceGuTexImage(0,tex.biWidth, tex.biHeight, tex.biWidth,tex.biData);
sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGB);
sceGuTexFilter(GU_LINEAR,GU_LINEAR);
sceGuTexScale(1.0f,1.0f);
sceGuTexOffset(0.0f,0.0f);
sceGuAmbientColor(0xffffffff);
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

Code: Select all

sceGuEnable(GU_TEXTURE_2D);
perhaps?
GE Dominator
masterlodi
Posts: 11
Joined: Sat Mar 04, 2006 9:35 pm

Post by masterlodi »

I have already set that!

Code: Select all

   sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
	sceGuDepthBuffer(zbp,BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
	sceGuDepthRange(65535,0);
	sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuDepthFunc(GU_GEQUAL);
	sceGuEnable(GU_DEPTH_TEST);
	sceGuFrontFace(GU_CW);
	sceGuShadeModel(GU_SMOOTH);
	sceGuEnable(GU_CULL_FACE);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuEnable(GU_CLIP_PLANES);
ufoz
Posts: 86
Joined: Thu Nov 10, 2005 2:36 am
Location: Tokyo
Contact:

Post by ufoz »

Code: Select all

sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGB); 
Maybe try GU_TFX_MODULATE? Cause the way this looks, you're adding to FFFFFF which will stay white, unless I'm missing something.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

You need to use GU_TCC_RGBA as second arg to sceGuTexFunc if you are doing any blending... and if you aren't doing any blending, GU_TFX_REPLACE should work ;)
Shoot Pixels Not People!
Makeshift Development
masterlodi
Posts: 11
Joined: Sat Mar 04, 2006 9:35 pm

Post by masterlodi »

I set the ambient colour to 0xffffffff because I thought this would'nt colourise the texture map?!

I'm now using GU_TFX_REPLACE in the sceGuTexFunc call but no change?!
skwi
Posts: 22
Joined: Tue May 16, 2006 4:28 am

Post by skwi »

I've had the same problem because my texture was not alignated to 16 bytes, try this, this should work
masterlodi
Posts: 11
Joined: Sat Mar 04, 2006 9:35 pm

Post by masterlodi »

I still can't get this to work: -

Code: Select all

typedef struct
{
	u32 biWidth;
                u32 biHeight;
	u32 uSize;
	u8* biData;				
} __attribute__((aligned(16))) TEXTURE;


TEXTURE __attribute__((aligned(16))) texCube;


   pspDebugScreenInit(); 
   setupCallbacks(); 

   // setup GU 

   void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888); 
   void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888); 
   void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444); 

   BMP_Load("DATA\\TEST.BMP", &texCube); 
    
   sceGuInit(); 

   sceGuStart(GU_DIRECT,list); 
   sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH); 
   sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH); 
   sceGuDepthBuffer(zbp,BUF_WIDTH); 
   sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2)); 
   sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT); 
   sceGuDepthRange(65535,0); 
   sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT); 
   sceGuEnable(GU_SCISSOR_TEST); 
   sceGuDepthFunc(GU_GEQUAL); 
   sceGuEnable(GU_DEPTH_TEST); 
   sceGuFrontFace(GU_CW); 
   sceGuShadeModel(GU_SMOOTH); 
   sceGuEnable(GU_CULL_FACE); 
   sceGuEnable(GU_TEXTURE_2D); 
   sceGuEnable(GU_CLIP_PLANES); 
   sceGuFinish(); 
   sceGuSync(0,0); 

   sceDisplayWaitVblankStart(); 
   sceGuDisplay(GU_TRUE); 

   // run sample 

   int val = 0; 

   while(running()) 
   { 
      sceGuStart(GU_DIRECT,list); 

      // clear screen 

      sceGuClearColor(0xff554433); 
      sceGuClearDepth(0); 
      sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); 

      // setup matrices for cube 

      sceGumMatrixMode(GU_PROJECTION); 
      sceGumLoadIdentity(); 
      sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f); 

      sceGumMatrixMode(GU_VIEW); 
      sceGumLoadIdentity(); 

      sceGumMatrixMode(GU_MODEL); 
      sceGumLoadIdentity(); 
      { 
         ScePspFVector3 pos = { 0, 0, -2.5f }; 
         ScePspFVector3 rot = { val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f) }; 
         sceGumTranslate(&pos); 
         sceGumRotateXYZ(&rot); 
      } 

      // setup texture 

      sceGuTexMode(GU_PSM_8888,0,0,0); 
      sceGuTexImage(0,texCube.biWidth, texCube.biHeight, texCube.biWidth,texCube.biData); 
      sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); 
      sceGuTexEnvColor(0xffff00); 
      sceGuTexFilter(GU_LINEAR,GU_LINEAR); 
      sceGuTexScale(1.0f,1.0f); 
      sceGuTexOffset(0.0f,0.0f); 
      sceGuAmbientColor(0xffffffff); 

      // draw cube 

      sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,vertices); 

      sceGuFinish(); 
      sceGuSync(0,0); 

      sceDisplayWaitVblankStart(); 
      sceGuSwapBuffers(); 

      val++; 
   } 

   sceGuTerm(); 

   sceKernelExitGame(); 
   return 0;
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

masterlodi wrote:I still can't get this to work: -

Code: Select all

typedef struct
{
	u32 biWidth;
                u32 biHeight;
	u32 uSize;
	u8* biData;				
} __attribute__((aligned(16))) TEXTURE;


TEXTURE __attribute__((aligned(16))) texCube;

You know how this is not gonna align your biData to 16 bytes? You need to allocate biData with memalign
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
masterlodi
Posts: 11
Joined: Sat Mar 04, 2006 9:35 pm

Post by masterlodi »

Raphael - thank you!

It all works perfectly! PS2 was sooo much easier (well, with a SCEE license anyway) :-)
Post Reply