Combine with Tangram-ES


#1

I trying to implementing Cocos2D-X (C++) with Tangram-ES [C++].

This Code works, but very strange.
If i loaded them, it works generally ok, it shown me the result from Tangram.
But the problems are:

  • if i hover the app with the mouse it’s switching in black screen in the time im hovering it
  • No Cocos Nodes (Menu etc.) are shown in this time

This is the Class for the Tangram:

void MapScene::create() {
	if(!map) {
		platform = std::make_shared<Tangram::LinuxPlatform>();
		map = new Tangram::Map(platform);
		map->loadSceneAsync("Resources/scene.yaml", true, {}, nullptr, {});
	}
	
	mWindow = glfwGetCurrentContext();
	
	if(!mWindow) {
		glfwTerminate();
	}
	
	map->setupGL();
	
	int fWidth = 0, fHeight = 0;
	glfwGetWindowSize(mWindow, &fWidth, &fHeight);
	framebufferResizeCallback(mWindow, fWidth, fHeight);
	
	lastTime = glfwGetTime();
}

void MapScene::update(float dt) {
	map->update(dt);
	map->render();
	
	glfwSwapBuffers(mWindow);

	// Poll for and process events
	if(platform->isContinuousRendering()) {
		glfwPollEvents();
	} else {
		glfwWaitEvents();
	}
}

void MapScene::framebufferResizeCallback(GLFWwindow* mWindow, int fWidth, int fHeight) {
	int wWidth = 0, wHeight = 0;
	glfwGetWindowSize(mWindow, &wWidth, &wHeight);
	float new_density = (float)fWidth / (float)wWidth;
	if(new_density != density) {
		recreate_context = true;
		density = new_density;
	}
	
	map->setPixelScale(density);
	map->resize(fWidth, fHeight);
}

What can i do, to rendering Tangram correctly in Background ?

Thank you and best regards,
Roman H.