Combine with Tangram-ES

Combine with Tangram-ES
0.0 0

#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.


#2

Offer 50$ for working solution


#3

What does the header for MapScene look like?


#4

I tried it at start simple:

#ifndef __MAPSCENE_LINUX_HPP__
#define __MAPSCENE_LINUX_HPP__

#include <GLFW/glfw3.h>
#include "tangram.h"
#include "linuxPlatform.h"


class MapScene {
private:
    std::shared_ptr<Tangram::Platform> platform;
    Tangram::Map* map = nullptr;
    GLFWwindow* mWindow  = nullptr;
    float density = 1.0;
    bool recreate_context = false;
    
    double lastTime;
    double currentTime;
    double delta;
    
public:
    void create();
    void update(float);
    void framebufferResizeCallback(GLFWwindow*, int, int);
};

#endif // __MAPSCENE_LINUX_HPP__

#5

Can you post a picture of what is happening, please.


#6

Sure, i posting a video today or tomorrow as soon as i’m home.
Cocos2d should run in foreground and tangram-es in background.


#7

Here is the Video:

But: Theres flicker very fast, so fast, that i can’t record it (on Mouseover)