Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 void compileTo(VertexArrays& vas)
 {
     if (!glBlocks.empty())
         throw std::logic_error("Custom code cannot be recorded into a macro");
     
     std::stable_sort(ops.begin(), ops.end());
     for (DrawOps::const_iterator op = ops.begin(), end = ops.end(); op != end; ++op)
         op->compileTo(vas);
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 4
0
 void performDrawOpsAndCode()
 {
     // Apply Z-Ordering.
     std::stable_sort(ops.begin(), ops.end());
     
     RenderStateManager manager;
     #ifdef GOSU_IS_IPHONE
     if (ops.empty())
         return;
     
     DrawOps::const_iterator current = ops.begin(), last = ops.end() - 1;
     for (; current != last; ++current)
     {
         manager.setRenderState(current->renderState);
         current->perform(&*(current + 1));
     }
     manager.setRenderState(last->renderState);
     last->perform(0);
     #else
     for (DrawOps::const_iterator current = ops.begin(), last = ops.end();
         current != last; ++current)
     {
         manager.setRenderState(current->renderState);
         if (current->verticesOrBlockIndex >= 0)
             current->perform(0);
         else
         {
             // GL code
             int blockIndex = ~current->verticesOrBlockIndex;
             assert (blockIndex >= 0);
             assert (blockIndex < glBlocks.size());
             glBlocks[blockIndex]();
             manager.enforceAfterUntrustedGL();
         }
     }
     #endif
 }
Ejemplo n.º 5
0
 // This retains the current stack of transforms and clippings.
 void clearQueue()
 {
     glBlocks.clear();
     ops.clear();
 }