Пример #1
0
        public static TextureEntry Load(string fileName)
        {
            Texture2d tex;

            try {
                tex = Texture2d.Load(fileName);
            } catch (Exception ex) {
                Console.WriteLine("Error while creating Texture2d: {0}", ex.Message);

                return(null);
            }

            return(new TextureEntry(tex, fileName));
        }
Пример #2
0
        public MainWindow()
        {
            string devTexturesDir = @"..\..\Textures";

            if (IO.Directory.Exists("Textures"))
            {
                texturesDir = "Textures";
            }
            else if (IO.Directory.Exists(devTexturesDir))
            {
                texturesDir = devTexturesDir;
            }
            else
            {
                IO.Directory.CreateDirectory("Textures");
                texturesDir = "Textures";
            }

            Textures = new ObservableCollection <TextureEntry> ();
            LoadTextures();
            fsWatcher                     = new IO.FileSystemWatcher(texturesDir);
            fsWatcher.Created            += new IO.FileSystemEventHandler(fsWatcher_Created);
            fsWatcher.EnableRaisingEvents = true;

            Map2d map = Texture2d.Load(IO.Path.Combine(texturesDir, "checker_small.bmp"));

            //Map2d map = Texture2d.Load ( IO.Path.Combine ( texturesDir, "checker_small_2x2.bmp" ) );
            //Map2d map = Texture2d.Load ( IO.Path.Combine ( texturesDir, "checker.jpg" );
            //Map2d map = Texture2d.Load ( @"D:\Programming\Projects\msvs\SoftwareRendering\TextureFilteringDev\lines.bmp" );
            //Map2d map = Texture2d.Load ( IO.Path.Combine ( texturesDir, "checker_colored.jpg" ) );
            //Map2d map = Texture2d.Load ( @"C:\media\images\Wallpaper\Текстуры\Architectual\DRTCHEK1.JPG" );
            //Map2d map = Texture2d.Load ( @"C:\media\images\keira knightley\marso-uwi_bI.jpg" );
            //Map2d map = Texture2d.Load ( @"C:\media\images\my renders\my first raytracer\refraction_fixed_water_1.342.bmp" );
            //Map2d map = Texture2d.Load ( IO.Path.Combine ( texturesDir, "alena_zayac.jpg" ) );
            sampler = new Sampler2d(map, TextureWrap.Clamp, FilteringType.Nearest);

            InitializeComponent();

            mouseXRatio = 360.0 / System.Windows.SystemParameters.PrimaryScreenWidth;
            mouseYRatio = 360.0 / System.Windows.SystemParameters.PrimaryScreenHeight;

            figureTriStrip = GenQuadUsingTriangleStrip();
            GenCubeUsingIndices(out figureVertices, out figureIndices, out figureTexCoords);

            resizeTimer.Interval = TimeSpan.FromSeconds(0.5);
            resizeTimer.Tick    += new EventHandler(resizeTimer_Tick);
        }
Пример #3
0
 public Texture2d CreateTexture(string text, string fontName, float fontSize, Vector2 maxSize, Vector2 padding, BoxAlignment alignment, StringTrimming trimming, out Vector2 textureSize)
 {
     using (var bitmap = CreateBitmap(text, fontName, fontSize, maxSize, padding, alignment, trimming, out textureSize, false))
         return(Texture2d.Load(bitmap, $"text:{text}@{fontName}:{fontSize}"));
 }