Example #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 = &currentTransform();
     if (const ClipRect* cr = clipRectStack.maybeEffectiveRect())
         op.renderState.clipRect = *cr;
     ops.push_back(op);
 }
Example #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 = &currentTransform();
     if (const ClipRect* cr = clipRectStack.maybeEffectiveRect())
         op.renderState.clipRect = *cr;
     op.z = z;
     ops.push_back(op);
 }
Example #3
0
 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();
 }
Example #4
0
 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);
 }
Example #5
0
 void endClipping()
 {
     clipRectStack.endClipping();
 }
Example #6
0
 // 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();
 }