07.12.2009, 13:52
Makefile
TARGET = out
OBJS = $(wildcard *.cpp) $(wildcard *.c)
INCDIR =
CFLAGS = -O2 -G0 -Wall -g
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -g
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS = -lstdc++ -lc -lpspgu
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
dann main.cpp
#include
#include
#include
#include
#include "GraphicsObject.h"
#include
#include
// MODULE INITIALISATION
PSP_MODULE_INFO("Tutorial0", 0x0000, 1, 1);
/*!
* \fn int exit_callback(int arg1, int arg2, void *common)
* \brief Exits the game.
*
* @return 0
*/
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/*!
* \fn int CallbackThread(SceSize args, void *argp)
* \brief callback thread.
*
* @return 0
*/
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/*!
* \fn int SetupCallbacks(void)
* \brief Creates a callback thread and returns the thread ID.
*
* @return thid
*/
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); //als er foutenzijn dan kan het hieraanliggen
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
/*!
* \fn int Main(void)
* \brief The main function
*
* @return 0
*/
int main (void) {
// setup the callbacks
SetupCallbacks();
// setup the environment
GraphicsObject* gfx = GraphicsObject::Instance();
// init the 3D environment
gfx->Init3DGraphics();
// shutdown
sceGuTerm();
sceKernelExitGame();
return 0;
}
dann
#include "GraphicsObject.h"
#include
static unsigned int __attribute__((aligned(16))) list[262144];
GraphicsObject* GraphicsObject::_instance = 0;// initialize pointer
GraphicsObject* GraphicsObject::Instance (void) {
if (_instance == 0){
_instance = new GraphicsObject; // create sole instance
}
return _instance; // address of sole instance
}
GraphicsObject::GraphicsObject(void) {
// creation of object
}
GraphicsObject::~GraphicsObject(void) {
// clean up
}
bool GraphicsObject::Init3DGraphics(void) {
// Initialize the GraphicalSystem
sceGuInit();
sceGuStart(GU_DIRECT,list);
sceGuDrawBuffer(GU_PSM_8888,(void*)0,512);
sceGuDispBuffer(480,272,(void*)0x88000,512);
sceGuDepthBuffer((void*)0x110000,512);
sceGuOffset(2048 - (480/2),2048 - (272/2));
// create a viewport centered at 2048,2048 width 480 and height 272
sceGuViewport(2048,2048,480,272);
sceGuDepthRange(0xc350,0x2710);
sceGuScissor(0,0,480,272);
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);
sceGuEnable(GU_LIGHTING);
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuFinish();
// wait untill the list has finished.
sceGuSync(0,0);
// turn on the display
sceGuDisplay(GU_TRUE);
return true;
}
und der letzte ist
ifndef GRAPHICSOBJECT_H_
#define GRAPHICSOBJECT_H_
class GraphicsObject {
private:
static GraphicsObject* _instance;
protected:
GraphicsObject(void);
GraphicsObject(const GraphicsObject&);
GraphicsObject& operator= (const GraphicsObject&);
public:
static GraphicsObject* Instance(void);
~GraphicsObject(void);
bool Init3DGraphics(void);
};
#endif
ich hoffe ihr könnt mich einbisschen helfen.
TARGET = out
OBJS = $(wildcard *.cpp) $(wildcard *.c)
INCDIR =
CFLAGS = -O2 -G0 -Wall -g
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -g
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS = -lstdc++ -lc -lpspgu
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
dann main.cpp
#include
#include
// MODULE INITIALISATION
PSP_MODULE_INFO("Tutorial0", 0x0000, 1, 1);
/*!
* \fn int exit_callback(int arg1, int arg2, void *common)
* \brief Exits the game.
*
* @return 0
*/
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
/*!
* \fn int CallbackThread(SceSize args, void *argp)
* \brief callback thread.
*
* @return 0
*/
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/*!
* \fn int SetupCallbacks(void)
* \brief Creates a callback thread and returns the thread ID.
*
* @return thid
*/
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); //als er foutenzijn dan kan het hieraanliggen
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
/*!
* \fn int Main(void)
* \brief The main function
*
* @return 0
*/
int main (void) {
// setup the callbacks
SetupCallbacks();
// setup the environment
GraphicsObject* gfx = GraphicsObject::Instance();
// init the 3D environment
gfx->Init3DGraphics();
// shutdown
sceGuTerm();
sceKernelExitGame();
return 0;
}
dann
#include "GraphicsObject.h"
#include
static unsigned int __attribute__((aligned(16))) list[262144];
GraphicsObject* GraphicsObject::_instance = 0;// initialize pointer
GraphicsObject* GraphicsObject::Instance (void) {
if (_instance == 0){
_instance = new GraphicsObject; // create sole instance
}
return _instance; // address of sole instance
}
GraphicsObject::GraphicsObject(void) {
// creation of object
}
GraphicsObject::~GraphicsObject(void) {
// clean up
}
bool GraphicsObject::Init3DGraphics(void) {
// Initialize the GraphicalSystem
sceGuInit();
sceGuStart(GU_DIRECT,list);
sceGuDrawBuffer(GU_PSM_8888,(void*)0,512);
sceGuDispBuffer(480,272,(void*)0x88000,512);
sceGuDepthBuffer((void*)0x110000,512);
sceGuOffset(2048 - (480/2),2048 - (272/2));
// create a viewport centered at 2048,2048 width 480 and height 272
sceGuViewport(2048,2048,480,272);
sceGuDepthRange(0xc350,0x2710);
sceGuScissor(0,0,480,272);
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);
sceGuEnable(GU_LIGHTING);
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuFinish();
// wait untill the list has finished.
sceGuSync(0,0);
// turn on the display
sceGuDisplay(GU_TRUE);
return true;
}
und der letzte ist
ifndef GRAPHICSOBJECT_H_
#define GRAPHICSOBJECT_H_
class GraphicsObject {
private:
static GraphicsObject* _instance;
protected:
GraphicsObject(void);
GraphicsObject(const GraphicsObject&);
GraphicsObject& operator= (const GraphicsObject&);
public:
static GraphicsObject* Instance(void);
~GraphicsObject(void);
bool Init3DGraphics(void);
};
#endif
ich hoffe ihr könnt mich einbisschen helfen.