Exemplo n.º 1
0
        /// <summary>
        ///   Function to get the closest matching Axiom format to an internal GL format. To be precise, the format will be chosen that is most efficient to transfer to the card without losing precision
        /// </summary>
        /// <remarks>
        ///   It is valid for this function to always return PixelFormat.A8R8G8B8
        /// </remarks>
        /// <param name="fmt"> </param>
        /// <param name="dataType"> </param>
        /// <returns> </returns>
        public static PixelFormat GetClosestAxiomFormat(GLenum fmt, GLenum dataType)
        {
            switch (fmt)
            {
            case GLenum.CompressedRgbPvrtc2Bppv1Img:
                return(PixelFormat.PVRTC_RGB2);

            case GLenum.CompressedRgbaPvrtc2Bppv1Img:
                return(PixelFormat.PVRTC_RGBA2);

            case GLenum.CompressedRgbPvrtc4Bppv1Img:
                return(PixelFormat.PVRTC_RGB4);

            case GLenum.CompressedRgbaPvrtc4Bppv1Img:
                return(PixelFormat.PVRTC_RGBA4);

            case GLenum.Luminance:
                return(PixelFormat.L8);

            case GLenum.Alpha:
                return(PixelFormat.A8);

            case GLenum.LuminanceAlpha:
                return(PixelFormat.BYTE_LA);

            case GLenum.Rgb:
                switch (dataType)
                {
                case GLenum.UnsignedShort565:
                    return(PixelFormat.B5G6R5);

                default:
                    return(PixelFormat.R8G8B8);
                }

            case GLenum.Rgba:
                switch (dataType)
                {
                case GLenum.UnsignedShort5551:
                    return(PixelFormat.A1R5G5B5);

                case GLenum.UnsignedShort4444:
                    return(PixelFormat.A4R4G4B4);

                default:
                    return(PixelFormat.A8R8G8B8);
                }

            case GLenum.Bgra:
                return(PixelFormat.A8B8G8R8);

            default:
                //Ogre TODO: not supported
                return(PixelFormat.A8R8G8B8);
            }
        }
Exemplo n.º 2
0
        private void BuildMipmaps(PixelBox data)
        {
            int width, height, logW, logH, level;

            PixelBox scaled = data;

            scaled.Data   = data.Data;
            scaled.Left   = data.Left;
            scaled.Right  = data.Right;
            scaled.Top    = data.Top;
            scaled.Bottom = data.Bottom;
            scaled.Front  = data.Front;
            scaled.Back   = data.Back;

            width  = data.Width;
            height = data.Height;

            logW  = (int)System.Math.Log(width);
            logH  = (int)System.Math.Log(height);
            level = (logW > logH ? logW : logH);

            for (int mip = 0; mip < level; mip++)
            {
                All glFormat = GLES2PixelUtil.GetGLOriginFormat(scaled.Format);
                All dataType = GLES2PixelUtil.GetGLOriginDataType(scaled.Format);

                GL.TexImage2D(this.faceTarget, mip, (int)glFormat, width, height, 0, glFormat, dataType, scaled.Data.Pin());
                GLES2Config.GlCheckError(this);

                if (mip != 0)
                {
                    scaled.Data = null;
                }

                if (width > 1)
                {
                    width /= 2;
                }
                if (height > 1)
                {
                    height /= 2;
                }

                int sizeInBytes = PixelUtil.GetMemorySize(width, height, 1, data.Format);
                scaled      = new PixelBox(width, height, 1, data.Format);
                scaled.Data = BufferBase.Wrap(new byte[sizeInBytes]);
                Image.Scale(data, scaled, ImageFilter.Linear);
            }

            //Delete the scaled data for the last level
            if (level > 0)
            {
                scaled.Data = null;
            }
        }
 extern static CVReturn CVOpenGLESTextureCacheCreateTextureFromImage(
     /* CFAllocatorRef __nullable */ IntPtr allocator,
     /* CVOpenGLESTextureCacheRef */ IntPtr textureCache,
     /* CVImageBufferRef __nonnull */ IntPtr sourceImage,
     /* CFDictionaryRef __nullable */ IntPtr textureAttr,
     /* GLenum */ int target,
     /* GLint */ OpenTK.Graphics.ES20.All internalFormat,
     /* GLsizei */ int width,
     /* GLsizei */ int height,
     /* GLenum */ OpenTK.Graphics.ES20.All format,
     /* GLenum */ OpenTK.Graphics.ES20.DataType type,
     /* size_t */ IntPtr planeIndex,
     /* CVOpenGLESTextureRef __nullable * __nonnull */ out IntPtr textureOut);
Exemplo n.º 4
0
		public GLES2RenderBuffer( All format, int width, int height, int numSamples )
			: base( width, height, 1, GLES2PixelUtil.GetClosestAxiomFormat( format, (All) PixelFormat.A8R8G8B8 ), BufferUsage.WriteOnly )
		{
			GlInternalFormat = format;
			//Genearte renderbuffer
			GL.GenRenderbuffers( 1, ref this.renderBufferID );
			GLES2Config.GlCheckError( this );
			//Bind it to FBO
			GL.BindRenderbuffer( All.Renderbuffer, this.renderBufferID );
			GLES2Config.GlCheckError( this );

			//Allocate storage for depth buffer
			if ( numSamples > 0 ) {}
			else
			{
				GL.RenderbufferStorage( All.Renderbuffer, format, width, height );
				GLES2Config.GlCheckError( this );
			}
		}
Exemplo n.º 5
0
        /// <summary>
        /// Build the shaders
        /// </summary>
        private int LoadShader(All20 type, string source)
        {
            int shader = GL20.CreateShader(type);

            if (shader == 0)
            {
                throw new InvalidOperationException("Unable to create shader");
            }

            // Load the shader source
            int length = 0;

            GL20.ShaderSource(shader, 1, new string[] { source }, new int[] { source.Length });

            // Compile the shader
            GL20.CompileShader(shader);

            int[] compiled = new int[1];
            GL20.GetShader(shader, All20.CompileStatus, compiled);
            if (compiled[0] == 0)
            {
                length = 0;
                GL20.GetShader(shader, All20.InfoLogLength, ref length);
                var log = new StringBuilder(length);
                GL20.GetShaderInfoLog(shader, length, ref length, log);
                Console.WriteLine("GL2" + log.ToString());
                GL20.DeleteShader(shader);

                //length = 0;
                //GL20.GetShader(shader, All20.InfoLogLength, ref length);
                //if (length > 0)
                //{
                //    var log = new StringBuilder(length);
                //    GL20.GetShaderInfoLog(shader, length, ref length, log);
                //    Console.WriteLine("GL2" + log.ToString());
                //}
                //GL20.DeleteShader(shader);
                throw new InvalidOperationException("Unable to compile shader of type : " + type.ToString());
            }

            return(shader);
        }
Exemplo n.º 6
0
        public void SetRenderTargetGL20(RenderTarget2D rendertarget)
        {
            if (rendertarget == null)
            {
                GL20.BindFramebuffer(All20.Framebuffer, framebufferScreen);
                defaultFramebuffer = true;
            }
            else
            {
                GL20.BindFramebuffer(All20.Framebuffer, rendertarget.framebuffer);
                GL20.FramebufferTexture2D(All20.Framebuffer, All20.ColorAttachment0, All20.Texture2D, rendertarget.ID, 0);

                All20 status = GL20.CheckFramebufferStatus(All20.Framebuffer);
                if (status != All20.FramebufferComplete)
                {
                    throw new Exception("Error creating framebuffer: " + status);
                }
                defaultFramebuffer = false;
            }
        }
Exemplo n.º 7
0
        public GLES2RenderBuffer(All format, int width, int height, int numSamples)
            : base(width, height, 1, GLES2PixelUtil.GetClosestAxiomFormat(format, (All)PixelFormat.A8R8G8B8), BufferUsage.WriteOnly)
        {
            GlInternalFormat = format;
            //Genearte renderbuffer
            GL.GenRenderbuffers(1, ref this.renderBufferID);
            GLES2Config.GlCheckError(this);
            //Bind it to FBO
            GL.BindRenderbuffer(All.Renderbuffer, this.renderBufferID);
            GLES2Config.GlCheckError(this);

            //Allocate storage for depth buffer
            if (numSamples > 0)
            {
            }
            else
            {
                GL.RenderbufferStorage(All.Renderbuffer, format, width, height);
                GLES2Config.GlCheckError(this);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///   Takes the Axiom pixel format and returns the type that must be provided to GL as internal format. If no match exists, returns the cloest match.
        /// </summary>
        /// <param name="format"> The pixel format </param>
        /// <param name="hwGamma"> Whether a hardware gamma-corrected version is requested </param>
        /// <returns> </returns>
        public static GLenum GetClosestGLInternalFormat(PixelFormat format, bool hwGamma)
        {
            GLenum glformat = GetGLInternalFormat(format, hwGamma);

            if (glformat == GLenum.None)
            {
                if (hwGamma)
                {
                    //Ogre TODO: not supported
                    return(GLenum.Zero);
                }
                else
                {
                    return(GLenum.Rgba);
                }
            }
            else
            {
                return(glformat);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Build the shaders
        /// </summary>
        private int LoadShader(ALL20 type, string source)
        {
            int shader = GL20.CreateShader(type);

            if (shader == 0)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Unable to create shader: {0}", GL20.GetError()));
            }

            // Load the shader source
            int length = 0;

            GL20.ShaderSource(shader, 1, new string[] { source }, (int[])null);

            // Compile the shader
            GL20.CompileShader(shader);

            int compiled = 0;

            GL20.GetShader(shader, ALL20.CompileStatus, ref compiled);
            if (compiled == 0)
            {
                length = 0;
                GL20.GetShader(shader, ALL20.InfoLogLength, ref length);
                if (length > 0)
                {
                    var log = new StringBuilder(length);
                    GL20.GetShaderInfoLog(shader, length, ref length, log);
#if DEBUG
                    Console.WriteLine("GL2" + log.ToString());
#endif
                }

                GL20.DeleteShader(shader);
                throw new InvalidOperationException("Unable to compile shader of type : " + type.ToString());
            }

            return(shader);
        }
Exemplo n.º 10
0
 public void GetInteger(All name, ref int value)
 {
     GLES20.GetInteger(name, ref value);
 }
Exemplo n.º 11
0
 public All CheckFramebufferStatus(All target)
 {
     return(GLES20.CheckFramebufferStatus(target));
 }
Exemplo n.º 12
0
 public void BindRenderbuffer(All target, int renderbuffer)
 {
     GLES20.BindRenderbuffer(target, renderbuffer);
 }
Exemplo n.º 13
0
 public static void ExtTexObjectStateOverride(OpenTK.Graphics.ES20.All target, OpenTK.Graphics.ES20.All pname, Int32 param)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
			public All CheckFramebufferStatus (All target)
			{
				return GLES20.CheckFramebufferStatus (target);
			}
Exemplo n.º 15
0
			public void BindRenderbuffer (All target, int renderbuffer)
			{
				GLES20.BindRenderbuffer (target, renderbuffer);
			}
Exemplo n.º 16
0
 public static void AlphaFunc(OpenTK.Graphics.ES20.All func, Single @ref)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
		public GLES2HardwarePixelBuffer( int width, int height, int depth, PixelFormat format, BufferUsage usage )
			: base( width, height, depth, format, usage, false, false )
		{
			this.Buffer = new PixelBox( width, height, depth, format );
			this.GlInternalFormat = Glenum.None;
		}
Exemplo n.º 18
0
			/// <summary>
			/// Build the shaders
			/// </summary>
			private int LoadShader ( ALL20 type, string source )
	        {
	           int shader = GL20.CreateShader(type);
	
	           if ( shader == 0 )
	                   throw new InvalidOperationException(string.Format(
					"Unable to create shader: {0}", GL20.GetError ()));
	        
	           // Load the shader source
	           int length = 0;
	            GL20.ShaderSource(shader, 1, new string[] {source}, (int[])null);
	           
	           // Compile the shader
	           GL20.CompileShader( shader );
	                
	              int compiled = 0;
	            GL20.GetShader (shader, ALL20.CompileStatus, ref compiled);
	            if (compiled == 0) {
	                length = 0;
	                GL20.GetShader (shader, ALL20.InfoLogLength, ref length);
	                if (length > 0) {
	                    var log = new StringBuilder (length);
	                    GL20.GetShaderInfoLog (shader, length, ref length, log);
#if DEBUG					
	                    Console.WriteLine("GL2" + log.ToString ());
#endif
	                }
	
	                GL20.DeleteShader (shader);
	                throw new InvalidOperationException ("Unable to compile shader of type : " + type.ToString ());
	            }
	
	            return shader;
	        
	        }
Exemplo n.º 19
0
			public void BindFramebuffer (All target, int framebuffer)
			{
				GLES11.Oes.BindFramebuffer ((All11) target, framebuffer);
			}
Exemplo n.º 20
0
		public virtual void BindToFramebuffer( Glenum attachment, int zoffset )
		{
			//must be overriden
			throw new Core.AxiomException( "Framebuffer bind not possible for this pixelbuffer type" );
		}
Exemplo n.º 21
0
			public All CheckFramebufferStatus (All target)
			{
				return (All) GLES11.Oes.CheckFramebufferStatus ((All11) target);
			}
Exemplo n.º 22
0
			public void GetInteger (All name, ref int value)
			{
				GLES20.GetInteger (name, ref value);
			}
Exemplo n.º 23
0
			public void FramebufferRenderbuffer (
				All target, All attachment, All renderbuffertarget, int renderbuffer)
			{
				GLES20.FramebufferRenderbuffer (target, attachment, renderbuffertarget, renderbuffer);
			}
Exemplo n.º 24
0
		public override void BindToFramebuffer( All attachment, int zoffset )
		{
			GL.FramebufferTexture2D( All.Framebuffer, attachment, this.faceTarget, this.textureID, this.level );
			GLES2Config.GlCheckError( this );
		}
Exemplo n.º 25
0
			public void FramebufferRenderbuffer (
				All target, All attachment, All renderbuffertarget, int renderbuffer)
			{
				GLES11.Oes.FramebufferRenderbuffer (
					(All11) target, (All11) attachment, (All11) renderbuffertarget, renderbuffer);
			}
Exemplo n.º 26
0
		public virtual void GetBestDepthStencil( GLenum internalColorFormat, ref GLenum depthFormat, ref GLenum stencilFormat )
		{
			depthFormat = GLenum.None;
			stencilFormat = GLenum.None;
		}
Exemplo n.º 27
0
			public void BindFramebuffer (All target, int framebuffer)
			{
				GLES20.BindFramebuffer (target, framebuffer);
			}
Exemplo n.º 28
0
		/// <summary>
		///   Function to get the closest matching Axiom format to an internal GL format. To be precise, the format will be chosen that is most efficient to transfer to the card without losing precision
		/// </summary>
		/// <remarks>
		///   It is valid for this function to always return PixelFormat.A8R8G8B8
		/// </remarks>
		/// <param name="fmt"> </param>
		/// <param name="dataType"> </param>
		/// <returns> </returns>
		public static PixelFormat GetClosestAxiomFormat( GLenum fmt, GLenum dataType )
		{
			switch ( fmt )
			{
				case GLenum.CompressedRgbPvrtc2Bppv1Img:
					return PixelFormat.PVRTC_RGB2;
				case GLenum.CompressedRgbaPvrtc2Bppv1Img:
					return PixelFormat.PVRTC_RGBA2;
				case GLenum.CompressedRgbPvrtc4Bppv1Img:
					return PixelFormat.PVRTC_RGB4;
				case GLenum.CompressedRgbaPvrtc4Bppv1Img:
					return PixelFormat.PVRTC_RGBA4;

				case GLenum.Luminance:
					return PixelFormat.L8;
				case GLenum.Alpha:
					return PixelFormat.A8;
				case GLenum.LuminanceAlpha:
					return PixelFormat.BYTE_LA;
				case GLenum.Rgb:
					switch ( dataType )
					{
						case GLenum.UnsignedShort565:
							return PixelFormat.B5G6R5;
						default:
							return PixelFormat.R8G8B8;
					}
				case GLenum.Rgba:
					switch ( dataType )
					{
						case GLenum.UnsignedShort5551:
							return PixelFormat.A1R5G5B5;
						case GLenum.UnsignedShort4444:
							return PixelFormat.A4R4G4B4;
						default:
							return PixelFormat.A8R8G8B8;
					}
				case GLenum.Bgra:
					return PixelFormat.A8B8G8R8;

				default:
					//Ogre TODO: not supported
					return PixelFormat.A8R8G8B8;
			}
		}
Exemplo n.º 29
0
        /// <summary>
        /// Build the shaders
        /// </summary>
        private int LoadShader(All20 type, string source)
        {
            int shader = GL20.CreateShader(type);

            if (shader == 0)
                throw new InvalidOperationException("Unable to create shader");

            // Load the shader source
            int length = 0;
            GL20.ShaderSource(shader, 1, new string[] { source }, new int[] { source.Length });

            // Compile the shader
            GL20.CompileShader(shader);

            int[] compiled = new int[1];
            GL20.GetShader(shader, All20.CompileStatus, compiled);
            if (compiled[0] == 0)
            {
                length = 0;
                GL20.GetShader(shader, All20.InfoLogLength, ref length);
                var log = new StringBuilder(length);
                GL20.GetShaderInfoLog(shader, length, ref length, log);
                Console.WriteLine("GL2" + log.ToString());
                GL20.DeleteShader(shader);

                //length = 0;
                //GL20.GetShader(shader, All20.InfoLogLength, ref length);
                //if (length > 0)
                //{
                //    var log = new StringBuilder(length);
                //    GL20.GetShaderInfoLog(shader, length, ref length, log);
                //    Console.WriteLine("GL2" + log.ToString());
                //}
                //GL20.DeleteShader(shader);
                throw new InvalidOperationException("Unable to compile shader of type : " + type.ToString());
            }

            return shader;
        }
Exemplo n.º 30
0
 public static void ExtGetTexSubImage(OpenTK.Graphics.ES20.All target, Int32 level, Int32 xoffset, Int32 yoffset, Int32 zoffset, Int32 width, Int32 height, Int32 depth, OpenTK.Graphics.ES20.All format, OpenTK.Graphics.ES20.All type, [OutAttribute] IntPtr texels)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 31
0
 public void BindFramebuffer(All target, int framebuffer)
 {
     GLES11.Oes.BindFramebuffer((All11)target, framebuffer);
 }
Exemplo n.º 32
0
 public static void ExtGetTexSubImage <T10>(OpenTK.Graphics.ES20.All target, Int32 level, Int32 xoffset, Int32 yoffset, Int32 zoffset, Int32 width, Int32 height, Int32 depth, OpenTK.Graphics.ES20.All format, OpenTK.Graphics.ES20.All type, [InAttribute, OutAttribute] ref T10 texels)
     where T10 : struct
 {
     throw new NotImplementedException();
 }
Exemplo n.º 33
0
 public void FramebufferRenderbuffer(
     All target, All attachment, All renderbuffertarget, int renderbuffer)
 {
     GLES11.Oes.FramebufferRenderbuffer(
         (All11)target, (All11)attachment, (All11)renderbuffertarget, renderbuffer);
 }
Exemplo n.º 34
0
 public All CheckFramebufferStatus(All target)
 {
     return((All)GLES11.Oes.CheckFramebufferStatus((All11)target));
 }
Exemplo n.º 35
0
			public void GetInteger (All name, ref int value)
			{
				GLES11.GetInteger ((All11) name, ref value);
			}
Exemplo n.º 36
0
 public void BindRenderbuffer(All target, int renderbuffer)
 {
     GLES11.Oes.BindRenderbuffer((All11)target, renderbuffer);
 }
Exemplo n.º 37
0
 public override void BindToFramebuffer(All attachment, int zoffset)
 {
     GL.FramebufferRenderbuffer(All.Framebuffer, attachment, All.Renderbuffer, this.renderBufferID);
     GLES2Config.GlCheckError(this);
 }
Exemplo n.º 38
0
 public void GetInteger(All name, ref int value)
 {
     GLES11.GetInteger((All11)name, ref value);
 }
Exemplo n.º 39
0
        /// <summary>
        /// </summary>
        /// <param name="renderTarget"> </param>
        /// <returns> </returns>
        public override bool IsCompatible(RenderTarget renderTarget)
        {
            bool retVal = false;

            //Check standard stuff first.
            if (this._renderSystem.Capabilities.HasCapability(Capabilities.RTTDepthbufferResolutionLessEqual))
            {
                if (base.IsCompatible(renderTarget))
                {
                    return(false);
                }
            }
            else
            {
                if (Width != renderTarget.Width || Height != renderTarget.Height || Fsaa != renderTarget.FSAA)
                {
                    return(false);
                }
            }
            //Now check this is the appropriate format
            GLES2FrameBufferObject fbo = null;

            fbo = (GLES2FrameBufferObject)renderTarget["FBO"];

            if (fbo == null)
            {
                var windowContext = (GLES2Context)renderTarget["GLCONTEXT"];

                //Non-FBO and FBO depth surfaces don't play along, only dummmies which match the same
                //context
                if (this._depthBuffer == null && this._stencilBuffer == null && this._creatorContext == windowContext)
                {
                    retVal = true;
                }
            }
            else
            {
                //Check this isn't a dummy non-FBO depth buffer with an FBO target, don't mix them.
                //If you don't want depth buffer, use a Null Depth Buffer, not a dummy one.
                if (this._depthBuffer != null || this._stencilBuffer != null)
                {
                    var    internalFormat = fbo.Format;
                    GLenum depthFormat = GLenum.None, stencilFormat = GLenum.None;
                    this._renderSystem.GetDepthStencilFormatFor(internalFormat, ref depthFormat, ref stencilFormat);
                    bool bSameDepth = false;
                    if (this._depthBuffer != null)
                    {
                        bSameDepth |= this._depthBuffer.GLFormat == depthFormat;
                    }

                    bool bSameStencil = false;
                    if (this._stencilBuffer == null || this._stencilBuffer == this._depthBuffer)
                    {
                        bSameDepth = stencilFormat == GLenum.None;
                    }
                    else
                    {
                        if (this._stencilBuffer != null)
                        {
                            bSameStencil = stencilFormat == this._stencilBuffer.GLFormat;
                        }
                    }

                    retVal = bSameDepth && bSameStencil;
                }
            }

            return(retVal);
        }
Exemplo n.º 40
0
 public void BindFramebuffer(All target, int framebuffer)
 {
     GLES20.BindFramebuffer(target, framebuffer);
 }
Exemplo n.º 41
0
		//todo: replace object with actual type
		public void BindGLBuffer( GLenum target, int buffer )
		{
			if ( this.activeBufferMap.ContainsKey( target ) == false )
			{
				//Haven't cached this state yet. Insert it into the map
				this.activeBufferMap.Add( target, buffer );

				//Update GL
				GL.BindBuffer( target, buffer );
				GLES2Config.GlCheckError( this );
			}
			else
			{
				//Update the cached value if needed
				if ( this.activeBufferMap[ target ] != buffer )
				{
					this.activeBufferMap[ target ] = buffer;

					//Update GL
					GL.BindBuffer( target, buffer );
					GLES2Config.GlCheckError( this );
				}
			}
		}
Exemplo n.º 42
0
 public void FramebufferRenderbuffer(
     All target, All attachment, All renderbuffertarget, int renderbuffer)
 {
     GLES20.FramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
 }
Exemplo n.º 43
0
		//todo: replace object with actual type
		public void DeleteGLBuffer( GLenum target, int buffer )
		{
			if ( this.activeBufferMap.ContainsKey( target ) )
			{
				if ( this.activeBufferMap[ target ] == buffer )
				{
					this.activeBufferMap.Remove( target );
				}
			}
		}
Exemplo n.º 44
0
		public void GetDepthStencilFormatFor( GLenum internalColorFormat, ref GLenum depthFormat, ref GLenum stencilFormat )
		{
			this.rttManager.GetBestDepthStencil( internalColorFormat, ref depthFormat, ref stencilFormat );
		}
Exemplo n.º 45
0
		public override void BindToFramebuffer( All attachment, int zoffset )
		{
			GL.FramebufferRenderbuffer( All.Framebuffer, attachment, All.Renderbuffer, this.renderBufferID );
			GLES2Config.GlCheckError( this );
		}
Exemplo n.º 46
0
		public GLES2TextureBuffer( string baseName, All target, int id, int width, int height, All internalFormat, All format, int face, int level, BufferUsage usage, bool crappyCard, bool writeGamma, int fsaa )
			: base( 0, 0, 0, PixelFormat.Unknown, usage )
		{
			this.target = target;
			this.textureID = id;
			this.face = face;
			this.level = level;
			this.softwareMipmap = crappyCard;

			GLES2Config.GlCheckError( this );
			GL.BindTexture( target, this.textureID );
			GLES2Config.GlCheckError( this );

			//Get face identifier
			this.faceTarget = this.target;
			if ( this.target == All.TextureCubeMap )
			{
				this.faceTarget = All.TextureCubeMapPositiveX + face;
			}
			//Calculate the width and height of the texture at this mip level
			this.width = this.level == 0 ? width : (int) ( width / Math.Utility.Pow( 2, level ) );
			this.height = this.level == 0 ? height : (int) ( height / Math.Utility.Pow( 2, level ) );

			if ( this.width < 1 )
			{
				this.width = 1;
			}
			if ( this.height < 1 )
			{
				this.height = 1;
			}

			//Only 2D is supporte so depth is always 1
			depth = 1;

			GlInternalFormat = internalFormat;
			this.format = GLES2PixelUtil.GetClosestAxiomFormat( internalFormat, format );

			rowPitch = this.width;
			slicePitch = this.height * this.width;
			sizeInBytes = PixelUtil.GetMemorySize( this.width, this.height, depth, this.format );
			//Setup a pixel box
			Buffer = new PixelBox( this.width, this.height, depth, this.format );

			if ( this.width == 0 || this.height == 0 || depth == 0 )
			{
				//We are invalid, do not allocat a buffer
				return;
			}

			if ( ( (TextureUsage) usage & TextureUsage.RenderTarget ) == TextureUsage.RenderTarget )
			{
				//Create render target for each slice

				for ( int zoffset = 0; zoffset < depth; zoffset++ )
				{
					var name = "rtt/ " + GetHashCode() + "/" + baseName;
					var rtarget = new GLES2SurfaceDesc { buffer = this, zoffset = zoffset };
					var trt = GLES2RTTManager.Instance.CreateRenderTexture( name, rtarget, writeGamma, fsaa );
					this.sliceTRT.Add( trt );
					Core.Root.Instance.RenderSystem.AttachRenderTarget( this.sliceTRT[ zoffset ] );
				}
			}
		}
Exemplo n.º 47
0
 public static void ExtGetBufferPointer <T1>(OpenTK.Graphics.ES20.All target, [InAttribute, OutAttribute] ref T1 @params)
     where T1 : struct
 {
     throw new NotImplementedException();
 }
Exemplo n.º 48
0
 public static void FramebufferTexture2DMultisample(OpenTK.Graphics.ES20.All target, OpenTK.Graphics.ES20.All attachment, OpenTK.Graphics.ES20.All textarget, UInt32 texture, Int32 level, Int32 samples)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 49
0
 public static unsafe void ExtGetProgramBinarySource(UInt32 program, OpenTK.Graphics.ES20.All shadertype, [OutAttribute] StringBuilder source, [OutAttribute] Int32 *length)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 50
0
        public CVOpenGLESTexture TextureFromImage(CVImageBuffer imageBuffer, bool isTexture2d, OpenTK.Graphics.ES20.All internalFormat, int width, int height, OpenTK.Graphics.ES20.All pixelFormat, OpenTK.Graphics.ES20.DataType pixelType, int planeIndex, out CVReturn errorCode)
        {
            if (imageBuffer == null)
            {
                throw new ArgumentNullException("imageBuffer");
            }

            int    target = isTexture2d ? 0x0DE1 /* GL_TEXTURE_2D */ : 0x8D41 /* GL_RENDERBUFFER */;
            IntPtr texture;

            errorCode = CVOpenGLESTextureCacheCreateTextureFromImage(
                IntPtr.Zero,
                handle,                 /* textureCache dict, one day we might add it */
                imageBuffer.Handle,
                IntPtr.Zero,
                target,
                internalFormat, width, height, pixelFormat,
                pixelType, (IntPtr)planeIndex, out texture);
            if (errorCode != 0)
            {
                return(null);
            }
            return(new CVOpenGLESTexture(texture));
        }
Exemplo n.º 51
0
 public static unsafe void ExtGetTexLevelParameter(UInt32 texture, OpenTK.Graphics.ES20.All face, Int32 level, OpenTK.Graphics.ES20.All pname, [OutAttribute] Int32 * @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 52
0
 public static void ExtGetBufferPointer(OpenTK.Graphics.ES20.All target, [OutAttribute] IntPtr @params)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 53
0
			public void BindRenderbuffer (All target, int renderbuffer)
			{
				GLES11.Oes.BindRenderbuffer ((All11) target, renderbuffer);
			}