public static IDepthStencilState New(VideoTypes videoType, IDisposableResource parent, IDepthStencilStateDesc desc) { IDepthStencilState api = null; #if WIN32 if (videoType == VideoTypes.D3D9) api = new D3D9.DepthStencilState(parent, desc); #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) api = new D3D11.DepthStencilState(parent, desc); #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) api = new OpenGL.DepthStencilState(parent, desc); #endif #if XNA if (videoType == VideoTypes.XNA) api = new XNA.DepthStencilState(parent, desc); #endif #if VITA if (videoType == VideoTypes.Vita) api = new Vita.DepthStencilState(parent, desc); #endif if (api == null) Debug.ThrowError("DepthStencilStateAPI", "Unsuported InputType: " + videoType); return api; }
protected override void init(IDisposableResource parent, Stream stream, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback) { base.init(parent, stream, instanceCount, looped, loadedCallback); try { audio = parent.FindParentOrSelfWithException<Audio>(); audio.UpdateCallback += Update; com = new SoundWAVCom(); var error = com.Init(audio.com, data, formatCode, channels, sampleRate, formatAvgBytesPerSec, formatBlockAlign, bitDepth, formatExtraSize); data = null; for (int i = 0; i != instanceCount; ++i) { inactiveInstances.AddLast(new SoundWAVInstance(this, looped)); } } catch (Exception e) { FailedToLoad = true; Loader.AddLoadableException(e); Dispose(); if (loadedCallback != null) loadedCallback(this, false); return; } Loaded = true; if (loadedCallback != null) loadedCallback(this, true); }
public Shader(IDisposableResource parent, string filename, ShaderVersions shaderVersion, ShaderFloatingPointQuality vsQuality, ShaderFloatingPointQuality psQuality, Loader.LoadedCallbackMethod loadedCallback) : base(parent) { #if WINRT || WP8 Loader.AddLoadable(this); filename = Streams.StripFileExt(filename) + ".mrs"; #endif new StreamLoader(filename, delegate(object sender, bool succeeded) { if (succeeded) { init(filename, ((StreamLoader)sender).LoadedStream, shaderVersion, vsQuality, psQuality, loadedCallback); } else { FailedToLoad = true; Dispose(); if (loadedCallback != null) { loadedCallback(this, false); } } }); }
public MyJob( IConfigManager configManager, IDisposableResource diposableResource) { this.configManager = configManager ?? throw new ArgumentNullException(nameof(configManager)); this.diposableResource = diposableResource ?? throw new ArgumentNullException(nameof(diposableResource)); }
public static IMouse New(InputTypes inputType, IDisposableResource parent) { IMouse api = null; #if WIN32 if (inputType == InputTypes.WinForms) api = new WinForms.Mouse(parent); #endif #if WINRT if (inputType == InputTypes.WinRT) api = new WinRT.Mouse(parent); #endif #if OSX if (inputType == InputTypes.Cocoa) api = new Cocoa.Mouse(parent); #endif #if LINUX if (inputType == InputTypes.X11) api = new X11.Mouse(parent); #endif #if NaCl if (inputType == InputTypes.NaCl) api = new NaCl.Mouse(parent); #endif if (api == null) Debug.ThrowError("MouseAPI", "Unsuported InputType: " + inputType); return api; }
public static IVertexBuffer New(VideoTypes videoType, IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, VertexBufferTopologys topology, float[] vertices, int[] indices) { IVertexBuffer api = null; #if WIN32 if (videoType == VideoTypes.D3D9) api = new D3D9.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) api = new D3D11.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) api = new OpenGL.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); #endif #if XNA if (videoType == VideoTypes.XNA) api = new XNA.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); #endif #if VITA if (videoType == VideoTypes.Vita) api = new Vita.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); #endif if (api == null) Debug.ThrowError("VertexBufferAPI", "Unsuported InputType: " + videoType); return api; }
public static ITexture2D New(VideoTypes videoType, IDisposableResource parent, Image image, int width, int height, bool generateMipmaps, MultiSampleTypes multiSampleType, SurfaceFormats surfaceFormat, RenderTargetUsage renderTargetUsage, BufferUsages usage, Loader.LoadedCallbackMethod loadedCallback) { ITexture2D api = null; #if WIN32 if (videoType == VideoTypes.D3D9) api = new D3D9.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) api = new D3D11.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) api = new OpenGL.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); #endif #if XNA if (videoType == VideoTypes.XNA) api = new XNA.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); #endif #if VITA if (videoType == VideoTypes.Vita) api = new Vita.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); #endif if (api == null) Debug.ThrowError("Texture2DAPI", "Unsuported InputType: " + videoType); return api; }
private void init(IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, VertexBufferTopologys topology, float[] vertices, int[] indices) { try { var video = parent.FindParentOrSelfWithException <Video>(); this.topology = topology; REIGN_D3DPRIMITIVETYPE topologyType = REIGN_D3DPRIMITIVETYPE.TRIANGLELIST; switch (topology) { case VertexBufferTopologys.Triangle: topologyType = REIGN_D3DPRIMITIVETYPE.TRIANGLELIST; break; case VertexBufferTopologys.Line: topologyType = REIGN_D3DPRIMITIVETYPE.LINELIST; break; case VertexBufferTopologys.Point: topologyType = REIGN_D3DPRIMITIVETYPE.POINTLIST; break; } com = new VertexBufferCom(video.com, topologyType); var error = com.Init(vertices, REIGN_D3DUSAGE.WRITEONLY, vertexCount, vertexByteSize); if (error == VertexBufferErrors.VertexBuffer) { Debug.ThrowError("VertexBuffer", "Failed to create VertexBuffer"); } if (indices != null && indices.Length != 0) { indexBuffer = new IndexBuffer(this, usage, indices); } } catch (Exception e) { Dispose(); throw e; } }
public BlendState(IDisposableResource parent, IBlendStateDesc desc) : base(parent) { var video = parent.FindParentOrSelfWithException <Video>(); com = new BlendStateCom(video.com, ((BlendStateDesc)desc).com); }
public Model(IDisposableResource parent, SoftwareModel softwareModel, bool loadColors, bool loadUVs, bool loadNormals, string contentDirectory, Dictionary<string,Type> materialTypes, List<MaterialFieldBinder> value1BinderTypes, List<MaterialFieldBinder> value2BinderTypes, List<MaterialFieldBinder> value3BinderTypes, List<MaterialFieldBinder> value4BinderTypes, List<MaterialFieldBinder> textureBinderTypes, Dictionary<string,string> fileExtOverrides, int classicInstanceCount, Loader.LoadedCallbackMethod loadedCallback) : base(parent) { Loader.AddLoadable(this); new LoadWaiter(new ILoadable[]{softwareModel}, delegate(object sender, bool succeeeded) { if (succeeeded) { using (var stream = new MemoryStream()) { try { Model.Save(stream, false, softwareModel, loadColors, loadUVs, loadNormals); stream.Position = 0; } catch (Exception e) { FailedToLoad = true; Dispose(); if (loadedCallback != null) loadedCallback(this, false); } if (!FailedToLoad) init(null, stream, contentDirectory, materialTypes, value1BinderTypes, value2BinderTypes, value3BinderTypes, value4BinderTypes, textureBinderTypes, fileExtOverrides, classicInstanceCount, loadedCallback); } } else { FailedToLoad = true; Dispose(); if (loadedCallback != null) loadedCallback(this, false); } }); }
public static IViewPort New(VideoTypes videoType, IDisposableResource parent, Point2 location, Size2 size) { IViewPort api = null; #if WIN32 if (videoType == VideoTypes.D3D9) api = new D3D9.ViewPort(parent, location, size); #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) api = new D3D11.ViewPort(parent, location, size); #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) api = new OpenGL.ViewPort(parent, location, size); #endif #if XNA if (videoType == VideoTypes.XNA) api = new XNA.ViewPort(parent, location, size); #endif #if VITA if (videoType == VideoTypes.Vita) api = new Vita.ViewPort(parent, location, size); #endif if (api == null) Debug.ThrowError("ViewPortAPI", "Unsuported InputType: " + videoType); return api; }
public static IQuickDraw New(VideoTypes videoType, IDisposableResource parent, IBufferLayoutDesc desc) { IQuickDraw api = null; #if WIN32 if (videoType == VideoTypes.D3D9) api = new D3D9.QuickDraw(parent, desc); #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) api = new D3D11.QuickDraw(parent, desc); #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) api = new OpenGL.QuickDraw(parent, desc); #endif #if XNA if (videoType == VideoTypes.XNA) api = new XNA.QuickDraw(parent, desc); #endif #if VITA if (videoType == VideoTypes.Vita) api = new Vita.QuickDraw(parent, desc); #endif if (api == null) Debug.ThrowError("QuickDrawAPI", "Unsuported InputType: " + videoType); return api; }
public static IShader New(VideoTypes videoType, IDisposableResource parent, string filename, ShaderVersions shaderVersion, ShaderFloatingPointQuality vsQuality, ShaderFloatingPointQuality psQuality, Loader.LoadedCallbackMethod loadedCallback) { IShader api = null; #if WIN32 if (videoType == VideoTypes.D3D9) api = new D3D9.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) api = new D3D11.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) api = new OpenGL.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); #endif #if XNA if (videoType == VideoTypes.XNA) api = new XNA.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); #endif #if VITA if (videoType == VideoTypes.Vita) api = new Vita.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); #endif if (api == null) Debug.ThrowError("ShaderAPI", "Unsuported InputType: " + videoType); return api; }
public DepthStencilState(IDisposableResource parent, IDepthStencilStateDesc desc) : base(parent) { var video = parent.FindParentOrSelfWithException <Video>(); com = new DepthStencilStateCom(video.com, ((DepthStencilStateDesc)desc).com); }
public RootDisposableResource(IDisposableResource disposable) : base(disposable) { #if XNA && !SILVERLIGHT var parent = disposable.FindParentOrSelfWithException <RootDisposableResource>(); init(parent.Content); #endif }
public RenderTarget(IDisposableResource parent, Image image, int width, int height, bool generateMipmaps, MultiSampleTypes multiSampleType, SurfaceFormats surfaceFormat, DepthStencilFormats depthStencilFormat, RenderTargetUsage renderTargetUsage, BufferUsages usage, Loader.LoadedCallbackMethod loadedCallback) : base(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback) { if (initSuccess) { initDepthStencil(width, height, depthStencilFormat); } }
protected IVertexBuffer(IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, float[] vertices) : base(parent) { this.usage = usage; vertexByteSize = bufferLayoutDesc.ByteSize; vertexFloatArraySize = bufferLayoutDesc.FloatCount; vertexCount = vertices.Length / vertexFloatArraySize; }
public RootDisposableResource(IDisposableResource disposable) : base(disposable) { #if XNA && !SILVERLIGHT var parent = disposable.FindParentOrSelfWithException<RootDisposableResource>(); init(parent.Content); #endif }
public DepthStencil(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats) : base(parent) { try { var video = parent.FindParentOrSelfWithException <Video>(); Size = new Size2(width, height); SizeF = Size.ToVector2(); int depthBit = 16, stencilBit = 0; switch (depthStencilFormats) { case DepthStencilFormats.Defualt: depthBit = 24; stencilBit = 0; break; case DepthStencilFormats.Depth24Stencil8: depthBit = 24; stencilBit = 8; break; case DepthStencilFormats.Depth16: depthBit = 16; stencilBit = 0; break; case DepthStencilFormats.Depth24: depthBit = 24; stencilBit = 0; break; case DepthStencilFormats.Depth32: depthBit = 32; stencilBit = 0; break; default: Debug.ThrowError("Video", "Unsuported DepthStencilFormat type"); break; } com = new DepthStencilCom(); var error = com.Init(video.com, width, height, depthBit, stencilBit); switch (error) { case DepthStencilErrors.Textrue: Debug.ThrowError("DepthStencil", "Failed to create Texture2D"); break; case DepthStencilErrors.DepthStencilView: Debug.ThrowError("DepthStencil", "Failed to create DepthStencilView"); break; } } catch (Exception e) { Dispose(); throw e; } }
public DepthStencil(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats) : base(parent) { try { var video = parent.FindParentOrSelfWithException<Video>(); Size = new Size2(width, height); SizeF = Size.ToVector2(); int depthBit = 16, stencilBit = 0; switch (depthStencilFormats) { case DepthStencilFormats.Defualt: depthBit = 24; stencilBit = 0; break; case DepthStencilFormats.Depth24Stencil8: depthBit = 24; stencilBit = 8; break; case DepthStencilFormats.Depth16: depthBit = 16; stencilBit = 0; break; case DepthStencilFormats.Depth24: depthBit = 24; stencilBit = 0; break; case DepthStencilFormats.Depth32: depthBit = 32; stencilBit = 0; break; default: Debug.ThrowError("Video", "Unsuported DepthStencilFormat type"); break; } com = new DepthStencilCom(); var error = com.Init(video.com, width, height, depthBit, stencilBit); switch (error) { case DepthStencilErrors.Textrue: Debug.ThrowError("DepthStencil", "Failed to create Texture2D"); break; case DepthStencilErrors.DepthStencilView: Debug.ThrowError("DepthStencil", "Failed to create DepthStencilView"); break; } } catch (Exception e) { Dispose(); throw e; } }
protected IIndexBuffer(IDisposableResource parent, BufferUsages usage, int[] indices) : base(parent) { this.usage = usage; indexByteSize = sizeof(short); indexCount = indices.Length; _32BitIndices = indexCount > short.MaxValue; indexByteSize = _32BitIndices ? sizeof(int) : sizeof(short); }
protected virtual void init(IDisposableResource parent, Stream stream, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback) { using (stream) using (var reader = new BinaryReader(stream)) { readMetaData(stream, reader); data = reader.ReadBytes(dataSize); } }
public static void ThrowIfDisposed(this IDisposableResource resource) { Contract.Requires(resource != null); if (resource.IsDisposed) { throw new ObjectDisposedException(resource.ToString(), "An attempt was made to use a disposed object."); } }
public Video(IDisposableResource parent, IApplication application, DepthStencilFormats depthStencilFormats, bool vSync) : base(parent) { #if WINRT var xamlApp = application as XAMLApplication; init(parent, application, depthStencilFormats, vSync, xamlApp != null ? ((XAMLApplication)application).SwapChainPanel : null); #else init(parent, application, depthStencilFormats, vSync); #endif }
public Mouse(IDisposableResource parent) : base(parent) { input = parent.FindParentOrSelfWithException<Input>(); input.UpdateEventCallback += UpdateEvent; input.UpdateCallback += Update; Left = new PositionButton(); Middle = new PositionButton(); Right = new PositionButton(); }
public SoundWAV(IDisposableResource parent, string filename, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback) : base(parent) { for (int i = 0; i != instanceCount; ++i) { inactiveInstances.AddLast(new SoundWAVInstance(this, looped)); } Loaded = true; if (loadedCallback != null) loadedCallback(this, true); }
public Mouse(IDisposableResource parent) : base(parent) { input = parent.FindParentOrSelfWithException <Input>(); input.UpdateEventCallback += UpdateEvent; input.UpdateCallback += Update; Left = new PositionButton(); Middle = new PositionButton(); Right = new PositionButton(); }
public static IGamePad New(InputTypes inputType, IDisposableResource parent) { IGamePad api = null; #if XNA if (inputType == InputTypes.XNA) api = new XNA.GamePad(disposable); #endif if (api == null) Debug.ThrowError("GamePadAPI", "Unsuported InputType: " + inputType); return api; }
public QuickDraw(IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc) : base(parent, bufferLayoutDesc) { try { vertexBuffer = new VertexBuffer(this, bufferLayoutDesc, BufferUsages.Write, VertexBufferTopologys.Triangle, vertices); } catch (Exception e) { Dispose(); throw e; } }
public static IMusic New(AudioTypes audioType, IDisposableResource parent, string filename) { IMusic api = null; #if XNA if (audioType == AudioTypes.XNA) api = new XNA.Music(parent, filename); #endif if (audioType == AudioTypes.Dumby) api = new Dumby.Music(parent, filename); if (api == null) Debug.ThrowError("MusicAPI", "Unsuported InputType: " + audioType); return api; }
protected override bool init(IDisposableResource parent, Image image, int width, int height, bool generateMipmaps, MultiSampleTypes multiSampleType, SurfaceFormats surfaceFormat, RenderTargetUsage renderTargetUsage, BufferUsages usage, bool isRenderTarget, bool lockable, Loader.LoadedCallbackMethod loadedCallback) { initSuccess = base.init(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, true, lockable, loadedCallback); if (!initSuccess) { return(false); } try { if (usage == BufferUsages.Write) { Debug.ThrowError("RenderTarget", "Only Textures may be writable"); } if (image != null) { width = image.Size.Width; height = image.Size.Height; surfaceFormat = image.SurfaceFormat; } renderTargetCom = new RenderTargetCom(); var error = renderTargetCom.Init(video.com, com, width, height, 0, video.surfaceFormat(surfaceFormat), usage == BufferUsages.Read, lockable); switch (error) { case RenderTargetError.RenderTarget: Debug.ThrowError("RenderTarget", "Failed to create RenderTarget"); break; case RenderTargetError.StagingTexture: Debug.ThrowError("RenderTarget", "Failed to create Staging Texture"); break; } } catch (Exception e) { FailedToLoad = true; Loader.AddLoadableException(e); Dispose(); if (loadedCallback != null) { loadedCallback(this, false); } return(false); } Loaded = true; if (loadedCallback != null) { loadedCallback(this, true); } return(true); }
public Keyboard(IDisposableResource parent) : base(parent) { input = parent.FindParentOrSelfWithException<Input>(); input.UpdateEventCallback += UpdateEvent; input.UpdateCallback += Update; keys = new bool[256]; buttons = new Button[256]; for (int i = 0; i != 256; ++i) { buttons[i] = new Button(); } }
public Keyboard(IDisposableResource parent) : base(parent) { input = parent.FindParentOrSelfWithException <Input>(); input.UpdateEventCallback += UpdateEvent; input.UpdateCallback += Update; keys = new bool[256]; buttons = new Button[256]; for (int i = 0; i != 256; ++i) { buttons[i] = new Button(); } }
public unsafe IndexBuffer(IDisposableResource parent, BufferUsages bufferUsage, int[] indices) : base(parent, bufferUsage, indices) { try { video = parent.FindParentOrSelfWithException <Video>(); uint vPtr = 0; GL.GenBuffers(1, &vPtr); indexBuffer = vPtr; if (indexBuffer == 0) { Debug.ThrowError("IndexBuffer", "Failed to create IndexBuffer"); } GL.BindBuffer(GL.ELEMENT_ARRAY_BUFFER, indexBuffer); if (_32BitIndices) { fixed(int *indicesPtr = indices) { var bufferSize = new IntPtr(indexByteSize * indexCount); GL.BufferData(GL.ELEMENT_ARRAY_BUFFER, bufferSize, indicesPtr, GL.STATIC_DRAW); } } else { var indices16Bit = new short[indices.Length]; for (int i = 0; i != indices.Length; ++i) { indices16Bit[i] = (short)indices[i]; } fixed(short *indicesPtr = indices16Bit) { var bufferSize = new IntPtr(indexByteSize * indexCount); GL.BufferData(GL.ELEMENT_ARRAY_BUFFER, bufferSize, indicesPtr, GL.STATIC_DRAW); } } Video.checkForError(); } catch (Exception e) { Dispose(); throw e; } }
public static ITouchScreen New(InputTypes inputType, IDisposableResource parent) { ITouchScreen api = null; #if iOS if (inputType == InputTypes.Cocoa) TouchScreenAPI.Init(Reign.Input.Cocoa.TouchScreen.New); #endif #if ANDROID if (inputType == InputTypes.Android) TouchScreenAPI.Init(Reign.Input.Android.TouchScreen.New); #endif if (api == null) Debug.ThrowError("TouchScreenAPI", "Unsuported InputType: " + inputType); return api; }
public BufferLayout(IDisposableResource parent, IShader shader, IBufferLayoutDesc desc) : base(parent) { video = parent.FindParentOrSelfWithException<Video>(); this.shader = (Shader)shader; enabledStreamIndices = new bool[2]; streamBytesSizes = desc.StreamBytesSizes; layout = ((BufferLayoutDesc)desc).desc; attribLocations = new int[layout.Length]; for (int i = 0; i != layout.Length; ++i) { attribLocations[i] = GL.GetAttribLocation(this.shader.program, layout[i].Name); Video.checkForError(); } }
public BufferLayout(IDisposableResource parent, IShader shader, IBufferLayoutDesc desc) : base(parent) { video = parent.FindParentOrSelfWithException <Video>(); this.shader = (Shader)shader; enabledStreamIndices = new bool[2]; streamBytesSizes = desc.StreamBytesSizes; layout = ((BufferLayoutDesc)desc).desc; attribLocations = new int[layout.Length]; for (int i = 0; i != layout.Length; ++i) { attribLocations[i] = GL.GetAttribLocation(this.shader.program, layout[i].Name); Video.checkForError(); } }
public MyJob( IConfigManager configManager, IDisposableResource diposableResource) { if (configManager == null) { throw new ArgumentNullException("configManager"); } if (diposableResource == null) { throw new ArgumentNullException("diposableResource"); } this.configManager = configManager; this.diposableResource = diposableResource; }
public BufferLayout(IDisposableResource parent, IShader shader, IBufferLayoutDesc desc) : base(parent) { try { var video = parent.FindParentOrSelfWithException<Video>(); com = new BufferLayoutCom(); var error = com.Init(video.com, ((Shader)shader).vertex.com, ((BufferLayoutDesc)desc).com); if (error == BufferLayoutErrors.InputLayout) Debug.ThrowError("BufferLayout", "Failed to create InputLayout"); } catch (Exception e) { Dispose(); throw e; } }
public static IGamePad New(InputTypes inputType, IDisposableResource parent) { IGamePad api = null; #if XNA if (inputType == InputTypes.XNA) { api = new XNA.GamePad(disposable); } #endif if (api == null) { Debug.ThrowError("GamePadAPI", "Unsuported InputType: " + inputType); } return(api); }
public static IShader New(VideoTypes videoType, IDisposableResource parent, string filename, ShaderVersions shaderVersion, ShaderFloatingPointQuality vsQuality, ShaderFloatingPointQuality psQuality, Loader.LoadedCallbackMethod loadedCallback) { IShader api = null; #if WIN32 if (videoType == VideoTypes.D3D9) { api = new D3D9.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); } #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) { api = new D3D11.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); } #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) { api = new OpenGL.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); } #endif #if XNA if (videoType == VideoTypes.XNA) { api = new XNA.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); } #endif #if VITA if (videoType == VideoTypes.Vita) { api = new Vita.Shader(parent, filename, shaderVersion, vsQuality, psQuality, loadedCallback); } #endif if (api == null) { Debug.ThrowError("ShaderAPI", "Unsuported InputType: " + videoType); } return(api); }
public ShaderModel(IDisposableResource parent, string code, ShaderVersions shaderVersion, ShaderTypes shaderType) : base(parent) { try { var video = parent.FindParentOrSelfWithException <Video>(); string shaderLvl = ""; switch (shaderVersion) { case ShaderVersions.HLSL_2_0: shaderLvl = "_2_0"; break; case ShaderVersions.HLSL_2_a: shaderLvl = "_2_a"; break; case ShaderVersions.HLSL_3_0: shaderLvl = "_3_0"; break; default: Debug.ThrowError("ShaderModel", "Unsuported ShaderVersion: " + shaderVersion); break; } string shaderVersionType = shaderType.ToString().ToLower() + shaderLvl; com = new ShaderModelCom(); var codePtr = Marshal.StringToHGlobalAnsi(code); var shaderVersionTypePtr = Marshal.StringToHGlobalAnsi(shaderVersionType); string errorText; var error = com.Init(video.com, codePtr, code.Length, shaderVersionTypePtr, out errorText); if (codePtr != IntPtr.Zero) { Marshal.FreeHGlobal(codePtr); } if (shaderVersionTypePtr != IntPtr.Zero) { Marshal.FreeHGlobal(shaderVersionTypePtr); } switch (error) { case ShaderModelErrors.Compile: Debug.ThrowError("ShaderModel", string.Format("Failed to compile {0} shader: Errors: {1}", shaderType == ShaderTypes.VS ? "vs" : "ps", errorText)); break; } } catch (Exception e) { Dispose(); throw e; } }
public static IDepthStencilState New(VideoTypes videoType, IDisposableResource parent, IDepthStencilStateDesc desc) { IDepthStencilState api = null; #if WIN32 if (videoType == VideoTypes.D3D9) { api = new D3D9.DepthStencilState(parent, desc); } #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) { api = new D3D11.DepthStencilState(parent, desc); } #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) { api = new OpenGL.DepthStencilState(parent, desc); } #endif #if XNA if (videoType == VideoTypes.XNA) { api = new XNA.DepthStencilState(parent, desc); } #endif #if VITA if (videoType == VideoTypes.Vita) { api = new Vita.DepthStencilState(parent, desc); } #endif if (api == null) { Debug.ThrowError("DepthStencilStateAPI", "Unsuported InputType: " + videoType); } return(api); }
public static IViewPort New(VideoTypes videoType, IDisposableResource parent, Point2 location, Size2 size) { IViewPort api = null; #if WIN32 if (videoType == VideoTypes.D3D9) { api = new D3D9.ViewPort(parent, location, size); } #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) { api = new D3D11.ViewPort(parent, location, size); } #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) { api = new OpenGL.ViewPort(parent, location, size); } #endif #if XNA if (videoType == VideoTypes.XNA) { api = new XNA.ViewPort(parent, location, size); } #endif #if VITA if (videoType == VideoTypes.Vita) { api = new Vita.ViewPort(parent, location, size); } #endif if (api == null) { Debug.ThrowError("ViewPortAPI", "Unsuported InputType: " + videoType); } return(api); }
public static ITexture2D New(VideoTypes videoType, IDisposableResource parent, Image image, int width, int height, bool generateMipmaps, MultiSampleTypes multiSampleType, SurfaceFormats surfaceFormat, RenderTargetUsage renderTargetUsage, BufferUsages usage, Loader.LoadedCallbackMethod loadedCallback) { ITexture2D api = null; #if WIN32 if (videoType == VideoTypes.D3D9) { api = new D3D9.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); } #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) { api = new D3D11.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); } #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) { api = new OpenGL.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); } #endif #if XNA if (videoType == VideoTypes.XNA) { api = new XNA.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); } #endif #if VITA if (videoType == VideoTypes.Vita) { api = new Vita.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback); } #endif if (api == null) { Debug.ThrowError("Texture2DAPI", "Unsuported InputType: " + videoType); } return(api); }
public static IMouse New(InputTypes inputType, IDisposableResource parent) { IMouse api = null; #if WIN32 if (inputType == InputTypes.WinForms) { api = new WinForms.Mouse(parent); } #endif #if WINRT if (inputType == InputTypes.WinRT) { api = new WinRT.Mouse(parent); } #endif #if OSX if (inputType == InputTypes.Cocoa) { api = new Cocoa.Mouse(parent); } #endif #if LINUX if (inputType == InputTypes.X11) { api = new X11.Mouse(parent); } #endif #if NaCl if (inputType == InputTypes.NaCl) { api = new NaCl.Mouse(parent); } #endif if (api == null) { Debug.ThrowError("MouseAPI", "Unsuported InputType: " + inputType); } return(api); }
public static IQuickDraw New(VideoTypes videoType, IDisposableResource parent, IBufferLayoutDesc desc) { IQuickDraw api = null; #if WIN32 if (videoType == VideoTypes.D3D9) { api = new D3D9.QuickDraw(parent, desc); } #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) { api = new D3D11.QuickDraw(parent, desc); } #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) { api = new OpenGL.QuickDraw(parent, desc); } #endif #if XNA if (videoType == VideoTypes.XNA) { api = new XNA.QuickDraw(parent, desc); } #endif #if VITA if (videoType == VideoTypes.Vita) { api = new Vita.QuickDraw(parent, desc); } #endif if (api == null) { Debug.ThrowError("QuickDrawAPI", "Unsuported InputType: " + videoType); } return(api); }
public static IVertexBuffer New(VideoTypes videoType, IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, VertexBufferTopologys topology, float[] vertices, int[] indices) { IVertexBuffer api = null; #if WIN32 if (videoType == VideoTypes.D3D9) { api = new D3D9.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); } #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) { api = new D3D11.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); } #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) { api = new OpenGL.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); } #endif #if XNA if (videoType == VideoTypes.XNA) { api = new XNA.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); } #endif #if VITA if (videoType == VideoTypes.Vita) { api = new Vita.VertexBuffer(parent, bufferLayoutDesc, usage, topology, vertices, indices); } #endif if (api == null) { Debug.ThrowError("VertexBufferAPI", "Unsuported InputType: " + videoType); } return(api); }
public DepthStencilState(IDisposableResource parent, IDepthStencilStateDesc desc) : base(parent) { try { var video = parent.FindParentOrSelfWithException<Video>(); com = new DepthStencilStateCom(); var error = com.Init(video.com, ((DepthStencilStateDesc)desc).com); if (error == DepthStencilStateError.DepthStencil) Debug.ThrowError("DepthStencil", "Failed to create DepthStencil"); } catch (Exception e) { Dispose(); throw e; } }
public IndexBuffer(IDisposableResource parent, BufferUsages usage, int[] indices) : base(parent, usage, indices) { try { var video = parent.FindParentOrSelfWithException<Video>(); com = new IndexBufferCom(video.com); var bufferUsage = (usage == BufferUsages.Write) ? REIGN_D3D11_USAGE.DYNAMIC : REIGN_D3D11_USAGE.DEFAULT; var cpuUsage = (usage == BufferUsages.Write) ? REIGN_D3D11_CPU_ACCESS_FLAG.WRITE : (REIGN_D3D11_CPU_ACCESS_FLAG)0; var error = com.Init(indices, indexCount, indexByteSize, bufferUsage, cpuUsage, _32BitIndices); if (error == IndexBufferErrors.Buffer) Debug.ThrowError("IndexBuffer", "Failed to create Buffer"); } catch (Exception e) { Dispose(); throw e; } }
public SoundWAV(IDisposableResource parent, string filename, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback) : base(parent) { new StreamLoader(filename, delegate(object sender, bool succeeded) { if (succeeded) { init(parent, ((StreamLoader)sender).LoadedStream, instanceCount, looped, loadedCallback); } else { FailedToLoad = true; Dispose(); if (loadedCallback != null) loadedCallback(this, false); } }); }
public Font(IDisposableResource parent, IShader shader, ITexture2D texture, string metricsFileName, Loader.LoadedCallbackMethod loadedCallback) : base(parent) { new StreamLoader(metricsFileName, delegate(object sender, bool succeeded) { if (succeeded) { init(shader, texture, ((StreamLoader)sender).LoadedStream, metricsFileName, loadedCallback); } else { FailedToLoad = true; Dispose(); if (loadedCallback != null) loadedCallback(this, false); } }); }
public BlendState(IDisposableResource parent, IBlendStateDesc desc) : base(parent) { try { var video = parent.FindParentOrSelfWithException<Video>(); com = new BlendStateCom(); var error = com.Init(video.com, ((BlendStateDesc)desc).com); if (error == BlendStateError.BlendState) Debug.ThrowError("BlendState", "Failed to create BlendState"); } catch (Exception e) { Dispose(); throw e; } }