rendered paste body#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspgu.h>
#include <pspgum.h>
PSP_MODULE_INFO("Graphic", 0, 1, 0);
static unsigned int __attribute__((aligned(16))) list[262144]; // Für was stehen die 262144?
#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16)) // Make Colors easier
#define RGBA(r, g, b,a) ((r)|((g)<<8)|((b)<<16)|((a)<<24)) // // Make Colors + alphachannel easier
struct Vertex {
float u, v;
unsigned int color;
float x,y,z;
};
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
/* RESULTAT: *freu* ich konnte oben links inner Ecke nen Pixel rot färben, toll...
Normalerweise sollte das ganze Teil dank/durch sceGuClearColor(RGBA(255,0,0,255)); Rot sein.
*/
int initGU() {
SetupCallbacks();
sceGuInit();
sceGuStart(GU_DIRECT, list); // Create new displaylist
// zonk nach bedeutung der void pointer fragen, was ist der VRAM, warum setzen ein paar samples vom SDK den pointer anders? (haben ne vram.h included)
sceGuDrawBuffer(GU_PSM_8888,(void*)0,512); // Create backbuffer with 24bit color, 512bit buffer width
sceGuDispBuffer(480,272,(void*)0x88000,512); // Create displaybuffer @ 480x272, 512bit buffer width
sceGuDepthBuffer((void*)0x110000,512); // Create depthbuffer @ 0x110000, 512bit buffer width <-- zonk nach bedeutung fragen
sceGuOffset(2048-(480/2),2048-(480/2)); // Center the screen
sceGuViewport(2048,2048,480,272); // Set viewport to 2048,2048 @ 480x272px
sceGuDepthRange(65535,0); // Set depthrange <-- zonk nach bedeutung fragen
// sceGuScissor(0,0,480,272); // Set the clipping area
// sceGuEnable(GU_CLIPPING_PLANES); // Enable clipping
sceGuEnable(GU_DEPTH_TEST);
sceGuShadeModel(GU_SMOOTH); // Smooth shaden <-- vielleicht auch nochmal erklärn :)
sceGuTexFilter(GU_NEAREST, GU_NEAREST);
sceGuFinish(); // Finish displaylist
sceGuSync(0,0); // Synch displaylist
sceDisplayWaitVblankStart(); // Wait 1 frame
sceGuDisplay(GU_TRUE); // Enable display
return 0;
}
int main() {
SceCtrlData pad;
initGU();
while(1) {
sceCtrlReadBufferPositive(&pad,1);
sceGuStart(GU_DIRECT,list); // Open displaylist
sceGuClearColor(RGBA(255,0,0,255)); // Set clear color
sceGuClearDepth(0); // Clear Depthbuffer ??
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); // Clear Drawbuffer, Depth Buffer Bit??
// PROJECTION MATRIX
/*---------------------------------------------------------------------------*/
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);
// VIEWPORT
/*---------------------------------------------------------------------------*/
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
// MODELVIEW
/*---------------------------------------------------------------------------*/
sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();
sceGuAmbientColor(0xffffffff);
/*---------------------------------------------------------------------------*/
sceGuFinish(); // Finish displaylist
sceGuSync(0,0); // Synch displaylist
sceDisplayWaitVblankStart(); // Wait 1 frame;
sceGuSwapBuffers(); // Switch Front and Backbuffer
}
sceGuDisplay(GU_FALSE); // Disable display
sceGuTerm(); // Terminate the GU
return 0;
}