void pushGRS(GRS grs, bool force) { //push dest if(grs.isDestDirty || force) { SetDest(grs._dest); if(grs.pick) applyPickingMatrix(1, 1, grs.pick_x, grs.pick_y); } //push render mode if(grs.isRenderModeDirty || force) { //if(grs.pick) { // setRenderMode(RenderMode.Color); // device.RenderState.AlphaBlendEnable = false; //} else { if(grs._renderMode != null) { grs._renderMode.Apply(); grs.isSrcDirty = true; //setting the render mode will often reset the source texture to null //force it to be restored here } //} } //push color if(grs.isColorDirty || force) if(grs.pick) SetRenderColor(grs.pick_val); else SetRenderColor(grs._alpha, grs._color); //push src if(grs.isSrcDirty || force) SetTex(grs._src); //push transform if(grs.IsTransformDirty || force) World(grs.GetTransform()); //push clipping if(grs.isClipDirty || force) setClip(grs._clipEnabled, grs._clipRectangle); grs.undirty(); }
/// <summary> /// sets the specified render state to active and ensures that its state is pushed into the hardware. /// may be null if you are going to control d3d manually. /// </summary> public void setActiveRenderState(GRS grs) { //if the new active state is the pre-existing active state, just unforceingly push it if(activeGRS == grs) { if(grs != null) pushGRS(activeGRS, false); goto end; } //if the current render state is null, then we need to reset the 3d engine to the prerequisites for GRS if(activeGRS == null && grs != null) prepareRenderState(); activeGRS = grs; if(activeGRS == null) return; pushGRS(activeGRS, true); end: currTechnique.Refresh(); RasterizerState.Apply(); BlendState.Apply(); DepthStencilState.Apply(); for(int i=0;i<SamplerStates.Length;i++) SamplerStates[i].Apply(); }