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); }
void cxEngineLayout(cxInt width,cxInt height) { CX_LOGGER("openGL layout width=%d height=%d",width,height); cxEngine engine = cxEngineInstance(); engine->winsize = cxSize2fv(width, height); cxViewSetSize(engine->window, engine->winsize); if(!cxSize2Zero(engine->dessize)){ engine->scale = cxVec2fv(engine->winsize.w/engine->dessize.w, engine->winsize.h/engine->dessize.h); } // if(!engine->isInit){ cxOpenGLCheckFeature(); cxEngineMain(engine); } // cxFloat zeye = engine->winsize.h / 1.1566f; kmMat4 perspective={0}; kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); // kmMat4PerspectiveProjection(&perspective, 60.0f, engine->winsize.w / engine->winsize.h, 0.0f, zeye * 2); kmGLMultMatrix(&perspective); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); // cxOpenGLViewport(cxBox4fv(0, engine->winsize.w, 0, engine->winsize.h)); // cxMatrix4f matrix; cxEngineLookAt(&matrix,cxVec2fv(0, 0)); kmGLMultMatrix(&matrix); // engine->lastTime = cxTimestamp(); if(!engine->isInit){ cxViewEnter(engine->window); } cxViewLayout(engine->window); engine->isInit = true; }
CX_SETTER_DEF(cxAtlas, layers) { cxJson layers = cxJsonToArray(value); CX_JSON_ARRAY_EACH_BEG(layers, layer) { cxVec2f pos = cxVec2fv(0, 0); cxSize2f size = cxSize2fv(0, 0); cxBoxTex2f tex = cxBoxTex2fDefault(); cxColor4f color = cxColor4fv(1, 1, 1, 1); pos = cxJsonVec2f(layer, "pos", pos); size = cxJsonSize2f(layer, "size", size); cxConstChars key = cxJsonConstChars(layer, "key"); if(key != NULL){ tex = cxTextureBox(this->cxSprite.texture, key); }else{ tex = cxJsonBoxTex2f(layer, "coord", tex); } if(cxSize2Zero(size) && key != NULL){ size = cxTextureSize(this->cxSprite.texture, key); } color = cxJsonColor4f(layer, "color", color); cxAtlasAppendBoxPoint(this, pos, size, tex, color); }