 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
snow
Joined: 15 Dec 2007 Posts: 31
|
Posted: Sun Jan 27, 2008 12:58 am Post subject: 2D image failing to display |
|
|
I've been toying around with the snes emulator and this is simply me attempting to display a rendered frame. I've borrowed the rendering code from snes9xtyl. The native resolution of the snes is 256x224 (normally). I tried just writing to the VRAM directly which ended up at least showing me pixels but they were the wrong color and pretty much a mess :-P
I'm using the following initialization,
| Code: |
#define VRAM_ADDR 0x04000000
#define MAX_DRAW_BUFFER_SIZE (0x077800)
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
void* drawBufferAddress = 0;
{
sceGuInit();
sceGuStart(GU_DIRECT,list);
sceGuDrawBuffer(GU_PSM_5551,(void*)0,BUF_WIDTH);
sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)MAX_DRAW_BUFFER_SIZE,BUF_WIDTH);
sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
sceGuEnable(GU_SCISSOR_TEST);
sceGuClear(GU_COLOR_BUFFER_BIT);
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(1);
}
|
And my rendering loop,
| Code: |
{
sceKernelDcacheWritebackAll();
sceGuStart(GU_DIRECT,list);
sceGuDrawBufferList(GU_PSM_5551,(void*)drawBufferAddress,512);
sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGB);
sceGuEnable(GU_SCISSOR_TEST);
sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
sceGuDisable(GU_DEPTH_TEST);
sceGuDisable(GU_ALPHA_TEST);
sceGuTexMode(GU_PSM_5551,0,0,0);
sceGuTexImage(0,Width,Height,512,(void*)GFX.Screen);
sceGuTexFunc(GU_TFX_REPLACE,0);
sceGuTexFilter(GU_NEAREST,GU_NEAREST);
sceGuTexScale(1.0f/Width,1.0f/Height);
sceGuTexOffset(0,0);
sceGuTexWrap(GU_CLAMP,GU_CLAMP);
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(4 * sizeof(struct Vertex));
vertices[0].u = -128;
vertices[0].v = -112;
vertices[0].x = 0;
vertices[0].y = 0;
vertices[1].u = 128;
vertices[1].v = -112;
vertices[1].x = 480;
vertices[1].y = 0;
vertices[2].u = -128;
vertices[2].v = 112;
vertices[2].x = 0;
vertices[2].y = 272;
vertices[3].u = 128;
vertices[3].v = 112;
vertices[3].x = 480;
vertices[3].y = 272;
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D,4,0,vertices);
sceGuFinish();
sceGuSync(0,0);
drawBufferAddress = sceGuSwapBuffers();
}
|
Any help is appreciated. |
|
| Back to top |
|
 |
quadrizo
Joined: 23 Aug 2007 Posts: 21
|
Posted: Sun Jan 27, 2008 9:03 am Post subject: |
|
|
well ...
when you use GU_SPRITES you have to define only two vertices : the top left and the bottom right corner
so here you draw two sprites with no height
try:
| Code: |
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
vertices[0].u = -128;
vertices[0].v = -112;
vertices[0].x = 0;
vertices[0].y = 0;
vertices[1].u = 128;
vertices[1].v = 112;
vertices[1].x = 480;
vertices[1].y = 272;
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
| [/code] |
|
| Back to top |
|
 |
|
|
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
|