Skip to main content
GameDev.net gamedev.net
🔒 Locked

[solved] Wired iPhone IO?

Started by phew Sep 5, 2008 at 11:22 AM 2 replies 2.6k views
Original Post
phew
phew
hi, there i've built a test project using iPhone sdk and it runs but i cant see the result yet because my project needs models and textures, all these resource files are to be loaded manually and will be loaded use stdio FILE fopen etc. (im mixing using C++ and object c). the first texture smoothly loaded but there are problems when loading 2nd texture file : fopen returns okay (means the file exist), but the content readed is not OK (fread reported total 850 bytes loaded but it must be wrong because the texture is far bigger than 850 byts) (i will load the whole raw file into memory first, then parse and load it as texture), what could be the problem? acutally i've noticed only the first file read is really okay, and all the following read (fopen) are succeeded but they read only 850 bytes, its really wired, what could be the problem? guess all the resource files are packed together into one single file? not sure? or resource file has a size limit? thank you, im really new to iphone programming. [Edited by - phew on September 5, 2008 2:46:07 PM]
swiftcoder
swiftcoder
Quote:
Original post by phew
acutally i've noticed only the first file read is really okay, and all the following read (fopen) are succeeded but they read only 850 bytes, its really wired, what could be the problem?
I am reading multiple textures and models in my iPhone game, with no issues what so ever.

How are you adding the files to your XCode project? Have you tried opening the application bundle (right-click on the compiled app, and click "show bundle contents"), to check if the files are really complete?
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
phew
phew

thanks for the reply swiftcoder, i didnt know i can see the package's content that way.

by the displayed content list, the file to be loaded has a size of 260kb (256x256x32), but still can get it load correctly, and the process adding the resource files is this :
1. right click on the tree folder 'Resources' ->
2. 'add existing files' ->
3. select the folder 'media' where i place all the resources ->
4. 'Add' with default settings.

is it correct? thank you.

by the way, here is the code snippet i load the files
// from oolong enginevoid GetResourcePathASCII(char* cBuffer, int iLength){	NSString* readPath = [[NSBundle mainBundle] resourcePath];	[readPath getCString:cBuffer maxLength:iLength encoding:NSASCIIStringEncoding];}bool loadScene(){    char buf[0x200];    GetResourcePathASCII(buf, 0x200);    char path[0x200];    sprintf(path, "%s/tex1.raw", buf);    if (!loadTexture(path))    {        return false;    }    sprintf(path, "%s/tex2.raw", buf);    if (!loadTexture(path))    {        return false;    }     ....    return true;}  
phew
phew
okay, its all my fault -- the passed path is not a resource file path, its the path to the package (that is , i passed 'the buffer' to the function and expecting it to return something correct!!).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.