The resource = Resource (val_string (data)); line is returning a Resource object with a NULL data property.
If I understand correctly that Resource object is only a data structure and data is NULL because the asset is actually just a string that is assigned to the path property.
Then the heavy lifting is done by the PNG::Decode function.
In PNG::Decode, the file = lime::fopen (resource->path, "rb"); returns NULL in file and then returns, so the image is not being read.
The path of the file is assets/lime.png while I’d have expected it to be the full path to the resource in the application bundle. Any clues?
More progress on this. Lime is fine. OpenFL seems to be fine (codewise).
The problem is that the image isn’t located in the correct path. for some reason, at compile time, it gets copied in `assets/assets/lime.png".
If I move it back by one folder it works fine. Who’s telling where to copy those files?
I’m slowly getting there. I fixed the path for Lime and now it works correctly.
Now it’s only OpenFL that isn’t displaying anything other than a black screen. When I load the bitmap, it’s actually there and I see that it’s not null. Tracing the height and width it shows that it’s 512x200 so that’s fine. But when it’s added to the Sprite, it just doesn’t show anything.
The same happens when drawing directly on the screen with primitives.
Any idea what else I might be missing?
This is the SDL library that I used to make it running: https://dl.dropboxusercontent.com/u/3098924/openfl/sdl-tvos.zip
It still lacks support for the MFI joystick. Apparently it works fine on iOS even on retina displays but you should check it out as well to make sure I’m not missing anything. It’s based on a fork of the original SDL library at this revision: http://hg.libsdl.org/SDL/rev/63f03a567fe3
I’m going to ask someone over at SDL to pull those changes in the main tree, but I don’t know anyone there.
PR on the OpenFL repo. I pushed my tvos branch to your master.
Eventually, I wouldn’t mind being able to work on the official repo of Lime and its submodules as it’s a real pain to keep track of changes without forking all of the submodules and changing the references in my fork of Lime.
I can’t even switch between my iMac and MacBook without patching all this stuff by hand.
Cheers! Please let me know if you need anything to pull all this stuff in the official repos.
I’ve looked through the HXCPP pull request, it looks good to me, but I want to give Hugh a chance to take a look before pulling
The Lime changes looked good, I made a couple changes, I removed the additional “assets/” prefix in the getImage function. I believe that appending the paths later on in DefaultAssetLibrary.hx (similar to iOS) should already handle this
I pulled the changes for the Lime submodules, but I had to remain on our current SDL commit for the meantime. This should minimize manual changes on your end to the official Lime release, but a tweaked SDL submodule. We want to stay on main-line SDL as much as we can, perhaps you could try talking to @icculus on Twitter? He’s a core contributor and has been helpful before
SDL changes are a must if we want to offer tvOS as a target. I’ll get in touch with @icculus.
I’ve already merged my changes to their default repository. I only need to find how to send a pull request over
Are you sure about removing the “assets/” prefix? If you do so, any project using plain Lime won’t be able to read the correct assets. AKA the Lime examples will fail loading bitmaps.
As far as I understand, the default project uses “Assets”, renamed to “assets”, so “openfl.png” should be at “assets/openfl.png” when publishing.
The iOS project template puts all assets (of any name) under an “assets” folder, so “assets/openfl.png” is located at “assets/assets/openfl.png”
DefaultAssetLibrary prefixes all the path values with “assets/” on the iOS target (and now the tvOS target), so an asset of “assets/openfl.png” should result in a path of “assets/assets/openfl.png” and resolve to the correct file, right?
You’re right. It looks like the bitmap is being stretched in a weird way. But it doesn’t happen with plain SDL as I just checked it out moments ago. It’s definitely something we’re doing in Lime/OpenFL.
I can’t understand with the SimpleImage project of Lime if it’s doing the same as that texture does not fill the whole screen and I have no clue how to make it fill the screen
You can either change the data array to use window.width/window.height instead of image.width and image.height, or change the matrix to be image.width/image.height instead of window.width/window.height, and I think that should stretch the image across the whole screen, though it might be hard to tell if it was retina then
As far as I can tell, everything is right there in the latest develop branch of the projects involved. I’m pretty sure that you would need to create the static libraries of the current version of hxcpp by hand as they’re not being distributed at the time I’m writing this.
This won’t be an issue in future versions of hxcpp as the build system has changed and those static libraries will no longer be needed.
Ok, and can you provide command for rebuild tvOS static libraries of hxcpp?
Did I must use last version of openfl or can stay on last stable and can I use legacy version of openfl?
Thanks again
Unfortunately things fail while attempting to compile SDL. I believe the SDL version that lime includes is using some now-removed APIs for audio:
Error: While running :xcrun --sdk appletvos9.2 clang++ -Ilib/sdl/include/ -Ilib/sdl/include/configs/default/ -DHAVE_LIBC -D__IPHONEOS__ -D__TVOS__ -fobjc-arc -c -stdlib=libc++ -O2 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk -mappletvos-version-min=9.0 -fobjc-arc -DOBJC_ARC -Wno-parentheses -Wno-null-dereference -Wno-unused-value -Wno-bool-conversion -fno-stack-protector -DAPPLETV=APPLETV -DAPPLETVOS=APPLETVOS -fembed-bitcode -DENABLE_BITCODE=YES -DSTATIC_LINK -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=0 -I/usr/local/haxe/lib/hxcpp/git/include -fexceptions -fstrict-aliasing -x c ./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c -o/usr/local/haxe/lib/lime/git/project/obj/appletvos-c11-64/b3e8e549_SDL_coreaudio.o
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:682:5: error: implicit declaration of function 'AudioSessionInitialize' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
AudioSessionInitialize(NULL, NULL, NULL, nil);
^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:682:5: note: did you mean 'AudioUnitInitialize'?
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/AudioUnit.framework/Headers/AUComponent.h:1139:1: note: 'AudioUnitInitialize' declared here
AudioUnitInitialize( AudioUnit inUnit)
^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:683:23: error: use of undeclared identifier 'kAudioSessionCategory_AmbientSound'
UInt32 category = kAudioSessionCategory_AmbientSound;
^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:684:5: error: implicit declaration of function 'AudioSessionSetProperty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(UInt32), &category);
^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:684:5: note: did you mean 'AudioServicesSetProperty'?
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioServices.h:310:1: note: 'AudioServicesSetProperty' declared here
AudioServicesSetProperty( AudioServicesPropertyID inPropertyID,
^
./lib/sdl/src/audio/coreaudio/SDL_coreaudio.c:684:29: error: use of undeclared identifier 'kAudioSessionProperty_AudioCategory'
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(UInt32), &category);
^
I’m not really awesome enough with Haxe and all that to know what to do here. I assume somehow there are likely changes in the upstream SDL that need to be merged into Lime’s SDL or something like that?