public ModelRenderer(RenderControl control, File3di file) { _viewport = control; _file = file; _viewport.MakeCurrent(); OnLoad(EventArgs.Empty); _viewport.UpdateFrame += OnUpdateFrame; _viewport.RenderFrame += OnRenderFrame; }
private void LoadFile(PffEntry entry) { if (entry == null) { Text = FormatWindowTitle(string.Empty); //TODO: Clear preview return; } Text = FormatWindowTitle(entry.FilePath); var fileContents = entry.GetContents(); if (fileContents == null) { return; } Bitmap img; var ext = Path.GetExtension(entry.FilePath)?.Substring(1); switch (ext) { case "PCX": img = PcxConvert.LoadPcx(fileContents); ClientSize = img.Size; pictureBox.Image = img; pictureBox.Visible = true; break; case "TGA": img = TgaConvert.LoadTga(fileContents); ClientSize = img.Size; pictureBox.Image = img; pictureBox.Visible = true; break; case "JPG": img = LoadBitmap(fileContents); ClientSize = img.Size; pictureBox.Image = img; pictureBox.Visible = true; break; case "WAV": using (var stream = new MemoryStream(fileContents)) { var simpleSound = new SoundPlayer(stream); simpleSound.Play(); } break; case "3DI": var file = File3di.Open(fileContents); _renderer = new ModelRenderer(renderControl, file); renderControl.Visible = true; break; } }