aybe's picture

GL.GetAttachedShaders overload is bloated

Project:The Open Toolkit library
Version:1.0-2010-10-06
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:open
Description

At least one overload should provide count parameter as int.

Here is all the code needed just for this :

        /// <summary>
        /// Returns IDs of attached shaders.
        /// </summary>
        public unsafe int[] AttachedShaders
        {
            get
            {
                // Get number of attached shaders
                int maxCount;
                GL.GetProgram(_id, ProgramParameter.AttachedShaders, out maxCount);
 
                // Get IDs of attached shaders
                IntPtr ptr = Marshal.AllocHGlobal(sizeof(int));
                void* pointer = ptr.ToPointer();
                int* count = (int*)pointer;
                int written;
 
                int[] shaders = new int[maxCount];
                GL.GetAttachedShaders(_id, maxCount, count, shaders);
 
                // Get the number of IDs written
                written = *count;
 
                Marshal.FreeHGlobal(ptr);
 
                return shaders;
            }
        }

Thread I opened first on forum : Using GL.GetAttachedShaders

Thanks !