Esempio n. 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");
                }
            }
Esempio n. 2
0
        /// <summary>
        /// Handle the destruction of the object
        /// </summary>
        /// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
        protected override void OnDispose(bool disposing)
        {
            if (disposing)
            {
                _stream?.Dispose();
            }

            sfMusic_destroy(CPointer);
        }
Esempio n. 3
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");
            }