• Cocos2d-x--Box2D使用GLES-Render.h渲染查看刚体


    分为两部分:文件拷贝和代码实现

    1.文件拷贝:

    在TestCpp下找到GLES-Render.h和GLES-Render.cpp两个文件

    复制到G:cocos2d-2.1rc0-x-2.1.3cocos2d-2.1rc0-x-2.1.3cocos2dxplatformwin32下

    工程中也要有一份

    2.代码实现:

    添加引用:#include <GLES-Render.h>

    创建世界的时候加上这些

    GLESDebugDraw * _debugDraw = new GLESDebugDraw(PTM_RATIO);
    world->SetDebugDraw(_debugDraw);
            uint32 flags = 0;
            flags += b2Draw::e_shapeBit;
            flags += b2Draw::e_jointBit;
            flags += b2Draw::e_aabbBit;
            flags += b2Draw::e_pairBit;
            flags += b2Draw::e_centerOfMassBit;
            _debugDraw->SetFlags(flags);


     

    添加或者修改 draw 方法

    void HelloWorld::draw()
    {
        CCLayer::draw();
    
        ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
    
        kmGLPushMatrix();
    
        world->DrawDebugData();
    
        kmGLPopMatrix();
    
        CHECK_GL_ERROR_DEBUG();
    }



     

  • 相关阅读:
    iOS-导航条
    iOS-存储
    iOS-模型传递
    iOS-日期相关
    iOS-UIViewController
    iOS-loadView方法
    iOS-UIWindow
    Spring 测试
    Spring条件注解@Conditional
    Spring多线程
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3162870.html
Copyright © 2020-2023  润新知