forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Textures not appearing

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
masterlodi



Joined: 04 Mar 2006
Posts: 11

PostPosted: Mon Jul 10, 2006 5:16 am    Post subject: Textures not appearing Reply with quote

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:
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);
Back to top
View user's profile Send private message
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Mon Jul 10, 2006 6:38 am    Post subject: Reply with quote

Code:
sceGuEnable(GU_TEXTURE_2D);
perhaps?
_________________
GE Dominator
Back to top
View user's profile Send private message
masterlodi



Joined: 04 Mar 2006
Posts: 11

PostPosted: Mon Jul 10, 2006 7:09 am    Post subject: Reply with quote

I have already set that!

Code:

   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);
Back to top
View user's profile Send private message
ufoz



Joined: 10 Nov 2005
Posts: 86
Location: Tokyo

PostPosted: Mon Jul 10, 2006 2:21 pm    Post subject: Reply with quote

Code:
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.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Jul 10, 2006 3:05 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
masterlodi



Joined: 04 Mar 2006
Posts: 11

PostPosted: Tue Jul 11, 2006 7:02 am    Post subject: Reply with quote

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?!
Back to top
View user's profile Send private message
skwi



Joined: 16 May 2006
Posts: 22

PostPosted: Wed Jul 19, 2006 5:09 am    Post subject: Reply with quote

I've had the same problem because my texture was not alignated to 16 bytes, try this, this should work
Back to top
View user's profile Send private message
masterlodi



Joined: 04 Mar 2006
Posts: 11

PostPosted: Wed Aug 02, 2006 5:36 pm    Post subject: Reply with quote

I still can't get this to work: -

Code:

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;
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Wed Aug 02, 2006 6:18 pm    Post subject: Reply with quote

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

Code:

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
Back to top
View user's profile Send private message Visit poster's website
masterlodi



Joined: 04 Mar 2006
Posts: 11

PostPosted: Thu Aug 03, 2006 8:04 am    Post subject: Reply with quote

Raphael - thank you!

It all works perfectly! PS2 was sooo much easier (well, with a SCEE license anyway) :-)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group