Exemplo n.º 1
0
 private static void LoadFunctionPointers()
 {
     GenBuffers = GetMethod <glGenBuffers>();
     BindBuffer = GetMethod <glBindBuffer>();
     BufferData = GetMethod <glBufferData>();
     EnableVertexAttribArray = GetMethod <glEnableVertexAttribArray>();
     VertexAttribPointer     = GetMethod <glVertexAttribPointer>();
     GenVertexArrays         = GetMethod <glGenVertexArrays>();
     BindVertexArray         = GetMethod <glBindVertexArray>();
     ClearColor = GetMethod <glClearColor>();
     Clear      = GetMethod <glClear>();
 }
Exemplo n.º 2
0
        public static void Init(IntPtr hwnd)
        {
            var dc = GetDC(hwnd);

            DC = dc;
            var pfd = new PixelFormatDescriptor(null);
            var pfn = ChoosePixelFormat(dc, ref pfd);

            DescribePixelFormat(dc, pfn, (short)Marshal.SizeOf(typeof(PixelFormatDescriptor)), ref pfd);
            SetPixelFormat(dc, pfn, ref pfd);
            GLContext = CreateContext(dc);
            MakeCurrent(dc, GLContext);
            GenVertexArray =
                (glGenVertexArray)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glGenVertexArrays"), typeof(glGenVertexArray));
            BindVertexArray =
                (glBindVertexArray)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glBindVertexArray"), typeof(glBindVertexArray));
            GenBuffer =
                (glGenBuffers)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glGenBuffers"), typeof(glGenBuffers));
            BindBuffer =
                (glBindBuffer)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glBindBuffer"), typeof(glBindBuffer));
            BufferData =
                (glBufferData)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glBufferData"), typeof(glBufferData));
            VertexAttribPointer =
                (glVertexAttribPointer)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glVertexAttribPointer"),
                                                      typeof(glVertexAttribPointer));
            EnableVertexAttribArray =
                (glEnableVertexAttribArray)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glEnableVertexAttribArray"),
                                                      typeof(glEnableVertexAttribArray));
            UniformMatrix4 =
                (glUniformMatrix4fv)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glUniformMatrix4fv"),
                                                      typeof(glUniformMatrix4fv));
            CreateShader =
                (glCreateShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glCreateShader"), typeof(glCreateShader));
            CreateProgram =
                (glCreateProgram)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glCreateProgram"), typeof(glCreateProgram));
            CompileShader =
                (glPassShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glCompileShader"), typeof(glPassShader));
            DeleteShader =
                (glPassShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glDeleteShader"), typeof(glPassShader));
            LinkProgram =
                (glPassShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glLinkProgram"), typeof(glPassShader));
            UseProgram =
                (glPassShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glUseProgram"), typeof(glPassShader));
            DeleteProgram =
                (glPassShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glDeleteProgram"), typeof(glPassShader));
            ShaderSource =
                (glShaderSource)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glShaderSource"), typeof(glShaderSource));
            AttachShader =
                (glAttachShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glAttachShader"), typeof(glAttachShader));
            DetachShader =
                (glAttachShader)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glDetachShader"), typeof(glAttachShader));
            GetUniformLocation =
                (glGetUniformLocation)
                Marshal.GetDelegateForFunctionPointer(wglGetProcAddress("glGetUniformLocation"),
                                                      typeof(glGetUniformLocation));
        }
Exemplo n.º 3
0
 public override void LoadFunctionPointers()
 {
     base.LoadFunctionPointers();
     GenVertexArrays = GL.GetMethod <glGenVertexArrays>();
     BindVertexArray = GL.GetMethod <glBindVertexArray>();
 }