Пример #1
0
 /// <summary>
 /// Link GLBuffer to existing OpenGL image. Used
 /// to provide debug information in the debug view.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="anno"></param>
 /// <param name="glname">OpenGL object to like to.</param>
 public GLImage(string name, string anno, int glname) : base(name, anno)
 {
     int f, t;
     this.glname = glname;
     this.Size = Enumerable.Repeat(1, 4).ToArray();
     GL.GetTextureParameter(glname, TexParameter.TextureTarget, out t);
     GL.GetTextureLevelParameter(glname, 0, TexParameter.TextureInternalFormat, out f);
     GL.GetTextureLevelParameter(glname, 0, TexParameter.TextureWidth, out Size[0]);
     GL.GetTextureLevelParameter(glname, 0, TexParameter.TextureHeight, out Size[1]);
     GL.GetTextureLevelParameter(glname, 0, TexParameter.TextureDepth, out Size[2]);
     Type = (TexTarget)t;
     Format = (GpuFormat)f;
     if (Type != TexTarget.Texture3D)
     {
         Size[3] = Size[2];
         Size[2] = 1;
     }
 }
Пример #2
0
 /// <summary>
 /// Allocate image memory and fill it with the specified data.
 /// </summary>
 /// <param name="target">texture target</param>
 /// <param name="width">texture width</param>
 /// <param name="height">texture height</param>
 /// <param name="depth">number of texture layers</param>
 /// <param name="length">number of texture layers</param>
 /// <param name="format">pixel format of the data to be uploaded</param>
 /// <param name="type">pixel type of the data to be uploaded</param>
 /// <param name="pixels">pixel data</param>
 private void TexImage(TexTarget target, int width, int height, int depth, int length,
     PixelFormat format, PixelType type, IntPtr pixels)
 {
     var colFormat = (GpuColorFormat)GpuFormat;
     switch (target)
     {
         case TexTarget.Texture1D:
             GL.TexImage1D(target, 0, colFormat, width, 0, format, type, pixels);
             break;
         case TexTarget.Texture1DArray:
             GL.TexImage2D(target, 0, colFormat, width, length, 0, format, type, pixels);
             break;
         case TexTarget.Texture2D:
             GL.TexImage2D(target, 0, colFormat, width, height, 0, format, type, pixels);
             break;
         case TexTarget.Texture2DArray:
             GL.TexImage3D(target, 0, colFormat, width, height, length, 0, format, type, pixels);
             break;
         case TexTarget.Texture3D:
             GL.TexImage3D(target, 0, colFormat, width, height, depth, 0, format, type, pixels);
             break;
     }
 }
Пример #3
0
 /// <summary>
 /// Allocate image memory.
 /// </summary>
 /// <param name="target">texture target</param>
 /// <param name="width">texture width</param>
 /// <param name="height">texture height</param>
 /// <param name="depth">number of texture layers</param>
 /// <param name="length">number of texture layers</param>
 /// <param name="levels">number of mipmap layers</param>
 private void TexImage(TexTarget target, int width, int height, int depth, int length, int levels)
 {
     levels = levels <= 0 ? MaxMipmapLevels(width, height) : 1;
     var colFormat = (SizedInternalFormat)GpuFormat;
     switch (target)
     {
         case TexTarget.Texture1D:
             GL.TexStorage1D((TextureTarget1d)target, levels, colFormat, width);
             break;
         case TexTarget.Texture1DArray:
             GL.TexStorage2D((TextureTarget2d)target, levels, colFormat, width, height);
             break;
         case TexTarget.Texture2D:
             GL.TexStorage2D((TextureTarget2d)target, levels, colFormat, width, height);
             break;
         case TexTarget.Texture2DArray:
             GL.TexStorage3D((TextureTarget3d)target, levels, colFormat, width, height, length);
             break;
         case TexTarget.Texture3D:
             GL.TexStorage3D((TextureTarget3d)target, levels, colFormat, width, height, depth);
             break;
     }
 }