//Renders an image on a static position with the given angle and flip public static void RenderAdvancedStatic (IntPtr texture, float posX, float posY , ushort spriteWidth, ushort spriteHeight , ushort spriteX, ushort spriteY , float angle, SDL.SDL_Point center, SDL.SDL_RendererFlip flip) { SDL.SDL_Rect source = new SDL.SDL_Rect { x = spriteX, y = spriteY, w = spriteWidth, h = spriteHeight }; SDL.SDL_Rect target = new SDL.SDL_Rect { x = (int)(posX), y = (int)(posY), w = spriteWidth, h = spriteHeight }; SDL.SDL_RenderCopyEx(Renderer, texture, ref source, ref target, angle, ref center, flip); }
public static void Draw(IntPtr texture, SDL.SDL_Rect src, SDL.SDL_Rect dst, SDL.SDL_RendererFlip flip) { SDL.SDL_Point centre; centre.x = dst.x; centre.y = dst.y; SDL.SDL_RenderCopyEx(Shared.Renderer, texture, ref src, ref dst, 0, ref centre, flip); }
public void DrawObject(GameObject gameObject, SDL.SDL_RendererFlip flip = SDL.SDL_RendererFlip.SDL_FLIP_NONE) { var texture = gameObject.Texture; var center = new SDL.SDL_Point(); center.x = gameObject.Rect.w / 2; center.y = gameObject.Rect.h / 2; SDL.SDL_RenderCopyEx(_render, texture.Pointer, ref texture.Rect, ref gameObject.Rect, gameObject.Rotation, ref center, flip); }
//Renders an image on screen depending on the camera position with //the given angle and flip. public static void RenderAdvancedDynamic (IntPtr texture, float camX, float camY , float posX, float posY , ushort spriteWidth, ushort spriteHeight , ushort spriteX, ushort spriteY , float angle, SDL.SDL_Point center, SDL.SDL_RendererFlip flip) { RenderAdvancedStatic(texture, posX - camX, posY - camY , spriteWidth, spriteHeight, spriteX, spriteY, angle, center, flip); }
public void DrawTexture(Texture texture, Transformation2D transformation, bool flip) { SDL.SDL_Point center; SDL.SDL_Rect sourceRect = texture.SourceRectangle; SDL.SDL_Rect renderRect = texture.RenderRectangle; double angleDegrees = transformation.RotationRadians * _rad2deg; renderRect.x = (int)transformation.Position.X; renderRect.y = (int)transformation.Position.Y; center.x = (renderRect.w) / 2; center.y = (renderRect.h) / 2; SDL.SDL_RendererFlip renderFlip = flip ? SDL.SDL_RendererFlip.SDL_FLIP_HORIZONTAL : SDL.SDL_RendererFlip.SDL_FLIP_NONE; SDL.SDL_RenderCopyEx(_renderer, texture.SDLTexture, ref sourceRect, ref renderRect, angleDegrees, ref center, renderFlip); }
public Image(IntPtr renderer, string fileName, SDL.SDL_RendererFlip flipFlag = SDL.SDL_RendererFlip.SDL_FLIP_NONE) { _renderer = renderer; IntPtr img = SDL_image.IMG_Load(fileName); Texture = SDL.SDL_CreateTextureFromSurface(_renderer, img); SDL.SDL_FreeSurface(img); SDL.SDL_QueryTexture(Texture, out Format, out Access, out Params.w, out Params.h); SetColor(255, 255, 255); FlipFlag = flipFlag; }
public void SetAnimation(string name, char flip_axis) { SDL.SDL_RendererFlip flip = SDL.SDL_RendererFlip.SDL_FLIP_NONE; try { if (flip_axis == 'h') { flip = SDL.SDL_RendererFlip.SDL_FLIP_HORIZONTAL; } else if (flip_axis == 'v') { flip = SDL.SDL_RendererFlip.SDL_FLIP_VERTICAL; } else if (flip_axis == 'n') { flip = SDL.SDL_RendererFlip.SDL_FLIP_NONE; } else if (flip_axis == 'b') { flip = SDL.SDL_RendererFlip.SDL_FLIP_VERTICAL | SDL.SDL_RendererFlip.SDL_FLIP_HORIZONTAL; } else { throw new ArgumentOutOfRangeException(); } } catch (ArgumentOutOfRangeException e) { Console.WriteLine("SetAnimation: Flip axis must be vertical (v), horizontal (h), both (b) or none (n)"); } finally { try { _currentAnimation = _animations.Find(x => x.Name == name); if (_currentAnimation != null) { _currentAnimation.Flip = SDL.SDL_RendererFlip.SDL_FLIP_NONE; } } catch (ArgumentNullException e) { Console.WriteLine("No animation set! No animation found with name: " + name); } } }
//Renders texture at given point public void render(int x, int y, SDL.SDL_Rect?clip = null, double angle = 0, SDL.SDL_Point?center = null, SDL.SDL_RendererFlip flip = SDL.SDL_RendererFlip.SDL_FLIP_NONE) { //Set rendering space and render to screen SDL.SDL_Rect renderQuad = new SDL.SDL_Rect { x = x, y = y, w = mWidth, h = mHeight }; var myCenter = center ?? new SDL.SDL_Point(); //Set clip rendering dimensions if (clip != null) { renderQuad.w = clip.Value.w; renderQuad.h = clip.Value.h; var myClip = clip.Value; SDL.SDL_RenderCopyEx(Program.gRenderer, mTexture, ref myClip, ref renderQuad, angle, ref myCenter, flip); return; } SDL.SDL_RenderCopyEx(Program.gRenderer, mTexture, IntPtr.Zero, ref renderQuad, angle, ref myCenter, flip); }
public void DrawEx(IntPtr rendererId, int x, int y, double angle, Vector?center, SDL.SDL_RendererFlip flipMode) { var source = new SDL.SDL_Rect() { x = this.X, y = this.Y, w = Width, h = Height }; var destination = new SDL.SDL_Rect() { x = x, y = y, w = Width, h = Height }; if (center.HasValue) { var centerPoint = new SDL.SDL_Point { x = (int)center.Value.X, y = (int)center.Value.Y }; SDL.SDL_RenderCopyEx(rendererId, TextureId, ref source, ref destination, angle, ref centerPoint, flipMode); } else { SDL.SDL_RenderCopyEx(rendererId, TextureId, ref source, ref destination, angle, IntPtr.Zero, flipMode); } }
public void setFlip(SDL.SDL_RendererFlip flip) { this.flip = flip; }
public void RenderCopyEx(SDLTexture TheTexture, ref SDL.SDL_Rect Srcrect, ref SDL.SDL_Rect Dstrect, double Angle, ref SDL.SDL_Point Center, SDL.SDL_RendererFlip Flip) { Util.ThrowIfResultIsError(SDL.SDL_RenderCopyEx(myPtr, TheTexture.Ptr, ref Srcrect, ref Dstrect, Angle, ref Center, Flip)); }