コード例 #1
0
ファイル: Context.cs プロジェクト: rboissel/ratchet-opengl
        internal void DeleteProgram(glProgram Program)
        {
            int programHandle = Program.Handle;

            lock (this)
            {
#if NET_STANDARD_13
                _glDeleteProgram(programHandle);
#else
                if (_CurrentThreadId == Thread.CurrentThread.ManagedThreadId)
                {
                    _glDeleteProgram(programHandle);
                }
                else
                {
                    if (_PendingProgramDeleteCount == _PendingProgramDelete.Length)
                    {
                        Array.Resize <int>(ref _PendingProgramDelete, _PendingProgramDelete.Length * 2);
                    }
                    _PendingProgramDelete[_PendingProgramDeleteCount] = programHandle;
                    _PendingProgramDeleteCount++;
                }
#endif
            }
        }
コード例 #2
0
ファイル: Context.cs プロジェクト: rboissel/ratchet-opengl
 internal int GetUniformLocation(glProgram Program, string Name)
 {
     byte[] NameData       = System.Text.UTF8Encoding.UTF8.GetBytes(Name);
     byte[] ZeroTerminated = new byte[NameData.Length + 1];
     for (int n = 0; n < NameData.Length; n++)
     {
         ZeroTerminated[n] = NameData[n];
     }
     ZeroTerminated[ZeroTerminated.Length - 1] = 0;
     fixed(byte *pNameData = &ZeroTerminated[0])
     {
         return(_glGetUniformLocation(Program.Handle, new IntPtr(pNameData)));
     }
 }
コード例 #3
0
ファイル: Context.cs プロジェクト: rboissel/ratchet-opengl
 internal void BindAttribLocation(glProgram Program, int Index, string Name)
 {
     byte[] NameData       = System.Text.UTF8Encoding.UTF8.GetBytes(Name);
     byte[] ZeroTerminated = new byte[NameData.Length + 1];
     for (int n = 0; n < NameData.Length; n++)
     {
         ZeroTerminated[n] = NameData[n];
     }
     ZeroTerminated[ZeroTerminated.Length - 1] = 0;
     fixed(byte *pNameData = &ZeroTerminated[0])
     {
         _glBindAttribLocation(Program.Handle, Index, new IntPtr(pNameData));
     }
 }
コード例 #4
0
ファイル: Context.cs プロジェクト: rboissel/ratchet-opengl
        internal void LinkProgram(glProgram Program)
        {
            _glLinkProgram(Program.Handle);
            int linkStatus = 0;

            _glGetProgramiv(Program.Handle, (int)glProgram.SymbolicName.GL_LINK_STATUS, new IntPtr(&linkStatus));
            if (linkStatus == 0)
            {
                int logSize = 0;
                _glGetProgramiv(Program.Handle, (int)glProgram.SymbolicName.GL_INFO_LOG_LENGTH, new IntPtr(&logSize));
                if (logSize <= 0)
                {
                    throw new Exception("Failed to link the program");
                }
                IntPtr infoLogBuffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(logSize);
                if (infoLogBuffer.ToInt64() == 0)
                {
                    throw new Exception("Failed to link the program");
                }
                string log = "";
                try
                {
                    IntPtr sizeTLogSize = new IntPtr(logSize);
                    _glGetProgramInfoLog(Program.Handle, sizeTLogSize, new IntPtr(&sizeTLogSize), infoLogBuffer);
                    if (sizeTLogSize.ToInt32() > 0)
                    {
                        byte * pLog = (byte *)infoLogBuffer.ToPointer();
                        byte[] data = new byte[sizeTLogSize.ToInt32()];
                        for (int n = 0; n < data.Length && *pLog != 0; n++)
                        {
                            data[n] = *pLog;
                            pLog++;
                        }
                        log = System.Text.Encoding.UTF8.GetString(data);
                    }
                }
                finally
                {
                    System.Runtime.InteropServices.Marshal.FreeHGlobal(infoLogBuffer);
                }

                throw new Exception("Failed to link the program: " + log);
            }
        }
コード例 #5
0
ファイル: Context.cs プロジェクト: rboissel/ratchet-opengl
 internal void UseProgram(glProgram Program)
 {
     _glUseProgram(Program.Handle);
 }
コード例 #6
0
ファイル: Context.cs プロジェクト: rboissel/ratchet-opengl
 internal void AttachShader(glProgram Program, glShader Shader)
 {
     _glAttachShader(Program.Handle, Shader.Handle);
 }