Beispiel #1
0
cxAny cxPlayerInstance()
{
    if(instance == NULL){
        instance = CX_ALLOC(cxPlayer);
    }
    return instance;
}
Beispiel #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);
}
Beispiel #3
0
cxTextureFactory cxTextureFactoryInstance()
{
    if(instance == NULL){
        instance = CX_ALLOC(cxTextureFactory);
    }
    return instance;
}
Beispiel #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;
}
Beispiel #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;
}
Beispiel #6
0
static cxStack cxAutoPoolStack()
{
    if(autopool == NULL){
        autopool = CX_ALLOC(cxStack);
    }
    return autopool;
}
Beispiel #7
0
void cxAutoPoolPush()
{
    cxAutoPool pool = CX_ALLOC(cxAutoPool);
    cxStack stack = cxAutoPoolStack();
    cxStackPush(stack, pool);
    CX_RELEASE(pool);
}
Beispiel #8
0
cxEventBase cxEventBaseInstance()
{
    if(instance == NULL){
        instance = CX_ALLOC(cxEventBase);
    }
    return instance;
}
Beispiel #9
0
cxEngine cxEngineInstance()
{
    if(instance == NULL) {
        CX_LOGGER("cxEngine Version: %d",CX_ENGINE_VERSION);
        instance = CX_ALLOC(cxEngine);
    }
    return instance;
}
Beispiel #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);
}
Beispiel #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);
}
Beispiel #12
0
static cxStack cxMemPoolStack()
{
    cxAny pool = pthread_getspecific(autoPoolKey);
    if(pool == NULL){
        pool = CX_ALLOC(cxStack);
        pthread_setspecific(autoPoolKey, pool);
    }
    return pool;
}
Beispiel #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);
}
Beispiel #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;
}
Beispiel #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);
}
Beispiel #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);
    }
Beispiel #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);
}
Beispiel #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);
}
Beispiel #19
0
CX_OBJECT_INIT(cxActionRoot, cxObject)
{
    cxObjectSetReadAttrFunc(this, cxActionRootReadAttr);
    this->codes = CX_ALLOC(cxHash);
    CX_METHOD_OVERRIDE(this->Make, cxActionRootMakeElement);
}
Beispiel #20
0
CX_OBJECT_INIT(cxAutoPool, cxObject)
{
    this->objects = CX_ALLOC(cxArray);
}
Beispiel #21
0
CX_INIT(cxMemPool, cxObject)
{
    this->objects = CX_ALLOC(cxArray);
}
Beispiel #22
0
CX_OBJECT_INIT(cxHashRoot, cxObject)
{
    this->items = CX_ALLOC(cxHash);
}
Beispiel #23
0
void cxTypesInit()
{
    types = CX_ALLOC(cxHash);
    cxInitTypes();
}
Beispiel #24
0
CX_OBJECT_INIT(cxPlayer, cxObject)
{
    this->tracks = CX_ALLOC(cxHash);
}
Beispiel #25
0
CX_OBJECT_INIT(cxFreeFont, cxObject)
{
    this->chars = CX_ALLOC(cxHash);
}
Beispiel #26
0
CX_INIT(cxTextureMTF, cxTexture)
{
    this->caches = CX_ALLOC(cxHash);
}
Beispiel #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);
}
Beispiel #28
0
CX_INIT(cxBMPFont, cxObject)
{
    this->textures = CX_ALLOC(cxHash);
    this->chars = CX_ALLOC(cxHash);
    this->kernings = CX_ALLOC(cxHash);
}
Beispiel #29
0
CX_OBJECT_INIT(cxStack, cxObject)
{
    this->array = CX_ALLOC(cxArray);
}