-Improved JGE texture loading, improved Wagic cache
- Jge small changes in mp3 methods
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-04-09 13:31:07 +00:00
parent 4a8aaf5187
commit 387c75e16d
14 changed files with 177 additions and 92 deletions

View File

@@ -124,7 +124,7 @@ public:
/// @param mode - Choose to put texture in VRAM (PSP only). /// @param mode - Choose to put texture in VRAM (PSP only).
/// ///
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JTexture* LoadTexture(const char* filename, int mode = 0); JTexture* LoadTexture(const char* filename, int mode = 0, int textureFormat = TEXTURE_FORMAT);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// Create texture from memory on the fly. /// Create texture from memory on the fly.
@@ -527,10 +527,10 @@ private:
bool mVRAM; bool mVRAM;
}; };
void LoadJPG(TextureInfo &textureInfo, const char *filename, int mode = 0); void LoadJPG(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT);
void LoadPNG(TextureInfo &textureInfo, const char *filename, int mode = 0); void LoadPNG(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT);
void LoadGIF(TextureInfo &textureInfo, const char *filename, int mode = 0); void LoadGIF(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT);
int image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode = 0); int image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode = 0, int TextureFormat = TEXTURE_FORMAT);
static JRenderer* mInstance; static JRenderer* mInstance;
@@ -547,6 +547,9 @@ private:
PIXEL_TYPE* mVRAM; PIXEL_TYPE* mVRAM;
int mCurrentTex; int mCurrentTex;
int mCurrentBlend; int mCurrentBlend;
int mCurrentTextureFormat;
int PixelSize(int textureMode);
#endif #endif

View File

@@ -48,6 +48,7 @@ public:
JMusic(); JMusic();
~JMusic(); ~JMusic();
void Update(); void Update();
int getPlayTime();
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
@@ -173,6 +174,7 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void SetVolume(int volume); void SetVolume(int volume);
int mChannel;
protected: protected:
JSoundSystem(); JSoundSystem();
~JSoundSystem(); ~JSoundSystem();
@@ -189,7 +191,7 @@ private:
#endif #endif
int mVolume; int mVolume;
int mChannel;
static JSoundSystem* mInstance; static JSoundSystem* mInstance;

View File

@@ -143,7 +143,10 @@ typedef uint32_t u32;
PSP_CTRL_NOTE = 0x800000 PSP_CTRL_NOTE = 0x800000
} PspCtrlButtons; } PspCtrlButtons;
#define TEXTURE_FORMAT 0
#define GU_PSM_8888 0
#define GU_PSM_5551 0
#define GU_PSM_4444 0
#define PIXEL_TYPE DWORD #define PIXEL_TYPE DWORD
#else // PSP #else // PSP
@@ -327,7 +330,7 @@ public:
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
GLuint mTexId; GLuint mTexId;
#else #else
int mTextureFormat;
int mTexId; int mTexId;
bool mInVideoRAM; bool mInVideoRAM;
PIXEL_TYPE* mBits; PIXEL_TYPE* mBits;

Binary file not shown.

Binary file not shown.

View File

@@ -102,6 +102,7 @@ JTexture::JTexture()
{ {
mBits = NULL; mBits = NULL;
mInVideoRAM = false; mInVideoRAM = false;
mTextureFormat = TEXTURE_FORMAT;
} }
JTexture::~JTexture() JTexture::~JTexture()
@@ -190,12 +191,13 @@ void JRenderer::InitRenderer()
} }
#endif #endif
mSwizzle = 1; mSwizzle = 0;
mVsync = false; mVsync = false;
mTexCounter = 0; mTexCounter = 0;
mCurrentTex = -1; mCurrentTex = -1;
mCurrentBlend = -1; mCurrentBlend = -1;
mCurrentTextureFormat = TEXTURE_FORMAT;
mFOV = 75.0f; mFOV = 75.0f;
@@ -568,7 +570,12 @@ void JRenderer::PlotArray(float *x, float *y, int count, PIXEL_TYPE color)
// v3---v4 // v3---v4
void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float xScale, float yScale) void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float xScale, float yScale)
{ {
if (mCurrentTex != quad->mTex->mTexId) if (mCurrentTextureFormat != quad->mTex->mTextureFormat){
mCurrentTextureFormat = quad->mTex->mTextureFormat;
sceGuTexMode(mCurrentTextureFormat, 0, 0, mSwizzle);
}
if (mCurrentTex != quad->mTex->mTexId)
{ {
sceGuTexImage(0, quad->mTex->mTexWidth, quad->mTex->mTexHeight, quad->mTex->mTexWidth, quad->mTex->mBits); sceGuTexImage(0, quad->mTex->mTexWidth, quad->mTex->mTexHeight, quad->mTex->mTexWidth, quad->mTex->mBits);
mCurrentTex = quad->mTex->mTexId; mCurrentTex = quad->mTex->mTexId;
@@ -580,6 +587,8 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
mCurrentBlend = quad->mBlend; mCurrentBlend = quad->mBlend;
} }
//float destWidth = quad->mWidth*quad->mScaleX; //float destWidth = quad->mWidth*quad->mScaleX;
float destHeight = quad->mHeight*yScale; float destHeight = quad->mHeight*yScale;
float x = xo - quad->mHotSpotX*xScale; float x = xo - quad->mHotSpotX*xScale;
@@ -736,6 +745,11 @@ void JRenderer::RenderQuad(JQuad* quad, float xo, float yo, float angle, float x
void JRenderer::RenderQuad(JQuad* quad, VertexColor* points) void JRenderer::RenderQuad(JQuad* quad, VertexColor* points)
{ {
if (mCurrentTextureFormat != quad->mTex->mTextureFormat){
mCurrentTextureFormat = quad->mTex->mTextureFormat;
sceGuTexMode(mCurrentTextureFormat, 0, 0, mSwizzle);
}
if (mCurrentTex != quad->mTex->mTexId) if (mCurrentTex != quad->mTex->mTexId)
{ {
sceGuTexImage(0, quad->mTex->mTexWidth, quad->mTex->mTexHeight, quad->mTex->mTexWidth, quad->mTex->mBits); sceGuTexImage(0, quad->mTex->mTexWidth, quad->mTex->mTexHeight, quad->mTex->mTexWidth, quad->mTex->mBits);
@@ -748,6 +762,8 @@ void JRenderer::RenderQuad(JQuad* quad, VertexColor* points)
mCurrentBlend = quad->mBlend; mCurrentBlend = quad->mBlend;
} }
// allocate memory on the current display list for temporary storage // allocate memory on the current display list for temporary storage
// in order to rotate, we use 4 vertices this time // in order to rotate, we use 4 vertices this time
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(4 * sizeof(struct Vertex)); struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(4 * sizeof(struct Vertex));
@@ -978,7 +994,21 @@ static void jpeg_mem_src(j_decompress_ptr cinfo, u8 *mem, int len)
} }
void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode) int JRenderer::PixelSize(int textureMode){
switch (textureMode) {
case PSP_DISPLAY_PIXEL_FORMAT_565:
return 2;
case PSP_DISPLAY_PIXEL_FORMAT_5551:
return 2;
case PSP_DISPLAY_PIXEL_FORMAT_4444:
return 2;
case PSP_DISPLAY_PIXEL_FORMAT_8888:
return 4;
}
return PIXEL_SIZE;
}
void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode, int textureMode)
{ {
textureInfo.mBits = NULL; textureInfo.mBits = NULL;
char filenamenew[4096]; char filenamenew[4096];
@@ -992,9 +1022,13 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
struct jpeg_decompress_struct cinfo; struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr; struct jpeg_error_mgr jerr;
u8 *rgbadata, *scanline, *p, *q; u8 *scanline, *p;
u16 *rgbadata16, *q16, *bits16;
u32 *rgbadata32, *q32, *bits32;
int rawsize, i; int rawsize, i;
int pixelSize = PixelSize(textureMode);
bits16 = NULL;
bits32 = NULL;
FILE * fp = fopen(filenamenew, "rb"); FILE * fp = fopen(filenamenew, "rb");
if (fp==NULL) if (fp==NULL)
@@ -1020,40 +1054,53 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
int tw = getNextPower2(cinfo.output_width); int tw = getNextPower2(cinfo.output_width);
int th = getNextPower2(cinfo.output_height); int th = getNextPower2(cinfo.output_height);
PIXEL_TYPE* bits = NULL;
bool videoRAMUsed = false; bool videoRAMUsed = false;
int size = tw * th * sizeof(PIXEL_TYPE); int size = tw * th * pixelSize;
if (useVideoRAM)// && (mCurrentPointer+size)<0x200000) if (useVideoRAM)// && (mCurrentPointer+size)<0x200000)
{ {
//bits = (PIXEL_TYPE*) (0x04000000+0x40000000+mCurrentPointer); //bits = (PIXEL_TYPE*) (0x04000000+0x40000000+mCurrentPointer);
//mCurrentPointer += size; //mCurrentPointer += size;
bits = (PIXEL_TYPE*)valloc(size); if (pixelSize == 2){
bits16 = (u16*)valloc(size);
}else{
bits32 = (u32*)valloc(size);
}
videoRAMUsed = true; videoRAMUsed = true;
} }
//else //else
if (bits == NULL) if (bits16 == NULL && bits32 == NULL)
{ {
videoRAMUsed = false; videoRAMUsed = false;
bits = (PIXEL_TYPE*) memalign(16, size); if (pixelSize == 2){
bits16 = (u16*)memalign(16, size);
}else{
bits32 = (u32*)memalign(16, size);
}
} }
rgbadata = (u8 *)bits; //rgbadata = (u8 *)bits;
rgbadata16 = bits16;
rgbadata32 = bits32;
if (mSwizzle) if (mSwizzle)
{ {
rgbadata = (u8 *) memalign(16, size); //rgbadata = (u8 *) memalign(16, size);
if (rgbadata16) rgbadata16 = (u16*) memalign(16, size);
if(!rgbadata) if (rgbadata32) rgbadata32 = (u32*) memalign(16, size);
if(!rgbadata16 && !rgbadata32)
{ {
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
if (videoRAMUsed) if (videoRAMUsed){
//mCurrentPointer -= size; //mCurrentPointer -= size;
vfree(bits); if (bits16) vfree(bits16);
else if (bits32) vfree(bits32);
free (bits); }else{
if (bits16) free(bits16);
if (bits32) free(bits32);
}
return; return;
} }
} }
@@ -1063,36 +1110,67 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
{ {
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
if (videoRAMUsed) if (videoRAMUsed){
//mCurrentPointer -= size; if (bits16) vfree(bits16);
vfree(bits); if (bits32) vfree(bits32);
else }else{
free (bits); if (bits16) free(bits16);
if (bits32) free(bits32);
if (mSwizzle) }
if (rgbadata) if (mSwizzle){
free(rgbadata); if (rgbadata16)
free(rgbadata16);
if (rgbadata32)
free(rgbadata32);
}
return; return;
} }
u8* currRow = rgbadata; u16 * currRow16 = rgbadata16;
u32 * currRow32 = rgbadata32;
u16 color16;
u32 color32;
while(cinfo.output_scanline < cinfo.output_height) while(cinfo.output_scanline < cinfo.output_height)
{ {
p = scanline; p = scanline;
jpeg_read_scanlines(&cinfo, &scanline, 1); jpeg_read_scanlines(&cinfo, &scanline, 1);
q = currRow; q16 = currRow16;
for(i=0; i<(int)cinfo.output_width; i++) q32 = currRow32;
{ for(i=0; i<(int)cinfo.output_width; i++){
q[0] = p[0]; int a = 255;
q[1] = p[1]; int r = p[0];
q[2] = p[2]; int g = p[1];
q[3] = 255; int b = p[2];
switch (textureMode) {
case PSP_DISPLAY_PIXEL_FORMAT_565:
color16 = (r >> 3) | ((g >> 2) << 5) | ((b >> 3) << 11);
*(q16) = color16;
break;
case PSP_DISPLAY_PIXEL_FORMAT_5551:
color16 = (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | ((a >> 7) << 15);
*(q16) = color16;
break;
case PSP_DISPLAY_PIXEL_FORMAT_4444:
color16 = (r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12);
*(q16) = color16;
break;
case PSP_DISPLAY_PIXEL_FORMAT_8888:
color32 = r | (g << 8) | (b << 16) | (a << 24);
*(q32) = color32;
break;
}
//q[0] = p[0];
//q[1] = p[1];
//q[2] = p[2];
//q[3] = 255;
p+=3; q+=4; p+=3;
if (q16) q16+=1;
if (q32) q32+=1;
} }
currRow += tw*4; if (currRow32) currRow32+= tw;
if (currRow16) currRow16+= tw;
} }
free(scanline); free(scanline);
@@ -1103,13 +1181,20 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
if (mSwizzle) if (mSwizzle)
{ {
swizzle_fast((u8*)bits, (const u8*)rgbadata, tw*sizeof(PIXEL_TYPE), th/*cinfo.output_height*/); if (rgbadata16){
free (rgbadata); swizzle_fast((u8*)bits16, (const u8*)rgbadata16, tw*pixelSize, th/*cinfo.output_height*/);
free (rgbadata16);
}
if (rgbadata32){
swizzle_fast((u8*)bits32, (const u8*)rgbadata32, tw*pixelSize, th/*cinfo.output_height*/);
free (rgbadata32);
}
} }
textureInfo.mBits = (u8 *)bits; if (bits16) textureInfo.mBits = (u8 *)bits16;
else textureInfo.mBits = (u8 *)bits32;
textureInfo.mWidth = cinfo.output_width; textureInfo.mWidth = cinfo.output_width;
textureInfo.mHeight = cinfo.output_height; textureInfo.mHeight = cinfo.output_height;
textureInfo.mTexWidth = tw; textureInfo.mTexWidth = tw;
@@ -1121,18 +1206,18 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
} }
JTexture* JRenderer::LoadTexture(const char* filename, int mode) JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureMode)
{ {
TextureInfo textureInfo; TextureInfo textureInfo;
textureInfo.mVRAM = false; textureInfo.mVRAM = false;
textureInfo.mBits = NULL; textureInfo.mBits = NULL;
if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL) if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL)
LoadJPG(textureInfo, filename, mode); LoadJPG(textureInfo, filename, mode, textureMode);
else if(strstr(filename, ".gif")!=NULL || strstr(filename, ".GIF")!=NULL) else if(strstr(filename, ".gif")!=NULL || strstr(filename, ".GIF")!=NULL)
LoadGIF(textureInfo,filename, mode); LoadGIF(textureInfo,filename, mode, textureMode);
else else
LoadPNG(textureInfo, filename, mode); LoadPNG(textureInfo, filename, mode, textureMode);
if (textureInfo.mBits == NULL) if (textureInfo.mBits == NULL)
return NULL; return NULL;
@@ -1146,7 +1231,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode)
mImageFilter->ProcessImage((PIXEL_TYPE*)textureInfo.mBits, textureInfo.mWidth, textureInfo.mHeight); mImageFilter->ProcessImage((PIXEL_TYPE*)textureInfo.mBits, textureInfo.mWidth, textureInfo.mHeight);
tex->mTexId = mTexCounter++; tex->mTexId = mTexCounter++;
tex->mTextureFormat = textureMode;
tex->mWidth = textureInfo.mWidth; tex->mWidth = textureInfo.mWidth;
tex->mHeight = textureInfo.mHeight; tex->mHeight = textureInfo.mHeight;
tex->mTexWidth = textureInfo.mTexWidth; tex->mTexWidth = textureInfo.mTexWidth;
@@ -1174,7 +1259,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode)
// http://svn.ps2dev.org/filedetails.php?repname=psp&path=/trunk/libpng/screenshot/main.c&rev=0&sc=0 // http://svn.ps2dev.org/filedetails.php?repname=psp&path=/trunk/libpng/screenshot/main.c&rev=0&sc=0
// Load PNG as texture // Load PNG as texture
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode) void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode, int textureMode)
{ {
textureInfo.mBits = NULL; textureInfo.mBits = NULL;
@@ -1342,7 +1427,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// GIF Support /// GIF Support
int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode) int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode, int textureMode)
{ {
bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM); bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM);
// pixel ** image_data=NULL; // pixel ** image_data=NULL;
@@ -1544,7 +1629,7 @@ int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
} }
void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode) void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode, int textureMode)
{ {
textureInfo.mBits = NULL; textureInfo.mBits = NULL;
//bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM); //bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM);

View File

@@ -196,7 +196,7 @@ bool JMP3::update() {
// Output // Output
m_samplesPlayed += sceAudioSRCOutputBlocking(m_volume, tempBuffer); m_samplesPlayed += sceAudioSRCOutputBlocking(m_volume, tempBuffer);
m_playTime = (m_samplingRate > 0) ? (m_samplesPlayed / m_samplingRate) : 0; m_playTime = (m_samplingRate > 0) ? (m_samplesPlayed / (m_samplingRate/1000)) : 0;
} }
} }
@@ -225,9 +225,9 @@ int JMP3::playTime() const {
} }
int JMP3::playTimeMinutes() { int JMP3::playTimeMinutes() {
return m_playTime / 60; return (m_playTime / 1000) / 60;
} }
int JMP3::playTimeSeconds() { int JMP3::playTimeSeconds() {
return m_playTime % 60; return (m_playTime/1000) % 60;
} }

View File

@@ -28,7 +28,12 @@ JMusic::~JMusic()
} }
void JMusic::Update(){ void JMusic::Update(){
//if (mTrack) mTrack->update();
}
int JMusic::getPlayTime(){
if (mTrack) return mTrack->playTime();
return 0;
} }
JSample::JSample() JSample::JSample()

View File

@@ -119,6 +119,7 @@ void JSprite::Update(float dt)
} }
} }
} }

View File

@@ -38,7 +38,7 @@ extern void SwizzlePlot(u8* out, PIXEL_TYPE color, int i, int j, unsigned int wi
JTTFont::JTTFont(int cacheImageSize) JTTFont::JTTFont(int cacheImageSize)
{ {
mColor = 0xffffffff; mColor = ARGB(255,255,255,255);
mAngle = 0.0; mAngle = 0.0;
mLibrary = 0; mLibrary = 0;
mFace = 0; mFace = 0;

View File

@@ -599,7 +599,7 @@ static void jpeg_mem_src(j_decompress_ptr cinfo, byte *mem, int len)
LoadJPG LoadJPG
============== ==============
*/ */
void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode) void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode, int TextureFormat)
{ {
@@ -746,7 +746,7 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
} }
JTexture* JRenderer::LoadTexture(const char* filename, int mode) JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureFormat)
{ {
TextureInfo textureInfo; TextureInfo textureInfo;
@@ -835,7 +835,7 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode)
return tex; return tex;
} }
void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode) void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode, int TextureFormat)
{ {
//TextureInfo* textureInfo = new TextureInfo; //TextureInfo* textureInfo = new TextureInfo;
@@ -1030,7 +1030,7 @@ void JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// GIF Support /// GIF Support
int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode) int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode, int TextureFormat)
{ {
// pixel ** image_data=NULL; // pixel ** image_data=NULL;
@@ -1172,7 +1172,7 @@ int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
} }
void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode) void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode, int TextureFormat)
{ {
///* ///*
//FILE * fp = fopen(filename, "rb"); //FILE * fp = fopen(filename, "rb");
@@ -1294,7 +1294,7 @@ void JRenderer::Enable2D()
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix glLoadIdentity (); // Reset The Projection Matrix
gluOrtho2D(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F-1.0f); gluOrtho2D(0.0f, SCREEN_WIDTH_F, 0.0f, SCREEN_HEIGHT_F);
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity (); // Reset The Modelview Matrix glLoadIdentity (); // Reset The Modelview Matrix

View File

@@ -18,10 +18,14 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JMusic::JMusic() JMusic::JMusic()
{ {
} }
void JMusic::Update(){ void JMusic::Update(){
}
int JMusic::getPlayTime(){
return FSOUND_GetCurrentPosition(JSoundSystem::GetInstance()->mChannel)/44.1; //todo more generic, here it's only 44kHz
} }
JMusic::~JMusic() JMusic::~JMusic()
@@ -151,11 +155,6 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
void JSoundSystem::PlayMusic(JMusic *music, bool looping) void JSoundSystem::PlayMusic(JMusic *music, bool looping)
{ {
// if (music && music->mTrack)
// {
// FMUSIC_SetLooping(music->mTrack, (looping?1:0));
// FMUSIC_PlaySong(music->mTrack);
// }
if (music && music->mTrack) if (music && music->mTrack)
{ {
@@ -212,20 +211,6 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
} }
// void JSoundSystem::FreeSample(JSample *sample)
// {
// if (sample)
// {
// if (sample->mSample)
// FSOUND_Sample_Free(sample->mSample);
//
// //delete sample;
// //sample = NULL;
// }
//
// }
void JSoundSystem::PlaySample(JSample *sample) void JSoundSystem::PlaySample(JSample *sample)
{ {
if (sample && sample->mSample) if (sample && sample->mSample)

View File

@@ -2,7 +2,7 @@
#define _TEXTURES_CACHE_H #define _TEXTURES_CACHE_H
#define MAX_CACHE_OBJECTS 100 #define MAX_CACHE_OBJECTS 100
#define CACHE_SIZE_PIXELS 1000000 #define CACHE_SIZE_PIXELS 6000000
#define CACHE_CARD 1 #define CACHE_CARD 1
#define CACHE_THUMB 2 #define CACHE_THUMB 2

View File

@@ -72,12 +72,13 @@ int TexturesCache::cleanup(){
JQuad * TexturesCache::getQuad(MTGCard * card, int type){ JQuad * TexturesCache::getQuad(MTGCard * card, int type){
int cache_id = getCacheById(card->getId(), type); int cache_id = getCacheById(card->getId(), type);
if (cache_id == -1){ if (cache_id == -1){
fprintf(stderr, "not found %d %i\n", card->getId(), type);
//Not found in the cache, we have to load the file and put it in the cache //Not found in the cache, we have to load the file and put it in the cache
if (cleanup()){ if (cleanup()){
cache_id = nb_textures; cache_id = nb_textures;
cache[cache_id] = NEW CardTexture(card, type); cache[cache_id] = NEW CardTexture(card, type);
totalsize+= cache[cache_id]->nbpixels; totalsize+= cache[cache_id]->nbpixels;
fprintf(stderr, "Total Size of cache in pixels: %i\n", totalsize);
nb_textures++; nb_textures++;
} }
} }
@@ -105,7 +106,7 @@ CardTexture::CardTexture(MTGCard * card, int _type): type(_type){
OutputDebugString(filename); OutputDebugString(filename);
#endif #endif
if (fileExists(filename)) if (fileExists(filename))
tex = JRenderer::GetInstance()->LoadTexture(filename, false); tex = JRenderer::GetInstance()->LoadTexture(filename, false,GU_PSM_5551);
if (tex){ if (tex){
quad = NEW JQuad(tex, 0.0f, 0.0f, tex->mWidth, tex->mHeight); quad = NEW JQuad(tex, 0.0f, 0.0f, tex->mWidth, tex->mHeight);
nbpixels = tex->mTexHeight * tex->mTexWidth; nbpixels = tex->mTexHeight * tex->mTexWidth;