Cocos2d-x and XBOX One

passsed cert

Update: Passed certification!

Still planning on launching this game sometime next month when the other platforms are ready.

Something surprising and quite nice: the Xbox Live SDK is now open source. I found their leaderboards example in the samples useful too.

2 Likes

@rusty congrats!! Maybe it is time for me to buy an Xbox one!

Hi,

Thank you.
Do you have any experience with Kinect?
What is preferred way to connect cocos2d-x, Xbox and Kinect?

Regards,
CHP

Microsoft announced yesterday that they’re significantly increasing the resources available on Xbox for UWP games in the fall update.

  • 6 CPU cores - up from 4
  • 5GB of RAM - up from 1GB
  • Full GPU Access - up from 45%

The announcement also states the full GPU access is for DirectX 12 games. I’m not sure if there will be an increase for DirectX 11. Cocos2d-x uses ANGLE to convert it’s OpenGL ES calls into DirectX 11, so I’m not sure if the GPU improvement will affect Cocos2d-x games.

For me, the most significant change will be the increase to RAM.

@slackmoehrle Thank you! Looking forward to sharing the game soon.

@CrazyHappyGame According to this list of not supported features on Xbox, only some of the Kinect works.

Xbox Universal Windows Apps don’t support skeletal tracking. Xbox provides support for using the infrared, depth, and color feeds from Kinect.

2 Likes

This is good news any way you slice it!

Ok, first Xbox One game released! Train Bandit is now live on Xbox One. I made a new thread for it here.

2 Likes

Update on the Xbox One launch.

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.

@rusty how are you making out? How may we be of service?

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. :crossed_fingers:

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:

 void Renderer::drawBatchedTriangles()
{
    ...

    /************** 2: Copy vertices/indices to GL objects *************/
    if (Configuration::getInstance()->supportsShareableVAO())
    {
        ....
    }
    else
    {
        // Client Side Arrays

        ....

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT )
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _filledIndex, _indices, GL_DYNAMIC_DRAW);
#else
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _filledIndex, _indices, GL_STATIC_DRAW);
#endif

    }
    ....
}

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. ¯_(ツ)_/¯

1 Like

Could you create pull request for this?

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.

What does your AppDelegate look like?

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
}

I see. I don’t pass design resolution to make my rect.

If you place a break point is it hitting glview = GLViewImpl::create("Lumps of Clay");?

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

cocos2d: warning, Director::setProjection() failed because size is 0

{
gl.version: OpenGL ES 2.0 (ANGLE 2.1.13.6fde4e24ab73)
gl.supports_NPOT: true
cocos2d.x.version: cocos2d-x-3.15.1
cocos2d.x.compiled_with_profiler: false
cocos2d.x.build_type: DEBUG
gl.supports_discard_framebuffer: true
cocos2d.x.compiled_with_gl_state_cache: true
gl.max_texture_size: 8192
gl.supports_S3TC: false
gl.supports_OES_packed_depth_stencil: true
gl.vendor: Google Inc.
gl.renderer: ANGLE (SraKmd Direct3D11 vs_4_0 ps_4_0)
gl.max_texture_units: 32
gl.supports_ETC1: true
gl.supports_ATITC: false
gl.supports_PVRTC: false
gl.supports_OES_depth24: false
gl.supports_BGRA8888: false
gl.supports_vertex_array_object: true
gl.supports_OES_map_buffer: true
}

Not sure if it still works with the current Windows SDK, but this is how I got full 1080p output last year.

Also, see my posts in this thread for other misc tips.

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?

I think Xbox requires at least Windows 10 SDK 10.0.10586 now.

I shipped with Cocos2d-x 3.13.1. Both Dig Dog and Train Bandit.

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!