예제 #1
0
void RenderManager::PrepareRealMatrix()
{
    if (mappingMatrixChanged)
    {
        mappingMatrixChanged = false;
        Vector2 realDrawScale(viewMappingDrawScale.x * userDrawScale.x, viewMappingDrawScale.y * userDrawScale.y);
        Vector2 realDrawOffset(viewMappingDrawOffset.x + userDrawOffset.x * viewMappingDrawScale.x, viewMappingDrawOffset.y + userDrawOffset.y * viewMappingDrawScale.y);
	
	if (realDrawScale != currentDrawScale || realDrawOffset != currentDrawOffset) 
	{

		currentDrawScale = realDrawScale;
		currentDrawOffset = realDrawOffset;

        
        Matrix4 glTranslate, glScale;
        glTranslate.glTranslate(currentDrawOffset.x, currentDrawOffset.y, 0.0f);
        glScale.glScale(currentDrawScale.x, currentDrawScale.y, 1.0f);
        
        glTranslate = glScale * glTranslate;
        SetMatrix(MATRIX_MODELVIEW, glTranslate);
//        Logger::Info("2D matricies recalculated");
//        Matrix4 modelViewSave = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_MODELVIEW);
//        Logger::Info("Model matrix");
//        modelViewSave.Dump();
//        Matrix4 projectionSave = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_PROJECTION);
//        Logger::Info("Proj matrix");
//        projectionSave.Dump();
    }
}
}
예제 #2
0
void RenderManager::PrepareRealMatrix()
{
    if (mappingMatrixChanged)
    {
        mappingMatrixChanged = false;
        Vector2 realDrawScale(viewMappingDrawScale.x * userDrawScale.x, viewMappingDrawScale.y * userDrawScale.y);
        Vector2 realDrawOffset(viewMappingDrawOffset.x + userDrawOffset.x * viewMappingDrawScale.x, viewMappingDrawOffset.y + userDrawOffset.y * viewMappingDrawScale.y);
	
        if (realDrawScale != currentDrawScale || realDrawOffset != currentDrawOffset)
        {
            currentDrawScale = realDrawScale;
            currentDrawOffset = realDrawOffset;

            Matrix4 glTranslate, glScale;
            glTranslate.glTranslate(currentDrawOffset.x, currentDrawOffset.y, 0.0f);
            glScale.glScale(currentDrawScale.x, currentDrawScale.y, 1.0f);
            
            renderer2d.viewMatrix = glScale * glTranslate;
            SetDynamicParam(PARAM_VIEW, &renderer2d.viewMatrix, UPDATE_SEMANTIC_ALWAYS);
        }
    }
    
    Matrix4 glTranslate, glScale;
    glTranslate.glTranslate(currentDrawOffset.x, currentDrawOffset.y, 0.0f);
    glScale.glScale(currentDrawScale.x, currentDrawScale.y, 1.0f);
    
    Matrix4 check = glScale * glTranslate;
    DVASSERT(check == renderer2d.viewMatrix);
}