Fixed the graphics whiteout bug I introduced when switching profiles. When Refresh() was being called on the texture, the bitmap wasn't been re-transferred back into the openGL context.
While debugging this, I noticed a separate issue: when changing profiles, we'd actually call refresh twice. Removed the spurious call, as reloading profiles doesn't need to concern itself with the image cache - that's already covered by the game options menu. Also did some minor formatting / cleanup in the JGfx code for PSP - stubbed out a bunch of JLOG calls I had put in while debugging the PNG loading code.
This commit is contained in:
@@ -149,10 +149,11 @@ public:
|
|||||||
** However, this doesn't work if you want to call LoadTexture in a separate worker thread, as
|
** However, this doesn't work if you want to call LoadTexture in a separate worker thread, as
|
||||||
** OpenGL has a limitation where only one thread can run the context. Now, the image loading/decompression
|
** OpenGL has a limitation where only one thread can run the context. Now, the image loading/decompression
|
||||||
** happens in LoadTexture, and the JQuad constructor will complete the texture binding with this helper function.
|
** happens in LoadTexture, and the JQuad constructor will complete the texture binding with this helper function.
|
||||||
|
**
|
||||||
|
** On PSP, this is a no-op.
|
||||||
*/
|
*/
|
||||||
#if defined (WIN32) || defined (LINUX)
|
void TransferTextureToGLContext(JTexture& inTexture);
|
||||||
void static TransferTextureToGLContext(JTexture& inTexture);
|
|
||||||
#endif
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Create texture from memory on the fly.
|
/// Create texture from memory on the fly.
|
||||||
///
|
///
|
||||||
|
|||||||
+199
-173
@@ -770,6 +770,14 @@ void JRenderer::RenderQuad(JQuad* quad, VertexColor* points)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** No-op on PSP. This is purely a PC openGL utility.
|
||||||
|
*/
|
||||||
|
void JRenderer::TransferTextureToGLContext(JTexture& inTexture)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
// Taken from:
|
// Taken from:
|
||||||
@@ -1054,205 +1062,223 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
|
|
||||||
int size = tw * th * pixelSize;
|
int size = tw * th * pixelSize;
|
||||||
|
|
||||||
if (useVideoRAM)
|
if (useVideoRAM)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (pixelSize == 2){
|
if (pixelSize == 2)
|
||||||
bits16 = (u16*)valloc(size);
|
{
|
||||||
}else{
|
bits16 = (u16*)valloc(size);
|
||||||
bits32 = (u32*)valloc(size);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bits32 = (u32*)valloc(size);
|
||||||
|
}
|
||||||
|
videoRAMUsed = true;
|
||||||
}
|
}
|
||||||
videoRAMUsed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//else
|
//else
|
||||||
if (bits16 == NULL && bits32 == NULL)
|
if (bits16 == NULL && bits32 == NULL)
|
||||||
{
|
{
|
||||||
videoRAMUsed = false;
|
videoRAMUsed = false;
|
||||||
if (pixelSize == 2){
|
if (pixelSize == 2)
|
||||||
bits16 = (u16*)memalign(16, size);
|
{
|
||||||
}else{
|
bits16 = (u16*)memalign(16, size);
|
||||||
bits32 = (u32*)memalign(16, size);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bits32 = (u32*)memalign(16, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rgbadata16 = bits16;
|
rgbadata16 = bits16;
|
||||||
rgbadata32 = bits32;
|
rgbadata32 = bits32;
|
||||||
if (mSwizzle)
|
if (mSwizzle)
|
||||||
{
|
{
|
||||||
if (rgbadata16) rgbadata16 = (u16*) memalign(16, size);
|
if (rgbadata16) rgbadata16 = (u16*) memalign(16, size);
|
||||||
if (rgbadata32) rgbadata32 = (u32*) memalign(16, size);
|
if (rgbadata32) rgbadata32 = (u32*) memalign(16, size);
|
||||||
if(!rgbadata16 && !rgbadata32)
|
if(!rgbadata16 && !rgbadata32)
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
if (videoRAMUsed){
|
if (videoRAMUsed)
|
||||||
if (bits16) vfree(bits16);
|
{
|
||||||
if (bits32) vfree(bits32);
|
if (bits16) vfree(bits16);
|
||||||
}else{
|
if (bits32) vfree(bits32);
|
||||||
if (bits16) free(bits16);
|
}
|
||||||
if (bits32) free(bits32);
|
else
|
||||||
}
|
{
|
||||||
return;
|
if (bits16) free(bits16);
|
||||||
}
|
if (bits32) free(bits32);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
scanline = (u8 *)malloc(cinfo.output_width * 3);
|
}
|
||||||
if(!scanline)
|
|
||||||
{
|
|
||||||
jpeg_destroy_decompress(&cinfo);
|
|
||||||
|
|
||||||
if (videoRAMUsed){
|
|
||||||
if (bits16) vfree(bits16);
|
|
||||||
if (bits32) vfree(bits32);
|
|
||||||
}else{
|
|
||||||
if (bits16) free(bits16);
|
|
||||||
if (bits32) free(bits32);
|
|
||||||
}
|
}
|
||||||
if (mSwizzle){
|
|
||||||
if (rgbadata16)
|
scanline = (u8 *)malloc(cinfo.output_width * 3);
|
||||||
free(rgbadata16);
|
if(!scanline)
|
||||||
if (rgbadata32)
|
{
|
||||||
free(rgbadata32);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
|
|
||||||
|
if (videoRAMUsed)
|
||||||
|
{
|
||||||
|
if (bits16) vfree(bits16);
|
||||||
|
if (bits32) vfree(bits32);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (bits16) free(bits16);
|
||||||
|
if (bits32) free(bits32);
|
||||||
|
}
|
||||||
|
if (mSwizzle)
|
||||||
|
{
|
||||||
|
if (rgbadata16)
|
||||||
|
free(rgbadata16);
|
||||||
|
if (rgbadata32)
|
||||||
|
free(rgbadata32);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
u16 * currRow16 = rgbadata16;
|
u16 * currRow16 = rgbadata16;
|
||||||
u32 * currRow32 = rgbadata32;
|
u32 * currRow32 = rgbadata32;
|
||||||
u16 color16;
|
u16 color16;
|
||||||
u32 color32;
|
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);
|
||||||
|
|
||||||
q16 = currRow16;
|
q16 = currRow16;
|
||||||
q32 = currRow32;
|
q32 = currRow32;
|
||||||
for(i=0; i<(int)cinfo.output_width; i++){
|
for (i=0; i<(int)cinfo.output_width; ++i)
|
||||||
int a = 255;
|
{
|
||||||
int r = p[0];
|
int a = 255;
|
||||||
int g = p[1];
|
int r = p[0];
|
||||||
int b = p[2];
|
int g = p[1];
|
||||||
switch (textureMode) {
|
int b = p[2];
|
||||||
case GU_PSM_5650:
|
switch (textureMode)
|
||||||
color16 = (r >> 3) | ((g >> 2) << 5) | ((b >> 3) << 11);
|
{
|
||||||
*(q16) = color16;
|
case GU_PSM_5650:
|
||||||
break;
|
color16 = (r >> 3) | ((g >> 2) << 5) | ((b >> 3) << 11);
|
||||||
case GU_PSM_5551:
|
*(q16) = color16;
|
||||||
color16 = (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | ((a >> 7) << 15);
|
break;
|
||||||
*(q16) = color16;
|
case GU_PSM_5551:
|
||||||
break;
|
color16 = (r >> 3) | ((g >> 3) << 5) | ((b >> 3) << 10) | ((a >> 7) << 15);
|
||||||
case GU_PSM_4444:
|
*(q16) = color16;
|
||||||
color16 = (r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12);
|
break;
|
||||||
*(q16) = color16;
|
case GU_PSM_4444:
|
||||||
break;
|
color16 = (r >> 4) | ((g >> 4) << 4) | ((b >> 4) << 8) | ((a >> 4) << 12);
|
||||||
case GU_PSM_8888:
|
*(q16) = color16;
|
||||||
color32 = r | (g << 8) | (b << 16) | (a << 24);
|
break;
|
||||||
*(q32) = color32;
|
case GU_PSM_8888:
|
||||||
break;
|
color32 = r | (g << 8) | (b << 16) | (a << 24);
|
||||||
}
|
*(q32) = color32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
p+=3;
|
p+=3;
|
||||||
if (q16) q16+=1;
|
if (q16) q16+=1;
|
||||||
if (q32) q32+=1;
|
if (q32) q32+=1;
|
||||||
}
|
}
|
||||||
if (currRow32) currRow32+= tw;
|
if (currRow32) currRow32+= tw;
|
||||||
if (currRow16) currRow16+= tw;
|
if (currRow16) currRow16+= tw;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(scanline);
|
free(scanline);
|
||||||
|
|
||||||
try{
|
try
|
||||||
jpeg_finish_decompress(&cinfo);
|
{
|
||||||
}catch(...){}
|
jpeg_finish_decompress(&cinfo);
|
||||||
|
|
||||||
|
|
||||||
if (mSwizzle)
|
|
||||||
{
|
|
||||||
if (rgbadata16){
|
|
||||||
swizzle_fast((u8*)bits16, (const u8*)rgbadata16, tw*pixelSize, th/*cinfo.output_height*/);
|
|
||||||
free (rgbadata16);
|
|
||||||
}
|
}
|
||||||
if (rgbadata32){
|
catch(...)
|
||||||
swizzle_fast((u8*)bits32, (const u8*)rgbadata32, tw*pixelSize, th/*cinfo.output_height*/);
|
{}
|
||||||
free (rgbadata32);
|
|
||||||
|
if (mSwizzle)
|
||||||
|
{
|
||||||
|
if (rgbadata16){
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (bits16) textureInfo.mBits = (u8 *)bits16;
|
if (bits16) textureInfo.mBits = (u8 *)bits16;
|
||||||
else textureInfo.mBits = (u8 *)bits32;
|
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;
|
||||||
textureInfo.mTexHeight = th;
|
textureInfo.mTexHeight = th;
|
||||||
textureInfo.mVRAM =videoRAMUsed;
|
textureInfo.mVRAM =videoRAMUsed;
|
||||||
|
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
delete [] rawdata;
|
delete [] rawdata;
|
||||||
JLOG("-- OK -- JRenderer::LoadJPG");
|
JLOG("-- OK -- JRenderer::LoadJPG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureMode)
|
JTexture* JRenderer::LoadTexture(const char* filename, int mode, int textureMode)
|
||||||
{
|
{
|
||||||
JLOG("JRenderer::LoadTexture");
|
JLOG("JRenderer::LoadTexture");
|
||||||
TextureInfo textureInfo;
|
TextureInfo textureInfo;
|
||||||
textureInfo.mVRAM = false;
|
textureInfo.mVRAM = false;
|
||||||
textureInfo.mBits = NULL;
|
textureInfo.mBits = NULL;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL)
|
if (strstr(filename, ".jpg")!=NULL || strstr(filename, ".JPG")!=NULL)
|
||||||
LoadJPG(textureInfo, filename, mode, textureMode);
|
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)
|
||||||
textureMode = TEXTURE_FORMAT; //textureMode not supported in Gif yet
|
{
|
||||||
LoadGIF(textureInfo,filename, mode, textureMode);
|
textureMode = TEXTURE_FORMAT; //textureMode not supported in Gif yet
|
||||||
}
|
LoadGIF(textureInfo,filename, mode, textureMode);
|
||||||
else if(strstr(filename, ".png")!=NULL || strstr(filename, ".PNG")!=NULL) {
|
}
|
||||||
textureMode = TEXTURE_FORMAT; //textureMode not supported in PNG yet
|
else if(strstr(filename, ".png")!=NULL || strstr(filename, ".PNG")!=NULL)
|
||||||
ret = LoadPNG(textureInfo, filename, mode, textureMode);
|
{
|
||||||
if (ret < 0) {
|
textureMode = TEXTURE_FORMAT; //textureMode not supported in PNG yet
|
||||||
char buf[512];
|
ret = LoadPNG(textureInfo, filename, mode, textureMode);
|
||||||
sprintf(buf, "--LoadPNG sent error code: %i for file %s", ret, filename);
|
if (ret < 0)
|
||||||
JLOG(buf);
|
{
|
||||||
|
char buf[512];
|
||||||
|
sprintf(buf, "--LoadPNG sent error code: %i for file %s", ret, filename);
|
||||||
|
JLOG(buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (textureInfo.mBits == NULL)
|
if (textureInfo.mBits == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
JLOG("Allocating Texture");
|
JTexture* tex = new JTexture();
|
||||||
JTexture* tex = new JTexture();
|
if (tex)
|
||||||
if (tex)
|
{
|
||||||
{
|
if (mImageFilter != NULL)
|
||||||
if (mImageFilter != NULL)
|
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->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;
|
||||||
tex->mTexHeight = textureInfo.mTexHeight;
|
tex->mTexHeight = textureInfo.mTexHeight;
|
||||||
tex->mInVideoRAM = textureInfo.mVRAM;
|
tex->mInVideoRAM = textureInfo.mVRAM;
|
||||||
tex->mBits = (PIXEL_TYPE *)textureInfo.mBits;
|
tex->mBits = (PIXEL_TYPE *)textureInfo.mBits;
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (!done)
|
||||||
|
{
|
||||||
|
SAFE_DELETE(tex);
|
||||||
|
}
|
||||||
|
|
||||||
if (!done)
|
JLOG("-- OK -- JRenderer::LoadTexture");
|
||||||
{
|
return tex;
|
||||||
SAFE_DELETE(tex);
|
|
||||||
}
|
|
||||||
|
|
||||||
JLOG("-- OK -- JRenderer::LoadTexture");
|
|
||||||
return tex;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1300,8 +1326,8 @@ void ReadPngLine( png_structp& png_ptr, u32_ptr& line, png_uint_32 width, int pi
|
|||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode, int textureMode)
|
int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode, int textureMode)
|
||||||
{
|
{
|
||||||
JLOG("JRenderer::LoadPNG: ");
|
//JLOG("JRenderer::LoadPNG: ");
|
||||||
JLOG(filename);
|
//JLOG(filename);
|
||||||
textureInfo.mBits = NULL;
|
textureInfo.mBits = NULL;
|
||||||
|
|
||||||
bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM);
|
bool useVideoRAM = (mode == TEX_TYPE_USE_VRAM);
|
||||||
@@ -1319,13 +1345,13 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
|||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
|
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
|
||||||
|
|
||||||
JLOG("PNG opened - creating read struct");
|
//JLOG("PNG opened - creating read struct");
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if (png_ptr == NULL) {
|
if (png_ptr == NULL) {
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile();
|
||||||
return JGE_ERR_PNG;
|
return JGE_ERR_PNG;
|
||||||
}
|
}
|
||||||
JLOG("Setting error callback func");
|
//JLOG("Setting error callback func");
|
||||||
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
|
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (info_ptr == NULL) {
|
if (info_ptr == NULL) {
|
||||||
@@ -1377,7 +1403,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
|||||||
const unsigned int kVerticalBlockSize = 8;
|
const unsigned int kVerticalBlockSize = 8;
|
||||||
if (mSwizzle)
|
if (mSwizzle)
|
||||||
{
|
{
|
||||||
JLOG("allocating swizzle buffer");
|
//JLOG("allocating swizzle buffer");
|
||||||
buffer = (PIXEL_TYPE*) memalign(16, texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE));
|
buffer = (PIXEL_TYPE*) memalign(16, texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE));
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
{
|
{
|
||||||
@@ -1452,14 +1478,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JLOG("Freeing line");
|
//JLOG("Freeing line");
|
||||||
free (line);
|
free (line);
|
||||||
JLOG("Reading end");
|
//JLOG("Reading end");
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
JLOG("Destroying read struct");
|
//JLOG("Destroying read struct");
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||||
|
|
||||||
JLOG("Closing PNG");
|
//JLOG("Closing PNG");
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile();
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
@@ -2217,4 +2243,4 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
|
|||||||
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
|
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
|
||||||
{
|
{
|
||||||
mImageFilter = imageFilter;
|
mImageFilter = imageFilter;
|
||||||
}
|
}
|
||||||
+12
-20
@@ -287,10 +287,8 @@ static glslFunctions g_glslfuncts;
|
|||||||
JQuad::JQuad(JTexture *tex, float x, float y, float width, float height)
|
JQuad::JQuad(JTexture *tex, float x, float y, float width, float height)
|
||||||
:mTex(tex), mX(x), mY(y), mWidth(width), mHeight(height)
|
:mTex(tex), mX(x), mY(y), mWidth(width), mHeight(height)
|
||||||
{
|
{
|
||||||
|
|
||||||
JASSERT(tex != NULL);
|
JASSERT(tex != NULL);
|
||||||
|
JRenderer::GetInstance()->TransferTextureToGLContext(*tex);
|
||||||
JRenderer::TransferTextureToGLContext(*tex);
|
|
||||||
|
|
||||||
mHotSpotX = 0.0f;
|
mHotSpotX = 0.0f;
|
||||||
mHotSpotY = 0.0f;
|
mHotSpotY = 0.0f;
|
||||||
@@ -302,7 +300,6 @@ JQuad::JQuad(JTexture *tex, float x, float y, float width, float height)
|
|||||||
mVFlipped = false;
|
mVFlipped = false;
|
||||||
|
|
||||||
SetTextureRect(x, y, width, height);
|
SetTextureRect(x, y, width, height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JQuad::SetTextureRect(float x, float y, float w, float h)
|
void JQuad::SetTextureRect(float x, float y, float w, float h)
|
||||||
@@ -316,7 +313,6 @@ void JQuad::SetTextureRect(float x, float y, float w, float h)
|
|||||||
mTY0 = y/mTex->mTexHeight;
|
mTY0 = y/mTex->mTexHeight;
|
||||||
mTX1 = (x+w)/mTex->mTexWidth;
|
mTX1 = (x+w)/mTex->mTexWidth;
|
||||||
mTY1 = (y+h)/mTex->mTexHeight;
|
mTY1 = (y+h)/mTex->mTexHeight;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -350,16 +346,16 @@ JTexture::JTexture() : mBuffer(NULL)
|
|||||||
|
|
||||||
JTexture::~JTexture()
|
JTexture::~JTexture()
|
||||||
{
|
{
|
||||||
checkGlError();
|
checkGlError();
|
||||||
if (mTexId != (GLuint)-1)
|
if (mTexId != (GLuint)-1)
|
||||||
glDeleteTextures(1, &mTexId);
|
glDeleteTextures(1, &mTexId);
|
||||||
checkGlError();
|
checkGlError();
|
||||||
|
|
||||||
if (mBuffer)
|
if (mBuffer)
|
||||||
{
|
{
|
||||||
delete [] mBuffer;
|
delete [] mBuffer;
|
||||||
mBuffer = NULL;
|
mBuffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1669,7 +1665,7 @@ void JRenderer::TransferTextureToGLContext(JTexture& inTexture)
|
|||||||
checkGlError();
|
checkGlError();
|
||||||
glGenTextures(1, &texid);
|
glGenTextures(1, &texid);
|
||||||
inTexture.mTexId = texid;
|
inTexture.mTexId = texid;
|
||||||
JRenderer::GetInstance()->mCurrentTex = texid;
|
mCurrentTex = texid;
|
||||||
|
|
||||||
// glError = glGetError();
|
// glError = glGetError();
|
||||||
|
|
||||||
@@ -1679,7 +1675,7 @@ void JRenderer::TransferTextureToGLContext(JTexture& inTexture)
|
|||||||
// OpenGL texture has (0,0) at lower-left
|
// OpenGL texture has (0,0) at lower-left
|
||||||
// Pay attention when doing texture mapping!!!
|
// Pay attention when doing texture mapping!!!
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, inTexture.mTexId); // Bind To The Texture ID
|
glBindTexture(GL_TEXTURE_2D, mCurrentTex); // Bind To The Texture ID
|
||||||
|
|
||||||
/* NOT USED
|
/* NOT USED
|
||||||
if (mode == TEX_TYPE_MIPMAP) // generate mipmaps
|
if (mode == TEX_TYPE_MIPMAP) // generate mipmaps
|
||||||
@@ -1750,10 +1746,6 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
|
|||||||
tex->mTexHeight = textureInfo.mTexHeight;
|
tex->mTexHeight = textureInfo.mTexHeight;
|
||||||
|
|
||||||
tex->mBuffer = textureInfo.mBits;
|
tex->mBuffer = textureInfo.mBits;
|
||||||
GLuint texid;
|
|
||||||
//checkGlError();
|
|
||||||
glGenTextures(1, &texid);
|
|
||||||
tex->mTexId = texid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ public:
|
|||||||
//The sanity=false option returns the adjusted path even if the file doesn't exist.
|
//The sanity=false option returns the adjusted path even if the file doesn't exist.
|
||||||
string profileFile(string filename="", string fallback="", bool sanity=false,bool relative=false);
|
string profileFile(string filename="", string fallback="", bool sanity=false,bool relative=false);
|
||||||
|
|
||||||
void reloadProfile(bool images = true); //Reloads profile using current options[ACTIVE_PROFILE]
|
void reloadProfile(); //Reloads profile using current options[ACTIVE_PROFILE]
|
||||||
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
|
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
|
||||||
void createUsersFirstDeck(int setId);
|
void createUsersFirstDeck(int setId);
|
||||||
|
|
||||||
|
|||||||
@@ -635,12 +635,10 @@ string GameSettings::profileFile(string filename, string fallback, bool sanity,
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSettings::reloadProfile(bool images)
|
void GameSettings::reloadProfile()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(profileOptions);
|
SAFE_DELETE(profileOptions);
|
||||||
checkProfile();
|
checkProfile();
|
||||||
if (images)
|
|
||||||
WResourceManager::Instance()->Refresh(); //Update images
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSettings::checkProfile()
|
void GameSettings::checkProfile()
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Reload list of unlocked sets, now that we know about the sets.
|
//Reload list of unlocked sets, now that we know about the sets.
|
||||||
options.reloadProfile(false);
|
options.reloadProfile();
|
||||||
genNbCardsStr();
|
genNbCardsStr();
|
||||||
resetDirectory();
|
resetDirectory();
|
||||||
//All major things have been loaded, resize the cache to use it as efficiently as possible
|
//All major things have been loaded, resize the cache to use it as efficiently as possible
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ void GameStateOptions::Update(float dt)
|
|||||||
if (newProfile != "")
|
if (newProfile != "")
|
||||||
{
|
{
|
||||||
options[Options::ACTIVE_PROFILE] = newProfile;
|
options[Options::ACTIVE_PROFILE] = newProfile;
|
||||||
options.reloadProfile(false);
|
options.reloadProfile();
|
||||||
optionsTabs->Reload();
|
optionsTabs->Reload();
|
||||||
}
|
}
|
||||||
newProfile = "";
|
newProfile = "";
|
||||||
@@ -192,7 +192,7 @@ void GameStateOptions::Update(float dt)
|
|||||||
}
|
}
|
||||||
if (mReload)
|
if (mReload)
|
||||||
{
|
{
|
||||||
options.reloadProfile(true);
|
options.reloadProfile();
|
||||||
Translator::EndInstance();
|
Translator::EndInstance();
|
||||||
Translator::GetInstance()->init();
|
Translator::GetInstance()->init();
|
||||||
optionsTabs->Reload();
|
optionsTabs->Reload();
|
||||||
|
|||||||
@@ -252,13 +252,15 @@ void WCachedTexture::Refresh()
|
|||||||
texture = NULL;
|
texture = NULL;
|
||||||
|
|
||||||
if (!Attempt(mFilename, loadedMode, error))
|
if (!Attempt(mFilename, loadedMode, error))
|
||||||
SAFE_DELETE(texture);
|
SAFE_DELETE(texture);
|
||||||
|
|
||||||
if (!texture)
|
if (!texture)
|
||||||
texture = old;
|
texture = old;
|
||||||
else
|
else
|
||||||
SAFE_DELETE(old);
|
SAFE_DELETE(old);
|
||||||
|
|
||||||
|
JRenderer::GetInstance()->TransferTextureToGLContext(*texture);
|
||||||
|
|
||||||
for (vector<WTrackedQuad*>::iterator it = trackedQuads.begin(); it != trackedQuads.end(); it++)
|
for (vector<WTrackedQuad*>::iterator it = trackedQuads.begin(); it != trackedQuads.end(); it++)
|
||||||
{
|
{
|
||||||
if ((*it) && (*it)->quad) (*it)->quad->mTex = texture;
|
if ((*it) && (*it)->quad) (*it)->quad->mTex = texture;
|
||||||
|
|||||||
Reference in New Issue
Block a user