public void Render(double delta) { if (game.Graphics.LostContext) { return; } IGraphicsApi gfx = game.Graphics; #if !USE_DX && !ANDROID gfx.AlphaBlending = true; //gfx.DepthWrite = false; gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos2.Z), new Vector3(pos1.X, pos2.Y, pos2.Z)); gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos2.Z), new Vector3(pos1.X, pos2.Y, pos1.Z)); gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos1.Z), new Vector3(pos2.X, pos2.Y, pos1.Z)); gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos1.Z), new Vector3(pos2.X, pos2.Y, pos2.Z)); gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos2.Z), new Vector3(pos2.X, pos1.Y, pos2.Z)); gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos2.Z), new Vector3(pos1.X, pos1.Y, pos2.Z)); gfx.DrawLine(new Vector3(pos1.X, pos2.Y, pos1.Z), new Vector3(pos1.X, pos1.Y, pos1.Z)); gfx.DrawLine(new Vector3(pos2.X, pos2.Y, pos1.Z), new Vector3(pos2.X, pos1.Y, pos1.Z)); gfx.DrawLine(new Vector3(pos2.X, pos1.Y, pos2.Z), new Vector3(pos1.X, pos1.Y, pos2.Z)); gfx.DrawLine(new Vector3(pos1.X, pos1.Y, pos2.Z), new Vector3(pos1.X, pos1.Y, pos1.Z)); gfx.DrawLine(new Vector3(pos1.X, pos1.Y, pos1.Z), new Vector3(pos2.X, pos1.Y, pos1.Z)); gfx.DrawLine(new Vector3(pos2.X, pos1.Y, pos1.Z), new Vector3(pos2.X, pos1.Y, pos2.Z)); //gfx.DepthWrite = true; gfx.AlphaBlending = false; #else gfx.AlphaBlending = true; gfx.DepthWrite = false; gfx.SetBatchFormat(VertexFormat.P3fC4b); gfx.UpdateDynamicVb_IndexedTris(vb, vertices, index); gfx.DepthWrite = true; gfx.AlphaBlending = false; #endif if (pickingBlock) { //gfx.AlphaTest = true; gfx.Texturing = true; //gfx.AlphaTest = true; gfx.AlphaBlending = true; gfx.FaceCulling = true; float[] texCols = new float[4]; texCols[0] = (127f / 256f); texCols[1] = (127f / 256f); texCols[2] = (127f / 256f); texCols[3] = (128f / 256f); /*GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Combine); * //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.CombineRgb, (int)TextureEnvModeCombine.Subtract); * GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.CombineAlpha, (int)TextureEnvModeCombine.Subtract); * GL.TexEnvfv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvColor, texCols); * //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Source0Rgb, (int)TextureEnvModeSource.Texture); * GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Src0Alpha, (int)TextureEnvModeSource.PrimaryColor); * //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Src1Rgb, (int)TextureEnvModeSource.Constant); * GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.Src1Alpha, (int)TextureEnvModeSource.Constant);*/ //GL.Enable(EnableCap.ColorMaterial); //graphics.AlphaTestFunc(CompareFunc.Greater, 0.0f); //GL.BlendFuncSeparate(BlendingFactor.DstColor, BlendingFactor.SrcColor, BlendingFactor.DstAlpha, BlendingFactor.DstAlpha); graphics.RGBAlphaBlendFunc(BlendFunc.DestColor, BlendFunc.SourceColor, BlendFunc.DestAlpha, BlendFunc.SourceAlpha); //VertexP3fT2fC4b[] vertices2 = new VertexP3fT2fC4b[8 * 10 * (4 * 4)]; //game.Graphics.CreateDynamicVb(VertexFormat.P3fT2fC4b, vertices.Length); gfx.BindTexture(pickTexId); gfx.SetBatchFormat(VertexFormat.P3fT2fC4b); gfx.BindVb(vb2); gfx.UpdateDynamicVb_IndexedTris(vb2, vertices2, index2); //graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha); graphics.AlphaBlendFunc(BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha); //graphics.AlphaTestFunc(CompareFunc.Greater, 0.5f); //GL.Disable(EnableCap.ColorMaterial); //GL.TexEnvi(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate); gfx.FaceCulling = false; gfx.AlphaBlending = false; //gfx.AlphaTest = false; gfx.Texturing = false; //gfx.AlphaTest = false; } }
protected override void OnLoad( EventArgs e ) { #if !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api( this ); #endif try { Options.Load(); } catch( IOException ) { Utils.LogWarning( "Unable to load options.txt" ); } ViewDistance = Options.GetInt( "viewdist", 16, 8192, 512 ); Keys = new KeyMap(); InputHandler = new InputHandler( this ); Chat = new ChatLog( this ); Drawer2D = new GdiPlusDrawer2D( Graphics ); defaultIb = Graphics.MakeDefaultIb(); ModelCache = new ModelCache( this ); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader( skinServer ); Graphics.PrintGraphicsInfo(); TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D ); Animations = new Animations( this ); TexturePackExtractor extractor = new TexturePackExtractor(); extractor.Extract( defaultTexPack, this ); Inventory = new Inventory( this ); BlockInfo = new BlockInfo(); BlockInfo.Init(); BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete ); Map = new Map( this ); LocalPlayer = new LocalPlayer( this ); Players[255] = LocalPlayer; width = Width; height = Height; MapRenderer = new MapRenderer( this ); MapEnvRenderer = new MapEnvRenderer( this ); EnvRenderer = new StandardEnvRenderer( this ); if( IPAddress == null ) { Network = new Singleplayer.SinglePlayerServer( this ); } else { Network = new NetworkProcessor( this ); } Graphics.LostContextFunction = Network.Tick; firstPersonCam = new FirstPersonCamera( this ); thirdPersonCam = new ThirdPersonCamera( this ); Camera = firstPersonCam; CommandManager = new CommandManager(); CommandManager.Init( this ); SelectionManager = new SelectionManager( this ); ParticleManager = new ParticleManager( this ); WeatherRenderer = new WeatherRenderer( this ); WeatherRenderer.Init(); Graphics.SetVSync( this, true ); Graphics.DepthTest = true; Graphics.DepthTestFunc( CompareFunc.LessEqual ); //Graphics.DepthWrite = true; Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha ); Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f ); Title = Utils.AppName; fpsScreen = new FpsScreen( this ); fpsScreen.Init(); Culling = new FrustumCulling(); EnvRenderer.Init(); MapEnvRenderer.Init(); Picking = new PickingRenderer( this ); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) ); Network.Connect( IPAddress, Port ); }
protected override void OnLoad( EventArgs e ) { #if !USE_DX Graphics = new OpenGLApi(); #else Graphics = new Direct3D9Api( this ); #endif Graphics.MakeGraphicsInfo(); Options.Load(); ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 ); InputHandler = new InputHandler( this ); Chat = new ChatLog( this ); Chat.FontSize = Options.GetInt( OptionsKey.FontSize, 6, 30, 12 ); defaultIb = Graphics.MakeDefaultIb(); MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 ); BlockInfo = new BlockInfo(); BlockInfo.Init(); ChatLines = Options.GetInt( OptionsKey.ChatLines, 1, 30, 12 ); ModelCache = new ModelCache( this ); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader( skinServer ); Drawer2D = new GdiPlusDrawer2D( Graphics ); Drawer2D.UseBitmappedChat = !Options.GetBool( OptionsKey.ArialChatFont, false ); TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D ); Animations = new Animations( this ); TexturePackExtractor extractor = new TexturePackExtractor(); extractor.Extract( defaultTexPack, this ); Inventory = new Inventory( this ); BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete ); Map = new Map( this ); LocalPlayer = new LocalPlayer( this ); LocalPlayer.SpeedMultiplier = Options.GetInt( OptionsKey.Speed, 1, 50, 10 ); Players[255] = LocalPlayer; width = Width; height = Height; MapRenderer = new MapRenderer( this ); MapEnvRenderer = new MapEnvRenderer( this ); EnvRenderer = new StandardEnvRenderer( this ); if( IPAddress == null ) { Network = new Singleplayer.SinglePlayerServer( this ); } else { Network = new NetworkProcessor( this ); } Graphics.LostContextFunction = Network.Tick; firstPersonCam = new FirstPersonCamera( this ); thirdPersonCam = new ThirdPersonCamera( this ); forwardThirdPersonCam = new ForwardThirdPersonCamera( this ); Camera = firstPersonCam; CommandManager = new CommandManager(); CommandManager.Init( this ); SelectionManager = new SelectionManager( this ); ParticleManager = new ParticleManager( this ); WeatherRenderer = new WeatherRenderer( this ); WeatherRenderer.Init(); bool vsync = Options.GetBool( OptionsKey.VSync, true ); Graphics.SetVSync( this, vsync ); Graphics.DepthTest = true; Graphics.DepthTestFunc( CompareFunc.LessEqual ); //Graphics.DepthWrite = true; Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha ); Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f ); fpsScreen = new FpsScreen( this ); fpsScreen.Init(); Culling = new FrustumCulling(); EnvRenderer.Init(); MapEnvRenderer.Init(); Picking = new PickingRenderer( this ); string connectString = "Connecting to " + IPAddress + ":" + Port + ".."; Graphics.WarnIfNecessary( Chat ); SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) ); Network.Connect( IPAddress, Port ); }