Anyways, I was messing around with the ortho example, trying to convert it into c++ code.
The following code doesn't draws debug info on the screen, but it doesn't draw the primitives, until I quit usbhostfs_pc. Then it immediately starts to draw the primitive.
When I don't use psplink to do this, nothing at all shows up on the screen.
Code:
Code: Select all
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspgu.h>
#include <pspgum.h>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include "../common/callbacks.h"
#include "../common/vram.h"
PSP_MODULE_INFO("Tetris", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
// This is a command list for sceGuStart, at arbitrary size
static unsigned int __attribute__((aligned(16))) list[262144];
const int BUF_WIDTH = 512;
const int SCR_WIDTH = 480;
const int SCR_HEIGHT = 272;
//Vertex structure for a simple vertex.
struct Vertex
{
unsigned int color;
float x, y ,z;
};
int main ()
{
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);
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);
sceGuFrontFace(GU_CW);
sceGuShadeModel(GU_SMOOTH);
sceGuDisable(GU_TEXTURE_2D);
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
sceGuDisplay(GU_TRUE);
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
Vertex __attribute__((aligned(16))) vertices [4] =
{
{0xFF0000FF, -5.0f, -5.0f, 0.0f}, // Top, red
{0xFF00FFFF, -5.0f, 5.0f, 0.0f},
{0xFF00FF00, 5.0f, -5.0f, 0.0f}, // Right, green
{0xFFFF0000, 5.0f, 5.0f, 0.0f} // Left, blue
};
int frame = 0;
float blockSize= 13.0f;
ScePspFVector3 pos = {240.0f, 136.0f, 0.0f};
while (running())
{
SceCtrlData pad;
sceGuStart(GU_DIRECT,list);
sceCtrlPeekBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_UP)
sceCtrlPeekBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_UP)
//pos.z += 1.0f / 100.0f;
if(pad.Buttons & PSP_CTRL_DOWN)
//pos.z -= 1.0f / 100.0f;
if(abs(pad.Lx-128) > 32)
pos.x += ((pad.Lx-128)/128.0f);
if(abs(pad.Ly-128) > 32)
pos.y += ((pad.Ly-128)/128.0f);
//pos.z += 1.0f / 100.0f;
if(pad.Buttons & PSP_CTRL_DOWN)
//pos.z -= 1.0f / 100.0f;
if(abs(pad.Lx-128) > 32)
pos.x += ((pad.Lx-128)/128.0f);
if(abs(pad.Ly-128) > 32)
pos.y += ((pad.Ly-128)/128.0f);
// Clear the buffers
sceGuClearColor(0);
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
// Set ortho mode and load
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumOrtho(0, 480, 272, 0, -1, 1);
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();
// Draw primitives
//Tetrominoe s(Tetrominoe_I);
sceGumTranslate(&pos);
//sceGumRotateZ(frame*0.03f);
sceGumDrawArray(GU_TRIANGLES,GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,1*4,0,vertices);
// Finish and wait until display lists are done drawing
sceGuFinish();
sceGuSync(0,0);
pspDebugScreenSetOffset((int)fbp0);
pspDebugScreenSetXY(0,0);
//pspDebugScreenPrintf("Frame: %i", frame);
pspDebugScreenPrintf("x: %.2f y: %.2f z: %.2f",pos.x,pos.y,pos.z);
sceDisplayWaitVblankStart();
fbp0 = sceGuSwapBuffers();
frame++;
}
// Quit Gu
sceGuTerm();
// Exit game
sceKernelExitGame();
return 0;
}
In addition, when I set up code to call sceGumDrawArray more than once it only draws the last call to sceGumDrawArray (after I quit usbhostfs_pc, of course).
Thanks