Exemple #1
0
    void scheduleDrawOp(DrawOp op)
    {
        if (clipRectStack.clippedWorldAway())
            return;

        #ifdef GOSU_IS_IPHONE
        // No triangles, no lines supported
        assert (op.verticesOrBlockIndex == 4);
        #endif

        op.renderState.transform = &transformStack.current();
        if (const ClipRect* cr = clipRectStack.maybeEffectiveRect())
            op.renderState.clipRect = *cr;
        ops.push_back(op);
    }
Exemple #2
0
    void scheduleGL(std::tr1::function<void()> glBlock, ZPos z)
    {
        // TODO: Document this case: Clipped-away GL blocks are *not* being run.
        if (clipRectStack.clippedWorldAway())
            return;

        int complementOfBlockIndex = ~(int)glBlocks.size();
        glBlocks.push_back(glBlock);

        DrawOp op;
        op.verticesOrBlockIndex = complementOfBlockIndex;
        op.renderState.transform = &transformStack.current();
        if (const ClipRect* cr = clipRectStack.maybeEffectiveRect())
            op.renderState.clipRect = *cr;
        op.z = z;
        ops.push_back(op);
    }
Exemple #3
0
    void beginClipping(double x, double y, double width, double height, double screenHeight)
    {
        // Apply current transformation.

        double left = x, right = x + width;
        double top = y, bottom = y + height;

        applyTransform(transformStack.current(), left, top);
        applyTransform(transformStack.current(), right, bottom);

        double physX = std::min(left, right);
        double physY = std::min(top, bottom);
        double physWidth = std::abs(left - right);
        double physHeight = std::abs(top - bottom);

        // Adjust for OpenGL having the wrong idea of where y=0 is.
        // TODO: This should really happen *right before* setting up
        // the glScissor.
        physY = screenHeight - physY - physHeight;

        clipRectStack.beginClipping(physX, physY, physWidth, physHeight);
    }