public void PerformOperation(GLCmdImageInstructionSet instructionSet) { }
public void PerformOperation(GLCmdImageInstructionSet instructionSet) { const int DEFAULT_UNPACK_ALIGNMENT = 4; { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "PerformOperation BEFORE : " + error); } if (instructionSet == null) { return; } foreach (var inst in instructionSet.LoadImageData) { if (inst.Target == MgImageType.TYPE_1D) { if (inst.PixelFormat == (int)All.CompressedTextureFormats) { GL.Ext.CompressedTextureSubImage1D( inst.TextureId, TextureTarget.Texture1D, inst.Level, inst.Slice, inst.Width, (PixelFormat)inst.InternalFormat, inst.Size, inst.Data ); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "CompressedTextureSubImage1D END : " + error); } } else { // Set pixel alignment to match texel size in bytes GL.PixelStore(PixelStoreParameter.UnpackAlignment, GetUnpackSize(inst.Format)); GL.Ext.TextureSubImage1D( inst.TextureId, TextureTarget.Texture1D, inst.Level, 0, inst.Width, (PixelFormat)inst.PixelFormat, (PixelType)inst.PixelType, inst.Data ); GL.PixelStore(PixelStoreParameter.UnpackAlignment, DEFAULT_UNPACK_ALIGNMENT); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "TextureSubImage1D END : " + error); } } } else if (inst.Target == MgImageType.TYPE_2D) { if (inst.PixelFormat == (int)All.CompressedTextureFormats) { GL.Ext.CompressedTextureSubImage2D( inst.TextureId, TextureTarget.Texture1D, inst.Level, 0, inst.Slice, inst.Width, inst.Height, (PixelFormat)inst.InternalFormat, inst.Size, inst.Data ); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "CompressedTextureSubImage2D END : " + error); } } else { // Set pixel alignment to match texel size in bytes GL.PixelStore(PixelStoreParameter.UnpackAlignment, GetUnpackSize(inst.Format)); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "PixelStore BEGIN : " + error); } // SEEMS to behave like glTexImage2D // https://www.opengl.org/sdk/docs/man/html/glTexImage2D.xhtml GL.Ext.TextureSubImage2D( inst.TextureId, TextureTarget.Texture2D, inst.Level, 0, inst.Slice, inst.Width, inst.Height, (PixelFormat)inst.PixelFormat, (PixelType)inst.PixelType, inst.Data ); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "TextureSubImage2D END : " + error); } GL.PixelStore(PixelStoreParameter.UnpackAlignment, DEFAULT_UNPACK_ALIGNMENT); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "PixelStore END : " + error); } } } else if (inst.Target == MgImageType.TYPE_3D) { if (inst.PixelFormat == (int)All.CompressedTextureFormats) { GL.Ext.CompressedTextureSubImage3D( inst.TextureId, TextureTarget.Texture1D, inst.Level, 0, 0, inst.Slice, inst.Width, inst.Height, inst.Depth, (PixelFormat)inst.InternalFormat, inst.Size, inst.Data ); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "CompressedTextureSubImage3D END : " + error); } } else { // Set pixel alignment to match texel size in bytes GL.PixelStore(PixelStoreParameter.UnpackAlignment, GetUnpackSize(inst.Format)); GL.Ext.TextureSubImage3D( inst.TextureId, TextureTarget.Texture3D, inst.Level, 0, 0, inst.Slice, inst.Width, inst.Height, inst.Depth, (PixelFormat)inst.PixelFormat, (PixelType)inst.PixelType, inst.Data ); GL.PixelStore(PixelStoreParameter.UnpackAlignment, DEFAULT_UNPACK_ALIGNMENT); { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "TextureSubImage3D END : " + error); } } } } { var error = GL.GetError(); Debug.WriteLineIf(error != ErrorCode.NoError, "PerformOperation END : " + error); } }