/*
* HbcGuSampleApp.h
* Sample implementation of the 3dHomebrew base class
* to demonstrate it's usage
*
* (c) André Borrmann 2010
* Permission to copy, use, modify and distribute of this software is
* granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied warranty,
* and with no claim as to it's suitability for any purpose
*/
#ifndef HBCGUSAMPLEAPP_H_
#define HBCGUSAMPLEAPP_H_
#include <3dHomebrew.h>
class ClHbcGuSampleApp : public Cl3dHomebrew {
public:
static ClHbcGuSampleApp* getInstance();
static void releaseInstance();
bool init();
void render();
protected:
ClHbcGuSampleApp();
virtual ~ClHbcGuSampleApp();
static ClHbcGuSampleApp* _instance;
};
#endif /* HBCGUSAMPLEAPP_H_ */[/php
/*
* HbcGuSampleApp.cpp
* Sample implementation of the 3dHomebrew base class
* to demonstrate it's usage
*
* (c) André Borrmann 2010
* Permission to copy, use, modify and distribute of this software is
* granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied warranty,
* and with no claim as to it's suitability for any purpose
*/
extern "C"{
#include <pspgu.h>
#include <pspgum.h>
}
#include "HbcGuSampleApp.h"
ClHbcGuSampleApp* ClHbcGuSampleApp::_instance = 0;
ClHbcGuSampleApp *ClHbcGuSampleApp::getInstance(){
if(!_instance){
_instance = new ClHbcGuSampleApp();
}
return _instance;
}
void ClHbcGuSampleApp::releaseInstance(){
if (_instance) {
delete(_instance);
_instance = 0;
}
}
bool ClHbcGuSampleApp::init(){
if (!Cl3dHomebrew::init()) return false;
return true;
}
/*
* sample rendering implementation just render a triangle ;o)
*/
void ClHbcGuSampleApp::render(){
typedef struct Vertex {
int color;
float x, y, z;
}Vertex;
//get memory for 3 vertices
Vertex* triangle = (Vertex*)sceGuGetMemory(sizeof(Vertex)*3);
//set up the vertices for our triangle
triangle[0].x = -4.0f;
triangle[0].y = -2.0f;
triangle[0].z = -10.0f;
triangle[0].color = 0xff0000ff;
triangle[1].x = 0.0f;
triangle[1].y = 2.0f;
triangle[1].z = -10.0f;
triangle[1].color = 0xffff0000;
triangle[2].x = 4.0f;
triangle[2].y = -2.0f;
triangle[2].z = -10.0f;
triangle[2].color = 0xff00ff00;
//clear the screen with different color than the 3DHomebrew class does
sceGuClearColor(0xff442222);
sceGuClear(GU_COLOR_BUFFER_BIT);
// set the View and Model Matrix
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();
//set the smooth shade model
sceGuShadeModel(GU_SMOOTH);
//disable textures as we have no
sceGuDisable(GU_TEXTURE_2D);
//render the triangle
sceGumDrawArray(GU_TRIANGLES, GU_TRANSFORM_3D | GU_VERTEX_32BITF | GU_COLOR_8888, 3, 0, triangle);
}
ClHbcGuSampleApp::ClHbcGuSampleApp() {
// TODO Auto-generated constructor stub
}
ClHbcGuSampleApp::~ClHbcGuSampleApp() {
// TODO Auto-generated destructor stub
}
/*
* main.cpp Sample program to show how the homebrew common classes
* can be used for your own homebrews
*
* (c) André Borrmann 2010
* Permission to copy, use, modify and distribute of this software is
* granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied warranty,
* and with no claim as to it's suitability for any purpose
*
*/
extern "C"{
#include <pspkernel.h>
}
#include "HbcGuSampleApp.h"
PSP_MODULE_INFO("HBC GU Sample", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(-1024);
int main(int argc, char* argv[])
{
ClHbcGuSampleApp* myHomebrew = ClHbcGuSampleApp::getInstance();
if (myHomebrew->init()){
myHomebrew->run();
myHomebrew->exit();
}
ClHbcGuSampleApp::releaseInstance();
sceKernelExitGame();
return 0;
}
LIBS = -lstdc++ -lpsphbc -lpspgum -lpspgu
Bitte beachten, dass in der Reihenfolge psphbc vor pspgu und pspgum stehen muss.