//Overload the cSpriteComposite draw function public override void draw( cGraphics pgraphics, int drawflags ) { /* Use the base _spriteattitude and then walk the array of child sprites and call their imagedraw methods. */ pgraphics.pushMatrix(); pgraphics.multMatrix( _spriteattitude ); foreach (cSprite s in _childspriteptr) _childspriteptr.ElementAt().draw(pgraphics, drawflags); pgraphics.popMatrix(); }
public override void draw(cGraphics pgraphics, int drawflags = 0) { /* Use the base _spriteattitude and then walk the array of child sprites and call their imagedraw methods. Don't try and imagedraw the base cSprite, as it's only there to hold the _spriteattitude. Note that the cSpriteShowOneChild child class only cascades the imagedraw to one child. */ pgraphics.pushMatrix(); pgraphics.multMatrix(_spriteattitude); /* For now, let's not try and use display lists for the composites, but only for the individual pieces. */ foreach (cSprite s in _childspriteptr) _childspriteptr.ElementAt().draw(pgraphics, drawflags); //If there happen to be any. //If you don't want to draw the first sprite, like wiht a polypoly, start with i at 1, pgraphics.popMatrix(); }
public virtual void draw(cGraphics pgraphics, int drawflags) { /* This is an example of the Template Method. For the primitive (non-composite) * sprites we only overload the imagedraw method and use this template code. */ if ((drawflags & ACView.DF_WIREFRAME) != 0) { if (this is cSpriteQuake) { cSpriteSphere sphere = new cSphere(_radius, Color.DarkGreen); sphere.LineColor = Color.Black; sphere.draw(pgraphics, drawflags); } } pgraphics.pushMatrix(); pgraphics.multMatrix(_spriteattitude); /* If I don't have UNCONDITIONAL_ADJUSTATTRIBUTES turned on in * cGraphicsOpenGL, then I should actually call pgraphics.adjustAttributes(this); * right here instead of down inside the display list --- see the comment where * UNCONDITIONAL_ADJUSTATTRIBUTES is defined. */ if (EnabledDisplayList && pgraphics.SupportsDisplayList) { if (!pgraphics.activateDisplayList(this)) /* If you plan to use display lists, * look if one's ready, and if not, open one and draw into it. */ { pgraphics.adjustAttributes(this); //See comment above. imagedraw(pgraphics, drawflags); } pgraphics.callActiveDisplayList(this); //Now call the display list. } else //Not trying to use display lists for this kind of sprite. Just draw it. { pgraphics.adjustAttributes(this); //See comment above. imagedraw(pgraphics, drawflags); } pgraphics.popMatrix(); //After the draw, tell the sprite that its current geometry has now been drawn once. NewGeometryFlag = false; /* This is for use by the cGraphicsOpenGL for * knowing when it may need to change any display list id being used for the sprites. */ }