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

            SetColor(color);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="target"></param>
		/// <param name="writeGamma"></param>
		/// <param name="fsaa"></param>
		public GLESPBRenderTexture( GLESPBRTTManager manager, string name, GLESSurfaceDescription target, bool writeGamma, int fsaa )
			: base( name, target, writeGamma, fsaa )
		{
			this._manager = manager;
			this._pbFormat = PixelUtil.GetComponentType( target.Buffer.Format );
			this._manager.RequestPBuffer( _pbFormat, Width, Height );
		}
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        protected virtual void SetupTexture2D(GraphicsInterface gi, int width, int height, TextureInternalFormat internalFormat, TexturePixelFormat pixelFormat, PixelComponentType pixelType, IntPtr pixelData, bool createMipMaps)
        {
            fWidth = width;
            fHeight = height;

            fInternalFormat = internalFormat;
            fPixelFormat = pixelFormat;
            fPixelType = pixelType;

            // Setup the alignment
            fGI.PixelStore(PixelStore.UnpackAlignment, 1);

            // Allocate storage for the texture
            // We do this once at the beginning to allocate space for the texture object
            fGI.TexImage2D(0, internalFormat, fWidth, fHeight, 0, pixelFormat, pixelType, pixelData);

            // Setup default filters and wrapping
            SetupFiltering();
            SetupWrapping();

            if (createMipMaps)
            {
                // Make call to generate MipMap
                //fGI.GenerateMipmap();
                
                // Alter the min filter to use the mipmap
                fGI.TexParameter(TextureParameterTarget.Texture2d, TextureParameterName.TextureMinFilter, TextureMinFilter.LinearMipmapLinear);
            }

        }
Ejemplo n.º 5
0
		public void ReleasePBuffer( PixelComponentType ctype )
		{
			--this._pixelBuffers[ (int) ctype ].ReferenceCount;
			if ( this._pixelBuffers[ (int) ctype ].ReferenceCount == 0 )
			{
				//_pixelBuffers[ (int)ctype ].Buffer.Dispose();
				this._pixelBuffers[ (int) ctype ].Buffer = null;
			}
		}
Ejemplo n.º 6
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();
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
		public void RequestPBuffer( PixelComponentType ctype, int width, int height )
		{
			PBRef current = this._pixelBuffers[ (int) ctype ];
			// Check size
			if ( current.Buffer != null )
			{
				if ( current.Buffer.Width < width || current.Buffer.Height < height )
				{
					// If the current PBuffer is too small, destroy it and create a new one					
					//current.Buffer.Dispose();
					current.Buffer = null;
				}
			}

			if ( current.Buffer == null )
			{
				// Create pbuffer via rendersystem
				current.Buffer = this._support.CreatePixelBuffer( ctype, width, height );
			}
			++current.ReferenceCount;
			this._pixelBuffers[ (int) ctype ] = current;
		}
Ejemplo n.º 9
0
			public PixelFormatDescription( string name, PixelFormat format, byte elemBytes, PixelFormatFlags flags,
			                               PixelComponentType componentType, byte componentCount, byte rbits, byte gbits,
			                               byte bbits, byte abits, uint rmask, uint gmask, uint bmask, uint amask, byte rshift,
			                               byte gshift, byte bshift, byte ashift )
			{
				this.name = name;
				this.format = format;
				this.elemBytes = elemBytes;
				this.flags = flags;
				this.componentType = componentType;
				this.componentCount = componentCount;
				this.rbits = rbits;
				this.gbits = gbits;
				this.bbits = bbits;
				this.abits = abits;
				this.rmask = rmask;
				this.gmask = gmask;
				this.bmask = bmask;
				this.amask = amask;
				this.rshift = rshift;
				this.gshift = gshift;
				this.bshift = bshift;
				this.ashift = ashift;
			}
Ejemplo n.º 10
0
		/// <summary>
		/// Get GL rendering context for a certain component type and size.
		/// </summary>
		/// <param name="pcType"></param>
		/// <param name="width"></param>
		/// <param name="height"></param>
		/// <returns></returns>
		public GLContext GetContextFor( PixelComponentType pcType, int width, int height )
		{
			// Faster to return main context if the RTT is smaller than the window size
			// and pcType is PixelComponentType.Byte. This must be checked every time because the window might have been resized
			if ( pcType == PixelComponentType.Byte )
			{
				if ( width <= this._mainWindow.Width && height <= this._mainWindow.Height )
					return this._mainGLContext;
			}
			Debug.Assert( pBuffers[ (int)pcType ].PixelBuffer != null );
			return pBuffers[ (int)pcType ].PixelBuffer.Context;
		}
Ejemplo n.º 11
0
 public void TexImage1D(Texture1DTarget target, int level, TextureInternalFormat internalformat, int width, int border, TexturePixelFormat format, PixelComponentType type, object pixels)
 {
     gl.glTexImage1D((int)target, level, (int)internalformat, width, border, (int)format, (int)type, pixels);
 }
Ejemplo n.º 12
0
		/// <summary>
		/// Create PBuffer for a certain pixel format and size
		/// </summary>
		/// <param name="pcType"></param>
		/// <param name="width"></param>
		/// <param name="height"></param>
		public void RequestPBuffer( PixelComponentType pcType, int width, int height )
		{
			// Check Size
			GLPBuffer pBuffer = pBuffers[ (int)pcType ].PixelBuffer;
			if ( pBuffer != null )
			{
				if ( pBuffer.Width < width || pBuffer.Height < height )
				{
					// if the current buffer is too small destroy it and recreate it
					pBuffer = null;
					pBuffers[ (int)pcType ].PixelBuffer = null;
				}
			}

			if ( pBuffer == null )
			{
				// create pixelbuffer via rendersystem
				pBuffers[ (int)pcType ].PixelBuffer = this._glSupport.CreatePBuffer( pcType, width, height );
			}
			pBuffers[ (int)pcType ].InUseCount++;
		}
Ejemplo n.º 13
0
		/// <summary>
		/// Release PBuffer for a certain pixel format
		/// </summary>
		/// <param name="pcType"></param>
		public void ReleasePBuffer( PixelComponentType pcType )
		{
			--pBuffers[ (int)pcType ].InUseCount;
			if ( pBuffers[ (int)pcType ].InUseCount == 0 )
			{
				pBuffers[ (int)pcType ].PixelBuffer = null;
			}
		}
Ejemplo n.º 14
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();
 }
Ejemplo n.º 15
0
 public static ColorRGBA GetColor(PixelLayout layout, PixelComponentType pType, byte[] data)
 {
     return GetColor(layout, pType, data, 0);
 }
Ejemplo n.º 16
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();
        }
Ejemplo n.º 17
0
 internal void DrawPixels(int width, int height, PixelLayout format, PixelComponentType type, float[] pixels)
 {
     gl.glDrawPixels(width, height, (int)format, (int)type, pixels);
     CheckException();
 }
Ejemplo n.º 18
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="format"></param>
		/// <param name="width"></param>
		/// <param name="height"></param>
		public GLPBuffer( PixelComponentType format, int width, int height )
		{
		}
Ejemplo n.º 19
0
        public static ColorRGBA GetColor(PixelLayout layout, PixelComponentType pType, byte[] data, int startIndex)
        {
            int bytesPerPixel = PixelInformation.GetBytesPerPixel(layout, pType);

            // how many components are there?
            int nComponents = PixelInformation.GetComponentsPerLayout(layout);
            int componentSize = PixelInformation.GetBytesPerComponent(pType);
            double maxValue = PixelInformation.GetMaxComponentValue(pType);

            float[] floats = new float[nComponents];

            for (int component = 0; component < nComponents; component++)
            {
                float afloat = 0f;

                switch (pType)
                {
                    case PixelComponentType.Byte:
                    case PixelComponentType.UnsignedByte:
                        afloat = (float)(data[startIndex+component * componentSize] / maxValue);
                        break;

                    case PixelComponentType.Short:
                        afloat = (float)(BitConverter.ToInt16(data, startIndex + component * componentSize) / maxValue);
                        break;

                    case PixelComponentType.Int:
                        afloat = (float)(BitConverter.ToInt32(data, startIndex + component * componentSize) / maxValue);
                        break;

                    case PixelComponentType.Float:
                        afloat = (float)(BitConverter.ToSingle(data, startIndex + component * componentSize) / maxValue);
                        break;

                    case PixelComponentType.Double:
                        afloat = (float)(BitConverter.ToDouble(data, startIndex + component * componentSize) / maxValue);
                        break;
                }

                floats[component] = afloat;
            }

            ColorRGBA newColor = new ColorRGBA(floats);

            return newColor;
        }
Ejemplo n.º 20
0
        public void TexSubImage2D(Texture2DTarget target, int level, int xoffset, int yoffset, int width, int height, TexturePixelFormat format, PixelComponentType type, IntPtr pixels)
        {
            if (null == pixels || pixels == IntPtr.Zero)
                return;

            gl.glTexSubImage2D((int)target, level, xoffset, yoffset, width, height, (int)format, (int)type, pixels);
        }
Ejemplo n.º 21
0
 public void TexImage2D(Texture2DTarget target, int level, TextureInternalFormat internalformat, int width, int height, int border, TexturePixelFormat format, PixelComponentType type, object pixels)
 {
     gl.glTexImage2D((int)target, level, (int)internalformat, width, height, border, (int)format, (int)type, pixels);
     CheckException();
 }
Ejemplo n.º 22
0
 public static int GetAlignedRowStride(int width, PixelLayout format, PixelComponentType pType, int alignment)
 {
     return GetAlignedRowStride(width, PixelInformation.GetBitsPerPixel(format, pType), alignment);
 }
Ejemplo n.º 23
0
 public GLTexture2D(GraphicsInterface gi, int width, int height, TextureInternalFormat internalFormat, TexturePixelFormat pixelFormat, PixelComponentType pixelType, IntPtr pixelData, bool createMipMaps)
     : base(gi, TextureBindTarget.Texture2d)
 {
     SetupTexture2D(gi, width, height, internalFormat, pixelFormat, pixelType, pixelData, createMipMaps);
 }
Ejemplo n.º 24
0
 public PixelRectangleInfo(int width, int height, PixelLayout layout, PixelComponentType compType, int alignment)
     : this(width, height, layout, compType, PixmapOrientation.TopToBottom, alignment)
 {
 }
Ejemplo n.º 25
0
 public void TexSubImage1D(int level, int xoffset, int width, TexturePixelFormat format, PixelComponentType type, object[] pixels)
 {
     gl.glTexSubImage1D((int)Texture1DTarget.Texture1d, level, xoffset, width, (int)format, (int)type, pixels);
 }
Ejemplo n.º 26
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);
 }
Ejemplo n.º 27
0
 public void TexSubImage2D(Texture2DTarget target, int level, int xoffset, int yoffset, int width, int height, TexturePixelFormat format, PixelComponentType type, byte[] pixels)
 {
     gl.glTexSubImage2D((int)target, level, xoffset, yoffset, width, height, (int)format, (int)type, pixels);
 }
Ejemplo n.º 28
0
 public static void TexImage1D(int level, TextureInternalFormat internalformat, int width, int border, TexturePixelFormat format, PixelComponentType type, IntPtr pixels)
 {
     gl.glTexImage1D((int)Texture1DTarget.Texture1d, level, (int)internalformat, width, border, (int)format, (int)type, pixels);
 }
Ejemplo n.º 29
0
		public virtual GLPBuffer CreatePBuffer( PixelComponentType format, int width, int height )
		{
			return null;
		}
Ejemplo n.º 30
0
 public static void DrawPixels(int width, int height, PixelLayout format, PixelComponentType type, float[] pixels)
 {
     gl.glDrawPixels(width, height, (int)format, (int)type, pixels);
 }