private void addShaders() { _shaders.Add( ShaderFileLoader.CreateDefault(asset("shaders/")).Load(".") ); new[] { "uvcolor", "photon" }.ForEach(name => _shaders.MakeShaderProgram(name)); }
protected override void Initialize() { ShaderManager.Add("VS_2D", Resources.GetShader("VS", "VS", "UI2D.fx")).SetInputLayout(Vertex2D.Elements); ShaderManager.Add("PS_2D", Resources.GetShader("PS", "PS", "UI2D.fx")); FontManager.Add("small", Resources.GetFont("Fonts/small")); FontManager.Add("default", Resources.GetFont("Fonts/default")); ScreenshotManager.Initialize(); QuadRenderer.Initialize(); InputManager.Initialize(); WebWindow.Initialize(); DebugPerfMonitor.Initialize(); ScreenManager.AddScreen(new StartupScreen()); ScreenManager.GotoScreen("Startup"); Form.KeyDown += Form_KeyDown; }
public SurfaceManager() { shaders.Add( ShaderFileLoader.CreateDefault(asset("shaders/")).Load(".") ); new[] { "geometry", "uvcolor" }.ForEach(name => shaders.MakeShaderProgram(name)); ConsoleBackground = new IndexedSurface <PrimitiveVertexData>() .WithShader(shaders["geometry"]) .AndSettings(ViewMatrix, ProjectionMatrix); ConsoleFont = Font.FromJsonFile(font("inconsolata.json")); ConsoleFontSurface = new IndexedSurface <UVColorVertexData>() .WithShader(shaders["uvcolor"]) .AndSettings( ViewMatrix, ProjectionMatrix, new TextureUniform("diffuse", new Texture(font("inconsolata.png"), preMultiplyAlpha: true)) ); }
public override void Initialize() { instance = this; ShaderManager.Add("VS_Debug", Resources.GetShader("VS", "VS", "Debug.fx")).SetInputLayout(VertexColor.Elements); ShaderManager.Add("PS_Debug", Resources.GetShader("PS", "PS", "Debug.fx")); ShaderManager.Add("VS_UI3D", Resources.GetShader("VS", "VS", "UI3D.fx")).SetInputLayout(VertexTextureColor.Elements); ShaderManager.Add("PS_UI3D", Resources.GetShader("PS", "PS", "UI3D.fx")); ShaderManager.Add("VS_Model", Resources.GetShader("VS", "VS", "Model.fx")).SetInputLayout(VertexTextureColor.Elements); ShaderManager.Add("PS_Model", Resources.GetShader("PS", "PS", "Model.fx")); ShaderManager.Add("VS_Terrain", Resources.GetShader("VS", "VS", "Terrain.fx")).SetInputLayout(VertexTexture.Elements); ShaderManager.Add("PS_Terrain", Resources.GetShader("PS", "PS", "Terrain.fx")); ShaderManager.Add("VS_Water", Resources.GetShader("VS", "VS", "Water.fx")).SetInputLayout(VertexTexture.Elements); ShaderManager.Add("PS_Water", Resources.GetShader("PS", "PS", "Water.fx")); SceneManager.Initialize(); InputManager.AssignKey("up", new[] { "Z" }); InputManager.AssignKey("down", new[] { "S" }); InputManager.AssignKey("left", new[] { "Q" }); InputManager.AssignKey("right", new[] { "D" }); InputManager.AssignKey("zoom_in", new[] { "Add" }); InputManager.AssignKey("zoom_out", new[] { "Subtract" }); //--------------------------------------------------------------------------------------------------- RawMap mapFile; string mapname = "(2) Germanium Island"; mapFile = RawMap.Load(mapname); ForegroundGame.Map = new TerrainInfo(); ForegroundGame.Map.width = mapFile.Width; ForegroundGame.Map.height = mapFile.Height; ForegroundGame.Map.altitudeData = new float[mapFile.Width, mapFile.Height]; for (int y = 0; y < mapFile.Height; y++) { for (int x = 0; x < mapFile.Width; x++) { float h = mapFile.Data[x + y * mapFile.Width]; ForegroundGame.Map.altitudeData[x, y] = h; if (h > ForegroundGame.Map.maxAltitude) { ForegroundGame.Map.maxAltitude = h; } } } ForegroundGame.Map.accessibilityArray = mapFile.Accessibilty_Array; GlobalConstantVars.SunColor = mapFile.Sun_Color; GlobalConstantVars.SunDirection.X = (float)Math.Sin(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Y = (float)Math.Sin(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Z = (float)Math.Cos(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height); GlobalConstantVars.SunDirection.Normalize(); GlobalConstantVars.AmbientColor = new Vector4(mapFile.Ambient_Color, mapFile.Ambient); ForegroundGame.Map.waterColor = new Vector4(mapFile.Water_Color, mapFile.Water_Density); ForegroundGame.Map.waterLevel = mapFile.Water_Level; ForegroundGame.Map.WaterBump = Resources.GetTexture("Maps/Shared/wave"); ForegroundGame.Map.ColorMap = Resources.GetTexture("Maps/" + mapname + "/_colorMap.png", false); ForegroundGame.Map.TextureMap = Resources.GetTexture("Maps/" + mapname + "/_textureMap.png", false); ForegroundGame.Map.Shore = RageEngine.ContentPipeline.Resources.GetTexture("Maps/Shared/shore.jpg"); ForegroundGame.Map.Clouds = RageEngine.ContentPipeline.Resources.GetTexture("Maps/Shared/clouds.jpg"); string[] texturesWithNormal = new string[mapFile.Textures.Length * 2]; for (uint i = 0; i < mapFile.Textures.Length; i++) { texturesWithNormal[i * 2] = "Maps/Shared/" + mapFile.Textures[i]; texturesWithNormal[i * 2 + 1] = "Maps/Shared/" + mapFile.Textures[i] + "_bump"; } ForegroundGame.Map.TextureArray = Resources.GetTextureArray(texturesWithNormal); ForegroundGame.Map.Load(); var Map_Dimensions = new Point3D(ForegroundGame.Map.width, 1000, ForegroundGame.Map.height); var Map_Division = new Point3D(100, 1, 100); BackgroundGame.IntObjsLQDB = new LocalityQueryProximityDatabase <InteractiveObject>(Map_Dimensions, Map_Division); BackgroundGame.MapSpace = new MapSpace(ForegroundGame.Map); terrain = new Terrain(ForegroundGame.Map); SceneManager.Add(terrain); ForegroundGame.TerrainDebug = new TerrainDebug(ForegroundGame.Map); SceneManager.Add(ForegroundGame.TerrainDebug); SceneManager.Add(new TerrainWater(ForegroundGame.Map)); //-------------------------------------------------------------------------------------------------- ForegroundGame.startegicIcons = Resources.GetTexture("Textures/startegicIcon.png", false); ForegroundGame.selectionBrackets = Resources.GetTexture("Textures/selectionBrackets.png", false); ForegroundGame.unitPlaceholder = Resources.GetTexture("Textures/unitplaceholder.png", false); camera = new TopDownCamera(); SceneManager.Camera = camera; uitest = new WebWindow(200, Display.Height, "UI/InGame/index.html"); uitest.position.X = Display.Width - 200; uitest.Bind("GlobalBuildClick", _globalBuildClick); uitest.Bind("BuildClick", _globalBuildClick); InputManager.MouseDown += new Action <MouseInputEventArgs>(Input_MouseDown); InputManager.MouseUp += new Action <MouseInputEventArgs>(Input_MouseUp); InputManager.MouseMove += new Action <MouseInputEventArgs>(Input_MouseMove); InputManager.Wheel += new Action <MouseInputEventArgs>(Input_Wheel); ForegroundGame.IntObjsManager = new InteractiveObject2DManager(); SceneManager.Add(ForegroundGame.IntObjsManager); BlueprintIntObject.Initialize(); //BlueprintProjectile.Initialize("Scripts/Projectiles/"); int column = 0, line = 0; for (int i = 0; i < 200; i++) { if (line > 17) { column++; line = 0; } InteractiveObject obj = BackgroundGame.Scripts_IObjects.Make <InteractiveObject>("Engy", new Type[2] { typeof(InteractiveObject), typeof(BlueprintIntObject) }, null, BlueprintIntObject.Find("Engy")); //new Engy(null,BlueprintIntObject.list); obj.Init(0, new FVector2((fint)(150 + column * 2), (fint)(100 + line * 2)), 0); BackgroundGame.IntObjs.Add(obj); line++; } camera.ZoomLevel = 50; camera.Position = new Vector2(170, 120); Task.Factory.StartNew(UpdateThread, TaskCreationOptions.LongRunning); ForegroundGame.timer.Start(); }
protected override void WinInitialize() { instance = this; form = (MainWindow)Main.Form; loading = true; if (Display.device.IsDisposed) { return; } //Display.device.SetRenderState(RenderState.FillMode,FillMode.Wireframe); ShaderManager.Add("VS_2D", Resources.GetShader("VS", "VS", "UI2D.fx")).SetInputLayout(Vertex2D.Elements); ShaderManager.Add("PS_2D", Resources.GetShader("PS", "PS", "UI2D.fx")); ShaderManager.Add("VS_Debug", Resources.GetShader("VS", "VS", "Debug.fx")).SetInputLayout(VertexColor.Elements); ShaderManager.Add("PS_Debug", Resources.GetShader("PS", "PS", "Debug.fx")); ShaderManager.Add("VS_Terrain", Resources.GetShader("VS", "VS", "TerrainDebug.fx")).SetInputLayout(TerrainTriangle.Elements); ShaderManager.Add("PS_Terrain", Resources.GetShader("PS", "PS", "TerrainDebug.fx")); ShaderManager.Add("VS_Water", Resources.GetShader("VS", "VS", "Water.fx")).SetInputLayout(VertexTexture.Elements); ShaderManager.Add("PS_Water", Resources.GetShader("PS", "PS", "Water.fx")); FontManager.Add("default", Resources.GetFont("Fonts/default")); SceneManager.Initialize(); QuadRenderer.Initialize(); /*------------------------------------------------------------------------------------------*/ Texture2DDescription desc = new Texture2DDescription() { ArraySize = 1, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Format = Format.R8G8B8A8_UNorm, Width = 512, Height = 512, MipLevels = 1, OptionFlags = ResourceOptionFlags.None, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, }; brushTexture = new Texture2D(Display.device, desc); brushRenderTarget = new RenderTargetView(Display.device, brushTexture); Texture2DDescription descReadable = desc; descReadable.BindFlags = BindFlags.None; descReadable.CpuAccessFlags = CpuAccessFlags.Read; descReadable.Usage = ResourceUsage.Staging; brushTextureReadable = new Texture2D(Display.device, descReadable); defaultBrushShape = Resources.GetTexture("blob.png", false); DefaultBrush = defaultBrushShape; CurrentBrush = new Texture(DefaultBrush.Tex); CurrentBrushColor = new Color4(1, 0, 0, 0); camera = new EditorCamera(); SceneManager.Camera = camera; LoadMap(MainWindow.mapFile); firstRun = false; loading = false; return; }