Dispose() public method

Explicitly dispose the object
public Dispose ( ) : void
return void
Example #1
0
            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Load both the vertex and fragment shaders from custom streams
            ///
            /// This function can load both the vertex and the fragment
            /// shaders, or only one of them: pass NULL if you don't want to load
            /// either the vertex shader or the fragment shader.
            /// The sources must be valid shaders in GLSL language. GLSL is
            /// a C-like language dedicated to OpenGL shaders; you'll
            /// probably need to read a good documentation for it before
            /// writing your own shaders.
            /// </summary>
            /// <param name="vertexShaderStream">Source stream to read the vertex shader from, or null to skip this shader</param>
            /// <param name="fragmentShaderStream">Source stream to read the fragment shader from, or null to skip this shader</param>
            /// <exception cref="LoadingFailedException" />
            ////////////////////////////////////////////////////////////
            public Shader(Stream vertexShaderStream, Stream fragmentShaderStream) :
                base(IntPtr.Zero)
            {
                if ((fragmentShaderStream != null) || (vertexShaderStream != null))
                {
                    if (fragmentShaderStream == null)
                    {
                        StreamAdaptor vertexAdaptor = new StreamAdaptor(vertexShaderStream);
                        CPointer = sfShader_createFromStream(vertexAdaptor.InputStreamPtr, IntPtr.Zero);
                        vertexAdaptor.Dispose();
                    }
                    else if (vertexShaderStream == null)
                    {
                        StreamAdaptor fragmentAdaptor = new StreamAdaptor(fragmentShaderStream);
                        CPointer = sfShader_createFromStream(IntPtr.Zero, fragmentAdaptor.InputStreamPtr);
                        fragmentAdaptor.Dispose();
                    }
                    else
                    {
                        StreamAdaptor vertexAdaptor = new StreamAdaptor(vertexShaderStream);
                        StreamAdaptor fragmentAdaptor = new StreamAdaptor(fragmentShaderStream);
                        CPointer = sfShader_createFromStream(vertexAdaptor.InputStreamPtr, fragmentAdaptor.InputStreamPtr);
                        vertexAdaptor.Dispose();
                        fragmentAdaptor.Dispose();
                    }
                }

                if (CPointer == IntPtr.Zero)
                    throw new LoadingFailedException("shader");
            }
Example #2
0
            ////////////////////////////////////////////////////////////
            /// <summary>
            /// Load both the vertex and fragment shaders from custom streams
            ///
            /// This function can load both the vertex and the fragment
            /// shaders, or only one of them: pass NULL if you don't want to load
            /// either the vertex shader or the fragment shader.
            /// The sources must be valid shaders in GLSL language. GLSL is
            /// a C-like language dedicated to OpenGL shaders; you'll
            /// probably need to read a good documentation for it before
            /// writing your own shaders.
            /// </summary>
            /// <param name="vertexShaderStream">Source stream to read the vertex shader from, or null to skip this shader</param>
            /// <param name="fragmentShaderStream">Source stream to read the fragment shader from, or null to skip this shader</param>
            /// <exception cref="LoadingFailedException" />
            ////////////////////////////////////////////////////////////
            public Shader(Stream vertexShaderStream, Stream fragmentShaderStream) :
                base(IntPtr.Zero)
            {
                StreamAdaptor vertexAdaptor = new StreamAdaptor(vertexShaderStream);
                StreamAdaptor fragmentAdaptor = new StreamAdaptor(fragmentShaderStream);
                SetThis(sfShader_createFromStream(vertexAdaptor.InputStreamPtr, fragmentAdaptor.InputStreamPtr));
                vertexAdaptor.Dispose();
                fragmentAdaptor.Dispose();

                if (CPointer == IntPtr.Zero)
                    throw new LoadingFailedException("shader");
            }