コード例 #1
0
        /// <summary>
        /// Get a function pointer from the OpenGL driver.
        /// </summary>
        /// <param name="function">
        /// A <see cref="String"/> that specifies the function name.
        /// </param>
        /// <returns>
        /// It returns an <see cref="IntPtr"/> that specifies the address of the function <paramref name="function"/>.
        /// </returns>
        public IntPtr GetOpenGLProcAddress(string function)
        {
            IntPtr procAddress = UnsafeNativeMethods.wglGetProcAddress(function);

#if PLATFORM_LOG_ENABLED
            KhronosApi.LogFunction("wglGetProcAddress({0}) = 0x{1}", function, procAddress.ToString("X8"));
#endif

            return(procAddress);
        }
コード例 #2
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting managed/unmanaged resources.
 /// </summary>
 /// <param name="disposing">
 ///
 /// A <see cref="System.Boolean"/> indicating whether the disposition is requested explictly.
 /// </param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if ((_OwnDisplay == true) && (Display != IntPtr.Zero))
         {
             Glx.UnsafeNativeMethods.XCloseDisplay(Display);
             KhronosApi.LogFunction("XCloseDisplay({0})", Display.ToString("X"));
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Initializes the X11 multithreading.
        /// </summary>
        /// <exception cref='InvalidOperationException'>
        /// Is thrown when an operation cannot be performed.
        /// </exception>
        public static void InitializeMultithreading()
        {
            // Ensure to have X11 thread system initialized
            int initialized = Glx.UnsafeNativeMethods.XInitThreads();

            KhronosApi.LogFunction("XInitThreads() = {0}", initialized);

            if (initialized == 0)
            {
                throw new InvalidOperationException("platform does not support multithreading");
            }

            _MultithreadingInitialized = true;
        }
コード例 #4
0
        /// <summary>
        /// Construct a <see cref="Derm.Render.XServerDeviceContext"/> class that opens the specified display.
        /// </summary>
        /// <param name="display">
        /// A <see cref="System.IntpPtr"/> that will be argument of <see cref="Glx.XOpenDisplay"/>, indeed
        /// specifying the display to connect to.
        /// </param>
        /// <remarks>
        /// The property <see cref="WindowHandle"/> must be set to a valid value, since no window is created. The
        /// window handle shall be created using the display <see cref="Display"/>.
        /// </remarks>
        /// <exception cref='InvalidOperationException'>
        /// Exception thrown in the case it is not possible to connect with the display <paramref name="display"/>.
        /// </exception>
        public XServerDeviceContext(IntPtr display)
        {
            // Open display (follows DISPLAY environment variable)
            _Display = Glx.UnsafeNativeMethods.XOpenDisplay(display);
            KhronosApi.LogFunction("XOpenDisplay(0x0) = 0x{0}", _Display.ToString("X"));
            if (_Display == IntPtr.Zero)
            {
                throw new InvalidOperationException(String.Format("unable to connect to X server display {0}", display.ToInt32()));
            }
            // Need to close display
            _OwnDisplay = true;
            // Screen
            _Screen = Glx.UnsafeNativeMethods.XDefaultScreen(_Display);

            // Query GLX extensions
            QueryVersion();
        }
コード例 #5
0
ファイル: GetProcAddressOS.cs プロジェクト: kf6kjg/OpenGL.Net
        /// <summary>
        /// Get a function pointer from a library, specified by handle.
        /// </summary>
        /// <param name="library">
        /// A <see cref="IntPtr"/> which represents an opaque handle to the library containing the function.
        /// </param>
        /// <param name="function">
        /// A <see cref="String"/> that specifies the function name.
        /// </param>
        /// <returns>
        /// It returns an <see cref="IntPtr"/> that specifies the address of the function <paramref name="function"/>.
        /// </returns>
        private IntPtr GetProcAddress(IntPtr library, string function)
        {
            if (library == IntPtr.Zero)
            {
                throw new ArgumentNullException("library");
            }
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }

            IntPtr procAddress = UnsafeNativeMethods.Win32GetProcAddress(library, function);

#if PLATFORM_LOG_ENABLED
            KhronosApi.LogFunction("GetProcAddress(0x{0}, {1}) = 0x{2}", library.ToString("X8"), function, procAddress.ToString("X8"));
#endif

            return(procAddress);
        }
コード例 #6
0
        private IntPtr GetLibraryHandle(string libraryPath)
        {
            IntPtr libraryHandle;

            if (_LibraryHandles.TryGetValue(libraryPath, out libraryHandle) == false)
            {
                libraryHandle = UnsafeNativeMethods.LoadLibrary(libraryPath);
#if PLATFORM_LOG_ENABLED
                KhronosApi.LogFunction("LoadLibrary({0}) = 0x{1}", libraryPath, libraryHandle.ToString("X8"));
#endif

                _LibraryHandles.Add(libraryPath, libraryHandle);
            }

            if (libraryHandle == IntPtr.Zero)
            {
                throw new InvalidOperationException(String.Format("unable to load library at {0}", libraryPath));
            }

            return(libraryHandle);
        }