Universal App support in 1.6 - broken?
by Warthog · in iTorque 2D · 03/27/2013 (2:51 pm) · 4 replies
Hi All,
I'm having issues with the universal App support in 1.6. When I run on my iPad 2 I don't see the _hd graphics or the _ipad graphics. It loads the low res version. Yuk!
And how is Retina iPad handled now? I don't have one so I can only test it in the Xcode simulator, but when I run it there, it does load the _hd graphics but creating hd graphics for Retina iPhone are going to be pretty different than hd graphics for Retina iPad. And exactly what happens with iPhone 5 now?
Looking through the images folder for the Feature Demo, I see _ipad graphics, but don't know when they would be used, they don't come up on any device I have or can simulate.
Also, when in the Editor and I choose run and then iPhone or iPhone 4 or iPad, it always looks exactly the same, not loading the hd graphics or changing the display window size. Has this feature been eliminated? Or is it broken?
And since there seems to be no new docs for 1.6:
1. can anyone explain why I'm seeing this a lot: "oniOSBecomeActive: Unknown command." and "oniOSResignActive: Unknown command".
2. Are there more $platform values in 1.6 than "iphone" "ipad" and "iphone4"? Like is there "iPhone5" or "iPadRetina" (for iPad 3 and 4)? ODDLY, all I get for $platform is iOS, no matter what device I'm on. Is there a different way to query what device you are on, or what resolution or aspect ratio, etc?
I hope I've just missed the docs for this or am doing something wrong. I read through the docs on Universal App support and followed those instructions carefully.
I have been waiting a long time to move from iT2D 1.4.1 and I really hoped for a stable engine in 1.6 while I wait for MIT to have editors.
Thanks for any help!
I'm having issues with the universal App support in 1.6. When I run on my iPad 2 I don't see the _hd graphics or the _ipad graphics. It loads the low res version. Yuk!
And how is Retina iPad handled now? I don't have one so I can only test it in the Xcode simulator, but when I run it there, it does load the _hd graphics but creating hd graphics for Retina iPhone are going to be pretty different than hd graphics for Retina iPad. And exactly what happens with iPhone 5 now?
Looking through the images folder for the Feature Demo, I see _ipad graphics, but don't know when they would be used, they don't come up on any device I have or can simulate.
Also, when in the Editor and I choose run and then iPhone or iPhone 4 or iPad, it always looks exactly the same, not loading the hd graphics or changing the display window size. Has this feature been eliminated? Or is it broken?
And since there seems to be no new docs for 1.6:
1. can anyone explain why I'm seeing this a lot: "oniOSBecomeActive: Unknown command." and "oniOSResignActive: Unknown command".
2. Are there more $platform values in 1.6 than "iphone" "ipad" and "iphone4"? Like is there "iPhone5" or "iPadRetina" (for iPad 3 and 4)? ODDLY, all I get for $platform is iOS, no matter what device I'm on. Is there a different way to query what device you are on, or what resolution or aspect ratio, etc?
I hope I've just missed the docs for this or am doing something wrong. I read through the docs on Universal App support and followed those instructions carefully.
I have been waiting a long time to move from iT2D 1.4.1 and I really hoped for a stable engine in 1.6 while I wait for MIT to have editors.
Thanks for any help!
#2
To tell what device you are on, use: $pref::iOS::DeviceType
A value of 2 is iPhone5. A value of 1 is any iPad. A value of 0 is everything else.
So I do the following to fix the horrible stretching that occurs under the current system, which is especially unacceptable on the iPhone 5:
My game is in portrait mode and I am not providing retina graphics so this sets the camera to the correct size for iPhone 5 and adjusts it down so that I only see extra sceneGraph at the top. Seeing extra real estate only at the top was the best solution for me and I wrote script that if iPhone5 was detected, would move my GUI elements at the top of the screen up by 44 units so they would be correct. You can obviously adapt this to whatever your situation is.
Due to the large nature of my graphics I can't create iPad retina versions. They won't load. However I've found that because iPhone 4 and iPad Retina are EXACTLY 4 times the resolution, graphics created at the lower resolution work great. My graphics are cartoon style so very little is to be gained from the higher rez.
$pref::iOS::RetinaEnabled will also be useful to you.
The system under 1.6 is designed to load the "_hd" graphics (as described in docs) when anything is $pref::iOS::RetinaEnabled == true. That doesn't solve the iPad problem at all. So I reason there are two choices:
1. Make all your graphics for iPad standard res, let the retina iPad devices scale them naturally which looks great. For Retina iPhone use the set camera command above to either crop or scale them in a way that suits your game. You could then scale them way down using the camera if you are looking for iPhone 3Gs compatibility. This requires no change to the source and allows you to have only one set of graphics.
2. Modify the source code in T2DImageMapDatablock.cc function t2dImageMapDatablock::loadSrcBitmap to consider all iPads as Retina and to load _hd graphics for them. I did this but I'm not sure I won't use solution number 1. You could probably modify the code to create a third type of graphics as it looked like GG was starting to do, evidenced by the presence of some _iPad graphics in the tutorials. But this would lead to a lot of different versions of the graphics.
As the iPhone3Gs falls from use it may be easier to abandon that resolution. Or if you are always running up against memory warnings like me, you may continue to create at the lower rez and let the iPhone's natural 4x scaling handle the job for you.
In the post below is the function I modified...
04/16/2013 (10:17 am)
Yes and No. After spending days reading the C++ code and trying different things I came up with something that I hope will work for me. I will try to put together what I learned in a somewhat coherent manner.To tell what device you are on, use: $pref::iOS::DeviceType
A value of 2 is iPhone5. A value of 1 is any iPad. A value of 0 is everything else.
So I do the following to fix the horrible stretching that occurs under the current system, which is especially unacceptable on the iPhone 5:
if($pref::iOS::DeviceType == 2)
{
sceneWindow2D.setCurrentCameraPosition(0, -44, 320, 568);
}My game is in portrait mode and I am not providing retina graphics so this sets the camera to the correct size for iPhone 5 and adjusts it down so that I only see extra sceneGraph at the top. Seeing extra real estate only at the top was the best solution for me and I wrote script that if iPhone5 was detected, would move my GUI elements at the top of the screen up by 44 units so they would be correct. You can obviously adapt this to whatever your situation is.
Due to the large nature of my graphics I can't create iPad retina versions. They won't load. However I've found that because iPhone 4 and iPad Retina are EXACTLY 4 times the resolution, graphics created at the lower resolution work great. My graphics are cartoon style so very little is to be gained from the higher rez.
$pref::iOS::RetinaEnabled will also be useful to you.
The system under 1.6 is designed to load the "_hd" graphics (as described in docs) when anything is $pref::iOS::RetinaEnabled == true. That doesn't solve the iPad problem at all. So I reason there are two choices:
1. Make all your graphics for iPad standard res, let the retina iPad devices scale them naturally which looks great. For Retina iPhone use the set camera command above to either crop or scale them in a way that suits your game. You could then scale them way down using the camera if you are looking for iPhone 3Gs compatibility. This requires no change to the source and allows you to have only one set of graphics.
2. Modify the source code in T2DImageMapDatablock.cc function t2dImageMapDatablock::loadSrcBitmap to consider all iPads as Retina and to load _hd graphics for them. I did this but I'm not sure I won't use solution number 1. You could probably modify the code to create a third type of graphics as it looked like GG was starting to do, evidenced by the presence of some _iPad graphics in the tutorials. But this would lead to a lot of different versions of the graphics.
As the iPhone3Gs falls from use it may be easier to abandon that resolution. Or if you are always running up against memory warnings like me, you may continue to create at the lower rez and let the iPhone's natural 4x scaling handle the job for you.
In the post below is the function I modified...
#3
I hope that helps you. I just pushed out an update using 1.6 and was able to work around most of the problems, and today I start adapting the new game (about half developed) to be a Universal App. I probably have some more testing to do before deciding on option 1 vs. 2
Best of luck!
04/16/2013 (10:18 am)
Here is the function I modified, but please be advised, I am out of my depth here editing source, but it does seem to work in testing ;-) And I did comment the changes fairly well. This starts at line 792 in T2DImageMapDatablock.cc://------------------------------------------------------------------------------
// Load Src Bitmap.
//------------------------------------------------------------------------------
bool t2dImageMapDatablock::loadSrcBitmap( void )
{
// Have we a source bitmap?
if ( !mpSrcBitmap )
{
char szFullPathBuffer[1024];
bool retinaEnabled = Con::getBoolVariable("$pref::iOS::RetinaEnabled");
#ifndef TORQUE_TOOLS
//-----------Andy adds a way to load hd graphics for iPad-----------
//-----------First I create a variable filled with the device type------
S32 deviceType = dAtoi(Con::getVariable("$pref::iOS::DeviceType"));
//----------Then I create a Boolean for iPad and fill it with false-------
bool isItAniPad = false;
//----------Then I check to see if the device type indicated iPad and if so I change my boolean to true-------
if(deviceType == 1)
{
isItAniPad = true;
}
//-----------Here I changed the boolean check of the if stmt, replacing RetinaEnabled with isItAniPad-------
//-----------This causes the HD graphics to load for all iPads, not just Retina-------
if(mUseHDImage && isItAniPad)
{
if(!dStrcmp(mSrcBitmapNameHD, ""))
{
dSprintf( szFullPathBuffer, sizeof(szFullPathBuffer), "%s%s", mSrcBitmapName, "_hd");
}
else
{
// First see if the user manually specified the file to use for HD
Con::printf("HD Image %s specified", mSrcBitmapNameHD);
Con::expandScriptFilename( szFullPathBuffer, sizeof(szFullPathBuffer), mSrcBitmapNameHD );
}
}
else
#endif
Con::expandScriptFilename( szFullPathBuffer, sizeof(szFullPathBuffer), mSrcBitmapName );
// Final fallback if hd was specified and the hd image could not be found
//if(!Platform::isFile(szFullPathBuffer))
// dStrcpy( szFullPathBuffer, mSrcBitmapName);
// No, so attempt to fetch Bitmap Resource.
mpSrcBitmap = TextureManager::loadBitmapInstance( StringTable->insert( szFullPathBuffer ) );
// Does texture-file exist?
if ( !mpSrcBitmap )
{
// No, so Error!
THROW_IMAGEMAP_ERROR( T2D_IMAGEMAP_ERROR_INVALID_BITMAP );
}
//Luma: control 16bit settings on a per-bitmap basis, not a global engine basis!
mpSrcBitmap->mForce16Bit = mForce16bit;
// Fetch Source Bitmap Dimensions.
mSrcBitmapWidth = S32( mpSrcBitmap->getWidth() );
mSrcBitmapHeight = S32( mpSrcBitmap->getHeight() );
//-----------Here I changed the boolean check of the if stmt, replacing RetinaEnabled with isItAniPad-------
//-----------This causes the HD graphics to load for all iPads, not just Retina-------
#ifndef TORQUE_TOOLS
if(mUseHDImage && isItAniPad)
{
S32 lowResImageWidth = mCellCountX * mCellWidth;
S32 lowResImageHeight = mCellCountY * mCellHeight;
F32 percentageX = (F32)mCellWidth / lowResImageWidth;
F32 percentageY = (F32)mCellHeight / lowResImageHeight;
mCellWidth = mSrcBitmapWidth * percentageX;
mCellHeight = mSrcBitmapHeight * percentageY;
}
#endif
}
// Return No Error.
return true;
}I hope that helps you. I just pushed out an update using 1.6 and was able to work around most of the problems, and today I start adapting the new game (about half developed) to be a Universal App. I probably have some more testing to do before deciding on option 1 vs. 2
Best of luck!
#4
04/18/2013 (1:37 pm)
Thanks a lot for your response. I will try it out and see how it goes.
Torque Owner Hitesh Patel
Default Studio Name