Example #1
0
        public void Initialize(RenderControl window, GxContext context)
        {
            Dispatcher = Dispatcher.CurrentDispatcher;

            mContext     = context;
            RenderWindow = window;
            Surface      = new DrawSurface(context);
            Surface.GraphicsInit();
            Surface.OnResize(window.ClientSize.Width, window.ClientSize.Height);
            mQuadSampler = new Sampler(context)
            {
                AddressU = SharpDX.Direct3D11.TextureAddressMode.Clamp,
                AddressV = SharpDX.Direct3D11.TextureAddressMode.Clamp,
                AddressW = SharpDX.Direct3D11.TextureAddressMode.Clamp,
                Filter   = SharpDX.Direct3D11.Filter.MinMagMipPoint
            };

            RenderWindow.Text = Strings.MainWindowTitle;

            mViews.Add(AppState.Splash, new SplashView());
            mViews.Add(AppState.FileSystemInit, new FileSystemInitView());
            mViews.Add(AppState.MapSelect, new MapSelectView());
            mViews.Add(AppState.EntrySelect, new EntrySelectView());
            mViews.Add(AppState.LoadingScreen, new LoadingScreenView());
            mViews.Add(AppState.World, new WorldView());
            mActiveView = mViews[AppState.Splash];

            InitMesh();
            InitMessages();

            foreach (var pair in mViews)
            {
                pair.Value.OnResize(new SharpDX.Vector2(RenderWindow.ClientSize.Width, RenderWindow.ClientSize.Height));
            }
        }
Example #2
0
        public GxContext(RenderControl window)
        {
            mWindow = window;
            mFactory = new Factory1();
            if (mFactory.Adapters1.Length == 0)
                throw new InvalidOperationException(
                    "Sorry, but DirectX returned that there is no graphics card installed on your system. Please check if all your drivers are up to date!");

            Adapter = mFactory.GetAdapter1(0);
            if (Adapter.Outputs.Length == 0)
                throw new InvalidOperationException(
                    "Sorry, but DirectX returned that there is no output (monitor) assigned to the graphics card: \"" +
                    Adapter.Description.Description
                    +
                    "\". Please check if your drivers are OK and if your graphics card and monitor show up in the device manager.");

            mOutput = Adapter.Outputs[0];
        }
Example #3
0
        public void Initialize(RenderControl window, GxContext context)
        {
            mGlobalBuffer = new ConstantBuffer(context);
            mGlobalParamsBuffer = new ConstantBuffer(context);
            mGlobalParamsBufferStore = new GlobalParamsBuffer
            {
                mapAmbient = new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
                mapDiffuse = new Vector4(0.25f, 0.5f, 1.0f, 1.0f),
                fogColor = new Vector4(0.25f, 0.5f, 1.0f, 1.0f),
                fogParams = new Vector4(500.0f, 900.0f, mMainCamera.FarClip, 0.0f),
                brushParameters = new Vector4(45.0f, 55.0f, 0.0f, 0.0f),
                mousePosition = new Vector4(float.MaxValue),
                eyePosition = Vector4.Zero,
                brushSettings = new Vector4(0, 1, 0, 0)
            };

            mGlobalParamsBuffer.UpdateData(mGlobalParamsBufferStore);

            mGlobalBufferStore = new GlobalBuffer
            {
                eyePosition = Vector4.Zero,
                matProj = Matrix.Identity,
                matView = Matrix.Identity
            };

            mGlobalBuffer.UpdateData(mGlobalBufferStore);

            Dispatcher = new GraphicsDispatcher();
            MapChunkRender.Initialize(context);
            MapAreaLowRender.Initialize(context);
            WmoGroupRender.Initialize(context);
            M2BatchRenderer.Initialize(context);
            M2ModelRenderer.Initialize(context);

            StaticAnimationThread.Instance.Initialize();

            WmoManager.Initialize();
            M2Manager.Initialize();

            GraphicsContext = context;

            SetActiveCamera(mMainCamera);
            TextureManager.Instance.Initialize(context);

            MapManager.Initialize();

            mMainCamera.ViewChanged += ViewChanged;
            mMainCamera.ProjectionChanged += ProjectionChanged;

            ViewChanged(mMainCamera, mMainCamera.View);
            ProjectionChanged(mMainCamera, mMainCamera.Projection);

            CamControl = new CameraControl(window);
            CamControl.PositionChanged += MapManager.UpdatePosition;

            if (!LeftHandedCamera)
                CamControl.InvertY = true;
        }