Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Ps3ngine Camera header
- **/
- #ifndef __CAMERA_INCLUDED
- #define __CAMERA_INCLUDED
- #include <PSGL/psgl.h>
- #include <PSGL/psglu.h>
- class Camera
- {
- public:
- void initCam();
- void setXrot(float);
- void setYrot(float);
- void setXpos(float);
- void setYpos(float);
- void setZpos(float);
- void setAngle(float);
- float getXrot();
- float getYrot();
- float getXpos();
- float getYpos();
- float getZpos();
- float getAngle();
- void updateCamera();
- private:
- float xRotate;
- float yRotate;
- float xPos;
- float yPos;
- float zPos;
- float Angle;
- };
- #endif ///__CAMERA_INCLUDED
- #include "Camera.hpp"
- void Camera::initCam()
- {
- xRotate = 0;
- yRotate = 0;
- xPos = 0;
- yPos = 0;
- zPos = 0;
- Angle = 0;
- }
- void Camera::setXrot(float Val){xRotate = Val;}
- void Camera::setYrot(float Val){yRotate = Val;}
- void Camera::setXpos(float Val){xPos = Val;}
- void Camera::setYpos(float Val){yPos = Val;}
- void Camera::setZpos(float Val){zPos = Val;}
- void Camera::setAngle(float Val){Angle = Val;}
- float Camera::getXrot(){return xRotate;}
- float Camera::getYrot(){return yRotate;}
- float Camera::getXpos(){return xPos;}
- float Camera::getYpos(){return yPos;}
- float Camera::getZpos(){return zPos;}
- float Camera::getAngle(){return Angle;}
- void Camera::updateCamera()
- {
- glRotatef(xRotate,1.0,0.0,0.0);
- glRotatef(yRotate,0.0,1.0,0.0);
- glTranslatef(-xPos,-yPos,-zPos);
- }
- /**
- Ps3ngine Control Input header
- **/
- #ifndef __CONTROLS_INCLUDED
- #define __CONTROLS_INCLUDED
- #include <cell/pad.h>
- static const int MAX_CON = 7;
- enum cKeys
- {
- JOY_RIGHT_X = 4,
- JOY_RIGHT_Y = 5,
- JOY_LEFT_X = 6,
- JOY_LEFT_Y = 7,
- PAD_RIGHT = 8,
- PAD_LEFT = 9,
- PAD_UP = 10,
- PAD_DOWN = 11,
- PAD_TRIANGLE = 12,
- PAD_CIRCLE = 13,
- PAD_CROSS = 14,
- PAD_SQUARE = 15,
- PAD_L1 = 16,
- PAD_R1 = 17,
- PAD_L2 = 18,
- PAD_R2 = 19,
- SIXAXIS_X = 20,
- SIXAXIS_Y = 21,
- SIXAXIS_Z = 22,
- SIXAXIS_GYRO = 23
- };
- class Controller
- {
- public:
- ~Controller( void );
- int initController( void );
- int readPad( void );
- bool readKey(const int, const int);
- bool enableSixaxis(int);
- bool disableSixaxis(int);
- unsigned int rightJoyX(int);
- unsigned int rightJoyY(int);
- unsigned int leftJoyX(int);
- unsigned int leftJoyY(int);
- unsigned int sixaxisX(int);
- unsigned int sixaxisY(int);
- unsigned int sixaxisZ(int);
- unsigned int sixaxisGyro(int);
- private:
- CellPadInfo padInfo;
- CellPadData padData[MAX_CON];
- CellPadCapabilityInfo Capability[MAX_CON];
- CellPadActParam actParam[MAX_CON];
- };
- #endif ///__CONTROLS_INCLUDED
- #include "Controls.hpp"
- Controller::~Controller( void )
- {
- cellPadEnd();
- }
- int Controller::initController( void )
- {
- return cellPadInit(MAX_CON);
- }
- int Controller::readPad( void )
- {
- cellPadGetData(0, &padData[0]);
- return (cellPadGetInfo(&padInfo));
- }
- bool Controller::readKey(const int Pad, const int Key)
- {
- if(Key > 7 && Key < 20)
- {
- return (padData[Pad].button[Key]);
- }
- return 0;
- }
- bool Controller::enableSixaxis(int Pad)
- {
- if(cellPadInfoSensorMode(Pad))
- {
- cellPadSetSensorMode(Pad, true);
- return true;
- }
- return 0;
- }
- bool Controller::disableSixaxis(int Pad)
- {
- return cellPadSetSensorMode(Pad, false);
- }
- unsigned int Controller::rightJoyX(int Pad){return (padData[Pad].button[JOY_RIGHT_X]);}
- unsigned int Controller::rightJoyY(int Pad){return (padData[Pad].button[JOY_RIGHT_Y]);}
- unsigned int Controller::leftJoyX(int Pad){return (padData[Pad].button[JOY_LEFT_X]);}
- unsigned int Controller::leftJoyY(int Pad){return (padData[Pad].button[JOY_LEFT_Y]);}
- unsigned int Controller::sixaxisX(int Pad){return (padData[Pad].button[SIXAXIS_X]);}
- unsigned int Controller::sixaxisY(int Pad){return (padData[Pad].button[SIXAXIS_Y]);}
- unsigned int Controller::sixaxisZ(int Pad){return (padData[Pad].button[SIXAXIS_Z]);}
- unsigned int Controller::sixaxisGyro(int Pad){return (padData[Pad].button[SIXAXIS_GYRO]);}
- /**
- Ps3ngine Rendering header
- **/
- #ifndef __RENDERGLES_INCLUDED
- #define __RENDERGLES_INCLUDED
- #include <sys/spu_initialize.h>
- #include <cell/sysmodule.h>
- #include <PSGL/psgl.h>
- #include <PSGL/psglu.h>
- class Display
- {
- public:
- void initDisplay();
- void clearDisplay( void );
- void finalizeDisplay( void );
- GLuint getScreenWidth( void );
- GLuint getScreenHeight( void );
- GLfloat getAspectRatio( void );
- private:
- PSGLinitOptions Options;
- PSGLdevice *Device;
- PSGLcontext *Context;
- GLuint screenWidth;
- GLuint screenHeight;
- GLfloat aspectRatio;
- };
- #endif ///__RENDERGLES_INCLUDED
- #include "RenderGLES.hpp"
- void Display::initDisplay()
- {
- sys_spu_initialize(6, 1);
- screenWidth = 1280;
- screenHeight = 720;
- cellSysmoduleLoadModule(CELL_SYSMODULE_GCM_SYS);
- cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
- cellSysmoduleLoadModule(CELL_SYSMODULE_USBD);
- cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
- Options.enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS;
- Options.maxSPUs = 1;
- Options.initializeSPUs = GL_FALSE;
- Options.persistentMemorySize = 0,
- Options.transientMemorySize = 0,
- Options.errorConsole = 0,
- Options.fifoSize = 256*1024,
- Options.hostMemorySize = 128*1024*1024;
- psglInit(&Options);
- Device = psglCreateDeviceAuto(GL_ARGB_SCE,GL_DEPTH_COMPONENT24,GL_MULTISAMPLING_4X_SQUARE_ROTATED_SCE);
- psglGetDeviceDimensions(Device, &screenWidth, &screenHeight);
- aspectRatio = psglGetDeviceAspectRatio(Device);
- Context = psglCreateContext();
- psglMakeCurrent(Context, Device);
- psglResetCurrentContext();
- glViewport(0, 0, screenWidth, screenHeight);
- glScissor(0, 0, screenWidth, screenHeight);
- glClearColor(0.0, 0.0, 0.0, 1.0);
- glClearDepthf(1.0f);
- glEnable(GL_DEPTH_TEST);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- psglSwap();
- }
- GLuint Display::getScreenWidth(void){return screenWidth;}
- GLuint Display::getScreenHeight(void){return screenHeight;}
- GLfloat Display::getAspectRatio(void){return aspectRatio;}
- void Display::clearDisplay( void )
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- }
- void Display::finalizeDisplay( void )
- {
- psglSwap();
- }
- /**
- Ps3ngine File IO header
- **/
- #ifndef __FILEIO_INCLUDED
- #define __FILEIO_INCLUDED
- class File
- {
- public:
- File(const char *, const char *);
- bool Open(const char *, const char *);
- int Print(char *, ...);
- int Close( void );
- int Read(void *, size_t, size_t);
- int Write(const void *, size_t, size_t);
- int Seek(long, int);
- FILE *getFile( void );
- private:
- FILE *F;
- };
- #endif //__FILEIO_INCLUDED
- #include <stdio.h>
- #include "FileIO.hpp"
- File::File(const char *FileName, const char *Mode)
- {
- F = fopen(FileName, Mode);
- }
- bool File::Open(const char *FileName, const char *Mode)
- {
- F = fopen(FileName, Mode);
- return !F;
- }
- int File::Print(char *Format, ...)
- {
- va_list Args;
- char Buffer[BUFSIZ];
- va_start(Args, Format);
- vsnprintf(Buffer, BUFSIZ, Format, Args);
- va_end(Args);
- return fprintf(F, Buffer);
- }
- int File::Close(void)
- {
- return fclose(F);
- }
- int File::Read(void *Data, size_t Size, size_t Count)
- {
- return fread(Data, Size, Count, F);
- }
- int File::Write(const void *Data, size_t Size, size_t Count)
- {
- return fwrite(Data, Size, Count, F);
- }
- int File::Seek(long Offset, int Origin)
- {
- return fseek(F, Offset, Origin);
- }
- FILE *File::getFile( void )
- {
- return F;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement