Ejemplo n.º 1
0
cxAny cxPlayerInstance()
{
    if(instance == NULL){
        instance = CX_ALLOC(cxPlayer);
    }
    return instance;
}
Ejemplo n.º 2
0
CX_OBJECT_INIT(cxEventBase, cxObject)
{
    cxEngine engine = cxEngineInstance();
    CX_SLOT_CONNECT(engine->onUpdate, this, onUpdate, cxEventUpdate);
    this->base = event_base_new();
    this->conns = CX_ALLOC(cxHash);
}
Ejemplo n.º 3
0
cxTextureFactory cxTextureFactoryInstance()
{
    if(instance == NULL){
        instance = CX_ALLOC(cxTextureFactory);
    }
    return instance;
}
Ejemplo n.º 4
0
cxAny cxPlayEffect(cxConstChars file,cxBool loop)
{
    cxPlayer this = cxPlayerInstance();
    JniMethodInfo methodInfo;
    cxBool ret = cxGetStaticMethodInfo(&methodInfo, CLASS_NAME, "cxEnginePlayEffect","(Ljava/lang/String;Z)I");
    CX_ASSERT(ret, "get static method info failed");
    CX_UNUSED_PARAM(ret);
    jstring path = (*methodInfo.env)->NewStringUTF(methodInfo.env,file);
    cxInt soundId = (*methodInfo.env)->CallStaticIntMethod(methodInfo.env, methodInfo.classID, methodInfo.methodID, path, loop);
    (*methodInfo.env)->DeleteLocalRef(methodInfo.env,path);
    if(soundId <= 0){
        CX_ERROR("play file failed %s",file);
        return NULL;
    }
    cxTrack track = cxHashGet(this->tracks, cxHashStrKey(file));
    //add or replace
    if(track == NULL || track->soundId != soundId){
        track = CX_ALLOC(cxTrack);
        track->file = cxStringAllocChars(file);
        track->soundId = soundId;
        cxHashSet(this->tracks, cxHashStrKey(file), track);
        CX_RELEASE(track);
    }
    return track;
}
Ejemplo n.º 5
0
cxString cxStringAllocChars(cxConstChars str)
{
    CX_ASSERT(str != NULL, "str null");
    cxString rv = CX_ALLOC(cxString);
    cxStringAppend(rv, (void *)str, (cxInt)strlen(str));
    return rv;
}
Ejemplo n.º 6
0
static cxStack cxAutoPoolStack()
{
    if(autopool == NULL){
        autopool = CX_ALLOC(cxStack);
    }
    return autopool;
}
Ejemplo n.º 7
0
void cxAutoPoolPush()
{
    cxAutoPool pool = CX_ALLOC(cxAutoPool);
    cxStack stack = cxAutoPoolStack();
    cxStackPush(stack, pool);
    CX_RELEASE(pool);
}
Ejemplo n.º 8
0
cxEventBase cxEventBaseInstance()
{
    if(instance == NULL){
        instance = CX_ALLOC(cxEventBase);
    }
    return instance;
}
Ejemplo n.º 9
0
cxEngine cxEngineInstance()
{
    if(instance == NULL) {
        CX_LOGGER("cxEngine Version: %d",CX_ENGINE_VERSION);
        instance = CX_ALLOC(cxEngine);
    }
    return instance;
}
Ejemplo n.º 10
0
CX_OBJECT_INIT(cxTextureFactory, cxObject)
{
    cxEngine engine = cxEngineInstance();
    this->caches = CX_ALLOC(cxHash);
    
    CX_SLOT_CONNECT(engine->onMemory, this, onMemory, cxTextureFactoryMemory);
    CX_EVENT_QUICK(engine->onFree, cxTextureFactoryDestroy);
}
Ejemplo n.º 11
0
CX_OBJECT_INIT(cxAtlas, cxSprite)
{
    this->isDirty = true;
    glGenVertexArrays(1, &this->vaoid);
    glGenBuffers(2, this->vboid);
    CX_METHOD_SET(this->cxSprite.cxView.Draw, cxAtlasDraw);
    CX_EVENT_APPEND(this->cxSprite.cxView.onResize, cxAtlasResize);
    this->items = CX_ALLOC(cxHash);
}
Ejemplo n.º 12
0
static cxStack cxMemPoolStack()
{
    cxAny pool = pthread_getspecific(autoPoolKey);
    if(pool == NULL){
        pool = CX_ALLOC(cxStack);
        pthread_setspecific(autoPoolKey, pool);
    }
    return pool;
}
Ejemplo n.º 13
0
CX_INLINE cxMemPool cxMemPoolInstance()
{
    cxStack stack = cxMemPoolStack();
    if(cxStackLength(stack) == 0){
        cxMemPool pool = CX_ALLOC(cxMemPool);
        cxStackPush(stack, pool);
        CX_RELEASE(pool);
    }
    return cxStackTop(stack);
}
Ejemplo n.º 14
0
static cxAutoPool cxAutoPoolInstance()
{
    cxAutoPool pool = NULL;
    cxStack stack = cxAutoPoolStack();
    if(cxStackLength(stack) == 0){
        pool = CX_ALLOC(cxAutoPool);
        cxStackPush(stack, pool);
        CX_RELEASE(pool);
    }else{
        pool = cxStackTop(stack);
    }
    return pool;
}
Ejemplo n.º 15
0
CX_OBJECT_INIT(cxView, cxObject)
{
    this->super.cxBase = cxBaseTypeView;
    this->hideTop = true;
    this->isBorder = false;
    this->isVisible = true;
    this->isDirty = true;
    this->color = cxColor4fv(1.0f, 1.0f, 1.0f, 1.0f);
    this->size = cxSize2fv(0.0f, 0.0f);
    this->anchor = cxVec2fv(0.5f, 0.5f);
    this->raxis = cxVec3fv(0.0f, 0.0f, 1.0f);
    this->scale = cxVec2fv(1.0f, 1.0f);
    this->fixscale = cxVec2fv(1.0f, 1.0f);
    this->subViews = CX_ALLOC(cxList);
    CX_METHOD_OVERRIDE(this->IsTouch, cxViewIsTouch);
    CX_METHOD_OVERRIDE(this->IsOnKey, cxViewIsOnKey);
    cxObjectSetReadAttrFunc(this, cxViewReadAttr);
    
    this->actions = CX_ALLOC(cxHash);
    this->caches = CX_ALLOC(cxHash);
    this->removes = CX_ALLOC(cxArray);
}
Ejemplo n.º 16
0
cxVec2f cxWindowPointToViewPoint(cxAny pview,cxVec2f wPoint)
{
    cxView this = pview;
    cxView pv = this;
    cxVec3f out;
    cxMatrix4f matrix;
    kmVec3Fill(&out, wPoint.x, wPoint.y, 0);
    cxArray list = CX_ALLOC(cxArray);
    while (pv != NULL && pv->parentView != NULL) {
        cxArrayAppend(list, pv);
        pv = pv->parentView;
    }
    CX_ARRAY_REVERSE(list, ele){
        pv = cxArrayObject(ele);
        kmMat4Inverse(&matrix, &pv->normalMatrix);
        kmVec3Transform(&out, &out, &matrix);
        kmMat4Inverse(&matrix, &pv->anchorMatrix);
        kmVec3Transform(&out, &out, &matrix);
    }
Ejemplo n.º 17
0
CX_OBJECT_INIT(cxEngine, cxObject)
{
    cxAllocatorInit();
    cxAutoPoolInit();
    kmGLInitialize();
    xmlInitGlobals();
    this->frameInterval = 1.0f/60.0f;
    this->isShowBorder = true;
    this->isTouch = true;
    this->scale     = cxVec2fv(1.0f, 1.0f);
    this->window    = CX_ALLOC(cxWindow);
    this->scripts   = CX_ALLOC(cxHash);
    this->datasets  = CX_ALLOC(cxHash);
    this->actions   = CX_ALLOC(cxHash);
    this->dbenvs    = CX_ALLOC(cxHash);
    this->bmpfonts  = CX_ALLOC(cxHash);
    gL = lua_newstate(cxEngineLuaAllocFunc, this);
    CX_ASSERT(gL != NULL, "new lua state error");
    lua_atpanic(gL, cxEngineLuaPanic);
    luaL_openlibs(gL);
    cxEngineAddLuaLoader(gL);
}
Ejemplo n.º 18
0
CX_OBJECT_INIT(cxTimeLine, cxAction)
{
    CX_METHOD_SET(this->cxAction.Init, cxTimeLineInit);
    CX_METHOD_SET(this->cxAction.Step, cxTimeLineStep);
    this->times = CX_ALLOC(cxArray);
}
Ejemplo n.º 19
0
CX_OBJECT_INIT(cxActionRoot, cxObject)
{
    cxObjectSetReadAttrFunc(this, cxActionRootReadAttr);
    this->codes = CX_ALLOC(cxHash);
    CX_METHOD_OVERRIDE(this->Make, cxActionRootMakeElement);
}
Ejemplo n.º 20
0
CX_OBJECT_INIT(cxAutoPool, cxObject)
{
    this->objects = CX_ALLOC(cxArray);
}
Ejemplo n.º 21
0
CX_INIT(cxMemPool, cxObject)
{
    this->objects = CX_ALLOC(cxArray);
}
Ejemplo n.º 22
0
CX_OBJECT_INIT(cxHashRoot, cxObject)
{
    this->items = CX_ALLOC(cxHash);
}
Ejemplo n.º 23
0
void cxTypesInit()
{
    types = CX_ALLOC(cxHash);
    cxInitTypes();
}
Ejemplo n.º 24
0
CX_OBJECT_INIT(cxPlayer, cxObject)
{
    this->tracks = CX_ALLOC(cxHash);
}
Ejemplo n.º 25
0
CX_OBJECT_INIT(cxFreeFont, cxObject)
{
    this->chars = CX_ALLOC(cxHash);
}
Ejemplo n.º 26
0
CX_INIT(cxTextureMTF, cxTexture)
{
    this->caches = CX_ALLOC(cxHash);
}
Ejemplo n.º 27
0
void cxJsonInit()
{
    json_set_alloc_funcs((json_malloc_t)allocator->malloc, (json_free_t)allocator->free);
    convertFuncs = CX_ALLOC(cxHash);
    cxSetConvert("formatConvert", cxStrFormatConvert);
}
Ejemplo n.º 28
0
CX_INIT(cxBMPFont, cxObject)
{
    this->textures = CX_ALLOC(cxHash);
    this->chars = CX_ALLOC(cxHash);
    this->kernings = CX_ALLOC(cxHash);
}
Ejemplo n.º 29
0
CX_OBJECT_INIT(cxStack, cxObject)
{
    this->array = CX_ALLOC(cxArray);
}