Beispiel #1
0
        public BasicEffect(GraphicsDevice device, EffectPool effectPool)
            : base(device, new byte[] { 0 }, CompilerOptions.None, effectPool)

        {
            //this.CacheEffectParams(device);
            //this.InitializeEffectParams();
        }
Beispiel #2
0
        public BasicEffect(GraphicsDevice device, EffectPool effectPool)
            : base(device, new byte[]{0}, CompilerOptions.None, effectPool)

        {
            //this.CacheEffectParams(device);
            //this.InitializeEffectParams();
        }
Beispiel #3
0
 public Effect(
     GraphicsDevice graphicsDevice,
     byte[] effectCode,
     CompilerOptions options,
     EffectPool pool)
 {
     // GG EDIT we are specializing this to the default shader because we happen to know
     // that this is only called with empty bytes
     Init("__NO_NAME__", GGShader.EmptyShader, graphicsDevice);
 }
Beispiel #4
0
        public Effect(GraphicsDevice graphicsDevice, byte[] effectCode, CompilerOptions options, EffectPool pool) 
        {
            int fragmentblocklength = BitConverter.ToInt32(effectCode, 0);

            int vertexblocklength = BitConverter.ToInt32(effectCode, fragmentblocklength + 4);

            if (fragmentblocklength != 0)
            {
                fragment_handle = Gl.glCreateShader(Gl.GL_FRAGMENT_SHADER);
                fragment = true;
            }

            if (vertexblocklength != 0)
            {
                vertex_handle = Gl.glCreateShader(Gl.GL_VERTEX_SHADER);
                vertex = true;
            }

            if (fragment)
            {
                string[] fragmentstring = new string[1] { Encoding.UTF8.GetString(effectCode, 4, fragmentblocklength) };
                int[] fragmentLength = new int[1] { fragmentstring[0].Length };
                Gl.glShaderSource(fragment_handle, 1, fragmentstring, fragmentLength);
            }

            if (vertex)
            {
                string[] vertexstring = new string[1] { Encoding.UTF8.GetString(effectCode, fragmentblocklength + 8, vertexblocklength) };
                int[] vertexLength = new int[1] { vertexstring[0].Length };
                Gl.glShaderSource(vertex_handle, 1, vertexstring, vertexLength);
            }

            if (fragment)
            {
                Gl.glCompileShader(fragment_handle);
            }

            if (vertex)
            {
                Gl.glCompileShader(fragment_handle);
            }
        }
Beispiel #5
0
 public Effect(GraphicsDevice graphicsDevice, Stream effectCodeFileStream, CompilerOptions options, EffectPool pool) 
 {
     throw new NotImplementedException(); 
 }
Beispiel #6
0
 public Effect(GraphicsDevice graphicsDevice, Stream effectCodeFileStream, int numberBytes, CompilerOptions options, EffectPool pool)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
 public BasicEffect(GraphicsDevice device, EffectPool effectPool)
     : base(device, new byte[]{0}, CompilerOptions.None, effectPool)
 {
     createBasicEffect();
 }
Beispiel #8
0
 public TerrainEffect( GraphicsDevice GraphicsDevice, CompilerOptions Options, EffectPool Pool )
 {
     mEffect = XNAUtility.GameArgs.Current.ContentManager.Load<Effect>( "Terrain" );
     mEffect.CurrentTechnique = mEffect.Techniques[ "DefaultTechnique" ];
 }
    public void TestEqualsWithIncpmpatibleDrawContext() {
      MockedGraphicsDeviceService service = new MockedGraphicsDeviceService();
      using(IDisposable keeper = service.CreateDevice()) {
#if XNA_4
        using(BasicEffect effect = new BasicEffect(service.GraphicsDevice)) {
          TestEffectDrawContext test1 = new TestEffectDrawContext(effect);
          TestDrawContext test2 = new TestDrawContext();
          Assert.IsFalse(test1.Equals((object)test2));
        }
#else
        using(EffectPool pool = new EffectPool()) {
          using(BasicEffect effect = new BasicEffect(service.GraphicsDevice, pool)) {
            TestEffectDrawContext test1 = new TestEffectDrawContext(effect);
            TestDrawContext test2 = new TestDrawContext();
            Assert.IsFalse(test1.Equals((object)test2));
          }
        }
#endif
      }
    }
    public void TestEffectRetrieval() {
      MockedGraphicsDeviceService service = new MockedGraphicsDeviceService();
      using(IDisposable keeper = service.CreateDevice()) {
#if XNA_4
        using(BasicEffect effect = new BasicEffect(service.GraphicsDevice)) {
          TestEffectDrawContext test = new TestEffectDrawContext(effect);

          Assert.AreSame(effect, test.Effect);
        }
#else
        using(EffectPool pool = new EffectPool()) {
          using(BasicEffect effect = new BasicEffect(service.GraphicsDevice, pool)) {
            TestEffectDrawContext test = new TestEffectDrawContext(effect);

            Assert.AreSame(effect, test.Effect);
          }
        }
#endif
      }
    }
    public void TestBeginEnd() {
      MockedGraphicsDeviceService service = new MockedGraphicsDeviceService();
      using(IDisposable keeper = service.CreateDevice()) {
#if XNA_4
        using(BasicEffect effect = new BasicEffect(service.GraphicsDevice)) {
          TestEffectDrawContext test = new TestEffectDrawContext(effect);

          for(int pass = 0; pass < test.Passes; ++pass) {
            test.Apply(pass);
          }
        }
#else
        using(EffectPool pool = new EffectPool()) {
          using(BasicEffect effect = new BasicEffect(service.GraphicsDevice, pool)) {
            TestEffectDrawContext test = new TestEffectDrawContext(effect);

            test.Begin();
            try {
              for(int pass = 0; pass < test.Passes; ++pass) {
                test.BeginPass(pass);
                test.EndPass();
              }
            }
            finally {
              test.End();
            }
          }
        }
#endif
      }
    }
    public void TestConstructor() {
      MockedGraphicsDeviceService service = new MockedGraphicsDeviceService();
      using(IDisposable keeper = service.CreateDevice()) {
#if XNA_4
        using(BasicEffect effect = new BasicEffect(service.GraphicsDevice)) {
          TestEffectDrawContext test = new TestEffectDrawContext(effect);
          Assert.GreaterOrEqual(test.Passes, 1);
        }
#else
        using(EffectPool pool = new EffectPool()) {
          using(BasicEffect effect = new BasicEffect(service.GraphicsDevice, pool)) {
            TestEffectDrawContext test = new TestEffectDrawContext(effect);
            Assert.GreaterOrEqual(test.Passes, 1);
          }
        }
#endif
      }
    }
Beispiel #13
0
        public Effect(GraphicsDevice graphicsDevice, byte[] effectCode, CompilerOptions options, EffectPool pool)
        {
            int fragmentblocklength = BitConverter.ToInt32(effectCode, 0);

            int vertexblocklength = BitConverter.ToInt32(effectCode, fragmentblocklength + 4);

            if (fragmentblocklength != 0)
            {
                fragment_handle = Gl.glCreateShader(Gl.GL_FRAGMENT_SHADER);
                fragment        = true;
            }

            if (vertexblocklength != 0)
            {
                vertex_handle = Gl.glCreateShader(Gl.GL_VERTEX_SHADER);
                vertex        = true;
            }

            if (fragment)
            {
                string[] fragmentstring = new string[1] {
                    Encoding.UTF8.GetString(effectCode, 4, fragmentblocklength)
                };
                int[] fragmentLength = new int[1] {
                    fragmentstring[0].Length
                };
                Gl.glShaderSource(fragment_handle, 1, fragmentstring, fragmentLength);
            }

            if (vertex)
            {
                string[] vertexstring = new string[1] {
                    Encoding.UTF8.GetString(effectCode, fragmentblocklength + 8, vertexblocklength)
                };
                int[] vertexLength = new int[1] {
                    vertexstring[0].Length
                };
                Gl.glShaderSource(vertex_handle, 1, vertexstring, vertexLength);
            }

            if (fragment)
            {
                Gl.glCompileShader(fragment_handle);
            }

            if (vertex)
            {
                Gl.glCompileShader(fragment_handle);
            }
        }
Beispiel #14
0
        private void InitializeEffect()
        {
            EffectPool EP = new EffectPool();
            CompiledEffect compiledEffect = Effect.CompileEffectFromFile(
                "ReallySimpleEffect.fx", null, null,
                CompilerOptions.Debug |
                CompilerOptions.SkipOptimization,
                TargetPlatform.Windows);

            Effect = new Effect(graphics.GraphicsDevice,
                compiledEffect.GetEffectCode(), CompilerOptions.None,
                EP);
        }
 /// <summary>Initializes a new instance of the 
 /// <see cref="T:XNAnimation.Effects.SkinnedModelBasicEffect" />
 /// class.
 /// </summary>
 /// <param name="graphicsDevice">The graphics device that will create the effect.</param>
 /// <param name="effectPool">Specifies a pool of resources to share between effects.</param>
 public SkinnedModelBasicEffect(GraphicsDevice graphicsDevice, EffectPool effectPool)
     : base(graphicsDevice, SkinnedModelBasicEffectCode.Code, CompilerOptions.None, effectPool)
 {
     CacheEffectParams();
     InitializeEffectParams();
 }
Beispiel #16
0
        public BasicEffect(GraphicsDevice device, EffectPool effectPool)
            : base(device, new byte[] { 0 }, CompilerOptions.None, effectPool)

        {
            createBasicEffect();
        }
        public void CreateGraphicsContext(int deviceWidth, int deviceHeight)
        {
            GraphicsDeviceManager m_Manager = new GraphicsDeviceManager(game);
            m_Manager.PreferredBackBufferWidth = deviceWidth;
            m_Manager.PreferredBackBufferHeight = deviceHeight;

            if (m_XNA_GraphicsDevice != null)
                return false;
            //create an XNA graphics device
            m_XNA_GraphicsDevice = m_Manager.GraphicsDevice();

            //check if graphics device was created
            Debug.Assert(m_XNA_GraphicsDevice != null, "XNA Graphics Device did not Initialize");

            m_EffectPool = new EffectPool();
            m_BasicEffect = new BasicEffect(m_XNA_GraphicsDevice, m_EffectPool);

            //set the model matrix to identity
            m_BasicEffect.World = Matrix.Identity;
            m_BasicEffect.View = Matrix.Identity;
            m_BasicEffect.Projection = Matrix.Identity;
            m_XNA_GraphicsDevice.RenderState.DepthBufferEnable = true;
            m_XNA_GraphicsDevice.RenderState.DepthBufferWriteEnable = true;

            return true;
        }
Beispiel #18
0
        public Effect(
            GraphicsDevice graphicsDevice,
            byte[] effectCode,
            CompilerOptions options,
            EffectPool pool)
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("Graphics Device Cannot Be Null");
            }
            this.graphicsDevice = graphicsDevice;

            if (pool == null)
            {
                return;
                // TODO throw new ArgumentNullException("Effect Pool Cannot Be Null");
            }

            int fragmentblocklength = BitConverter.ToInt32(effectCode, 0);

            int vertexblocklength = BitConverter.ToInt32(effectCode, fragmentblocklength + 4);

            if (fragmentblocklength != 0)
            {
                fragment_handle = GL.CreateShader(ShaderType.FragmentShader);
                fragment        = true;
            }

            if (vertexblocklength != 0)
            {
                vertex_handle = GL.CreateShader(ShaderType.VertexShader);
                vertex        = true;
            }

            if (fragment)
            {
                string[] fragmentstring = new string[1] {
                    Encoding.UTF8.GetString(effectCode, 4, fragmentblocklength)
                };
                //int[] fragmentLength = new int[1] { fragmentstring[0].Length };
                int fragmentLength = fragmentstring[0].Length;
                GL.ShaderSource(fragment_handle, 1, fragmentstring, ref fragmentLength);
            }

            if (vertex)
            {
                string[] vertexstring = new string[1] {
                    Encoding.UTF8.GetString(effectCode, fragmentblocklength + 8, vertexblocklength)
                };
                // int[] vertexLength = new int[1] { vertexstring[0].Length };
                int vertexLength = vertexstring[0].Length;
                GL.ShaderSource(vertex_handle, 1, vertexstring, ref vertexLength);
            }

            int compiled = 0;

            if (fragment)
            {
                GL.CompileShader(fragment_handle);

                GL.GetShader(fragment_handle, ShaderParameter.CompileStatus, out compiled);
                if (compiled == (int)All.False)
                {
                    Console.Write("Fragment Compilation Failed!");
                }
            }

            if (vertex)
            {
                GL.CompileShader(vertex_handle);
                GL.GetShader(vertex_handle, ShaderParameter.CompileStatus, out compiled);
                if (compiled == (int)All.False)
                {
                    Console.Write("Vertex Compilation Failed!");
                }
            }
        }
        public bool CreateGraphicsContext(IntPtr hwnd, ref PresentationParameters pp)
        {
            //define presentation parameters
            pp = new PresentationParameters();
            pp.BackBufferCount = 1;
            pp.BackBufferFormat = SurfaceFormat.Unknown;
            pp.DeviceWindowHandle = hwnd;
            pp.IsFullScreen = false;
            pp.SwapEffect = SwapEffect.Discard;
            pp.BackBufferHeight = Control.FromHandle(hwnd).Height;
            pp.BackBufferWidth = Control.FromHandle(hwnd).Width;
            //Initialize Z-buffer - need this for winform
            pp.EnableAutoDepthStencil = true;
            pp.AutoDepthStencilFormat = DepthFormat.Depth24;

            if (m_XNA_GraphicsDevice != null)
                return false;
            //create an XNA graphics device
            m_XNA_GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware,
                hwnd, pp);

            //check if graphics device was created
            Debug.Assert(m_XNA_GraphicsDevice != null, "XNA Graphics Device did not Initialize");

            m_EffectPool = new EffectPool();
            m_BasicEffect = new BasicEffect(m_XNA_GraphicsDevice, m_EffectPool);

            //set the model matrix to identity
            m_BasicEffect.World = Matrix.Identity;
            m_BasicEffect.View = Matrix.Identity;
            m_BasicEffect.Projection = Matrix.Identity;
            m_XNA_GraphicsDevice.RenderState.DepthBufferEnable = true;
            m_XNA_GraphicsDevice.RenderState.DepthBufferWriteEnable = true;

            return true;
        }
Beispiel #20
0
		public Effect (
         GraphicsDevice graphicsDevice,
         byte[] effectCode,
         CompilerOptions options,
         EffectPool pool)
		{
			
			if (graphicsDevice == null)
            {
                throw new ArgumentNullException("Graphics Device Cannot Be Null");
            }
			this.graphicsDevice = graphicsDevice;
			
			if (pool == null)
            { 
				return;
                // TODO throw new ArgumentNullException("Effect Pool Cannot Be Null");
            }
			
			int fragmentblocklength = BitConverter.ToInt32(effectCode, 0);

            int vertexblocklength = BitConverter.ToInt32(effectCode, fragmentblocklength + 4);

            if (fragmentblocklength != 0)
            {
                fragment_handle = GL.CreateShader( ShaderType.FragmentShader );
                fragment = true;
            }

            if (vertexblocklength != 0)
            {
                vertex_handle = GL.CreateShader( ShaderType.VertexShader );
                vertex = true;
            }

            if (fragment)
            {
                string[] fragmentstring = new string[1] { Encoding.UTF8.GetString(effectCode, 4, fragmentblocklength) };
                //int[] fragmentLength = new int[1] { fragmentstring[0].Length };
				int fragmentLength = fragmentstring[0].Length;
                GL.ShaderSource(fragment_handle, 1, fragmentstring, ref fragmentLength);
            }

            if (vertex)
            {
                string[] vertexstring = new string[1] { Encoding.UTF8.GetString(effectCode, fragmentblocklength + 8, vertexblocklength) };
                // int[] vertexLength = new int[1] { vertexstring[0].Length };
				int vertexLength = vertexstring[0].Length;
                GL.ShaderSource(vertex_handle, 1, vertexstring, ref vertexLength);
            }
			
			int compiled = 0;

            if (fragment)
            {
                GL.CompileShader(fragment_handle);
				
				GL.GetShader(fragment_handle, ShaderParameter.CompileStatus, out compiled );
				if (compiled == (int)All.False)
				{
					Console.Write("Fragment Compilation Failed!");
				}
            }

            if (vertex)
            {
                GL.CompileShader(vertex_handle);
				GL.GetShader(vertex_handle, ShaderParameter.CompileStatus, out compiled );
				if (compiled == (int)All.False)
				{
					Console.Write("Vertex Compilation Failed!");
				}
            }

		}
Beispiel #21
0
 public Effect(GraphicsDevice graphicsDevice, string effectCodeFile, CompilerOptions options, EffectPool pool)
 {
     throw new NotImplementedException();
 }