public SDLTexture RenderTextBlended(SDLRenderer renderer, string text, Color color) { // Check inputs. if (renderer == null) { throw new ArgumentNullException("renderer"); } // Convert color to SDL format. SDL.SDL_Color sdlColor = new SDL.SDL_Color(); sdlColor.r = color.RedByte; sdlColor.g = color.GreenByte; sdlColor.b = color.BlueByte; // Render the text message to an SDL_Surface and then convert the surface into an // SDL texture. SDLTexture texture; using (SDLSurface surface = new SDLSurface(SDL_ttf.TTF_RenderText_Blended( mFont, text, sdlColor))) { texture = new SDLTexture(renderer, surface); } return(texture); }
/// <summary> /// Create a new SDL texture. /// </summary> /// <param name="surface"></param> public SDLTexture( SDLRenderer renderer, SDLSurface surface ) { if ( renderer == null ) { throw new ArgumentNullException( "renderer" ); } if ( surface == null ) { throw new ArgumentNullException( "surface" ); } // Convert the SDL surface into an SDL texture. mTexture = SDL.SDL_CreateTextureFromSurface( renderer.RendererPtr, surface.SurfacePtr ); if ( mTexture == null ) { throw new SDLException( "Failed to convert SDL surface to texture" ); } ReadAndStoreTextureProperties(); }
/// <summary> /// Create a new SDL texture. /// </summary> /// <param name="surface"></param> public SDLTexture(SDLRenderer renderer, SDLSurface surface) { if (renderer == null) { throw new ArgumentNullException("renderer"); } if (surface == null) { throw new ArgumentNullException("surface"); } // Convert the SDL surface into an SDL texture. mTexture = SDL.SDL_CreateTextureFromSurface(renderer.RendererPtr, surface.SurfacePtr); if (mTexture == null) { throw new SDLException("Failed to convert SDL surface to texture"); } ReadAndStoreTextureProperties(); }
public SDLTexture RenderTextBlended( SDLRenderer renderer, string text, Color color ) { // Check inputs. if ( renderer == null ) { throw new ArgumentNullException( "renderer" ); } // Convert color to SDL format. SDL.SDL_Color sdlColor = new SDL.SDL_Color(); sdlColor.r = color.RedByte; sdlColor.g = color.GreenByte; sdlColor.b = color.BlueByte; // Render the text message to an SDL_Surface and then convert the surface into an // SDL texture. SDLTexture texture; using ( SDLSurface surface = new SDLSurface( SDL_ttf.TTF_RenderText_Blended( mFont, text, sdlColor ) ) ) { texture = new SDLTexture( renderer, surface ); } return texture; }