J :
* Unify with the windows version.
This commit is contained in:
+33
-32
@@ -29,6 +29,12 @@ extern "C" {
|
|||||||
#include "../../include/JFileSystem.h"
|
#include "../../include/JFileSystem.h"
|
||||||
#include "../../include/JAssert.h"
|
#include "../../include/JAssert.h"
|
||||||
|
|
||||||
|
#ifdef WIN23
|
||||||
|
#ifndef __attribute__
|
||||||
|
#define __attribute__((a))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -180,7 +186,11 @@ void JRenderer::BeginScene()
|
|||||||
{
|
{
|
||||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
|
||||||
glLoadIdentity (); // Reset The Modelview Matrix
|
glLoadIdentity (); // Reset The Modelview Matrix
|
||||||
|
#ifdef WIN32
|
||||||
|
float scaleH = (float)actualHeight/SCREEN_HEIGHT_F;
|
||||||
|
float scaleW = (float)actualWidth/SCREEN_WIDTH_F;
|
||||||
|
glScalef(scaleW,scaleW,1.f);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -527,7 +537,6 @@ static int getNextPower2(int width)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* unused... for now at least
|
|
||||||
static void jpg_null(j_decompress_ptr cinfo __attribute__((unused)))
|
static void jpg_null(j_decompress_ptr cinfo __attribute__((unused)))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -560,7 +569,6 @@ static void jpeg_mem_src(j_decompress_ptr cinfo, byte *mem, int len)
|
|||||||
cinfo->src->bytes_in_buffer = len;
|
cinfo->src->bytes_in_buffer = len;
|
||||||
cinfo->src->next_input_byte = mem;
|
cinfo->src->next_input_byte = mem;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
@@ -569,34 +577,34 @@ LoadJPG
|
|||||||
*/
|
*/
|
||||||
void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode __attribute__((unused)), int TextureFormat __attribute__((unused)))
|
void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode __attribute__((unused)), int TextureFormat __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
textureInfo.mBits = NULL;
|
textureInfo.mBits = NULL;
|
||||||
|
|
||||||
struct jpeg_decompress_struct cinfo;
|
struct jpeg_decompress_struct cinfo;
|
||||||
struct jpeg_error_mgr jerr;
|
struct jpeg_error_mgr jerr;
|
||||||
BYTE *rgbadata, *scanline, *p, *q;
|
BYTE *rawdata, *rgbadata, *scanline, *p, *q;
|
||||||
// int rawsize;
|
int rawsize, i;
|
||||||
int i;
|
|
||||||
|
|
||||||
char filenamenew[4096];
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
sprintf(filenamenew, "Res/%s", filename);
|
if (!fileSystem->OpenFile(filename)) return;
|
||||||
|
|
||||||
|
rawsize = fileSystem->GetFileSize();
|
||||||
|
|
||||||
// Initialise libJpeg Object
|
rawdata = new BYTE[rawsize];
|
||||||
|
|
||||||
|
if (!rawdata)
|
||||||
|
{
|
||||||
|
fileSystem->CloseFile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileSystem->ReadFile(rawdata, rawsize);
|
||||||
|
fileSystem->CloseFile();
|
||||||
|
|
||||||
|
// Initialize libJpeg Object
|
||||||
cinfo.err = jpeg_std_error(&jerr);
|
cinfo.err = jpeg_std_error(&jerr);
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress(&cinfo);
|
||||||
|
|
||||||
FILE* fp = fopen(filenamenew, "rb");
|
jpeg_mem_src(&cinfo, rawdata, rawsize);
|
||||||
if (fp == NULL)
|
|
||||||
{
|
|
||||||
//Failed to open file
|
|
||||||
jpeg_destroy_decompress(&cinfo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
jpeg_stdio_src(&cinfo, fp);
|
|
||||||
|
|
||||||
// Process JPEG header
|
// Process JPEG header
|
||||||
jpeg_read_header(&cinfo, true);
|
jpeg_read_header(&cinfo, true);
|
||||||
@@ -670,28 +678,21 @@ FILE* fp = fopen(filenamenew, "rb");
|
|||||||
// Free the scanline buffer
|
// Free the scanline buffer
|
||||||
free(scanline);
|
free(scanline);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
textureInfo.mBits = rgbadata;
|
textureInfo.mBits = rgbadata;
|
||||||
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;
|
||||||
|
|
||||||
|
|
||||||
// Finish Decompression
|
// Finish Decompression
|
||||||
jpeg_finish_decompress(&cinfo);
|
try {
|
||||||
|
jpeg_finish_decompress(&cinfo);
|
||||||
|
} catch(...) {}
|
||||||
|
|
||||||
// Destroy JPEG object
|
// Destroy JPEG object
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
|
|
||||||
|
delete[] rawdata;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user