Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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);
    }
Exemplo n.º 3
0
cxBool cxViewZeroSize(cxAny pview)
{
    cxView this = pview;
    return cxSize2Zero(this->size);
}