<commit_before>﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace CSharpGL
{
    /// <summary>
    /// Renders a bitmap in a square.
    /// </summary>
    class TextureRenderer : PickableRenderer
    {
        private string bitmapFilename;

        public static TextureRenderer Create(string bitmapFilename = "")
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
@"Resources.SquareRenderer.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
@"Resources.SquareRenderer.frag"), ShaderType.FragmentShader);
            var map = new PropertyNameMap();
            map.Add("in_Position", Square.strPosition);
            map.Add("in_TexCoord", Square.strTexCoord);
            var model = new Square();
            var renderer = new TextureRenderer(model, shaderCodes, map, Square.strPosition);
            renderer.bitmapFilename = bitmapFilename;
            return renderer;
        }

        private TextureRenderer(IBufferable bufferable, ShaderCode[] shaderCodes,
            PropertyNameMap propertyNameMap, string positionNameInIBufferable, params GLSwitch[] switches)
            : base(bufferable, shaderCodes, propertyNameMap, positionNameInIBufferable, switches)
        { }

        protected override void DoInitialize()
        {
            base.DoInitialize();

            Bitmap bitmap;
            if (string.IsNullOrEmpty(this.bitmapFilename))// display a cursor as default.
            { bitmap = ManifestResourceLoader.LoadBitmap(@"Resources\cursor_gold.png"); }
            else
            { bitmap = new Bitmap(this.bitmapFilename); }
            var texture = new Texture(bitmap, BindTextureTarget.Texture2D);
            texture.Initialize();
            bitmap.Dispose();
            this.SetUniform("tex", texture.ToSamplerValue());
        }
    }
}
<commit_msg>clean<commit_after>﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace CSharpGL
{
    /// <summary>
    /// Renders a bitmap in a square.
    /// </summary>
    class TextureRenderer : PickableRenderer
    {
        private string bitmapFilename;

        /// <summary>
        /// Gets a renderer that renders a bitmap in a square.
        /// </summary>
        /// <param name="bitmapFilename"></param>
        /// <returns></returns>
        public static TextureRenderer Create(string bitmapFilename = "")
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
@"Resources.SquareRenderer.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(ManifestResourceLoader.LoadTextFile(
@"Resources.SquareRenderer.frag"), ShaderType.FragmentShader);
            var map = new PropertyNameMap();
            map.Add("in_Position", Square.strPosition);
            map.Add("in_TexCoord", Square.strTexCoord);
            var model = new Square();
            var renderer = new TextureRenderer(model, shaderCodes, map, Square.strPosition);
            renderer.bitmapFilename = bitmapFilename;
            return renderer;
        }

        private TextureRenderer(IBufferable bufferable, ShaderCode[] shaderCodes,
            PropertyNameMap propertyNameMap, string positionNameInIBufferable, params GLSwitch[] switches)
            : base(bufferable, shaderCodes, propertyNameMap, positionNameInIBufferable, switches)
        { }

        protected override void DoInitialize()
        {
            base.DoInitialize();

            Bitmap bitmap;
            if (string.IsNullOrEmpty(this.bitmapFilename))// display a cursor as default.
            { bitmap = ManifestResourceLoader.LoadBitmap(@"Resources\cursor_gold.png"); }
            else
            { bitmap = new Bitmap(this.bitmapFilename); }
            var texture = new Texture(bitmap, BindTextureTarget.Texture2D);
            texture.Initialize();
            bitmap.Dispose();
            this.SetUniform("tex", texture.ToSamplerValue());
        }
    }
}

{'fraction_non_alphanumeric': 0.10009487666034156, 'fraction_numerical': 0.0018975332068311196, 'mean_word_length': 2.5436974789915965, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3956929', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1094, 'n_words': 243}