Effect Constructor (GraphicsDevice, Stream, Int32, CompilerOptions, EffectPool)
Initializes a new instance of this class from a compiled effect, specifying the compiled effect as a stream, as well as the number of bytes in the stream.
Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
Syntax
public Effect (
GraphicsDevice graphicsDevice,
Stream effectCodeFileStream,
int numberBytes,
CompilerOptions options,
EffectPool pool
)
Parameters
- graphicsDevice
The graphics device that will create the effect. - effectCodeFileStream
Stream containing the compiled byte code. - numberBytes
The number of bytes to read from the file. - options
Compilation optimization options. - pool
Specifies a pool of resources to share between effects.
Exceptions
Exception type | Condition |
---|---|
ArgumentNullException | graphicsDevice is null. The graphics device must not be null when creating new resources. |
InvalidOperationException | One of the following conditions is true:
|
ObjectDisposedException | Effect was called after pool was disposed. |
Remarks
Tip
In most cases, it is preferrable to initialize a new instance of an effect using the ContentManager.Load<Effect> method rather than using the Effect constructors. For an example of initializing an effect with this method, see How to: Create and Apply Custom Effects.
Obtaining the compiled byte code for effectCodeFileStream is a two-part process. First, you must compile the effect by using the static method Effect.CompileEffectFromFile or Effect.CompileEffectFromSource, either of which returns an instance of CompiledEffect. CompiledEffect.GetEffectCode returns the compiled byte code from the compiled effect.
See Also
Tasks
How to: Create and Apply Custom Effects
Reference
Effect.CompileEffectFromFile Method
Effect.CompileEffectFromSource Method
Effect Class
Effect Members
Microsoft.Xna.Framework.Graphics Namespace
Platforms
Xbox 360, Windows XP SP2, Windows Vista