cxAny cxPlayerInstance() { if(instance == NULL){ instance = CX_ALLOC(cxPlayer); } return instance; }
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); }
cxTextureFactory cxTextureFactoryInstance() { if(instance == NULL){ instance = CX_ALLOC(cxTextureFactory); } return instance; }
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; }
cxString cxStringAllocChars(cxConstChars str) { CX_ASSERT(str != NULL, "str null"); cxString rv = CX_ALLOC(cxString); cxStringAppend(rv, (void *)str, (cxInt)strlen(str)); return rv; }
static cxStack cxAutoPoolStack() { if(autopool == NULL){ autopool = CX_ALLOC(cxStack); } return autopool; }
void cxAutoPoolPush() { cxAutoPool pool = CX_ALLOC(cxAutoPool); cxStack stack = cxAutoPoolStack(); cxStackPush(stack, pool); CX_RELEASE(pool); }
cxEventBase cxEventBaseInstance() { if(instance == NULL){ instance = CX_ALLOC(cxEventBase); } return instance; }
cxEngine cxEngineInstance() { if(instance == NULL) { CX_LOGGER("cxEngine Version: %d",CX_ENGINE_VERSION); instance = CX_ALLOC(cxEngine); } return instance; }
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); }
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); }
static cxStack cxMemPoolStack() { cxAny pool = pthread_getspecific(autoPoolKey); if(pool == NULL){ pool = CX_ALLOC(cxStack); pthread_setspecific(autoPoolKey, pool); } return pool; }
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); }
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; }
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); }
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); }
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); }
CX_OBJECT_INIT(cxTimeLine, cxAction) { CX_METHOD_SET(this->cxAction.Init, cxTimeLineInit); CX_METHOD_SET(this->cxAction.Step, cxTimeLineStep); this->times = CX_ALLOC(cxArray); }
CX_OBJECT_INIT(cxActionRoot, cxObject) { cxObjectSetReadAttrFunc(this, cxActionRootReadAttr); this->codes = CX_ALLOC(cxHash); CX_METHOD_OVERRIDE(this->Make, cxActionRootMakeElement); }
CX_OBJECT_INIT(cxAutoPool, cxObject) { this->objects = CX_ALLOC(cxArray); }
CX_INIT(cxMemPool, cxObject) { this->objects = CX_ALLOC(cxArray); }
CX_OBJECT_INIT(cxHashRoot, cxObject) { this->items = CX_ALLOC(cxHash); }
void cxTypesInit() { types = CX_ALLOC(cxHash); cxInitTypes(); }
CX_OBJECT_INIT(cxPlayer, cxObject) { this->tracks = CX_ALLOC(cxHash); }
CX_OBJECT_INIT(cxFreeFont, cxObject) { this->chars = CX_ALLOC(cxHash); }
CX_INIT(cxTextureMTF, cxTexture) { this->caches = CX_ALLOC(cxHash); }
void cxJsonInit() { json_set_alloc_funcs((json_malloc_t)allocator->malloc, (json_free_t)allocator->free); convertFuncs = CX_ALLOC(cxHash); cxSetConvert("formatConvert", cxStrFormatConvert); }
CX_INIT(cxBMPFont, cxObject) { this->textures = CX_ALLOC(cxHash); this->chars = CX_ALLOC(cxHash); this->kernings = CX_ALLOC(cxHash); }
CX_OBJECT_INIT(cxStack, cxObject) { this->array = CX_ALLOC(cxArray); }