public void Init(Client tclient, ClientCVar cvar) { if (Context != null) { Context.Dispose(); } TheClient = tclient; CVars = cvar; Context = new AudioContext(AudioContext.DefaultDevice, 0, 0, false, true); Context.MakeCurrent(); try { if (Microphone != null) { Microphone.StopEcho(); } Microphone = new MicrophoneHandler(this); } catch (Exception ex) { SysConsole.Output("Loading microphone handling", ex); } if (Effects != null) { foreach (SoundEffect sfx in Effects.Values) { sfx.Internal = -2; } } Effects = new Dictionary <string, SoundEffect>(); PlayingNow = new List <ActiveSound>(); Noise = LoadSound(new DataStream(Convert.FromBase64String(NoiseDefault.NoiseB64)), "noise"); }
/// <summary> /// Starts up the client. /// </summary> public static void Init() { SysConsole.Output(OutputType.INIT, "Loading client..."); Username = Program.GetSetting("username"); SysConsole.Output(OutputType.INFO, "Username: "******"Invalid username!"); Process.GetCurrentProcess().Kill(); } SysConsole.Output(OutputType.INIT, "Loading command engine (Frenetic)..."); ClientOutputter output = new ClientOutputter(); ClientCommands.Init(output); ClientCVar.Init(output); SysConsole.Output(OutputType.INIT, "Loading window..."); Window = new GameWindow(800, 600, new GraphicsMode(32, 24, 0 /* TODO: Are these values good? */, ClientCVar.r_antialiasing.ValueI), Program.GameName, GameWindowFlags.FixedWindow); Window.UpdateFrame += new EventHandler <FrameEventArgs>(Window_UpdateFrame); Window.RenderFrame += new EventHandler <FrameEventArgs>(Window_RenderFrame); Window.Closed += new EventHandler <EventArgs>(Window_Closed); Window.Load += new EventHandler <EventArgs>(Window_Load); Window.KeyPress += new EventHandler <KeyPressEventArgs>(KeyHandler.PrimaryGameWindow_KeyPress); Window.KeyUp += new EventHandler <KeyboardKeyEventArgs>(KeyHandler.PrimaryGameWindow_KeyUp); Window.KeyDown += new EventHandler <KeyboardKeyEventArgs>(KeyHandler.PrimaryGameWindow_KeyDown); Window.MouseDown += new EventHandler <MouseButtonEventArgs>(KeyHandler.Mouse_ButtonDown); Window.MouseUp += new EventHandler <MouseButtonEventArgs>(KeyHandler.Mouse_ButtonUp); Window.MouseWheel += new EventHandler <MouseWheelEventArgs>(KeyHandler.Mouse_Wheel); SysConsole.Output(OutputType.INIT, "Running window startup sequence..."); Window.Run(60, 60); }
/// <summary> /// Start up and run the server. /// </summary> public void StartUp(string args) { Files.Init(); SysConsole.Output(OutputType.CLIENTINIT, "Launching as new client, this is " + (this == Central ? "" : "NOT ") + "the Central client."); SysConsole.Output(OutputType.CLIENTINIT, "Loading command system..."); Commands = new ClientCommands(); Commands.Init(new ClientOutputter(this), this); SysConsole.Output(OutputType.CLIENTINIT, "Loading CVar system..."); CVars = new ClientCVar(); CVars.Init(this, Commands.Output); SysConsole.Output(OutputType.CLIENTINIT, "Loading default settings..."); if (Files.Exists("clientdefaultsettings.cfg")) { string contents = Files.ReadText("clientdefaultsettings.cfg"); Commands.ExecuteCommands(contents); } Commands.ExecuteCommands(args); SysConsole.Output(OutputType.CLIENTINIT, "Generating window..."); DisplayDevice dd = DisplayDevice.Default; Window = new GameWindow(CVars.r_width.ValueI, CVars.r_height.ValueI, new GraphicsMode(24, 24, 0, 0), Program.GameName + " v" + Program.GameVersion + " (" + Program.GameVersionDescription + ")", GameWindowFlags.Default, dd, 4, 3, GraphicsContextFlags.ForwardCompatible); Window.Load += new EventHandler <EventArgs>(Window_Load); Window.RenderFrame += new EventHandler <FrameEventArgs>(Window_RenderFrame); Window.Mouse.Move += new EventHandler <MouseMoveEventArgs>(MouseHandler.Window_MouseMove); Window.KeyDown += new EventHandler <KeyboardKeyEventArgs>(KeyHandler.PrimaryGameWindow_KeyDown); Window.KeyPress += new EventHandler <KeyPressEventArgs>(KeyHandler.PrimaryGameWindow_KeyPress); Window.KeyUp += new EventHandler <KeyboardKeyEventArgs>(KeyHandler.PrimaryGameWindow_KeyUp); Window.Mouse.WheelChanged += new EventHandler <MouseWheelEventArgs>(KeyHandler.Mouse_Wheel); Window.Mouse.ButtonDown += new EventHandler <MouseButtonEventArgs>(KeyHandler.Mouse_ButtonDown); Window.Mouse.ButtonUp += new EventHandler <MouseButtonEventArgs>(KeyHandler.Mouse_ButtonUp); Window.Location = new Point(0, 0); Window.WindowState = CVars.r_fullscreen.ValueB ? WindowState.Fullscreen : WindowState.Normal; Window.Resize += Window_Resize; Window.Closed += Window_Closed; Window.ReduceCPUWaste = true; OnVsyncChanged(CVars.r_vsync, null); if (CVars.r_maxfps.ValueD < 1.0) { CVars.r_maxfps.Set("60"); } if (CVars.r_maxfps.ValueD > 200.0) { Window.Run(1); } else { Window.Run(1, CVars.r_maxfps.ValueD); } }
public void Init(Client tclient, ClientCVar cvar) { if (AudioInternal != null) { AudioInternal.Shutdown(); } if (Context != null) { Context.Dispose(); } TheClient = tclient; CVars = cvar; Context = new AudioContext(AudioContext.DefaultDevice, 0, 0, false, true); if (TheClient.CVars.a_enforce.ValueB) { AudioInternal = new AudioEnforcer(); AudioInternal.Init(Context); Context = null; } else { Context.MakeCurrent(); } try { if (Microphone != null) { Microphone.StopEcho(); } Microphone = new MicrophoneHandler(this); } catch (Exception ex) { SysConsole.Output("Loading microphone handling", ex); } if (Effects != null) { foreach (SoundEffect sfx in Effects.Values) { sfx.Internal = -2; } } Effects = new Dictionary <string, SoundEffect>(); PlayingNow = new List <ActiveSound>(); DeafLoop = GetSound("sfx/ringing/earring_loop"); }
public void Generate(Client tclient, ClientCVar cvars, TextureEngine eng, bool delayable) { TheClient = tclient; if (TextureID > -1) { GL.DeleteTexture(TextureID); GL.DeleteTexture(NormalTextureID); GL.DeleteTexture(HelpTextureID); } List <MaterialTextureInfo> texs = new List <MaterialTextureInfo>(MaterialHelpers.Textures.Length); TexList = texs; int extras = 0; for (int i = 0; i < MaterialHelpers.Textures.Length; i++) { string[] basic = MaterialHelpers.Textures[i].SplitFast('@')[0].SplitFast('$')[0].SplitFast('%')[0].SplitFast(','); texs.Add(new MaterialTextureInfo() { Mat = i, ResultantID = extras }); extras += basic.Length; } TEngine = eng; TextureID = GL.GenTexture(); TWidth = cvars.r_blocktexturewidth.ValueI; HelpTWMin = TEX_REQUIRED_BITS / (TWidth * TWidth); GL.BindTexture(TextureTarget.Texture2DArray, TextureID); int levels = TheClient.CVars.r_block_mipmaps.ValueB ? (TWidth == 256 ? 6 : 4) : 1; // TODO: 6/4 -> Setting GL.TexStorage3D(TextureTarget3d.Texture2DArray, levels, SizedInternalFormat.Rgba8, TWidth, TWidth, extras); GL.GenerateMipmap(GenerateMipmapTarget.Texture2DArray); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)(cvars.r_blocktexturelinear.ValueB ? TextureMinFilter.LinearMipmapLinear : TextureMinFilter.Nearest)); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)(cvars.r_blocktexturelinear.ValueB ? TextureMagFilter.Linear : TextureMagFilter.Nearest)); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); HelpTextureID = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2DArray, HelpTextureID); GL.TexStorage3D(TextureTarget3d.Texture2DArray, levels, SizedInternalFormat.Rgba8, TWidth, TWidth, extras + HelpTWMin); GL.GenerateMipmap(GenerateMipmapTarget.Texture2DArray); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); NormalTextureID = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); GL.TexStorage3D(TextureTarget3d.Texture2DArray, levels, SizedInternalFormat.Rgba8, TWidth, TWidth, extras); GL.GenerateMipmap(GenerateMipmapTarget.Texture2DArray); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); // TODO: Use normal.a! IntTexs = new string[MaterialHelpers.Textures.Length]; for (int ia = 0; ia < MaterialHelpers.Textures.Length; ia++) { int i = ia; Action a = () => { MaterialTextureInfo tex = texs[i]; int resID = tex.ResultantID; string[] refrornot = MaterialHelpers.Textures[i].SplitFast('@'); if (refrornot.Length > 1) { string[] rorn = refrornot[1].SplitFast('%'); if (rorn.Length > 1) { tex.RefrRate = Utilities.StringToFloat(rorn[1]); } tex.RefractTextures = rorn[0].SplitFast(','); } string[] glowornot = refrornot[0].SplitFast('!'); if (glowornot.Length > 1) { tex.GlowingTextures = glowornot[1].SplitFast(','); } string[] reflornot = glowornot[0].SplitFast('*'); if (reflornot.Length > 1) { tex.ReflectTextures = reflornot[1].SplitFast(','); } string[] specularornot = reflornot[0].SplitFast('&'); if (specularornot.Length > 1) { tex.SpecularTextures = specularornot[1].SplitFast(','); } string[] normalornot = specularornot[0].SplitFast('$'); GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); if (normalornot.Length > 1) { string[] rorn = normalornot[1].SplitFast('%'); if (rorn.Length > 1) { tex.NormRate = Utilities.StringToFloat(rorn[1]); } tex.NormalTextures = rorn[0].SplitFast(','); if (tex.NormalTextures.Length > 1) { SetAnimated((int)resID, tex.NormRate, tex.NormalTextures, NormalTextureID, -1); } } else { SetTexture((int)resID, "normal_def", -1); } string[] rateornot = normalornot[0].SplitFast('%'); if (rateornot.Length > 1) { tex.Rate = Utilities.StringToFloat(rateornot[1]); } tex.Textures = rateornot[0].SplitFast(','); GL.BindTexture(TextureTarget.Texture2DArray, TextureID); if (tex.Textures.Length > 1) { SetAnimated((int)resID, tex.Rate, tex.Textures, TextureID, resID); if (tex.NormalTextures == null) { GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); tex.NormalTextures = new string[tex.Textures.Length]; tex.NormRate = tex.Rate; for (int fz = 0; fz < tex.NormalTextures.Length; fz++) { tex.NormalTextures[fz] = "normal_def"; } SetAnimated((int)resID, tex.Rate, tex.NormalTextures, NormalTextureID, -1); } } else { SetTexture((int)resID, tex.Textures[0], resID); if (tex.NormalTextures == null) { tex.NormalTextures = new string[] { "normal_def" }; } } if (tex.ReflectTextures == null) { tex.ReflectTextures = new string[tex.Textures.Length]; for (int fz = 0; fz < tex.ReflectTextures.Length; fz++) { tex.ReflectTextures[fz] = "black"; } tex.RefractTextures = tex.ReflectTextures; tex.GlowingTextures = tex.ReflectTextures; tex.SpecularTextures = tex.ReflectTextures; } if (tex.NormRate != tex.Rate || tex.RefrRate != tex.Rate) { SysConsole.Output(OutputType.WARNING, "Rates wrong for " + MaterialHelpers.Textures[i]); tex.NormRate = tex.Rate; tex.RefrRate = tex.Rate; } if (tex.Textures.Length != tex.NormalTextures.Length || tex.ReflectTextures.Length != tex.Textures.Length) { SysConsole.Output(OutputType.WARNING, "Texture counts wrong for " + MaterialHelpers.Textures[i]); } IntTexs[(int)tex.Mat] = tex.Textures[0]; if (!delayable) { TheClient.PassLoadScreen(); } }; if (delayable) { TheClient.Schedule.ScheduleSyncTask(a, i * LoadRate); } else { a(); } } double time = (MaterialHelpers.Textures.Length + 1) * LoadRate; for (int ia = 0; ia < texs.Count; ia++) { int i = ia; Action a = () => { GL.BindTexture(TextureTarget.Texture2DArray, HelpTextureID); Bitmap combo = GetCombo(texs[i], 0); if ((texs[i].SpecularTextures != null) && (texs[i].ReflectTextures != null) && (texs[i].RefractTextures != null) && (texs[i].GlowingTextures != null) && texs[i].SpecularTextures.Length > 1) { Bitmap[] bmps = new Bitmap[texs[i].SpecularTextures.Length]; bmps[0] = combo; for (int x = 1; x < bmps.Length; x++) { bmps[x] = GetCombo(texs[i], x); } SetAnimated((int)texs[i].ResultantID + HelpTWMin, texs[i].RefrRate, bmps, HelpTextureID); for (int x = 1; x < bmps.Length; x++) { bmps[x].Dispose(); } } else { TEngine.LockBitmapToTexture(combo, (int)texs[i].ResultantID + HelpTWMin); } combo.Dispose(); if (!delayable) { TheClient.PassLoadScreen(); } }; if (delayable) { TheClient.Schedule.ScheduleSyncTask(a, time + i * LoadRate); } else { a(); } } if (TheClient.CVars.r_block_mipmaps.ValueB) { Action mipmap = () => { GL.BindTexture(TextureTarget.Texture2DArray, TextureID); GL.GenerateMipmap(GenerateMipmapTarget.Texture2DArray); GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); GL.GenerateMipmap(GenerateMipmapTarget.Texture2DArray); GL.BindTexture(TextureTarget.Texture2DArray, HelpTextureID); GL.GenerateMipmap(GenerateMipmapTarget.Texture2DArray); GraphicsUtil.CheckError("Mipmapping"); }; if (delayable) { TheClient.Schedule.ScheduleSyncTask(mipmap, time * 2); } else { mipmap(); } } GL.BindTexture(TextureTarget.Texture2DArray, 0); }
public void Generate(Client tclient, ClientCVar cvars, TextureEngine eng, bool delayable) { TheClient = tclient; if (Anims != null) { for (int i = 0; i < Anims.Count; i++) { Anims[i].Destroy(); } } if (TextureID > -1) { GL.DeleteTexture(TextureID); GL.DeleteTexture(NormalTextureID); GL.DeleteTexture(HelpTextureID); } Anims = new List <AnimatedTexture>(); TEngine = eng; TextureID = GL.GenTexture(); TWidth = cvars.r_blocktexturewidth.ValueI; GL.BindTexture(TextureTarget.Texture2DArray, TextureID); int levels = TheClient.CVars.r_block_mipmaps.ValueB ? 4 : 1; GL.TexStorage3D(TextureTarget3d.Texture2DArray, levels, SizedInternalFormat.Rgba8, TWidth, TWidth, MaterialHelpers.Textures.Length); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)(cvars.r_blocktexturelinear.ValueB ? TextureMinFilter.Linear: TextureMinFilter.Nearest)); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)(cvars.r_blocktexturelinear.ValueB ? TextureMagFilter.Linear : TextureMagFilter.Nearest)); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); HelpTextureID = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2DArray, HelpTextureID); GL.TexStorage3D(TextureTarget3d.Texture2DArray, 1, SizedInternalFormat.Rgba8, TWidth, TWidth, MaterialHelpers.Textures.Length); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); NormalTextureID = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); GL.TexStorage3D(TextureTarget3d.Texture2DArray, 1, SizedInternalFormat.Rgba8, TWidth, TWidth, MaterialHelpers.Textures.Length); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); // TODO: Use normal.a! List <MaterialTextureInfo> texs = new List <MaterialTextureInfo>(MaterialHelpers.Textures.Length); IntTexs = new string[MaterialHelpers.Textures.Length]; for (int ia = 0; ia < MaterialHelpers.Textures.Length; ia++) { int i = ia; Action a = () => { MaterialTextureInfo tex = new MaterialTextureInfo() { Mat = (Material)i }; string[] refrornot = MaterialHelpers.Textures[i].SplitFast('@'); if (refrornot.Length > 1) { string[] rorn = refrornot[1].SplitFast('%'); if (rorn.Length > 1) { tex.RefrRate = Utilities.StringToFloat(rorn[1]); } tex.RefractTextures = rorn[0].SplitFast(','); } string[] glowornot = refrornot[0].SplitFast('!'); if (glowornot.Length > 1) { tex.GlowingTextures = glowornot[1].SplitFast(','); } string[] reflornot = glowornot[0].SplitFast('*'); if (reflornot.Length > 1) { tex.ReflectTextures = reflornot[1].SplitFast(','); } string[] specularornot = reflornot[0].SplitFast('&'); if (specularornot.Length > 1) { tex.SpecularTextures = specularornot[1].SplitFast(','); } string[] normalornot = specularornot[0].SplitFast('$'); GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); if (normalornot.Length > 1) { string[] rorn = normalornot[1].SplitFast('%'); if (rorn.Length > 1) { tex.NormRate = Utilities.StringToFloat(rorn[1]); } tex.NormalTextures = rorn[0].SplitFast(','); SetTexture((int)tex.Mat, tex.NormalTextures[0]); if (tex.NormalTextures.Length > 1) { SetAnimated((int)tex.Mat, tex.NormRate, tex.NormalTextures, NormalTextureID); } } else { SetTexture((int)tex.Mat, "normal_def"); } string[] rateornot = normalornot[0].SplitFast('%'); if (rateornot.Length > 1) { tex.Rate = Utilities.StringToFloat(rateornot[1]); } tex.Textures = rateornot[0].SplitFast(','); GL.BindTexture(TextureTarget.Texture2DArray, TextureID); SetTexture((int)tex.Mat, tex.Textures[0]); if (tex.Textures.Length > 1) { SetAnimated((int)tex.Mat, tex.Rate, tex.Textures, TextureID); } texs.Add(tex); IntTexs[(int)tex.Mat] = tex.Textures[0]; if (!delayable) { TheClient.PassLoadScreen(); } }; if (delayable) { TheClient.Schedule.ScheduleSyncTask(a, i * LoadRate); } else { a(); } } double time = (MaterialHelpers.Textures.Length + 1) * LoadRate; if (TheClient.CVars.r_block_mipmaps.ValueB) { Action mipmap = () => { GL.BindTexture(TextureTarget.Texture2DArray, TextureID); GL.GenerateMipmap(GenerateMipmapTarget.Texture2DArray); View3D.CheckError("Mipmapping"); }; if (delayable) { TheClient.Schedule.ScheduleSyncTask(mipmap, time); } else { mipmap(); } } for (int ia = 0; ia < texs.Count; ia++) { int i = ia; Action a = () => { GL.BindTexture(TextureTarget.Texture2DArray, HelpTextureID); Bitmap combo = GetCombo(texs[i], 0); TEngine.LockBitmapToTexture(combo, (int)texs[i].Mat); if ((texs[i].SpecularTextures != null) && (texs[i].ReflectTextures != null) && (texs[i].RefractTextures != null) && (texs[i].GlowingTextures != null) && texs[i].SpecularTextures.Length > 1) { Bitmap[] bmps = new Bitmap[texs[i].SpecularTextures.Length]; bmps[0] = combo; for (int x = 1; x < bmps.Length; x++) { bmps[x] = GetCombo(texs[i], x); } SetAnimated((int)texs[i].Mat, texs[i].RefrRate, bmps, HelpTextureID); for (int x = 1; x < bmps.Length; x++) { bmps[x].Dispose(); } } combo.Dispose(); if (!delayable) { TheClient.PassLoadScreen(); } }; if (delayable) { TheClient.Schedule.ScheduleSyncTask(a, time + i * LoadRate); } else { a(); } } GL.BindTexture(TextureTarget.Texture2DArray, 0); GL.BindTexture(TextureTarget.Texture2DArray, 0); }
public void Generate(Client tclient, ClientCVar cvars, TextureEngine eng) { TheClient = tclient; if (Anims != null) { for (int i = 0; i < Anims.Count; i++) { Anims[i].Destroy(); } } if (TextureID > -1) { GL.DeleteTexture(TextureID); GL.DeleteTexture(NormalTextureID); GL.DeleteTexture(HelpTextureID); } Anims = new List <AnimatedTexture>(); TEngine = eng; TextureID = GL.GenTexture(); TWidth = cvars.r_blocktexturewidth.ValueI; GL.BindTexture(TextureTarget.Texture2DArray, TextureID); GL.TexStorage3D(TextureTarget3d.Texture2DArray, 1, SizedInternalFormat.Rgba8, TWidth, TWidth, MaterialHelpers.Textures.Length); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)(cvars.r_blocktexturelinear.ValueB ? TextureMinFilter.Linear: TextureMinFilter.Nearest)); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)(cvars.r_blocktexturelinear.ValueB ? TextureMagFilter.Linear : TextureMagFilter.Nearest)); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); HelpTextureID = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2DArray, HelpTextureID); GL.TexStorage3D(TextureTarget3d.Texture2DArray, 1, SizedInternalFormat.Rgba8, TWidth, TWidth, MaterialHelpers.Textures.Length); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); NormalTextureID = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); GL.TexStorage3D(TextureTarget3d.Texture2DArray, 1, SizedInternalFormat.Rgba8, TWidth, TWidth, MaterialHelpers.Textures.Length); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge); // TODO: Use normal.a! List <MaterialTextureInfo> texs = new List <MaterialTextureInfo>(MaterialHelpers.Textures.Length); IntTexs = new string[MaterialHelpers.Textures.Length]; //float time = 0; for (int ia = 0; ia < MaterialHelpers.Textures.Length; ia++) { int i = ia; // TODO: Make this saner, and don't allow entering a game until it's done maybe? //TheClient.Schedule.ScheduleSyncTask(() => { MaterialTextureInfo tex = new MaterialTextureInfo(); tex.Mat = (Material)i; string[] refrornot = MaterialHelpers.Textures[i].SplitFast('@'); if (refrornot.Length > 1) { string[] rorn = refrornot[1].SplitFast('%'); if (rorn.Length > 1) { tex.RefrRate = Utilities.StringToFloat(rorn[1]); } tex.RefractTextures = rorn[0].SplitFast(','); } string[] glowornot = refrornot[0].SplitFast('!'); if (glowornot.Length > 1) { tex.GlowingTextures = glowornot[1].SplitFast(','); } string[] reflornot = glowornot[0].SplitFast('*'); if (reflornot.Length > 1) { tex.ReflectTextures = reflornot[1].SplitFast(','); } string[] specularornot = reflornot[0].SplitFast('&'); if (specularornot.Length > 1) { tex.SpecularTextures = specularornot[1].SplitFast(','); } string[] normalornot = specularornot[0].SplitFast('$'); GL.BindTexture(TextureTarget.Texture2DArray, NormalTextureID); if (normalornot.Length > 1) { string[] rorn = normalornot[1].SplitFast('%'); if (rorn.Length > 1) { tex.NormRate = Utilities.StringToFloat(rorn[1]); } tex.NormalTextures = rorn[0].SplitFast(','); SetTexture((int)tex.Mat, tex.NormalTextures[0]); if (tex.NormalTextures.Length > 1) { SetAnimated((int)tex.Mat, tex.NormRate, tex.NormalTextures, NormalTextureID); } } else { SetTexture((int)tex.Mat, "normal_def"); } string[] rateornot = normalornot[0].SplitFast('%'); if (rateornot.Length > 1) { tex.Rate = Utilities.StringToFloat(rateornot[1]); } tex.Textures = rateornot[0].SplitFast(','); GL.BindTexture(TextureTarget.Texture2DArray, TextureID); SetTexture((int)tex.Mat, tex.Textures[0]); if (tex.Textures.Length > 1) { SetAnimated((int)tex.Mat, tex.Rate, tex.Textures, TextureID); } texs.Add(tex); IntTexs[(int)tex.Mat] = tex.Textures[0]; }//, i * LoadRate); //time = i * 0.1f; } for (int ia = 0; ia < texs.Count; ia++) { int i = ia; //TheClient.Schedule.ScheduleSyncTask(() => { GL.BindTexture(TextureTarget.Texture2DArray, HelpTextureID); Bitmap combo = GetCombo(texs[i], 0); TEngine.LockBitmapToTexture(combo, (int)texs[i].Mat); if ((texs[i].SpecularTextures != null) && (texs[i].ReflectTextures != null) && (texs[i].RefractTextures != null) && (texs[i].GlowingTextures != null) && texs[i].SpecularTextures.Length > 1) { Bitmap[] bmps = new Bitmap[texs[i].SpecularTextures.Length]; bmps[0] = combo; for (int x = 1; x < bmps.Length; x++) { bmps[x] = GetCombo(texs[i], x); } SetAnimated((int)texs[i].Mat, texs[i].RefrRate, bmps, HelpTextureID); for (int x = 1; x < bmps.Length; x++) { bmps[x].Dispose(); } } combo.Dispose(); }//, time + i * LoadRate); } GL.BindTexture(TextureTarget.Texture2DArray, 0); GL.BindTexture(TextureTarget.Texture2DArray, 0); }