Exemplo n.º 1
0
        public Pixel(PixelLayout layout, PixelComponentType pType, ColorRGBA color)
        {
            Layout = layout;
            ComponentType = pType;

            SetColor(color);
        }
Exemplo n.º 2
0
        protected PixelAccessor(int width, int height, PixelLayout layout, PixelComponentType pType, PixmapOrientation orientation,
            IntPtr pixelPointer)
        {
            PixRectInfo = new PixelRectangleInfo(width, height, layout, pType, orientation, 1);

            fPixelPointer = pixelPointer;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Construct a EmptyTechnique.
 /// </summary>
 /// <param name="texture">
 /// The <see cref="Texture1d"/> affected by this Technique.
 /// </param>
 /// <param name="level">
 /// The specific level of the target to define. Defaults to zero.
 /// </param>
 /// <param name="pixelFormat">
 /// The texture pixel format.
 /// </param>
 /// <param name="width">
 /// The width of the texture.
 /// </param>
 public EmptyTechnique(Texture1d texture, uint level, PixelLayout pixelFormat, uint width) :
     base(texture)
 {
     _Texture1d   = texture;
     _Level       = level;
     _PixelFormat = pixelFormat;
     _Width       = width;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Construct a EmptyTechnique.
 /// </summary>
 /// <param name="target">
 /// A <see cref="TextureTarget"/> that specify the texture target.
 /// </param>
 /// <param name="pixelFormat">
 /// The texture pixel format.
 /// </param>
 /// <param name="width">
 /// The width of the texture.
 /// </param>
 /// <param name="height">
 /// The height of the texture.
 /// </param>
 /// <param name="depth">
 /// The depth of the texture.
 /// </param>
 public EmptyTechnique(TextureTarget target, PixelLayout pixelFormat, uint width, uint height, uint depth)
 {
     Target      = target;
     PixelLayout = pixelFormat;
     Width       = width;
     Height      = height;
     Depth       = depth;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a TextureArray2D, defining the texture size (for level 0) and the internal format.
 /// </summary>
 /// <param name="width">
 /// A <see cref="UInt32"/> that specify the texture width, in pixels.
 /// </param>
 /// <param name="height">
 /// A <see cref="UInt32"/> that specify the texture height, in pixels.
 /// </param>
 /// <param name="layers">
 /// A <see cref="UInt32"/> that specify the number of layers defining the texture array.
 /// </param>
 /// <param name="format">
 /// A <see cref="PixelLayout"/> determining the texture internal format.
 /// </param>
 /// <param name="levels">
 /// A <see cref="UInt32"/> that specifies the number of mipmap levels to define.
 /// </param>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> or <paramref name="levels"/> is zero.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="format"/> equals to <see cref="PixelLayout.None"/>.
 /// </exception>
 /// <exception cref="InvalidOperationException">
 /// Exception thrown if no context is current to the calling thread.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
 /// the maximum allowed for 2D textures.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
 /// is not a power-of-two value.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="format"/> is not a supported internal format.
 /// </exception>
 public void Create(uint width, uint height, uint layers, PixelLayout format, uint levels)
 {
     if (Immutable == false)
     {
         throw new InvalidOperationException("must be immutable");
     }
     SetTechnique(new ImmutableEmptyTechnique(this, TextureTarget, format, width, height, layers, levels));
 }
Exemplo n.º 6
0
 //Constructor
 public FormatPrefs()
 {
     unchecked {
         pixelLayout = (PixelLayout)0;
         useMipmaps  = MipMapFormat.MIP_FMT_DEFAULT;
         alphaFormat = AlphaFormat.ALPHA_DEFAULT;
     }
 }
Exemplo n.º 7
0
        public void Create(PixelLayout internalFormat, uint size)
        {
            // Setup texture information
            mSize = size;

            // Setup technique for creation
            SetTechnique(new EmptyTechnique(internalFormat, size));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create a Texture1d, defining the texture extents and the internal format.
        /// </summary>
        /// <param name="width">
        /// A <see cref="UInt32"/> that specify the texture width.
        /// </param>
        /// <param name="format">
        /// A <see cref="PixelLayout"/> determining the texture internal format.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> is zero.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> equals to <see cref="PixelLayout.None"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> is greater than the maximum allowed for 1D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> is not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> is not a supported internal format.
        /// </exception>
        public void Create(uint width, PixelLayout format)
        {
            // Setup texture information
            PixelLayout = format;
            _Width      = width;

            // Setup technique for creation
            SetTechnique(new EmptyTechnique(format, width));
        }
Exemplo n.º 9
0
 public override void Edit(PixelLayout control)
 {
     using var dialog = new ReferenceDialog(PipelineController.Instance, (Value as List <string>).ToArray());
     if (dialog.ShowModal(control) && _eventHandler != null)
     {
         _eventHandler(dialog.References, EventArgs.Empty);
         PipelineController.Instance.OnReferencesModified();
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Construct a ImmutableEmptyTechnique.
 /// </summary>
 /// <param name="texture">
 /// The <see cref="Texture2D"/> affected by this Technique.
 /// </param>
 /// <param name="target">
 /// A <see cref="TextureTarget"/> that specify the texture target.
 /// </param>
 /// <param name="pixelFormat">
 /// The texture pixel format.
 /// </param>
 /// <param name="width">
 /// The width of the texture.
 /// </param>
 /// <param name="height">
 /// The height of the texture.
 /// </param>
 /// <param name="levels">
 /// A <see cref="UInt32"/> that specify the number of levels defining the texture.
 /// </param>
 public ImmutableEmptyTechnique(Texture2D texture, TextureTarget target, PixelLayout pixelFormat, uint width, uint height, uint levels) :
     base(texture, target, 0, pixelFormat, width, height)
 {
     if (levels == 0)
     {
         throw new ArgumentException("invalid value", "levels");
     }
     _MipmapLevels = levels;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Create Texture2d data, defining only the extents and the internal format.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for creating this Texture.
        /// </param>
        /// <param name="width">
        /// A <see cref="UInt32"/> that specify the texture width.
        /// </param>
        /// <param name="height">
        /// A <see cref="UInt32"/> that specify the texture height.
        /// </param>
        /// <param name="format">
        /// A <see cref="PixelLayout"/> determining the texture internal format.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> equals to <see cref="PixelLayout.None"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if <paramref name="ctx"/> is null and no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
        /// the maximum allowed for 2D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by <paramref name="ctx"/>, and <paramref name="width"/> or <paramref name="height"/>
        /// is not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> is not a supported internal format.
        /// </exception>
        public void Create(GraphicsContext ctx, uint width, uint height, PixelLayout format, uint levels)
        {
            CheckCurrentContext(ctx);

            // Define technique
            Create(width, height, format, levels);
            // Actually create texture
            Create(ctx);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Create a Texture2D, defining the texture extents and the internal format.
        /// </summary>
        /// <param name="width">
        /// A <see cref="UInt32"/> that specify the texture width.
        /// </param>
        /// <param name="height">
        /// A <see cref="UInt32"/> that specify the texture height.
        /// </param>
        /// <param name="format">
        /// A <see cref="PixelLayout"/> determining the texture internal format.
        /// </param>
        /// <param name="level">
        /// A <see cref="UInt32"/> that specify the texture level to create/update.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> equals to <see cref="PixelLayout.None"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
        /// the maximum allowed for 2D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
        /// is not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> is not a supported internal format.
        /// </exception>
        public void Create(uint width, uint height, uint level, PixelLayout format)
        {
            if (ImmutableFix)
            {
                throw new InvalidOperationException("immutable storage (see GL_ARB_texture_storage)");
            }

            SetTechnique(new EmptyTechnique(this, TextureTarget, level, format, width, height));
        }
Exemplo n.º 13
0
        public override void Edit(PixelLayout control)
        {
            var dialog = new PathDialog(PipelineController.Instance, Value.ToString());

            if (dialog.Show(control) && _eventHandler != null)
            {
                _eventHandler(dialog.Path, EventArgs.Empty);
            }
        }
Exemplo n.º 14
0
        public override void Edit(PixelLayout control)
        {
            var dialog = new ReferenceDialog(PipelineController.Instance, (Value as List <string>).ToArray());

            if (dialog.Run(control) == DialogResult.Ok && _eventHandler != null)
            {
                _eventHandler(dialog.References, EventArgs.Empty);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Construct a PixelLayoutInfo for a pixel format.
        /// </summary>
        /// <param name="pType">
        /// A <see cref="PixelLayout"/> that specify the pixel type (unique characteristic). All required information
        /// is retrieved using attributes of the enumeration field.
        /// </param>
        public PixelLayoutInfo(PixelLayout pType)
        {
            if (pType == PixelLayout.None)
            {
                throw new ArgumentException("invalid pixel type " + pType, "pType");
            }

            Type pixelType = typeof(PixelLayout);

            PixelColorspaceAttribute colorSpaceAttribute      = (PixelColorspaceAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelColorspaceAttribute));
            PixelComponentsAttribute colorComponentsAttribute = (PixelComponentsAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelComponentsAttribute));
            PixelPlanesAttribute     colorPlanesAttribute     = (PixelPlanesAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelPlanesAttribute));
            PixelPrecisionAttribute  colorPrecisionAttribute  = (PixelPrecisionAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelPrecisionAttribute));
            PixelNonLinearAttribute  colorNonLinearAttribute  = (PixelNonLinearAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelNonLinearAttribute));
            PixelStructureAttribute  structAttribute          = (PixelStructureAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelStructureAttribute));

            if (colorSpaceAttribute == null)
            {
                throw new InvalidOperationException(String.Format("pixel format {0} does not declare PixelColorspaceAttribute"));
            }
            if ((colorComponentsAttribute == null) && (colorPlanesAttribute == null))
            {
                throw new InvalidOperationException(String.Format("pixel format {0} does not declare PixelComponentsAttribute or PixelPlanesAttribute"));
            }
            if (colorPrecisionAttribute == null)
            {
                throw new InvalidOperationException(String.Format("pixel format {0} does not declare PixelPrecisionAttribute"));
            }

            // Store type
            DataFormat = pType;
            // Store color space
            ColorSpace = colorSpaceAttribute.PixelSpace;
            // Store components bits
            ComponentsCount = 0;
            ChromaXRatio    = ChromaYRatio = 0;

            if (colorComponentsAttribute != null)
            {
                ComponentsCount = colorComponentsAttribute.PixelComponents;
                ChromaXRatio    = ChromaYRatio = 1;
            }
            if (colorPlanesAttribute != null)
            {
                ComponentsCount = colorPlanesAttribute.PixelPlanes;
                ChromaXRatio    = colorPlanesAttribute.XRatio;
                ChromaYRatio    = colorPlanesAttribute.YRatio;
            }

            PixelBits  = colorPrecisionAttribute.PixelBits;
            PixelBytes = (byte)(((PixelBits + 7) / 8) & 0xFF);

            Linear = colorNonLinearAttribute == null;

            _PixelStructType = (structAttribute != null) ? structAttribute.PixelStructureType : null;
        }
Exemplo n.º 16
0
        Control PixelLayout()
        {
            var control = new PixelLayout();

            control.Add(new TextArea
            {
                Text = "Some text that is contained in a pixel layout."
            }, Point.Empty);
            return(control);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Create a Texture2d, defining the texture extents and the internal format.
        /// </summary>
        /// <param name="width">
        /// A <see cref="UInt32"/> that specify the texture width.
        /// </param>
        /// <param name="height">
        /// A <see cref="UInt32"/> that specify the texture height.
        /// </param>
        /// <param name="format">
        /// A <see cref="PixelLayout"/> determining the texture internal format.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> equals to <see cref="PixelLayout.None"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
        /// the maximum allowed for 2D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
        /// is not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> is not a supported internal format.
        /// </exception>
        public void Create(uint width, uint height, PixelLayout format)
        {
            // Setup texture information
            PixelLayout = format;
            _Width      = width;
            _Height     = height;

            // Setup technique for creation
            SetTechnique(new EmptyTechnique(TextureTarget, format, width, height));
        }
Exemplo n.º 18
0
 public PixelRectangleInfo(int width, int height, PixelLayout layout, PixelComponentType compType, PixmapOrientation orient, int alignment)
 {
     Width = width;
     Height = height;
     Layout = layout;
     ComponentType = compType;
     Orientation = orient;
     Alignment = alignment;
     BytesPerRow = GetBytesPerRow();
 }
Exemplo n.º 19
0
        public void Create(GraphicsContext ctx, PixelLayout internalFormat, uint size)
        {
            // Setup texture information
            mSize = size;

            // Setup technique for creation
            SetTechnique(new EmptyTechnique(internalFormat, size));
            // Actually create texture
            Create(ctx);
        }
Exemplo n.º 20
0
        public NiSourceTexture(NiFile niFile) : base(niFile)
        {
            useExternal = niFile.Reader.ReadByte();
            FileName    = niFile.Reader.ReadLengthPrefixedString();
            pixelLayout = (PixelLayout)niFile.Reader.ReadInt32();
            useMipMaps  = (MipMapFormat)niFile.Reader.ReadInt32();
            alphaFormat = (AlphaFormat)niFile.Reader.ReadInt32();

            isStatic = niFile.Reader.ReadByte();
        }
Exemplo n.º 21
0
 /// <summary>
 /// Construct a EmptyTechnique.
 /// </summary>
 /// <param name="texture">
 /// The <see cref="TextureArray2d"/> affected by this Technique.
 /// </param>
 /// <param name="target">
 /// A <see cref="TextureTarget"/> that specify the texture target.
 /// </param>
 /// <param name="pixelFormat">
 /// The texture pixel format.
 /// </param>
 /// <param name="width">
 /// The width of the texture.
 /// </param>
 /// <param name="height">
 /// The height of the texture.
 /// </param>
 /// <param name="layers">
 /// A <see cref="UInt32"/> that specify the number of layers defining the texture array.
 /// </param>
 public EmptyTechnique(TextureArray2d texture, TextureTarget target, PixelLayout pixelFormat, uint width, uint height, uint layers) :
     base(texture)
 {
     _TextureArray2d = texture;
     _Target         = target;
     _PixelFormat    = pixelFormat;
     _Width          = width;
     _Height         = height;
     _Layers         = layers;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Construct a EmptyTechnique.
 /// </summary>
 /// <param name="texture">
 /// The <see cref="Texture2d"/> affected by this Technique.
 /// </param>
 /// <param name="target">
 /// A <see cref="TextureTarget"/> that specify the texture target.
 /// </param>
 /// <param name="level">
 /// The specific level of the target to be defined.
 /// </param>
 /// <param name="pixelFormat">
 /// The texture pixel format.
 /// </param>
 /// <param name="width">
 /// The width of the texture.
 /// </param>
 /// <param name="height">
 /// The height of the texture.
 /// </param>
 public EmptyTechnique(Texture2d texture, TextureTarget target, uint level, PixelLayout pixelFormat, uint width, uint height) :
     base(texture)
 {
     _Texture2d   = texture;
     _Target      = target;
     _Level       = level;
     _PixelFormat = pixelFormat;
     _Width       = width;
     _Height      = height;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Create Texture2d from a Image instance.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for creating this Texture. If it null, the current context
        /// will be used.
        /// </param>
        /// <param name="image">
        /// An <see cref="Image"/> holding the texture data.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception throw if <paramref name="image"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="image"/> pixel data is not allocated (i.e. image not defined).
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if <paramref name="ctx"/> is null and no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="image"/> width or height are greater than the maximum allowed for 2D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by <paramref name="ctx"/> (or the current context if <paramref name="ctx"/> is
        /// null), and <paramref name="image"/> width or height are not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="image"/> format (<see cref="Image.PixelFormat"/> is not a supported internal format.
        /// </exception>
        public void Create(GraphicsContext ctx, PixelLayout internalFormat, Image image, uint layer)
        {
            CheckCurrentContext(ctx);
            if (layer >= Depth)
            {
                throw new ArgumentOutOfRangeException("layer", "exceeding upper boundary");
            }

            SetTechnique(new ImageTechnique(this, TextureTarget, internalFormat, image, layer));
            Create(ctx);
        }
Exemplo n.º 24
0
        Control ExpandedHeight()
        {
            var layout = new PixelLayout();

            layout.Add(new Label {
                BackgroundColor = Colors.Red, Text = "Expanded Height"
            }, 50, 50);
            return(new Scrollable {
                ExpandContentWidth = false, Content = layout
            });
        }
Exemplo n.º 25
0
        Control Default()
        {
            var layout = new PixelLayout();

            layout.Add(new Label {
                BackgroundColor = Colors.Red, Text = "Expanded Width/Height (default)"
            }, 50, 50);

            defaultScrollable.Content = layout;
            return(defaultScrollable);
        }
Exemplo n.º 26
0
        public StatusPanel(Main parent, int width, int height)
        {
            main     = parent;
            Size     = new Size(width, height);
            eotWhite = true;

            // Main panel
            mainPanel = new Drawable()
            {
                Size = new Size(width, height)
            };
            mainPanel.Paint += MainPanel_Paint;

            MainPanelLayout = new PixelLayout()
            {
                Size = new Size(mainPanel.Width, mainPanel.Height)
            };

            // Stats panel
            statsPanel = new Drawable()
            {
                Size = new Size(240, 60)
            };
            statsPanel.Paint   += StatsPanel_Paint;
            statsPanel.MouseUp += Panel_Click;
            MainPanelLayout.Add(statsPanel, 11, 38);

            // Unit panel
            unitPanel = new Drawable()
            {
                Size = new Size(240, this.Height - 117)
            };
            unitPanel.Paint   += UnitPanel_Paint;
            unitPanel.MouseUp += Panel_Click;
            MainPanelLayout.Add(unitPanel, 11, 106);

            mainPanel.Content = MainPanelLayout;
            Content           = mainPanel;

            Game.OnMapEvent += MapEventHappened;
            //Main.OnMapEvent += MapEventHappened;
            //Game.OnWaitAtTurnEnd += InitiateWaitAtTurnEnd;
            Game.OnPlayerEvent += PlayerEventHappened;
            Game.OnUnitEvent   += UnitEventHappened;

            // Timer for "end of turn" message
            timer = new UITimer()
            {
                Interval = 0.5
            };
            timer.Elapsed += (sender, e) => unitPanel.Invalidate();

            SizeChanged += OnSizeChanged;
        }
Exemplo n.º 27
0
        public ColourPad(CharacterHandler handler)
        {
            this.Handler             = handler;
            this.Handler.ColourStart = start;

            this.Handler.DrawAttributeChanged += new EventHandler <EventArgs> (HandleColourChanged).MakeWeak((e) => this.Handler.DrawAttributeChanged -= e);

            this.Handler.CurrentPage.PaletteChanged += new EventHandler <EventArgs> (delegate {
                SetColours();
                UpdateButtons();
                Invalidate();
            }).MakeWeak((e) => this.Handler.CurrentPage.PaletteChanged -= e);

            var boxSize      = new Size(30, 30);
            int boxOffset    = 10;
            int boxesPadding = 10;
            int boxesOffset  = boxSize.Width + boxOffset + boxesPadding;

            max = 8;             //Math.Min (16, Palette.Count / 2);

            Size       = new Size(40, boxesOffset + (max * 18) + 16 + 17);
            foreground = new FBColourBox {
                Size = boxSize,
                Pad  = this
            };

            background = new FBColourBox {
                Size = boxSize,
                Pad  = this
            };

            SetColours();

            var layout = new PixelLayout();

            layout.Add(background, boxOffset, boxOffset);
            layout.Add(foreground, 0, 0);

            colours = new SelectColourBox[max * 2];

            for (int i = 0; i < max; i++)
            {
                CreateButton(layout, i, 2, boxesOffset + i * 18);
                CreateButton(layout, i + max, 22, boxesOffset + i * 18);
            }

            layout.Add(SelectButton(), 10, this.Size.Height - 16);
            layout.Add(UpButton(), 2, this.Size.Height - 16 - 15);
            layout.Add(DownButton(), 22, this.Size.Height - 16 - 15);

            Content = layout;

            UpdateButtons();
        }
Exemplo n.º 28
0
        Control ColourButtons()
        {
            var layout = new PixelLayout {
                Size = new Size(17, 17 * 2 + 4)
            };

            layout.Add(AddButton(), 0, 0);
            layout.Add(RemoveButton(), 0, 17 + 4);

            return(layout);
        }
Exemplo n.º 29
0
        void InitializeComponent()
        {
            Title           = "HVH.Client";
            BackgroundColor = Colors.White;
            Icon            = new Icon(Directory.GetCurrentDirectory() + "/assets/helmholtz_owl.ico");
            ClientSize      = new Size(280, 430);
            Resizable       = false;
            Minimizable     = false;
            Maximizable     = false;

            controls["logo"] = new ImageView {
                Image = Utility.LoadBitmap("assets/helmholtz_owl.png"), Size = new Size(200, -1)
            };
            controls["roomControl"] = new Button {
                Text = "Room Control", Size = new Size(240, 30), Enabled = Client.Instance?.Status.Type != UserType.Normal
            };
            controls["issueReport"] = new Button {
                Text = "Issue Reporting", Size = new Size(240, 30), Enabled = Client.Instance?.Status.Type != UserType.Normal
            };
            controls["adminPanel"] = new Button {
                Text = "Admin Panel", Size = new Size(240, 30), Enabled = Client.Instance?.Status.Type == UserType.Admin
            };
            controls["seperator"] = new ProgressBar
            {
                BackgroundColor = Colors.Black,
                Indeterminate   = false,
                Value           = 0,
                Size            = new Size(240, 1)
            };
            controls["logout"] = new Button {
                Text = "Logout", Size = new Size(240, 30)
            };

            // Events
            (controls["logout"] as Button).Click += delegate
            {
                Client.Instance.SendLogout();
            };
            (controls["roomControl"] as Button).Click += delegate
            {
                Application.Instance.MainForm = new RoomControlForm();
                Application.Instance.MainForm.Show();
                Visible = false;
            };
            PixelLayout layout = new PixelLayout();

            layout.Add(controls["logo"], 40, 10);
            layout.Add(controls["roomControl"], 20, 250);
            layout.Add(controls["issueReport"], 20, 290);
            layout.Add(controls["adminPanel"], 20, 330);
            layout.Add(controls["seperator"], 20, 370);
            layout.Add(controls["logout"], 20, 380);
            Content = layout;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Create a Texture3d, defining the texture extents and the internal format.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for creating this Texture.
        /// </param>
        /// <param name="width">
        /// A <see cref="UInt32"/> that specify the texture width.
        /// </param>
        /// <param name="height">
        /// A <see cref="UInt32"/> that specify the texture height.
        /// </param>
        /// <param name="depth">
        /// A <see cref="UInt32"/> that specify the texture depth.
        /// </param>
        /// <param name="format">
        /// A <see cref="PixelLayout"/> determining the texture internal format.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> equals to <see cref="PixelFormat.None"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
        /// the maximum allowed for 2D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
        /// is not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> is not a supported internal format.
        /// </exception>
        public void Create(GraphicsContext ctx, uint width, uint height, uint depth, PixelLayout format)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }

            // Define technique
            Create(width, height, depth, format);
            // Actually create texture
            Create(ctx);
        }
Exemplo n.º 31
0
        /// <summary>
        /// Create a Texture3d, defining the texture extents and the internal format.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for creating this Texture.
        /// </param>
        /// <param name="images">
        /// An array of <see cref="Image"/> that specify the texture data.
        /// </param>
        /// <param name="format">
        /// A <see cref="PixelLayout"/> determining the texture internal format.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="images"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="images"/> has no items, or every item hasn't the same width and height.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if width, height or depth is greater than the maximum allowed for 3D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by current context, and width, height or depth
        /// is not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="format"/> is not a supported internal format.
        /// </exception>
        public void Create(GraphicsContext ctx, Image[] images, PixelLayout format)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }

            // Define technique
            Create(images, format);
            // Actually create texture
            Create(ctx);
        }
Exemplo n.º 32
0
        public override void Edit(PixelLayout control)
        {
            var dialog = new ColorDialog();

            dialog.Color = color;

            if (dialog.ShowDialog(control) == DialogResult.Ok && _eventHandler != null && dialog.Color != color)
            {
                var col = new Microsoft.Xna.Framework.Color(dialog.Color.Rb, dialog.Color.Gb, dialog.Color.Bb, dialog.Color.Ab);
                _eventHandler(col, EventArgs.Empty);
            }
        }
Exemplo n.º 33
0
        void CreateButton(PixelLayout layout, int index, int x, int y)
        {
            var b = new SelectColourBox {
                Pad     = this,
                Size    = new Size(16, 16),
                Index   = index,
                Enabled = index < Palette.Count
            };

            colours[index] = b;
            layout.Add(b, x, y);
        }
Exemplo n.º 34
0
        public Pixel(PixelLayout layout, PixelComponentType pType, byte[] data, int startIndex)
        {
            Layout = layout;
            ComponentType = pType;

            int pixelLength = PixelInformation.GetBytesPerPixel(layout, pType); 

            // Allocate some space to hold the pixel data
            Data = new byte[pixelLength];

            // Copy the pixel data into the new space
            Array.Copy(data, startIndex, Data, 0, pixelLength);
        }
Exemplo n.º 35
0
		/// <summary>
		/// Construct a render buffer.
		/// </summary>
		/// <param name="type">
		/// A <see cref="Type"/> that specify the type of the buffer. This parameter
		/// influence the framebuffer attachment, and the possible formats.
		/// </param>
		/// <param name="internalFormat">
		/// A <see cref="PixelLayout"/> that specify the internal OpenGL format for this
		/// RenderBuffer. From OpenGL 3.2 specification:
		/// @verbatim
		/// Implementations are required to support the same internal formats for renderbuffers
		/// as the required formats for textures enumerated in section 3.8.1, with the exception
		/// of the color formats labelled “texture-only”. Requesting one of these internal
		/// formats for a renderbuffer will allocate at least the internal component sizes and
		/// exactly the component types shown for that format in tables 3.12- 3.13.
		/// @endverbatim
		/// </param>
		public RenderBuffer(Type type, PixelLayout internalFormat, uint w, uint h)
		{
			if (w >= GraphicsContext.CurrentCaps.Limits.MaxRenderBufferSize)
				throw new ArgumentException("exceed maximum size", "w");
			if (h >= GraphicsContext.CurrentCaps.Limits.MaxRenderBufferSize)
				throw new ArgumentException("exceed maximum size", "w");

			// Set buffer type
			_Type = type;
			// Store internal format
			_InternalFormat = internalFormat;
			_Width = w;
			_Height = h;
		}
Exemplo n.º 36
0
		/// <summary>
		/// Construct a PixelLayoutInfo for a pixel format.
		/// </summary>
		/// <param name="pType">
		/// A <see cref="PixelLayout"/> that specifies the pixel type (unique characteristic). All required information
		/// is retrieved using attributes of the enumeration field.
		/// </param>
		public PixelLayoutInfo(PixelLayout pType)
		{
			if (pType == PixelLayout.None)
				throw new ArgumentException("invalid pixel type " + pType, "pType");

			Type pixelType = typeof(PixelLayout);

			PixelColorspaceAttribute colorSpaceAttribute = (PixelColorspaceAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelColorspaceAttribute));
			PixelComponentsAttribute colorComponentsAttribute = (PixelComponentsAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelComponentsAttribute));
			PixelPlanesAttribute colorPlanesAttribute = (PixelPlanesAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelPlanesAttribute));
			PixelPrecisionAttribute colorPrecisionAttribute = (PixelPrecisionAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelPrecisionAttribute));
			PixelNonLinearAttribute colorNonLinearAttribute = (PixelNonLinearAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelNonLinearAttribute));
			PixelStructureAttribute structAttribute = (PixelStructureAttribute)Attribute.GetCustomAttribute(pixelType.GetField(Enum.GetName(pixelType, pType)), typeof(PixelStructureAttribute));

			if (colorSpaceAttribute == null)
				throw new InvalidOperationException(String.Format("pixel format {0} does not declare PixelColorspaceAttribute"));
			if ((colorComponentsAttribute == null) && (colorPlanesAttribute == null))
				throw new InvalidOperationException(String.Format("pixel format {0} does not declare PixelComponentsAttribute or PixelPlanesAttribute"));
			if (colorPrecisionAttribute == null)
				throw new InvalidOperationException(String.Format("pixel format {0} does not declare PixelPrecisionAttribute"));

			// Store type
			DataFormat = pType;
			// Store color space
			ColorSpace = colorSpaceAttribute.PixelSpace;
			// Store components bits
			ComponentsCount = 0;
			ChromaXRatio = ChromaYRatio = 0;

			if (colorComponentsAttribute != null) {
				ComponentsCount = colorComponentsAttribute.PixelComponents;
				ChromaXRatio = ChromaYRatio = 1;
			}
			if (colorPlanesAttribute != null) {
				ComponentsCount = colorPlanesAttribute.PixelPlanes;
				ChromaXRatio = colorPlanesAttribute.XRatio;
				ChromaYRatio = colorPlanesAttribute.YRatio;
			}

			PixelBits = colorPrecisionAttribute.PixelBits;
			PixelBytes = (byte)(((PixelBits + 7) / 8) & 0xFF);

			Linear = colorNonLinearAttribute == null;

			mPixelStructType = (structAttribute != null) ? structAttribute.PixelStructureType : null;
		}
		/// <summary>
		/// Surface format with specified color and depth (no stencil, no multisample, no double/stereo buffering).
		/// </summary>
		/// <param name="color">
		/// A <see cref="PixelLayout"/> that specify the format of the color buffer.
		/// </param>
		/// <param name="depth">
		/// A <see cref="UInt32"/> that specify the bit count of the depth buffer fragment.
		/// </param>
		/// <remarks>
		/// <para>
		/// The buffer configurations are considered required but degradable. If it necessary a specific resolution,
		/// define those configurations using the related <i>Define*</i> routine.
		/// </para>
		/// </remarks>
		public GraphicsBuffersFormat(PixelLayout color, uint depth)
		{
			DefineColorBuffer(color);
			DefineDepthBuffer(depth);
		}
Exemplo n.º 38
0
 public static void DrawPixels(int width, int height, PixelLayout format, PixelComponentType type, float[] pixels)
 {
     gl.glDrawPixels(width, height, (int)format, (int)type, pixels);
 }
Exemplo n.º 39
0
 public static void glReadPixels(int x, int y, int width, int height, PixelLayout format, PixelComponentType type, float[] pixels)
 {
     gl.glReadPixels(x, y, width, height, (int)format, (int)type, pixels);
 }
		/// <summary>
		/// Define RenderSurface color buffer. 
		/// </summary>
		/// <param name="pType">
		/// A <see cref="PixelLayout"/>
		/// </param>
		/// <param name="policy">
		/// A <see cref="BufferPolicy"/>
		/// </param>
		public void DefineColorSRGBBuffer(PixelLayout pType, BufferPolicy policy)
		{
			if (pType == PixelLayout.None)
				throw new ArgumentException("invalid pixel type", "pType");

			// Define buffer
			DefineBuffer(BufferType.ColorSRGB, policy);
			// Set color buffer bits.
			mColorType = pType;
		}
Exemplo n.º 41
0
			/// <summary>
			/// Construct a EmptyTechnique.
			/// </summary>
			/// <param name="target">
			/// A <see cref="TextureTarget"/> that specify the texture target.
			/// </param>
			/// <param name="pixelFormat">
			/// The texture pixel format.
			/// </param>
			/// <param name="width">
			/// The width of the texture.
			/// </param>
			/// <param name="height">
			/// The height of the texture.
			/// </param>
			/// <param name="depth">
			/// The depth of the texture.
			/// </param>
			public EmptyTechnique(TextureTarget target, PixelLayout pixelFormat, uint width, uint height, uint depth)
			{
				Target = target;
				PixelLayout = pixelFormat;
				Width = width;
				Height = height;
				Depth = depth;
			}
Exemplo n.º 42
0
		static void ConvertPixelFormat(System.Drawing.Bitmap bitmap, out PixelLayout to)
		{
			System.Drawing.Imaging.PixelFormat from = bitmap.PixelFormat;
			int flags = bitmap.Flags;

			bool sRGB = false;

#if false
			foreach (System.Drawing.Imaging.PropertyItem exifProperty in bitmap.PropertyItems) {
				switch (exifProperty.Id) {
					case ImageCodecPlugin.ExifTagColorSpace:
						ImageCodecPlugin.ExifColorSpace value = (ImageCodecPlugin.ExifColorSpace)BitConverter.ToUInt16(exifProperty.Value, 0);

						switch (value) {
							case ImageCodecPlugin.ExifColorSpace.sRGB:
								sRGB = true;
								break;
							default:
								break;
						}
						break;
					case ImageCodecPlugin.ExifTagGamma:
						UInt32 a1 = BitConverter.ToUInt32(exifProperty.Value, 0);
						UInt32 a2 = BitConverter.ToUInt32(exifProperty.Value, 4);
						Double gamma = (Double)a1 / (Double)a2;


						break;
				}
			}

#endif

			if        ((flags & (int)System.Drawing.Imaging.ImageFlags.ColorSpaceRgb) != 0) {
				ConvertPixelFormatRgb(from, out to, sRGB);
			} else if ((flags & (int)System.Drawing.Imaging.ImageFlags.ColorSpaceGray) != 0) {
				switch (from) {
					case System.Drawing.Imaging.PixelFormat.Format1bppIndexed:
					case System.Drawing.Imaging.PixelFormat.Format4bppIndexed:
					case System.Drawing.Imaging.PixelFormat.Format8bppIndexed:
						to = PixelLayout.GRAY8;
						break;
					case System.Drawing.Imaging.PixelFormat.Format16bppGrayScale:
						to = PixelLayout.GRAY16;
						break;
					case System.Drawing.Imaging.PixelFormat.Format32bppArgb:
						to = PixelLayout.BGRA32;
						break;
					default:
						throw new ArgumentException(String.Format("GRAY pixel format {0} not supported", from));
				}
				
			} else if ((flags & (int)System.Drawing.Imaging.ImageFlags.ColorSpaceYcck) != 0) {
				throw new ArgumentException(String.Format("YCCK pixel format {0} not supported", from));
			} else if ((flags & (int)System.Drawing.Imaging.ImageFlags.ColorSpaceYcbcr) != 0) {
				ConvertPixelFormatRgb(from, out to, sRGB);
			} else if ((flags & (int)System.Drawing.Imaging.ImageFlags.ColorSpaceCmyk) != 0) {
				throw new ArgumentException(String.Format("CMYK pixel format {0} not supported", from));
			} else {
				throw new ArgumentException(String.Format("not RGB/GRAY pixel format {0} not supported", from));
			}
		}
Exemplo n.º 43
0
		/// <summary>
		/// Create TextureRectangle data, defining only the extents and the internal format.
		/// </summary>
		/// <param name="width">
		/// A <see cref="UInt32"/> that specify the texture width.
		/// </param>
		/// <param name="height">
		/// A <see cref="UInt32"/> that specify the texture height.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> equals to <see cref="PixelFormat.None"/>.
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// Exception thrown if <paramref name="ctx"/> is null and no context is current to the calling thread.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
		/// the maximum allowed for 2D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by the current context and <paramref name="width"/>
		/// or <paramref name="height"/> is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public TextureRectangle(uint width, uint height, PixelLayout format) : base(width, height, format)
		{
			
		}
Exemplo n.º 44
0
		/// <summary>
		/// Create a Texture3d, defining the texture extents and the internal format.
		/// </summary>
		/// <param name="images">
		/// An array of <see cref="Image"/> that specify the texture data.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// Exception thrown if <paramref name="images"/> is null.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="images"/> has no items, or every item hasn't the same width and height.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if width, height or depth is greater than the maximum allowed for 3D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by current context, and width, height or depth 
		/// is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public void Create(Image[] images, PixelLayout format)
		{
			if (images == null)
				throw new ArgumentNullException("images");
			if (images.Length == 0)
				throw new ArgumentException("no images", "images");
			if (!Array.TrueForAll(images, delegate(Image item) { return (item != null); }))
				throw new ArgumentException("null item in image set", "images");
			if (!Array.TrueForAll(images, delegate(Image item) { return (item.Width == images[0].Width && item.Height == images[0].Height); }))
				throw new ArgumentException("eterogeneous size in image set", "images");

			uint width = images[0].Width, height = images[0].Height;

			// Setup texture information
			PixelLayout = format;
			_Width = width;
			_Height = height;
			_Depth = (uint)images.Length;

			// Setup technique for creation
			SetTechnique(new ImageTechnique(TextureTarget, format, images));
		}
Exemplo n.º 45
0
		private static void ConvertPixelFormatRgb(System.Drawing.Imaging.PixelFormat from, out PixelLayout to, bool sRGB)
		{
			switch (from) {
				case System.Drawing.Imaging.PixelFormat.Format1bppIndexed:
				case System.Drawing.Imaging.PixelFormat.Format4bppIndexed:
				case System.Drawing.Imaging.PixelFormat.Format8bppIndexed:
					to = PixelLayout.BGR24;
					break;
				case System.Drawing.Imaging.PixelFormat.Format16bppRgb555:
					to = PixelLayout.BGR15;
					break;
				case System.Drawing.Imaging.PixelFormat.Format16bppRgb565:
					to = PixelLayout.BGR16;
					break;
				case System.Drawing.Imaging.PixelFormat.Format24bppRgb:
					to = sRGB ? PixelLayout.SBGR24 : PixelLayout.BGR24;
					break;
				case System.Drawing.Imaging.PixelFormat.Format32bppRgb:
					to = PixelLayout.BGRA32;
					break;
				case System.Drawing.Imaging.PixelFormat.Format16bppArgb1555:
					to = PixelLayout.BGR15;
					break;
				case System.Drawing.Imaging.PixelFormat.Format16bppGrayScale:
					to = PixelLayout.GRAY16;
					break;
				case System.Drawing.Imaging.PixelFormat.Format48bppRgb:
					to = PixelLayout.BGR48;
					break;
				case System.Drawing.Imaging.PixelFormat.Format64bppPArgb:
					throw new ArgumentException(String.Format("RGB pixel format {0} not supported", from));
				case System.Drawing.Imaging.PixelFormat.Canonical:
					to = (sRGB) ? PixelLayout.SBGR24 : PixelLayout.BGR24;
					break;
				case System.Drawing.Imaging.PixelFormat.Format32bppArgb:
					to = PixelLayout.BGRA32;
					break;
				case System.Drawing.Imaging.PixelFormat.Format64bppArgb:
					throw new ArgumentException(String.Format("RGB pixel format {0} not supported", from));
				default:
					throw new ArgumentException(String.Format("RGB pixel format {0} not supported", from));
			}
		}
Exemplo n.º 46
0
		/// <summary>
		/// Create a Texture3d, defining the texture extents and the internal format.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/> used for creating this Texture.
		/// </param>
		/// <param name="width">
		/// A <see cref="UInt32"/> that specify the texture width.
		/// </param>
		/// <param name="height">
		/// A <see cref="UInt32"/> that specify the texture height.
		/// </param>
		/// <param name="depth">
		/// A <see cref="UInt32"/> that specify the texture depth.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> equals to <see cref="PixelFormat.None"/>.
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// Exception thrown if no context is current to the calling thread.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
		/// the maximum allowed for 2D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
		/// is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public void Create(GraphicsContext ctx, uint width, uint height, uint depth, PixelLayout format)
		{
			if (ctx == null)
				throw new ArgumentNullException("ctx");

			// Define technique
			Create(width, height, depth, format);
			// Actually create texture
			Create(ctx);
		}
Exemplo n.º 47
0
		/// <summary>
		/// Create a Texture3d, defining the texture extents and the internal format.
		/// </summary>
		/// <param name="width">
		/// A <see cref="UInt32"/> that specify the texture width.
		/// </param>
		/// <param name="height">
		/// A <see cref="UInt32"/> that specify the texture height.
		/// </param>
		/// <param name="depth">
		/// A <see cref="UInt32"/> that specify the texture depth.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> equals to <see cref="PixelFormat.None"/>.
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// Exception thrown if no context is current to the calling thread.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
		/// the maximum allowed for 2D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
		/// is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public void Create(uint width, uint height, uint depth, PixelLayout format)
		{
			// Setup texture information
			PixelLayout = format;
			_Width = width;
			_Height = height;
			_Depth = depth;

			// Setup technique for creation
			SetTechnique(new EmptyTechnique(TextureTarget, format, width, height, depth));
		}
Exemplo n.º 48
0
			/// <summary>
			/// Construct a EmptyTechnique.
			/// </summary>
			/// <param name="target">
			/// A <see cref="TextureTarget"/> that specify the texture target.
			/// </param>
			/// <param name="pixelFormat">
			/// The texture pixel format.
			/// </param>
			/// <param name="images">
			/// The image set of the texture.
			/// </param>
			public ImageTechnique(TextureTarget target, PixelLayout pixelFormat, Image[] images)
			{
				if (images == null)
					throw new ArgumentNullException("images");
				if (images.Length == 0)
					throw new ArgumentException("no images", "images");
				if (!Array.TrueForAll(images, delegate(Image item) { return (item != null); }))
					throw new ArgumentException("null item in image set", "images");
				if (!Array.TrueForAll(images, delegate(Image item) { return (item.Width == images[0].Width && item.Height == images[0].Height); }))
					throw new ArgumentException("eterogeneous size in image set", "images");

				Target = target;
				PixelLayout = pixelFormat;
				Images = images;
				Array.ForEach(Images, delegate(Image image) { image.IncRef(); });	// Referenced
			}
Exemplo n.º 49
0
 internal void DrawPixels(int width, int height, PixelLayout format, PixelComponentType type, float[] pixels)
 {
     gl.glDrawPixels(width, height, (int)format, (int)type, pixels);
     CheckException();
 }
Exemplo n.º 50
0
		/// <summary>
		/// Create TextureRectangle data, defining only the extents and the internal format.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/> used for creating this Texture. If it null, the current context
		/// will be used.
		/// </param>
		/// <param name="width">
		/// A <see cref="UInt32"/> that specify the texture width.
		/// </param>
		/// <param name="height">
		/// A <see cref="UInt32"/> that specify the texture height.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> equals to <see cref="PixelFormat.None"/>.
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// Exception thrown if <paramref name="ctx"/> is null and no context is current to the calling thread.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
		/// the maximum allowed for 2D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by <paramref name="ctx"/> (or by the current context is <paramref name="ctx"/> is
		/// null), and <paramref name="width"/> or <paramref name="height"/> is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public TextureRectangle(GraphicsContext ctx, uint width, uint height, PixelLayout format) : base(ctx, width, height, format)
		{
			
		}
Exemplo n.º 51
0
 internal void ReadPixels(int x, int y, int width, int height, PixelLayout format, PixelComponentType type, byte[] pixels)
 {
     gl.glReadPixels(x, y, width, height, (int)format, (int)type, pixels);
     CheckException();
 }
Exemplo n.º 52
0
		/// <summary>
		/// Download Texture data to an Image instance.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/> used for downloading texture data.
		/// </param>
		/// <param name="pType">
		/// A <see cref="OpenGL.PixelLayout"/> determining the pixel format of the downloaded data.
		/// </param>
		/// <param name="target">
		/// A <see cref="TextureTarget"/> that specify the texture target.
		/// </param>
		/// <returns>
		/// 
		/// </returns>
		protected Image[] Get(GraphicsContext ctx, PixelLayout pType, TextureTarget target)
		{
			// Bind this Texture
			Bind(ctx);

			// Get texture extents
			int width, height;

			Gl.GetTexLevelParameter(TextureTarget, 0, GetTextureParameter.TextureWidth, out width);
			Gl.GetTexLevelParameter(TextureTarget, 0, GetTextureParameter.TextureHeight, out height);
			if ((width <= 0) || (height <= 0))
				throw new InvalidOperationException(String.Format("invalid texture extents {0}x{1}", width, height));

			// Create image
			Image image = new Image(pType, (uint)width, (uint)height);

			// Set pixel transfer
			foreach (int alignment in new int[] { 8, 4, 2, 1 }) {
				if (image.Stride % alignment == 0) {
					Gl.PixelStore(PixelStoreParameter.PackAlignment, alignment);
					break;
				}
			}

			// Download texture contents
			Gl.GetTexImage(target, 0, Pixel.GetGlFormat(pType), Pixel.GetPixelType(pType), image.ImageBuffer);

			// Unbind this texture
			Unbind(ctx);

			return (new Image[] { image });
		}
		/// <summary>
		/// Surface format with specified color (no depth, no stencil, no multisample, no double/stereo buffering).
		/// </summary>
		/// <param name="color">
		/// A <see cref="PixelLayout"/> that specify the format of the color buffer.
		/// </param>
		/// <remarks>
		/// <para>
		/// The buffer configurations are considered required but degradable. If it necessary a specific resolution,
		/// define those configurations using the related <i>Define*</i> routine.
		/// </para>
		/// </remarks>
		public GraphicsBuffersFormat(PixelLayout color)
		{
			DefineColorBuffer(color);
		}
Exemplo n.º 54
0
        //internal void DrawPixels(GLPixelRectangleInfo pixelRect)
        //{
        //    if (pixelRect.BufferObject == null)
        //        return ;

        //    IntPtr mappedPtr = pixelRect.BufferObject.MapBuffer(BufferAccess.ReadOnly);

        //    if (mappedPtr == null)
        //        return ;

        //    DrawPixels(pixelRect.Width, pixelRect.Height, pixelRect.PixelFormat, pixelRect.PixelType, mappedPtr);

        //    pixelRect.BufferObject.UnmapBuffer();
        //}

        //public void DrawPixels(int x, int y, GLPixelRectangleInfo pixelRect)
        //{
        //    RasterPos2i(x, y);
        //    DrawPixels(pixelRect);
        //}

        public void DrawPixels(int width, int height, PixelLayout format, PixelComponentType type, IntPtr pixels)
        {
            gl.glDrawPixels(width, height, (int)format, (int)type, pixels);
            CheckException();
        }
Exemplo n.º 55
0
		/// <summary>
		/// Create a Texture3d, defining the texture extents and the internal format.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/> used for creating this Texture.
		/// </param>
		/// <param name="images">
		/// An array of <see cref="Image"/> that specify the texture data.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// Exception thrown if <paramref name="images"/> is null.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="images"/> has no items, or every item hasn't the same width and height.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if width, height or depth is greater than the maximum allowed for 3D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by current context, and width, height or depth 
		/// is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public void Create(GraphicsContext ctx, Image[] images, PixelLayout format)
		{
			if (ctx == null)
				throw new ArgumentNullException("ctx");

			// Define technique
			Create(images, format);
			// Actually create texture
			Create(ctx);
		}
Exemplo n.º 56
0
		/// <summary>
		/// Construct a Texture3d, defining the texture extents and the internal format.
		/// </summary>
		/// <param name="width">
		/// A <see cref="UInt32"/> that specify the texture width.
		/// </param>
		/// <param name="height">
		/// A <see cref="UInt32"/> that specify the texture height.
		/// </param>
		/// <param name="depth">
		/// A <see cref="UInt32"/> that specify the texture depth.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> equals to <see cref="PixelFormat.None"/>.
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// Exception thrown if no context is current to the calling thread.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
		/// the maximum allowed for 2D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
		/// is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public Texture3d(GraphicsContext ctx, uint width, uint height, uint depth, PixelLayout format)
		{
			Create(ctx, width, height, depth, format);
		}
Exemplo n.º 57
0
		static void ConvertPixelFormat(PixelLayout from, out System.Drawing.Imaging.PixelFormat to, out int flags)
		{
			switch (from) {
				case PixelLayout.GRAY8:
					to = System.Drawing.Imaging.PixelFormat.Format8bppIndexed;
					flags = (int)ImageFlags.ColorSpaceGray;
					break;
				case PixelLayout.GRAY16:
					to = System.Drawing.Imaging.PixelFormat.Format16bppGrayScale;
					flags = (int)ImageFlags.ColorSpaceGray;
					break;
				case PixelLayout.BGR15:
					to = System.Drawing.Imaging.PixelFormat.Format16bppRgb555;
					flags = (int)ImageFlags.ColorSpaceRgb;
					break;
				case PixelLayout.BGR16:
					to = System.Drawing.Imaging.PixelFormat.Format16bppRgb565;
					flags = (int)ImageFlags.ColorSpaceRgb;
					break;
				case PixelLayout.BGR24:
					to = System.Drawing.Imaging.PixelFormat.Format24bppRgb;
					flags = (int)ImageFlags.ColorSpaceRgb;
					break;
				case PixelLayout.BGRA32:
					to = System.Drawing.Imaging.PixelFormat.Format32bppArgb;
					flags = (int)ImageFlags.ColorSpaceRgb;
					break;
				default:
					throw new ArgumentException(String.Format("pixel format {0} not supported", from));
			}
		}
Exemplo n.º 58
0
		/// <summary>
		/// Construct a Texture3d, defining the texture extents and the internal format.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/> used for creating this Texture.
		/// </param>
		/// <param name="width">
		/// A <see cref="UInt32"/> that specify the texture width.
		/// </param>
		/// <param name="height">
		/// A <see cref="UInt32"/> that specify the texture height.
		/// </param>
		/// <param name="depth">
		/// A <see cref="UInt32"/> that specify the texture depth.
		/// </param>
		/// <param name="format">
		/// A <see cref="PixelLayout"/> determining the texture internal format.
		/// </param>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is zero.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> equals to <see cref="PixelFormat.None"/>.
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// Exception thrown if no context is current to the calling thread.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/> or <paramref name="height"/> is greater than
		/// the maximum allowed for 2D textures.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by current context, and <paramref name="width"/> or <paramref name="height"/>
		/// is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		public Texture3d(uint width, uint height, uint depth, PixelLayout format)
		{
			Create(width, height, depth, format);
		}
Exemplo n.º 59
0
		/// <summary>
		/// Read this GraphicsSurface color buffer.
		/// </summary>
		/// <param name="ctx">
		/// A <see cref="GraphicsContext"/>
		/// </param>
		/// <param name="rBuffer">
		/// A <see cref="ReadBufferMode"/> that specify the read buffer where the colors are read from.
		/// </param>
		/// <param name="x">
		/// A <see cref="Int32"/> that specify the x coordinate of the lower left corder of the rectangle area to read.
		/// </param>
		/// <param name="y">
		/// A <see cref="Int32"/> that specify the y coordinate of the lower left corder of the rectangle area to read.
		/// </param>
		/// <param name="width">
		/// A <see cref="Int32"/> that specify the width of the rectangle area to read.
		/// </param>
		/// <param name="height">
		/// A <see cref="Int32"/> that specify the height of the rectangle area to read.
		/// </param>
		/// <param name="pType">
		/// A <see cref="PixelLayout"/> which determine the pixel storage of the returned image.
		/// </param>
		/// <returns>
		/// It returns an <see cref="Image"/> representing the current read buffer <paramref name="rBuffer"/>.
		/// </returns>
		protected Image ReadBuffer(GraphicsContext ctx, ReadBufferMode rBuffer, uint x, uint y, uint width, uint height, PixelLayout pType)
		{
			Image image = null;

			if ((x + width > Width) || (y + height > Height))
				throw new ArgumentException("specified region lies outside the GraphicsSurface");

			// Bind for reading
			BindRead(ctx);
			// Set for reading
			Gl.ReadBuffer(rBuffer);

			// Allocate image holding data read
			image = new Image();
			image.Create(pType, width, height);

			// Set pixel transfer
			foreach (int alignment in new int[] { 8, 4, 2, 1 }) {
				if (image.Stride % alignment == 0) {
					Gl.PixelStore(PixelStoreParameter.PackAlignment, alignment);
					break;
				}
			}

			// Grab frame buffer pixels
			PixelFormat rFormat = Pixel.GetGlFormat(pType);
			PixelType rType = Pixel.GetPixelType(pType);

			Gl.ReadPixels((int)x, (int)y, (int)width, (int)height, rFormat, rType, image.ImageBuffer);

			// Unbind from reading
			UnbindRead(ctx);

			return (image);
		}
Exemplo n.º 60
0
		/// <summary>
		/// Check whether the texture extents are compatible with context capabilities.
		/// </summary>
		/// <param name="caps">
		/// A <see cref="GraphicsCapabilities"/> determining the underlying texture capabilities.
		/// </param>
		/// <param name="width">
		/// A <see cref="UInt32"/> that specify the texture width.
		/// </param>
		/// <param name="height">
		/// A <see cref="UInt32"/> that specify the texture height.
		/// </param>
		/// <param name="depth">
		/// A <see cref="UInt32"/> that specify the texture depth.
		/// </param>
		/// <param name="format">
		/// A <see cref="OpenGL.PixelLayout"/> that specify the texture internal format.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// Exception throw if <paramref name="caps"/> is null.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="width"/>, <paramref name="height"/> or <paramref name="depth"/> is greater than
		/// the maximum allowed for the specific texture target.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if NPOT texture are not supported by <paramref name="caps"/>, and <paramref name="width"/>, <paramref name="height"/>
		/// or <paramref name="depth"/> is not a power-of-two value.
		/// </exception>
		/// <exception cref="ArgumentException">
		/// Exception thrown if <paramref name="format"/> is not a supported internal format.
		/// </exception>
		private void CheckCapabilities(GraphicsCapabilities caps, uint width, uint height, uint depth, PixelLayout format)
		{
			if (caps == null)
				throw new ArgumentNullException("caps");
			if (caps.GlExtensions == null)
				throw new ArgumentException("caps GL extensions not queried", "caps");
			if (caps.Limits == null)
				throw new ArgumentException("caps Limits not queried", "caps");
		
			// Texture maximum size
			switch (TextureTarget) {
				case TextureTarget.Texture1d:
					if (width > caps.Limits.MaxTexture2DSize)
						throw new ArgumentException(String.Format("width greater than maximum allowed ({0})", caps.Limits.MaxTexture2DSize));
					break;
				case TextureTarget.Texture2d:
					if (width > caps.Limits.MaxTexture2DSize)
						throw new ArgumentException(String.Format("width greater than maximum allowed ({0})", caps.Limits.MaxTexture2DSize));
					if (height > caps.Limits.MaxTexture2DSize)
						throw new ArgumentException(String.Format("height greater than maximum allowed ({0})", caps.Limits.MaxTexture2DSize));
					break;
				case TextureTarget.TextureRectangle:
					if (width > caps.Limits.MaxTextureRectSize)
						throw new ArgumentException(String.Format("width greater than maximum allowed ({0})", caps.Limits.MaxTextureRectSize));
					if (height > caps.Limits.MaxTextureRectSize)
						throw new ArgumentException(String.Format("height greater than maximum allowed ({0})", caps.Limits.MaxTextureRectSize));
					break;
				case TextureTarget.Texture3d:
					if (width > caps.Limits.MaxTexture3DSize)
						throw new ArgumentException(String.Format("width greater than maximum allowed ({0})", caps.Limits.MaxTexture3DSize));
					if (height > caps.Limits.MaxTexture3DSize)
						throw new ArgumentException(String.Format("height greater than maximum allowed ({0})", caps.Limits.MaxTexture3DSize));
					if (depth > caps.Limits.MaxTexture3DSize)
						throw new ArgumentException(String.Format("depth greater than maximum allowed ({0})", caps.Limits.MaxTexture3DSize));
					break;
				case TextureTarget.TextureCubeMap:
					if (width > caps.Limits.MaxTextureCubeSize)
						throw new ArgumentException(String.Format("width greater than maximum allowed ({0})", caps.Limits.MaxTextureCubeSize));
					if (height > caps.Limits.MaxTextureCubeSize)
						throw new ArgumentException(String.Format("height greater than maximum allowed ({0})", caps.Limits.MaxTextureCubeSize));
					break;
				default:
					throw new NotImplementedException("not implemented checks on texture " + GetType());
			}
			// Texture not-power-of-two
			if (caps.GlExtensions.TextureNonPowerOfTwo_ARB == false) {
				if (IsPowerOfTwo(width) == false)
					throw new ArgumentException(String.Format("NPOT texture width not supported (width is {0})", width));
				if (IsPowerOfTwo(height) == false)
					throw new ArgumentException(String.Format("NPOT texture height not supported (height is {0})", height));
				if (IsPowerOfTwo(depth) == false)
					throw new ArgumentException(String.Format("NPOT texture depth not supported (height is {0})", height));
			}
			// Texture internal format
			if (Pixel.IsSupportedInternalFormat(format) == false)
				throw new ArgumentException(String.Format("not supported texture internal format {0}", format), "format");
		}