diff --git a/Quik/OpenGL/GL.Texture.cs b/Quik/OpenGL/GL.Texture.cs index 1f74b16..806b51e 100644 --- a/Quik/OpenGL/GL.Texture.cs +++ b/Quik/OpenGL/GL.Texture.cs @@ -9,7 +9,9 @@ namespace Quik.OpenGL private delegate void PixelStoreiProc(GLEnum pname, int param); private delegate void PixelStorefProc(GLEnum pname, float param); private delegate void TexImage2DProc(GLEnum target, int level, GLEnum internalFormat, int width, int height, int border, GLEnum format, GLEnum pixelType, void *data); + private delegate void TexImage3DProc(GLEnum target, int level, GLEnum internalFormat, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, void* data); private delegate void TexSubImage2DProc(GLEnum target, int level, int x, int y, int width, int height, GLEnum format, GLEnum pixelType, void *data); + private delegate void TexSubImage3DProc(GLEnum target, int level, int x, int y, int z, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, void* data); private delegate void TexParameteriProc(GLEnum target, GLEnum pname, int value); private delegate void TexParameterfProc(GLEnum target, GLEnum pname, float value); private delegate void TexParameterivProc(GLEnum target, GLEnum pname, int* value); @@ -23,7 +25,9 @@ namespace Quik.OpenGL private static PixelStoreiProc _pixelStorei; private static PixelStorefProc _pixelStoref; private static TexImage2DProc _texImage2D; + private static TexImage3DProc _texImage3D; private static TexSubImage2DProc _texSubImage2D; + private static TexSubImage3DProc _texSubImage3D; private static TexParameteriProc _texParameteri; private static TexParameterfProc _texParameterf; private static TexParameterivProc _texParameteriv; @@ -39,7 +43,9 @@ namespace Quik.OpenGL _pixelStorei = GetProcAddress("glPixelStorei"); _pixelStoref = GetProcAddress("glPixelStoref"); _texImage2D = GetProcAddress("glTexImage2D"); + _texImage3D = GetProcAddress("glTexImage3D"); _texSubImage2D = GetProcAddress("glTexSubImage2D"); + _texSubImage3D = GetProcAddress("glTexSubImage3D"); _texParameteri = GetProcAddress("glTexParameteri"); _texParameterf = GetProcAddress("glTexParameterf"); _texParameteriv = GetProcAddress("glTexParameteriv"); @@ -92,7 +98,7 @@ namespace Quik.OpenGL _texImage2D(target, level, internalFormat, width, height, border, format, pixelType, (void*)data); [MethodImpl(AggressiveInlining)] - public static void TexImage2d(GLEnum target, int level, GLEnum internalFormat, int width, int height, int border, GLEnum format, GLEnum pixelType, in T data) where T : unmanaged + public static void TexImage2D(GLEnum target, int level, GLEnum internalFormat, int width, int height, int border, GLEnum format, GLEnum pixelType, in T data) where T : unmanaged { fixed(T *ptr = &data) _texImage2D(target, level, internalFormat, width, height, border, format, pixelType, ptr); @@ -100,7 +106,24 @@ namespace Quik.OpenGL [MethodImpl(AggressiveInlining)] public static void TexImage2D(GLEnum target, int level, GLEnum internalFormat, int width, int height, int border, GLEnum format, GLEnum pixelType, T[] data) where T : unmanaged => - TexImage2d(target, level, internalFormat, width, height, border, format, pixelType, in data[0]); + TexImage2D(target, level, internalFormat, width, height, border, format, pixelType, in data[0]); + + [MethodImpl(AggressiveInlining)] + public static void TexImage3D(GLEnum target, int level, GLEnum internalFormat, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, void* data) => + _texImage3D(target, level, internalFormat, width, height, depth, border, format, pixelType, data); + + [MethodImpl(AggressiveInlining)] + public static void TexImage3D(GLEnum target, int level, GLEnum internalFormat, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, in T data) + where T : unmanaged + { + fixed (T* ptr = &data) + _texImage3D(target, level, internalFormat, width, height, depth, border, format, pixelType, ptr); + } + + [MethodImpl(AggressiveInlining)] + public static void TexImage3D(GLEnum target, int level, GLEnum internalFormat, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, T[] data) + where T : unmanaged => + TexImage3D(target, level, internalFormat, width, height, depth, border, format, pixelType, in data[0]); [MethodImpl(AggressiveInlining)] public static void TexSubImage2D(GLEnum target, int level, int x, int y, int width, int height, GLEnum format, GLEnum pixelType, IntPtr data) => @@ -117,6 +140,23 @@ namespace Quik.OpenGL public static void TexSubImage2D(GLEnum target, int level, int x, int y, int width, int height, GLEnum format, GLEnum pixelType, T[] data) where T : unmanaged => TexSubImage2d(target, level, x, y, width, height, format, pixelType, in data[0]); + [MethodImpl(AggressiveInlining)] + public static void TexSubImage3D(GLEnum target, int level, int x, int y, int z, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, void* data) => + _texSubImage3D(target, level, x, y, z, width, height, depth, border, format, pixelType, data); + + [MethodImpl(AggressiveInlining)] + public static void TexSubImage3D(GLEnum target, int level, int x, int y, int z, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, in T data) + where T : unmanaged + { + fixed (T* ptr = &data) + _texSubImage3D(target, level, x, y, z, width, height, depth, border, format, pixelType, ptr); + } + + [MethodImpl(AggressiveInlining)] + public static void TexSubImage3D(GLEnum target, int level, int x, int y, int z, int width, int height, int depth, int border, GLEnum format, GLEnum pixelType, T[] data) + where T : unmanaged => + TexSubImage3D(target, level, x, y, z, width, height, depth, border, format, pixelType, in data[0]); + [MethodImpl(AggressiveInlining)] public static void TexParameter(GLEnum target, GLEnum pname, int value) => _texParameteri(target, pname, value); [MethodImpl(AggressiveInlining)] diff --git a/Quik/OpenGL/GLEnum.cs b/Quik/OpenGL/GLEnum.cs index 3fedce9..f358433 100644 --- a/Quik/OpenGL/GLEnum.cs +++ b/Quik/OpenGL/GLEnum.cs @@ -50,6 +50,7 @@ namespace Quik.OpenGL GL_TEXTURE6 = GL_TEXTURE0 + 6, GL_TEXTURE_2D = 0x0DE1, + GL_TEXTURE_2D_ARRAY = 0x8C1A, GL_UNPACK_ALIGNMENT = 0x0CF5, GL_TEXTURE_MAG_FILTER = 0x2800,