Train Bandit is live on the Xbox One Store. I’ve received a couple nice emails from Xbox One players. (Which is nice!)
Also, I’m seeing a few mysterious crashes. I’m not sure why they are happening and I’ve not seen any of them myself. But I wanted to post this here for anyone else running into similar issues. This crash info is all from Microsoft dev dashboard. (Which is also quite nice!)
UPDATE: Looks like the crashes were my fault. Fixed in an update.
Following up on the mysterious crashes, they might have been all related to another bug that I fixed. Still trying to independently verify, but everything seems to be going solid now.
I’ve been profiling Xbox One because I’m running into performance issue in more complex projects. I was stumped for a while, but found a very helpful post from flowerfx on performance fixes for Windows Mobile.
The relevant fix for me was in void Renderer::drawBatchedTriangles() by changing a GL_STATIC_DRAW usage to GL_DYNAMIC_DRAW:
The other suggestions from flowerfx didn’t seem to make a difference on Xbox One. I’m still trying to improve performance more, but this bit was a strong start.
Oddly, this use of GL_DYNAMIC_DRAW is contrary to Microsoft’s ANGLE performance tips. ¯_(ツ)_/¯
I know Win10 support isn’t supported anymore… but I was hoping someone who released a game on Xbox could chime in.
I can’t get the scene to fill the full screen on my Xbox One S.
I’m able to compile and run a project on Xbox (I’ve tried several different versions of cocos2d), however no matter what I set the resolutions to, I can’t get it to fill the entire screen. Setting the resolutions seem to only effect what is rendered within the frame - if that’s what its called. I tried setting the frame size manually too but that seemed to have no effect. I have black borders all around, and the director frame size is never at 1920x1080 no matter what I do.
The weird thing, is I can move the cursor into the black border.
UWP app in Windows opens fine in a window or if I launch it Full Screen.
See this image to see what I am talking about. I gave the rendered scene a blue background so you could see the black border.
I’ve tried all sorts of things… but no differences… it’s mostly unchanged from the the default template. This is one I’m playing with from 15.1.
#include "AppDelegate.h"
#include "HelloWorldScene.h"
// #define USE_AUDIO_ENGINE 1
// #define USE_SIMPLE_AUDIO_ENGINE 1
#if USE_AUDIO_ENGINE && USE_SIMPLE_AUDIO_ENGINE
#error "Don't use AudioEngine and SimpleAudioEngine at the same time. Please just select one in your game!"
#endif
#if USE_AUDIO_ENGINE
#include "audio/include/AudioEngine.h"
using namespace cocos2d::experimental;
#elif USE_SIMPLE_AUDIO_ENGINE
#include "audio/include/SimpleAudioEngine.h"
using namespace CocosDenshion;
#endif
USING_NS_CC;
static cocos2d::Size designResolutionSize = cocos2d::Size(1920, 1080);
static cocos2d::Size smallResolutionSize = cocos2d::Size(1920, 1080);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(1920, 1080);
static cocos2d::Size largeResolutionSize = cocos2d::Size(1920, 1080);
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
#if USE_AUDIO_ENGINE
AudioEngine::end();
#elif USE_SIMPLE_AUDIO_ENGINE
SimpleAudioEngine::end();
#endif
}
// if you want a different context, modify the value of glContextAttrs
// it will affect all platforms
void AppDelegate::initGLContextAttrs()
{
// set OpenGL context attributes: red,green,blue,alpha,depth,stencil
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setGLContextAttrs(glContextAttrs);
}
// if you want to use the package manager to install more packages,
// don't modify or remove this function
static int register_all_packages()
{
return 0; //flag for packages manager
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("Lumps of Clay", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("Lumps of Clay");
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0f / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
auto frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
return true;
}
// This function will be called when the app is inactive. Note, when receiving a phone call it is invoked.
void AppDelegate::applicationDidEnterBackground() {
Director::getInstance()->stopAnimation();
#if USE_AUDIO_ENGINE
AudioEngine::pauseAll();
#elif USE_SIMPLE_AUDIO_ENGINE
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
SimpleAudioEngine::getInstance()->pauseAllEffects();
#endif
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
Director::getInstance()->startAnimation();
#if USE_AUDIO_ENGINE
AudioEngine::resumeAll();
#elif USE_SIMPLE_AUDIO_ENGINE
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
SimpleAudioEngine::getInstance()->resumeAllEffects();
#endif
}
Nope I was playing with that as well. The breakpoints don’t get triggered there. I tried to dig into the code for CCGLViewImpl-winrt.cpp and tried to hard code some values in where I thought it was initializing it and there was no change.
Also when I run the app, the debugger says the following, not sure if this helps, but the first line here I thought might be of interest
Hmm… Yeah I tried that too… It basically changes the resolution of what’s going on within the blue rectangle and effects sizes of sprites, but it doesn’t bring it to the borders of the screen.
I’m running on SDK 10.0.14393.0 as that seems to be the only one that builds without a ton of compile errors.
Yeah I’ve scoured this thread quite a bit just to get it compiling and running- looking to see if I missed anything, and I see some helpful stuff for later too. I just would love to get this full screen! Then I’d be free to move on.
@Rusty what version of Cocos2d-x did you end up releasing on?
Shoot I just looked it up… If I’m reading it right, minimum is now 10.0.16299. link
Looks like unless I can get it to build on a newer SDK I may be out of luck then. Though I tested on 3.13.1 and it was the same thing. Must be something internal to Xbox and the latest OS version then if it used to work for you…
if anyone else can recreate the issue or have a fix, or able to compile at a higher SDK than 10.0.14393 - I’d love to hear any fixes!
Small update, trying to get cocos2d to compile on a higher SDK… cocos2d 3.15.1 has some compile issues with the bullet library so I skipped to 3.17 since that no longer has it. Since the win10 templates had been removed, the other day I spent many hours hacking together the old templates from cocos2d 3.15.1 and got them working with cocos2d 3.17 and was building under SDK 10.0.14393 - still with the issue where it wouldn’t fill the screen.
So the good news… I just got cocos2d 3.17 to compile under SDK 10.0.16299 up to 10.0.17763 by commenting out all the lines it errored on which were all related to Windows Phone. It looks like they deprecated all functions referencing it after 10.0.14393. So it’s fairly easy to get it compiling on the latest SDK… but…
the bad news… I’m still having the issue where it won’t fill the screen.
EDIT: I went back and tried it with cocos 3.15, and started by ignoring the errors related to Bullet and commented out all the errors related to Windows Phone, and the compile errors for Bullet went away too… so that compiles easily for the latest SDK as well… but still same issue with it not being full screen.
Doing some searching online about this during some downtime at work.
It looks like the borders are a “feature” of Xbox for overscan so that portions of your app don’t get cut off by your TV. You can disable this in the display settings.
Go to Settings > Display & sound > Video output. Then, under “Advanced” select “Video fidelity & overscan”.
You’ll see an option on the right that says “Apps can add a border”. Make sure this is not checked, and Edge should now fill up your whole screen.
But I read that if you have it disabled other apps on the xbox may get cut off that typically run full screen. There has to be a good way programmatically to disable it within the app itself.
I found this article from Microsoft saying how to disable it. link
But I’m confused because it says
C++/DirectX applications do not have to worry about this. The system will always render your application to the edge of the screen.
I assumed Cocos2d is setup as C++/DirectX project utilizing Angle to translate OpenGL to DirectX? I think I tried running the line of code they gave in the app.xaml.cpp, but I converted it to C++ and it crashed upon running. I’ll play with it more with it tonight when I get home. Maybe I placed it in the wrong spot. Or maybe there is a compiler flag or other option that needs to be set.
Edit: Doing a little more reading, I’m more excited to test it. I found you should add that line of code to OnLaunched function (for c# anyway… hoping it applies to C++ too even though it was supposed to work automatically as mentioned above!). I was adding it to the App() function , which was probably running before it was initialized then crashed. I’ll report back my results when I get home tonight!
Great news! I got it working to the edges of the screen! That was totally the issue. Ahhhh… I am so happy! hahahaha… It only took me a week to get working lol. Wish I looked at the xbox documentation earlier Now to start actually porting my code over to it for my existing game!
To fix the border issue and to get the correct resolution with @Rusty’s fix, just open up App.xaml.cpp and add the following code in the OnLaunched function.
if (Windows::System::Profile::AnalyticsInfo::VersionInfo->DeviceFamily == "Windows.Xbox") {
// fix resolution scale
Windows::UI::ViewManagement::ApplicationViewScaling::TrySetDisableLayoutScaling(true);
// fix full screen overscan borders - fill screen
Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->SetDesiredBoundsMode(Windows::UI::ViewManagement::ApplicationViewBoundsMode::UseCoreWindow);
}
Do you have any experience with releasing win32 apps in Windows Store?
It looks like it should be possible right for all Windows 10 devices: desktop/xbox/tablet/mobile (if any still exist ).
No I have not. I am mostly an iOS dev, so all this Windows stuff is new to me! The second link you attached is interesting to me, though I just skimmed it… If you can package a win32 app as a UWP app for distribution on Xbox, that would be very interesting! May be worth giving it a try! I’m on vacation for a week, so I won’t be able to test but I may when I return.