Exemple #1
0
        void SetPixels(byte[] pixels)
        {
            unsafe
            {
                fixed(byte *p = &pixels[0])
                Glfw_HelperFunctions.__SetGlfwImagePixels(Handle, Width, Height, p, pixels.Length);

                this.Pixels = pixels;
            }
        }
Exemple #2
0
 public GLFWImage(int width, int height, byte[] pixeldata)
 {
     if (pixeldata.Length != (width * height) * 4)
     {
         throw new ArgumentException($"Expected a pixel array of size {(width * height) * 4} but got {pixeldata.Length}. " +
                                     $"The pixels need to be 4 byte each. 1 byte per color channel (R,G,B,A). The pixeldata array needs to be width * height * 4 in length.");
     }
     Handle = Glfw_HelperFunctions.__CreateGlfwImage();
     Width  = width;
     Height = height;
     SetPixels(pixeldata);
 }
Exemple #3
0
 internal GLFWVideoMode(IntPtr handle)
 {
     Handle = handle;
     Glfw_HelperFunctions.__GetVideoModeValues(handle,
                                               out int width,
                                               out int height, out int red, out int green, out int blue, out int refresh);
     Width       = width;
     Height      = height;
     RedBits     = red;
     GreenBits   = green;
     BlueBits    = blue;
     RefreshRate = refresh;
 }
Exemple #4
0
        void __GetValues()
        {
            //probably not the best way of doing things but it should do the trick,
            //this isn't something that should be called often anyways.
            unsafe
            {
                Glfw_HelperFunctions.__GetGammaRampValues(Handle, out ushort *r, out ushort *g, out ushort *b, out uint size);
                red   = new ushort[size];
                green = new ushort[size];
                blue  = new ushort[size];

                for (int i = 0; i < this.size; i++)
                {
                    red[i]   = r[i];
                    green[i] = g[i];
                    blue[i]  = b[i];
                }
            }
        }
Exemple #5
0
        public void SetValues(ushort[] red, ushort[] blue, ushort[] green)
        {
            if (red.Length != blue.Length && red.Length != green.Length)
            {
                throw new ArgumentException("The arrays need to be of the same size");
            }

            this.red   = red;
            this.green = green;
            this.blue  = blue;
            size       = (uint)red.Length;
            unsafe
            {
                fixed(ushort *r = &red[0])
                fixed(ushort *g = &green[0])
                fixed(ushort *b = &blue[0])
                Glfw_HelperFunctions.__UpdateGammaRampValues(Handle, r, g, b, size);
            }
        }
Exemple #6
0
        internal static unsafe GLFWVideoMode[] __LoadVideoModes(GLFWMonitor monitor, out GLFWVideoMode activeMode)
        {
            IntPtr *nptrArr = Glfw_HelperFunctions.__GetVideoModes(monitor.Handle, out int count);
            IntPtr  active  = Glfw.__GetVideoMode(monitor.Handle);

            GLFWVideoMode[] modeArr = new GLFWVideoMode[count];
            activeMode = null;

            for (int i = 0; i < count; i++)
            {
                modeArr[i] = new GLFWVideoMode(nptrArr[i]);
                if (nptrArr[i].Equals(active))
                {
                    activeMode = modeArr[i];
                }
            }

            //Cleanup the array we created to store the pointers to the videomodes.
            Glfw_HelperFunctions.__DeleteVideoModeArr(nptrArr);

            return(modeArr);
        }
Exemple #7
0
 internal GLFWgammaramp()
 {
     nativeHandle = Glfw_HelperFunctions.__CreateGammaRamp();
 }