diff --git a/Quik/OpenGL/GL.VertexArray.cs b/Quik/OpenGL/GL.VertexArray.cs index 577c356..5094ca0 100644 --- a/Quik/OpenGL/GL.VertexArray.cs +++ b/Quik/OpenGL/GL.VertexArray.cs @@ -72,7 +72,7 @@ namespace Quik.OpenGL _vertexAttribPointer(location, size, type, normalized, stride, (IntPtr)offset); [MethodImpl(AggressiveInlining)] - public static void VertexAttibIPointer(int location, int size, GLEnum type, int stride, int offset) => + public static void VertexAttribIPointer(int location, int size, GLEnum type, int stride, int offset) => _vertexAttribIPointer(location, size, type, stride, (IntPtr)offset); } } \ No newline at end of file diff --git a/Quik/OpenGL/GL.cs b/Quik/OpenGL/GL.cs index 22cee23..7a2183c 100644 --- a/Quik/OpenGL/GL.cs +++ b/Quik/OpenGL/GL.cs @@ -17,8 +17,12 @@ namespace Quik.OpenGL private delegate void GLF4Proc(float x, float y, float z, float w); private delegate void DrawElementsProc(GLEnum primitive, int size, GLEnum type, void *offset); private delegate void DrawArraysProc(GLEnum primitive, int size, void *offset); + private delegate void GetIntegervProc(GLEnum pname, int *data); + private delegate void GetFloatvProc(GLEnum pname, float *data); + private delegate byte* GetStringProc(GLEnum pname); private const short AggressiveInlining = (short)MethodImplOptions.AggressiveInlining; + private static GetProcAddressProc _getProcAddress; private static GLEnum1Proc _enable; private static GLEnum1Proc _disable; @@ -29,6 +33,9 @@ namespace Quik.OpenGL private static GLF4Proc _clearColor; private static DrawElementsProc _drawElements; private static DrawArraysProc _drawArrays; + private static GetIntegervProc _getIntegerv; + private static GetFloatvProc _getFloatv; + private static GetStringProc _getString; private static T GetProcAddress(string procName) where T : Delegate @@ -50,6 +57,9 @@ namespace Quik.OpenGL _clearColor = GetProcAddress("glClearColor"); _drawElements = GetProcAddress("glDrawElements"); _drawArrays = GetProcAddress("glDrawArrays"); + _getIntegerv = GetProcAddress("glGetIntegerv"); + _getFloatv = GetProcAddress("glGetFloatv"); + _getString = GetProcAddress("glGetString"); LoadBuffer(); LoadProgram(); @@ -79,5 +89,36 @@ namespace Quik.OpenGL [MethodImpl(AggressiveInlining)] public static void DrawArrays(GLEnum primitive, int count, int offset) => _drawArrays(primitive, count, (void*)offset); + + [MethodImpl(AggressiveInlining)] + public static void Get(GLEnum pname, out int value) + { + value = default; + fixed(int* ptr = &value) + { + _getIntegerv(pname, ptr); + } + } + + [MethodImpl(AggressiveInlining)] + public static void Get(GLEnum pname, out float value) + { + value = default; + fixed (float* ptr = &value) + { + _getFloatv(pname, ptr); + } + } + + [MethodImpl(AggressiveInlining)] + public static string GetString(GLEnum pname) + { + int length; + byte* str = _getString(pname); + + for (length = 0; str[length] == 0 || length < 256; length++); + + return System.Text.Encoding.UTF8.GetString(str, length); + } } } \ No newline at end of file diff --git a/Quik/OpenGL/GLEnum.cs b/Quik/OpenGL/GLEnum.cs index edd1ff0..5b87531 100644 --- a/Quik/OpenGL/GLEnum.cs +++ b/Quik/OpenGL/GLEnum.cs @@ -2,6 +2,14 @@ namespace Quik.OpenGL { public enum GLEnum : int { + GL_OK = 0, + GL_MAJOR_VERSION = 0x821B, + GL_MINOR_VERSION = 0x821C, + GL_VENDOR = 0x1F00, + GL_RENDERER = 0x1F01, + GL_VERSION = 0x1F02, + GL_EXTENSIONS = 0x1F03, + GL_MULTISAMPLE = 0x809D, GL_BLEND = 0x0BE2, @@ -31,6 +39,14 @@ namespace Quik.OpenGL GL_STREAM_DRAW = 0x88E0, + GL_TEXTURE0 = 0x84C0, + GL_TEXTURE1 = GL_TEXTURE0 + 1, + GL_TEXTURE2 = GL_TEXTURE0 + 2, + GL_TEXTURE3 = GL_TEXTURE0 + 3, + GL_TEXTURE4 = GL_TEXTURE0 + 4, + GL_TEXTURE5 = GL_TEXTURE0 + 5, + GL_TEXTURE6 = GL_TEXTURE0 + 6, + GL_TEXTURE_2D = 0x0DE1, GL_UNPACK_ALIGNMENT = 0x0CF5,