forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[release] PSPHBC - homebrew common

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
anmabagima



Joined: 01 Oct 2009
Posts: 96

PostPosted: Wed Jan 20, 2010 6:32 pm    Post subject: [release] PSPHBC - homebrew common Reply with quote

Hi there,

I've always got very good support in this community and I guess it's time to give something back ;o)

I've seen that there are very often always the same steps needed to get started with a homebrew...As I'm using objec oriented C to develop I've created a "hombrew common" library which provides base classes doing most of the initialization stuff which from my point of view is common to the most homebrews. It's my first "release" and I would still see myself as newbie - so if you have any suggestions, please do not hesitate to provide valuable feedback :o)

Hope you enjoy

However, enough words...
Here is the link to the library and header files:
http://psp.anmabagima.de/__oneclick_uploads/2010/01/psphomebrewcommon.zip
The library was created using eclipse and minimalist PSPSDK on windows. I'm not sure if it works with cygwin as well.
To use this you could simply extract the zip file to the pspsdk folder:

x:\pspsdk\psp\sdk\

To give you in addition a sample how to use eg. the 3dHomebrew base class for your GU applications please have a look at the following code:


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 ClHbcGuSampleApp* getInstance();
   static void releaseInstance();

   bool init();
   void render();

protected:
   ClHbcGuSampleApp();
   virtual ~ClHbcGuSampleApp();
   static ClHbcGuSampleApp* _instance;
};

#endif /* HBCGUSAMPLEAPP_H_ */

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"

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
}


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", 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;
}


In the make file the following is nedded:
Code:
LIBS = -lstdc++ -lpsphbc -lpspgum -lpspgu

The psphbc library should be before pspgu and pspgum.
Back to top
View user's profile Send private message
Ameen



Joined: 14 Jun 2009
Posts: 12
Location: Bahrain

PostPosted: Wed Jan 20, 2010 11:12 pm    Post subject: Reply with quote

What a nice piece of contribution..
Thank you.
Back to top
View user's profile Send private message Visit poster's website
anmabagima



Joined: 01 Oct 2009
Posts: 96

PostPosted: Fri Jan 22, 2010 5:07 am    Post subject: Reply with quote

Thanks....
Back to top
View user's profile Send private message
CHERTS



Joined: 29 Oct 2007
Posts: 15

PostPosted: Fri Jan 22, 2010 2:36 pm    Post subject: Reply with quote

show the full Makefile

thanks!
Back to top
View user's profile Send private message
CHERTS



Joined: 29 Oct 2007
Posts: 15

PostPosted: Fri Jan 22, 2010 2:45 pm    Post subject: Reply with quote

everything works, thanks for the library

Code:
TARGET = PSPHBC

OBJS = main.o HbcGuSampleApp.o
CFLAGS = -O2 -g -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR=
LDFLAGS=
LIBS = -lstdc++ -lpsphbc -lpspgum -lpspgu -lm

EXTRA_TARGETS=EBOOT.PBP
PSP_EBOOT_TITLE=PSPHBC
#PSP_EBOOT_ICON=icon.png

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
Back to top
View user's profile Send private message
anmabagima



Joined: 01 Oct 2009
Posts: 96

PostPosted: Fri Jan 22, 2010 7:52 pm    Post subject: Reply with quote

CHERTS wrote:
show the full Makefile

thanks!


Hi,

thanks for posting the makefile. It really looks similar to mine ;O)

Sorry that I've missed it.

Regards
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group