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 = ¤tTransform(); if (const ClipRect* cr = clipRectStack.maybeEffectiveRect()) op.renderState.clipRect = *cr; ops.push_back(op); }
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 = ¤tTransform(); if (const ClipRect* cr = clipRectStack.maybeEffectiveRect()) op.renderState.clipRect = *cr; op.z = z; ops.push_back(op); }
void clear() { absoluteTransforms.resize(1); // Important!! Due to all the swapping, the first entry in the list is not necessarily // the base matrix. We need to restore it. absoluteTransforms.front() = scale(1); individualTransforms.resize(1); clipRectStack.clear(); glBlocks.clear(); ops.clear(); }
void beginClipping(int x, int y, int width, int height, int screenHeight) { // Apply current transformation. double left = x, right = x + width; double top = y, bottom = y + height; applyTransform(currentTransform(), left, top); applyTransform(currentTransform(), right, bottom); int physX = std::min(left, right); int physY = std::min(top, bottom); int physWidth = std::abs(int(left - right)); int physHeight = std::abs(int(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); }
void endClipping() { clipRectStack.endClipping(); }
// This clears the queue and starts with new stacks. This must not be called // when endClipping/popTransform calls might still be pending. void reset() { transformStack.reset(); clipRectStack.clear(); clearQueue(); }