iPhone support?


#92

I wouldn’t mind taking a stab at it. Point me to the repo please.


#93

The CVS repository is in SourceForge, under the project name “panda3d”.

David


#94

Sorry for the delay, but I just found time to move on to working with the iOS support in panda.

I have the source but I’m not sure how I actually build for iOS? I’m on a mac, can I use makepanda?


#95

You’ll need to use ppremake and use the BUILD_IPHONE setting, using the instructions that David posted earlier in this thread.


#96

Thanks, I got it compiling.

Unfortunately it seems the include/library paths are not set. I get build errors regarding not being able to find std c files like types.h.

I’ve also tried creating an “external build project” in xcode but I still get these errors. Any ideas?

Update: I tried setting CPLUS_INCLUDE_PATH, which resolved some issues, but they do seem to go on forever. There must be an easier way to set up the correct include paths

Update2: it appears that and older iphone sdk path is being used (2.0, I 'm using 4.3). I’ve tried grep to find where it is set but so far I have not found it

Update3: Added a -v flag to the compiler and got this output:

ignoring nonexistent directory “/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/include/c++/4.0.0/arm-apple-darwin10”
ignoring nonexistent directory “/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/local/include”
ignoring nonexistent directory “/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/gcc/arm-apple-darwin10/4.0.1/…/…/…/…/arm-apple-darwin10/include”
ignoring nonexistent directory “/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library/Frameworks”

Not sure how to get the compiler to use 4.2.1 instead of 4.0.0 (which would solve this directory not found problem)


#97

Look in dtool/pptempl/PostConfig.pp, it contains both the iPhoneOS version and it also gives the command directly to gcc-4.0.


#98

Got it, thanks. I changed to 4.2 (gcc) and it compiles now. Current file is:

// This file is included after including all of $DTOOL/Config.pp and
// the user's personal Config.pp file.  It makes decisions necessary 
// following the user's Config settings.

#if $[and $[OSX_PLATFORM],$[BUILD_IPHONE]]
  //#define IPH_PLATFORM iPhoneSimulator
  #define IPH_PLATFORM $[BUILD_IPHONE]
  #define IPH_VERSION 4.3
  
  #define dev /Developer/Platforms/$[IPH_PLATFORM].platform/Developer
  
  #if $[eq $[IPH_PLATFORM], iPhoneOS]
    #define ARCH_FLAGS -arch armv6 -mcpu=arm1176jzf-s
    #define osflags -fpascal-strings -miphoneos-version-min=4.3
    #define DEBUGFLAGS -gdwarf-2
    //#define DEBUGFLAGS
  #elif $[eq $[IPH_PLATFORM], iPhoneSimulator]
    #define ARCH_FLAGS -arch i386
    #define osflags -fpascal-strings -fasm-blocks -mmacosx-version-min=10.6
    #define DEBUGFLAGS -gdwarf-2
  #else
    #error Inappropriate value for BUILD_IPHONE.
  #endif
  
  #define env env MACOSX_DEPLOYMENT_TARGET=10.6 PATH="$[dev]/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
  #define CC $[env] $[dev]/usr/bin/gcc-4.2
  #define CXX $[env] $[dev]/usr/bin/g++-4.2
  #define OSX_CDEFS __IPHONE_OS_VERSION_MIN_REQUIRED=30200
  #define OSX_CFLAGS -isysroot $[dev]/SDKs/$[IPH_PLATFORM]$[IPH_VERSION].sdk $[osflags]

  #defer ODIR_SUFFIX -$[IPH_PLATFORM]

#endif

I’m on to the actual panda src tree now. First error is:

/bin/sh: /Users/colinn/Projects/panda3d/built/bin/interrogate: Bad CPU type in executable

Which makes sense since this was compiled in dtool with the iphone compiler. Am I supposed to compile dtool for Mac OSX without any of the iPhone stuff in Config.pp and then turn it on afterwards? I’ll give this a try and update with my results.

EDIT:

Rebuilt for Mac OSX and now I get:

interrogate -od Opt1-OSX/libp3express.in -oc Opt1-OSX/libp3express_igate.cxx -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__FLT_EVAL_METHOD__=0  -D__const=const -Dvolatile -Dmutable -D__LITTLE_ENDIAN__ -D__inline__=inline -D__GNUC__ -D__i386__ -S/Users/gongpei/Projects/panda3d/built/include/parser-inc  -I/Users/gongpei/Projects/panda3d/panda -I../pandabase -I/Users/gongpei/Projects/panda3d/built/include -I/usr/include/python2.6   -fnames -string -refcount -assert -python-native  -spam -module "pandaexpress" -library "libp3express" buffer.h ca_bundle_data_src.c checksumHashGenerator.h circBuffer.h compress_string.h config_express.h copy_stream.h datagram.h datagramGenerator.h datagramIterator.h datagramSink.h dcast.h encrypt_string.h error_utils.h export_dtool.h fileReference.h hashGeneratorBase.h hashVal.h indirectLess.h memoryInfo.h memoryUsage.h memoryUsagePointerCounts.h memoryUsagePointers.h multifile.h namable.h nodePointerTo.h nodePointerToBase.h nodeReferenceCount.h openSSLWrapper.h ordered_vector.h pStatCollectorForwardBase.h password_hash.h patchfile.h pointerTo.h pointerToArray.h pointerToArrayBase.h pointerToBase.h pointerToVoid.h profileTimer.h pta_int.h pta_uchar.h pta_double.h pta_float.h pta_stdfloat.h ramfile.h referenceCount.h subStream.h subStreamBuf.h subfileInfo.h temporaryFile.h threadSafePointerTo.h threadSafePointerToBase.h trueClock.h typedReferenceCount.h typedef.h vector_uchar.h vector_double.h vector_float.h vector_stdfloat.h virtualFileList.h virtualFileMount.h virtualFileComposite.h virtualFile.h virtualFileMountMultifile.h virtualFileMountRamdisk.h virtualFileMountSystem.h virtualFileSimple.h virtualFileSystem.h weakPointerCallback.h weakPointerTo.h weakPointerToBase.h weakPointerToVoid.h weakReferenceList.h windowsRegistry.h zStream.h zStreamBuf.h p3express_composite1.cxx p3express_composite2.cxxdyld: Library not loaded: libp3interrogatedb.dylib
  Referenced from: /Users/gongpei/Projects/panda3d/panda/../built/bin/interrogate
  Reason: image not found
Trace/BPT trap

Maybe I will just turn off python integration for now


#99

I’m an Android guy, but I’m really interested to see Panda running on an Iphone. So good luck!


#100

Here is the latest error:


env MACOSX_DEPLOYMENT_TARGET=10.6 PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv6 -mcpu=arm1176jzf-s -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -fpascal-strings -miphoneos-version-min=4.3  -o Opt1-OSX-iPhoneOS/check_adler Opt1-OSX-iPhoneOS/check_adler_check_adler.o    -L../downloader/Opt1-OSX-iPhoneOS -L../express/Opt1-OSX-iPhoneOS -L../pandabase/Opt1-OSX-iPhoneOS -L/Users/gongpei/Projects/panda3d/built/lib -L/Users/gongpei/Projects/panda3d/built/lib -lp3downloader -lp3express -lp3express -lp3pandabase -lp3pandabase -lp3interrogatedb -lp3prc -lp3dconfig -lp3dtoolutil -lp3dtoolbase -lp3pystub -lp3prc -lz  -framework Foundation
Undefined symbols for architecture armv6:
  "_Dtool_TypedReferenceCount", referenced from:
      MemoryUsagePointers::get_python_pointer(int) constin libp3express.a(p3express_p3express_composite1.o)
  "_Dtool_TypedObject", referenced from:
      MemoryUsagePointers::get_python_pointer(int) constin libp3express.a(p3express_p3express_composite1.o)
  "_Dtool_ReferenceCount", referenced from:
      MemoryUsagePointers::get_python_pointer(int) constin libp3express.a(p3express_p3express_composite1.o)
ld: symbol(s) not found for architecture armv6

I’m guessing these symbols should be in dtoolbase?


#101

So the error is in downloadutils. I’m not sure what this is for. Can I just turn it off for iPhone? If so, how would I do that.

thanks
colin


#102

You should not put built/bin on your PATH. This makes the installer use the copy of interrogate that is in there, which will not work because it is compiled for a different architecture.

Instead, leave your system Panda3D SDK somewhere on the PATH. Just keep in mind that interrogate depends on other Panda3D libraries in dtool that, when added to the DYLD_LIBRARY_PATH, may interfere with your build.

Also keep in mind that the “dtool” tree contains libraries that need to be linked into other Panda libraries later in the process, so compiling the “dtool” tree for Mac OS X instead of iPhoneOS to solve the interrogate issue will not work. You really need two separate versions of Panda3D; the iPhoneOS ones you are building, and the one that is used by utilities that need to be run during the build (mainly interrogate), which could simply be an existing installation of the Panda3D SDK for Mac OS X.

For the record, I do not recommend compiling with an optimize level of 1 when building for such a low-end machine; it’s usually best to squeeze out every drop of performance to make it run decently. Optimize 1 will be exceedingly slow on the iPhone.

The errors you’re getting indicate that the _igate.o file for libp3express didn’t get properly linked in. Can you show me the compilation steps for a clean build of the express directory?


#103

Doing a clean build now. I turned off interrogate and python support adding:

#define INTERROGATE_PYTHON_INTERFACE
#define HAVE_PYTHON false

in my Config.pp

I also didn’t have an installed Python when first attempting this, so I deleted everything and started anew without trying to turn off interrogate and python (which could be the cause of this igate issue)

colin


#104

This error must have been related to either my attempt at disabling interrogate (maybe dtool wasn’t cleaned?).

I suppose I can look into the original error more if you are interested, but for now with python/interrogate enabled I have a complete build.

Thanks for the heads up on the OPTIMIZE setting but 1 is intended since I’m statically linking panda to my app and I want as much debugging as possible until I push out a final build. :slight_smile:


#105

Sorry for all the handholding, but I have another question.

Here is my current Config.pp


#define OPTIMIZE 1
#define BUILD_IPHONE iPhoneOS
#define HAVE_GLES 1
#define GLES_LIBS
#define HAVE_FREETYPE
#define FREETYPE_CONFIG
#define COMPILE_IN_DEFAULT_FONT

#define HAVE_OPENGL
#define HAVE_GL

#define HAVE_OPENSSL
#define LINK_ALL_STATIC

I’ve turned off open gl since glstuff would not compile, but I then get errors in included files present in the glstuff directory:


cd ./src/iphonedisplay && make all
env MACOSX_DEPLOYMENT_TARGET=10.5 PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -ftemplate-depth-30 -arch armv6 -mcpu=arm1176jzf-s -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -fpascal-strings -miphoneos-version-min=2.0 -c -o Opt1-OSX-iPhoneOS/p3iphonedisplay_config_iphonedisplay.o -I. -I/Users/colinn/Projects/panda3d/panda -I../../metalibs/panda -I../audio -I../chan -I../char -I../collide -I../cull -I../device -I../dgraph -I../display -I../downloader -I../dxml -I../event -I../express -I../framework -I../glesgsg -I../glstuff -I../gobj -I../grutil -I../gsgbase -I../linmath -I../mathutil -I../movies -I../nativenet -I../net -I../pandabase -I../parametrics -I../pgraph -I../pgraphnodes -I../pgui -I../pipeline -I../pnmimage -I../pnmimagetypes -I../pstatclient -I../putil -I../recorder -I../text -I../tform -I/Users/colinn/Projects/panda3d/built/include -I/usr/include/python2.6 -I/usr/include/python2.6   -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -Wall -gdwarf-2 -fPIC config_iphonedisplay.mm
env MACOSX_DEPLOYMENT_TARGET=10.5 PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -ftemplate-depth-30 -arch armv6 -mcpu=arm1176jzf-s -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -fpascal-strings -miphoneos-version-min=2.0 -c -o Opt1-OSX-iPhoneOS/p3iphonedisplay_viewController.o -I. -I/Users/colinn/Projects/panda3d/panda -I../../metalibs/panda -I../audio -I../chan -I../char -I../collide -I../cull -I../device -I../dgraph -I../display -I../downloader -I../dxml -I../event -I../express -I../framework -I../glesgsg -I../glstuff -I../gobj -I../grutil -I../gsgbase -I../linmath -I../mathutil -I../movies -I../nativenet -I../net -I../pandabase -I../parametrics -I../pgraph -I../pgraphnodes -I../pgui -I../pipeline -I../pnmimage -I../pnmimagetypes -I../pstatclient -I../putil -I../recorder -I../text -I../tform -I/Users/colinn/Projects/panda3d/built/include -I/usr/include/python2.6 -I/usr/include/python2.6   -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -Wall -gdwarf-2 -fPIC viewController.mm
env MACOSX_DEPLOYMENT_TARGET=10.5 PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -ftemplate-depth-30 -arch armv6 -mcpu=arm1176jzf-s -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -fpascal-strings -miphoneos-version-min=2.0 -c -o Opt1-OSX-iPhoneOS/p3iphonedisplay_eaglView.o -I. -I/Users/colinn/Projects/panda3d/panda -I../../metalibs/panda -I../audio -I../chan -I../char -I../collide -I../cull -I../device -I../dgraph -I../display -I../downloader -I../dxml -I../event -I../express -I../framework -I../glesgsg -I../glstuff -I../gobj -I../grutil -I../gsgbase -I../linmath -I../mathutil -I../movies -I../nativenet -I../net -I../pandabase -I../parametrics -I../pgraph -I../pgraphnodes -I../pgui -I../pipeline -I../pnmimage -I../pnmimagetypes -I../pstatclient -I../putil -I../recorder -I../text -I../tform -I/Users/colinn/Projects/panda3d/built/include -I/usr/include/python2.6 -I/usr/include/python2.6   -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -Wall -gdwarf-2 -fPIC eaglView.mm
In file included from ../glstuff/glTextureContext_src.h:63,
                 from ../glstuff/glstuff_src.h:36,
                 from ../glesgsg/glesgsg.h:111,
                 from iPhoneGraphicsWindow.h:21,
                 from eaglView.mm:22:
../glstuff/glTextureContext_src.I: In constructor ‘GLESTextureContext::GLESTextureContext(PreparedGraphicsObjects*, Texture*, int)’:
../glstuff/glTextureContext_src.I:32: error: ‘GL_NONE_OES’ was not declared in this scope
make[1]: *** [Opt1-OSX-iPhoneOS/p3iphonedisplay_eaglView.o] Error 1

I’ll start looking into this error now, but if you know the problem I’d appreciate a solution to save me some time. :slight_smile:


#106

Has something has changed in the API:

Marks-iMac-2:panda colinn$ grep -Rn "GL_NONE_OES" /Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/OpenGLES.framework/*
Marks-iMac-2:panda colinn$ grep -Rn "GL_NONE" /Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/OpenGLES.framework/*
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES2/gl.h:489:#define GL_NONE 

How should I wrap this? Use HAVE_GLES?


#107

Not sure where that GL_NONE is supposed to be defined, so for now I just set it to 0


#define GL_NONE 0 // GL_NONE_OES

Next error is here:

void IPhoneGraphicsWindow::
close_window() {
  //  system_close_window();

  WindowProperties properties;
  properties.set_open(false);
  system_changed_properties(properties);

//  release_system_resources(false);
  _gsg.clear();
  [color=red]_active = false;
  GraphicsWindow::close_window();
}

_active isn’t found so I replaced it with set_active(false)


#108

Looks like direct is a little out of date:

cd ./src/showbase && make all
env MACOSX_DEPLOYMENT_TARGET=10.5 PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -ftemplate-depth-30 -arch armv6 -mcpu=arm1176jzf-s -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -fpascal-strings -miphoneos-version-min=2.0 -c -o Opt1-OSX-iPhoneOS/p3showbase_showBase_assist.o -I. -I/Users/colinn/Projects/panda3d/direct -I../directbase -I/Users/colinn/Projects/panda3d/built/include -I/Users/colinn/Projects/panda3d/built/include -I/usr/include/python2.6   -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -Wall -gdwarf-2 -fPIC showBase_assist.mm
showBase_assist.mm:7:27: error: AppKit/AppKit.h: No such file or directory
showBase_assist.mm: In function ‘void activate_osx_application()’:
showBase_assist.mm:17: error: ‘NSApplication’ was not declared in this scope
showBase_assist.mm:17: error: ‘YES’ was not declared in this scope

#109

So, does panda 3D games run on iphone now ?


#110

I think they have rendered since 2009, I don’t know if there is anything there for input or sound (although I guess you could just use openAL)

I tried building the iPhoneSimulator but got some linker errors in interrogate. I’m doing a clean, statically linked, release build for iPhoneOS to see how large pview is.

EDIT:

pview comes in at around 30 megabytes, which is rather large. I’ll be looking into whether or not I can get rid of some libraries.


#111

Thank you for the information. :slight_smile: