iOS compilation fixes
This commit is contained in:
+13
-6
@@ -85,7 +85,7 @@ void JFileSystem::Destroy()
|
||||
JFileSystem::JFileSystem()
|
||||
{
|
||||
mZipAvailable = false;
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
mFile = NULL;
|
||||
#else
|
||||
mFile = -1;
|
||||
@@ -95,9 +95,9 @@ JFileSystem::JFileSystem()
|
||||
mFileSize = 0;
|
||||
|
||||
#ifdef RESPATH
|
||||
mResourceRoot = RESPATH"/";
|
||||
SetResourceRoot(RESPATH"/");
|
||||
#else
|
||||
mResourceRoot = "Res/"; // default root folder
|
||||
SetResourceRoot("Res/"); // default root folder
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ bool JFileSystem::OpenFile(const string &filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX)|| defined (IOS)
|
||||
mFile = fopen(path.c_str(), "rb");
|
||||
if (mFile != NULL)
|
||||
{
|
||||
@@ -220,7 +220,7 @@ void JFileSystem::CloseFile()
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
if (mFile != NULL)
|
||||
fclose(mFile);
|
||||
#else
|
||||
@@ -238,7 +238,7 @@ int JFileSystem::ReadFile(void *buffer, int size)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
return fread(buffer, 1, size, mFile);
|
||||
#else
|
||||
return sceIoRead(mFile, buffer, size);
|
||||
@@ -255,7 +255,14 @@ int JFileSystem::GetFileSize()
|
||||
|
||||
void JFileSystem::SetResourceRoot(const string& resourceRoot)
|
||||
{
|
||||
#ifdef IOS
|
||||
NSString *pathUTF8 = [NSString stringWithUTF8String: resourceRoot.c_str()];
|
||||
NSString *fullpath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:pathUTF8];
|
||||
mResourceRoot = [fullpath cStringUsingEncoding:1];
|
||||
mResourceRoot += "/";
|
||||
#else
|
||||
mResourceRoot = resourceRoot;
|
||||
#endif
|
||||
}
|
||||
|
||||
string JFileSystem::GetResourceRoot()
|
||||
|
||||
@@ -188,7 +188,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
if (mCurr >= mCacheSize)
|
||||
mCurr = 0;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
@@ -225,7 +225,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
BYTE bitMask = 0x80;
|
||||
for (int z=0;z<8&&bitCount;z++)
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
if ((bits & bitMask) != 0)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255);
|
||||
else
|
||||
@@ -257,7 +257,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
for (int i=0;i<size;)
|
||||
{
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
x = 0;
|
||||
#else
|
||||
x = (int)mSprites[index]->mX;
|
||||
@@ -269,7 +269,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
|
||||
for (n=0;n<(mFontSize-8)/2;n++)
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE);
|
||||
@@ -286,7 +286,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
BYTE bitMask = 0x80;
|
||||
for (int z=0;z<8&&bitCount;z++)
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
if ((bits & bitMask) != 0)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(255,255,255,255);
|
||||
else
|
||||
@@ -308,7 +308,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
|
||||
for (n=0;n<(mFontSize-8)/2;n++)
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
mCharBuffer[y*mFontSize+x] = ARGB(0,0,0,0);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(0,0,0,0), x*PIXEL_SIZE, y, mTexture->mTexWidth*PIXEL_SIZE);
|
||||
@@ -324,7 +324,7 @@ int JGBKFont::PreCacheChar(const BYTE *ch)
|
||||
|
||||
mGBCode[index] = code;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
x = (int)mSprites[index]->mX;
|
||||
y = (int)mSprites[index]->mY;
|
||||
|
||||
|
||||
+2
-1
@@ -309,7 +309,8 @@ JGE::~JGE()
|
||||
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX) // Non-PSP code
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
// Non-PSP code
|
||||
|
||||
void JGE::Init()
|
||||
{
|
||||
|
||||
@@ -219,7 +219,7 @@ bool JMD2Model::Load(char *filename, char *textureName)
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// given 3 points, calculates the normal to the points
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
void JMD2Model::CalculateNormal(float *p1, float *p2, float *p3)
|
||||
#else
|
||||
void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, float *p3)
|
||||
@@ -243,7 +243,7 @@ void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, fl
|
||||
// calculate the length of the normal
|
||||
length = (float)sqrt(result[0]*result[0] + result[1]*result[1] + result[2]*result[2]);
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
// normalize and specify the normal
|
||||
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
glNormal3f(result[0]/length, result[1]/length, result[2]/length);
|
||||
@@ -277,7 +277,7 @@ void JMD2Model::Render(int frameNum)
|
||||
mRenderer->BindTexture(mModel->modelTex);
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
|
||||
// display the textured model with proper lighting normals
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
@@ -481,7 +481,7 @@ void JMD2Model::Render()
|
||||
|
||||
mRenderer->BindTexture(mModel->modelTex);
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
// FIXME
|
||||
|
||||
+2
-2
@@ -145,7 +145,7 @@ void JSprite::Render()
|
||||
// //mQuad->SetColor(ARGB(alpha,255,255,255));
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
mFrames[mCurrentFrame]->SetColor(alpha<<24 | mColor);
|
||||
// mQuad->SetFlip(mFlipped[mCurrentFrame], false);
|
||||
#else
|
||||
@@ -306,7 +306,7 @@ void JSprite::SetHotSpot(float x, float y, int index)
|
||||
|
||||
}
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&0x00ffffff); }
|
||||
#else
|
||||
void JSprite::SetColor(PIXEL_TYPE color) { mColor = (color&~MASK_ALPHA); }
|
||||
|
||||
+5
-5
@@ -258,7 +258,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
|
||||
FT_GlyphSlot slot = mFace->glyph;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
DWORD *texBuffer = new DWORD[mMaxCharWidth*mMaxCharHeight];
|
||||
memset(texBuffer, 0, mMaxCharWidth*mMaxCharHeight*sizeof(DWORD));
|
||||
#else
|
||||
@@ -278,7 +278,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
{
|
||||
int top = mSize-slot->bitmap_top+1;
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
int offset = top*mMaxCharWidth + slot->bitmap_left + 2;
|
||||
#else
|
||||
int xx = x + slot->bitmap_left + 2;
|
||||
@@ -303,7 +303,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
{
|
||||
grey = slot->bitmap.buffer[i * slot->bitmap.width + j];
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
texBuffer[i*mMaxCharWidth+j+offset] = RGBA(255, 255, 255, grey);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(grey,255,255,255), (xx+j)*PIXEL_SIZE, yy+i, mTexWidth*PIXEL_SIZE);
|
||||
@@ -326,7 +326,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
{
|
||||
if (bits&mask)
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
texBuffer[i*mMaxCharWidth+j*8+k+offset] = RGBA(255, 255, 255, 255);
|
||||
#else
|
||||
SwizzlePlot(pTexture, ARGB(255,255,255,255), (xx+j*8+k)*PIXEL_SIZE, yy+i, mTexWidth*PIXEL_SIZE);
|
||||
@@ -344,7 +344,7 @@ int JTTFont::PreCacheChar(u16 ch, u16 cachedCode)
|
||||
|
||||
mXAdvance[mCurr] = (u8)(slot->advance.x>>6);
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined (IOS)
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, mMaxCharWidth, mMaxCharHeight, GL_RGBA, GL_UNSIGNED_BYTE, texBuffer);
|
||||
#else
|
||||
sceKernelDcacheWritebackAll();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "..\..\include\hge\hgeparticle.h"
|
||||
#include "../../include/hge/hgeparticle.h"
|
||||
|
||||
|
||||
hgeParticleManager::hgeParticleManager()
|
||||
|
||||
+95
-10
@@ -9,6 +9,7 @@
|
||||
//-------------------------------------------------------------------------------------
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#ifndef IOS
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable : 4786)
|
||||
#pragma comment( lib, "giflib.lib" )
|
||||
@@ -26,7 +27,7 @@ extern "C" {
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //IOS
|
||||
|
||||
#include "../../include/JGE.h"
|
||||
#include "../../include/JRenderer.h"
|
||||
@@ -1469,7 +1470,7 @@ static int getNextPower2(int width)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef IOS
|
||||
static void jpg_null(j_decompress_ptr cinfo __attribute__((unused)))
|
||||
{
|
||||
}
|
||||
@@ -1649,7 +1650,6 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureFormat __attribute__((unused)))
|
||||
{
|
||||
TextureInfo textureInfo;
|
||||
@@ -1663,10 +1663,10 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
|
||||
else if(strstr(filename, ".png")!=NULL || strstr(filename, ".PNG")!=NULL)
|
||||
LoadPNG(textureInfo, filename);
|
||||
|
||||
if (textureInfo.mBits == NULL) {
|
||||
printf("Texture %s failed to load\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
if (textureInfo.mBits == NULL) {
|
||||
printf("Texture %s failed to load\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
|
||||
@@ -1720,10 +1720,10 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureInfo.mTexWidth, textureInfo.mTexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureInfo.mBits);
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureInfo.mTexWidth, textureInfo.mTexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureInfo.mBits);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
ret = true;
|
||||
|
||||
}
|
||||
else
|
||||
@@ -2038,7 +2038,92 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
|
||||
return ;//*/
|
||||
}
|
||||
|
||||
#else //IOS
|
||||
|
||||
#include <UIKit/UIImage.h>
|
||||
|
||||
JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureFormat __attribute__((unused)))
|
||||
{
|
||||
TextureInfo textureInfo;
|
||||
|
||||
textureInfo.mBits = NULL;
|
||||
|
||||
NSString *path = [NSString stringWithUTF8String: JGE_GET_RES(filename).c_str()];
|
||||
// NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:newString2];
|
||||
NSData *texData = [[NSData alloc] initWithContentsOfFile:path];
|
||||
UIImage *image = [[UIImage alloc] initWithData:texData];
|
||||
if (image == nil)
|
||||
NSLog(@"Do real error checking here");
|
||||
|
||||
textureInfo.mWidth = CGImageGetWidth(image.CGImage);
|
||||
textureInfo.mHeight = CGImageGetHeight(image.CGImage);
|
||||
textureInfo.mTexWidth = textureInfo.mWidth;
|
||||
textureInfo.mTexHeight = textureInfo.mHeight;
|
||||
|
||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
textureInfo.mBits = new u8 [ textureInfo.mHeight * textureInfo.mWidth * 4 ];
|
||||
CGContextRef context = CGBitmapContextCreate( textureInfo.mBits, textureInfo.mWidth, textureInfo.mHeight, 8, 4 * textureInfo.mWidth, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big );
|
||||
CGColorSpaceRelease( colorSpace );
|
||||
CGContextClearRect( context, CGRectMake( 0, 0, textureInfo.mWidth, textureInfo.mHeight ) );
|
||||
CGContextTranslateCTM( context, 0, textureInfo.mHeight - textureInfo.mHeight );
|
||||
CGContextDrawImage( context, CGRectMake( 0, 0, textureInfo.mWidth, textureInfo.mHeight ), image.CGImage );
|
||||
|
||||
if (textureInfo.mBits == NULL) {
|
||||
printf("Texture %s failed to load\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
|
||||
JTexture *tex = new JTexture();
|
||||
|
||||
if (tex)
|
||||
{
|
||||
if (mImageFilter != NULL)
|
||||
mImageFilter->ProcessImage((PIXEL_TYPE*)textureInfo.mBits, textureInfo.mWidth, textureInfo.mHeight);
|
||||
|
||||
tex->mFilter = TEX_FILTER_LINEAR;
|
||||
tex->mWidth = textureInfo.mWidth;
|
||||
tex->mHeight = textureInfo.mHeight;
|
||||
tex->mTexWidth = textureInfo.mTexWidth;
|
||||
tex->mTexHeight = textureInfo.mTexHeight;
|
||||
|
||||
GLuint texid;
|
||||
checkGlError();
|
||||
glGenTextures(1, &texid);
|
||||
tex->mTexId = texid;
|
||||
// glError = glGetError();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureInfo.mTexWidth, textureInfo.mTexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureInfo.mBits);
|
||||
|
||||
ret = true;
|
||||
}
|
||||
|
||||
CGContextRelease(context);
|
||||
|
||||
delete [] textureInfo.mBits;
|
||||
//delete textureInfo;
|
||||
|
||||
[image release];
|
||||
[texData release];
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
if (tex)
|
||||
delete tex;
|
||||
tex = NULL;
|
||||
}
|
||||
|
||||
checkGlError();
|
||||
return tex;
|
||||
}
|
||||
#endif //IOS
|
||||
|
||||
JTexture* JRenderer::CreateTexture(int width, int height, int mode __attribute__((unused)))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user