KINGx - Das inoffizielle PlayStation Forum & News Portal

Normale Version: [release] PSPHBC - homebrew common
Sie sehen gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hallo zusammen,

an alle die homebrews in C++ programmieren....
Ich hab' die Erfahrung gemacht, dass bestimmte Teile bei der Erstellung von Homebrews immer wieder auftachen. Um dies nicht immer neu Entwickeln zu müssen habe ich hier eine kleine Biblothek zusammengeschürt die es ermöglicht auf Basisklassen eigene Homebrews aufzusetzen bei dem der "Grundstein" immer schon gelegt ist.
Die Bibliothek ist mit eclipse und dem Windows PSPSDK erstellt, ich weiß also nicht ob das auch unter cygwin läuft.
Die Dokumentation der Header ist in English, aber wer mag kann die Entstehungsgeschichte in komplett deutscher doku in meinem Blog nachlesen Smile

Ich hoffe das erleichert einigen den Einstieg in die Hombrew-Entwicklung mit C++ und leifert schnell sichtbare Ergebnisse.

Doch genug der Worte..

Hier die Datei:
http://psp.anmabagima.de/__oneclick_uploads/2010/01/psphomebrewcommon.zip

Das Archiv einfach in den PSP-SDK Ordner entpacken
x:\pspsdk\psp\sdk\ dann kann es genutzt werden.

Anbei noch ein Beispielcode wie die Implementierung aussehen könnte, am Beispiel eines einfachen GU Homebrew das ein buntes Dreieck darstellt Smile

PHP-Code:
/* 
 * 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 
ClHbcGuSampleAppgetInstance(); 
   static 
void releaseInstance(); 

   
bool init(); 
   
void render(); 

protected: 
   
ClHbcGuSampleApp(); 
   
virtual ~ClHbcGuSampleApp(); 
   static 
ClHbcGuSampleApp_instance
}; 

#endif /* HBCGUSAMPLEAPP_H_ */[/php 

]

PHP-Code:
/* 
 * 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" 

ClHbcGuSampleAppClHbcGuSampleApp::_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 xyz
   }
Vertex

   
//get memory for 3 vertices 
   
Vertextriangle = (Vertex*)sceGuGetMemory(sizeof(Vertex)*3); 
   
//set up the vertices for our triangle 
   
triangle[0].= -4.0f
   
triangle[0].= -2.0f
   
triangle[0].= -10.0f
   
triangle[0].color 0xff0000ff

   
triangle[1].=  0.0f
   
triangle[1].=  2.0f
   
triangle[1].= -10.0f
   
triangle[1].color 0xffff0000

   
triangle[2].=  4.0f
   
triangle[2].= -2.0f
   
triangle[2].= -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_TRIANGLESGU_TRANSFORM_3D GU_VERTEX_32BITF GU_COLOR_888830triangle); 


ClHbcGuSampleApp::ClHbcGuSampleApp() { 
   
// TODO Auto-generated constructor stub 




ClHbcGuSampleApp::~ClHbcGuSampleApp() { 
   
// TODO Auto-generated destructor stub 

PHP-Code:
/* 
 * 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"011); 
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER); 
PSP_HEAP_SIZE_KB(-1024); 


int main(int argccharargv[]) 

   
ClHbcGuSampleAppmyHomebrew ClHbcGuSampleApp::getInstance(); 

   if (
myHomebrew->init()){ 
      
myHomebrew->run(); 
      
myHomebrew->exit(); 
   } 

   
ClHbcGuSampleApp::releaseInstance(); 
   
sceKernelExitGame(); 
   return 
0

In das Makefile muss dan die folgende Zeile rein:

Code:
LIBS = -lstdc++ -lpsphbc -lpspgum -lpspgu

Bitte beachten, dass in der Reihenfolge psphbc vor pspgu und pspgum stehen muss.

Danke, werds testen sobald ich kann. Und wenn ich wieder mal mit dem PC on bist kriegst du ein Danke Smile
Referenz-URLs