コード例 #1
0
        void CreateAssetsFor(SDLRenderer renderer)
        {
            // Get the size of the message
            textSize = font.TextSize(TEXT);

            // Create a Surface for the message
            var surface = font.TextBlended(TEXT, Color.White);

            // Turn the surface into a Texture
            textTure = renderer.CreateTextureFromSurface(surface);
        }
コード例 #2
0
    void CreateAssetsForRenderer(SDLRenderer renderer)
    {
        // Load Surface from a file
        //
        // NOTE:  Surfaces are deprecated and require conversion to Textures before blitting.
        surface = renderer.LoadSurface("pointsprite.png");

        // Set the blend mode for surface blitting
        surface.BlendMode = SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND;

        // Create a Texture from the Surface.
        //
        // No need to set the blend mode, etc - all rendering information is copied
        // directly in SDLRenderer.CreateTextureFromSurface() from the Surface settings.
        texture = renderer.CreateTextureFromSurface(surface);

        // Load a font from file.
        font = renderer.CreateFont(12, "LibertySans.ttf");
        if (font == null)
        {
            throw new Exception(string.Format("Unable to create font!\n\n{0}", SDL.SDL_GetError()));
        }
    }