分类 IT Technology 下的文章

unsigned int length = pointsArray.size(); // XXX
cocos2d::Vec2 *points = new cocos2d::Vec2[length];//XXX
int cnt = 0;// XXX
for (auto& p : pointsArray) {
    ValueMap &a = p.asValueMap();
    Vec2 *th = &points[cnt];//xxx
    th->x = a["x"].asFloat();//xxx
    th->y = a["y"].asFloat();//xxx
    cnt++;//xxx
}
DrawNode *node = DrawNode::create();
node->drawPoly(points, length, true, Color4F(1, 0, 0, 1));
addChild(node);
node->setPosition(xPos);
float rotation = 0;
if (dict.find("rotation") != dict.end()) {
    rotation = dict["rotation"].asFloat();
}
node->setRotation(rotation);
// set data for sort
Vec2 *data = new Vec2(xPos);
node->setUserData((void *)data);

int family = iterator->ai_family;
t_socket sock;
const char *err = inet_trycreate(&sock, family, SOCK_STREAM);
if (err) {
    continue; // check next
} else {
    t_timeout tm;
    struct addrinfo connecthints;
    memset(&connecthints, 0, sizeof(connecthints));
    connecthints.ai_socktype = SOCK_STREAM;
    /* make sure we try to connect only to the same family */
    connecthints.ai_family = family;
    
    if (family == PF_INET6) {
        int yes = 1;
        setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&yes, sizeof(yes));
    }
    timeout_markstart(&tm);
    err = inet_tryconnect(&sock, &family, (const char *)hbuf, "3006", &tm, &connecthints);
    if (err) {
        socket_destroy(&sock);
        continue; // check next
    } else {
        // find success one
        CCLOG("== xx:%s", hbuf);
    }
}

编译png

$cmake .. -DPNG_STATIC=ON -DZLIB_INCLUDE_DIR=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ -DZLIB_LIBRARY=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/

编译websockets

$cmake .. -DOPENSSL_ROOT_DIR=/home/u0u0/works/Cocos2d-thirdpart/tarballs/openssl-1.1.0c -DZLIB_INCLUDE_DIR=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ -DZLIB_LIBRARY=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ -DLWS_WITH_LIBUV=OFF -DLWS_WITH_SSL=ON -DLWS_WITH_SHARED=OFF -DLWS_WITHOUT_TEST_SERVER=ON -DLWS_WITHOUT_TEST_SERVER_EXTPOLL=ON -DLWS_WITHOUT_TEST_PING=ON -DLWS_WITHOUT_TEST_ECHO=ON -DLWS_WITHOUT_TEST_CLIENT=ON -DLWS_WITHOUT_TEST_FRAGGLE=ON -DLWS_IPV6=ON

编译OpenSSL

在 Linux 下自定义OpenSSL库,需要安装到一个路径,以便curl能找到。

./config --prefix=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/openssl_install --openssldir=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/openssl_install
make
make install

编译curl

./configure --enable-static --disable-ldap --enable-ipv6 --with-zlib=/home/u0u0/works/Cocos2d-thirdpart/tarballs/zlib-1.2.8/ --with-ssl=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/openssl_install --prefix=/home/u0u0/works/projects/Cocos2d-thirdpart/tarballs/curl_install
make
make install

编译OpenAL

$sudo apt-get install libasound2-dev
$cmake .. -DLIBTYPE=STATIC -DALSOFT_INSTALL=OFF -DALSOFT_REQUIRE_ALSA=ON

  1. 安装配置 mbpfan 风扇控制器: https://github.com/linux-on-mac/mbpfan
    mbpfan.service文件从github获取。

    sudo apt-get install mbpfan
    sudo cp mbpfan.service /etc/systemd/system/
    sudo systemctl enable mbpfan.service
    sudo systemctl daemon-reload
    sudo systemctl start mbpfan.service
  2. “软件和更新”中启用附加驱动,使用专有驱动。
  3. 安装最新的tlp电源管理。

    sudo apt install tlp
    sudo systemctl enable tlp.service
    sudo systemctl daemon-reload
    sudo systemctl start mbpfan.service
    sudo tlp start