Esempio n. 1
0
		static void Main()
		{
			string envDebug = Environment.GetEnvironmentVariable("DEBUG");

			if (envDebug == "GL") {
				KhronosApi.RegisterApplicationLogDelegate(delegate (string format, object[] args) {
					Console.WriteLine(format, args);
				});
			}

			try {
				// Gl.CurrentExtensions.FramebufferObject_ARB = false;		// Test P-Buffer
				// Egl.IsRequired = Egl.IsAvailable;						// Test EGL (not yet working)

				if (Gl.CurrentExtensions.FramebufferObject_ARB) {
					using (DeviceContext deviceContext = DeviceContext.Create()) {
						RenderOsdFramebuffer(deviceContext);
					}
				} else {
					// Fallback to old-school pbuffer
					using (INativePBuffer nativeBuffer = DeviceContext.CreatePBuffer(new DevicePixelFormat(24), 800, 600)) {
						using (DeviceContext deviceContext = DeviceContext.Create(nativeBuffer)) {
							RenderOsdPBuffer(deviceContext);
						}
					}
				}
			} catch (Exception exception) {
				Console.WriteLine("Unexpected exception: {0}", exception.ToString());
			}
		}
Esempio n. 2
0
        static void Main(string[] args)
        {
            Gl.Initialize();

            try {
                // Gl.CurrentExtensions.FramebufferObject_ARB = false;		// Test P-Buffer
                // Egl.IsRequired = Egl.IsAvailable;						// Test EGL (not yet working)

                if (Gl.CurrentExtensions.FramebufferObject_ARB)
                {
                    using (DeviceContext deviceContext = DeviceContext.Create()) {
                        RenderOsdFramebuffer(deviceContext);
                    }
                }
                else
                {
                    // Fallback to old-school pbuffer
                    using (INativePBuffer nativeBuffer = DeviceContext.CreatePBuffer(new DevicePixelFormat(24), 800, 600)) {
                        using (DeviceContext deviceContext = DeviceContext.Create(nativeBuffer)) {
                            RenderOsdPBuffer(deviceContext);
                        }
                    }
                }
            } catch (Exception exception) {
                Console.WriteLine("Unexpected exception: {0}", exception.ToString());
            }
        }
Esempio n. 3
0
        public void TestCreatePBuffer()
        {
            if (DeviceContext.IsPBufferSupported == false)
            {
                Assert.Inconclusive("platform don't support P-Buffers");
            }

            // Inconclusive test?
            switch (Platform.CurrentPlatformId)
            {
            case Platform.Id.WindowsNT:
                if (Wgl.CurrentExtensions.Pbuffer_ARB == false && Wgl.CurrentExtensions.Pbuffer_EXT == false)
                {
                    Assert.Inconclusive("no WGL_ARB_pbuffer or WGL_EXT_pbuffer support");
                }
                break;
            }

            INativePBuffer nativePBuffer = null;

            // P-Buffer creation should be possible on every platform
            Assert.DoesNotThrow(delegate() {
                nativePBuffer = DeviceContext.CreatePBuffer(new DevicePixelFormat(24), 64, 64);
            });
            Assert.IsNotNull(nativePBuffer);

            // Release resources
            nativePBuffer.Dispose();
        }
Esempio n. 4
0
        public static void Init()
        {
            Gl.Initialize();

            pixelBuff = DeviceContext.CreatePBuffer(new DevicePixelFormat(24), 128, 128);
            devCtx    = DeviceContext.Create(pixelBuff);
            glCtx     = devCtx.CreateContext(IntPtr.Zero);

            devCtx.MakeCurrent(glCtx);
        }
Esempio n. 5
0
 public Device(DevicePixelFormat pixelFormat)
 {
     if (DeviceContext.IsPBufferSupported)
     {
         _NativePBuffer = DeviceContext.CreatePBuffer(pixelFormat, 64, 64);
         Context        = DeviceContext.Create(_NativePBuffer);
     }
     else
     {
         Assert.Inconclusive("no UI backend available");
     }
 }
Esempio n. 6
0
        private void DeviceContext_Create3_Core()
        {
            if (DeviceContext.IsPBufferSupported == false)
            {
                Assert.Inconclusive("platform don't support P-Buffers");
            }

            DeviceContext deviceContext = null;

            using (INativePBuffer nativePBuffer = DeviceContext.CreatePBuffer(new DevicePixelFormat(24), 64, 64)) {
                Assert.DoesNotThrow(() => deviceContext = DeviceContext.Create(nativePBuffer));
                Assert.IsNotNull(nativePBuffer);

                // Release resources
                deviceContext.Dispose();
            }
        }
Esempio n. 7
0
        public void DeviceContext_CreatePBuffer_Core()
        {
            if (DeviceContext.IsPBufferSupported == false)
            {
                Assert.Inconclusive("platform don't support P-Buffers");
            }

            INativePBuffer nativePBuffer = null;

            Assert.Throws <ArgumentNullException>(() => DeviceContext.CreatePBuffer(null, 64, 64));

            // P-Buffer creation should be possible on every platform
            Assert.DoesNotThrow(() => nativePBuffer = DeviceContext.CreatePBuffer(new DevicePixelFormat(24), 64, 64));
            Assert.IsNotNull(nativePBuffer);

            // Release resources
            nativePBuffer.Dispose();
        }
Esempio n. 8
0
        private void TestUserCase3_Core()
        {
            if (DeviceContext.IsPBufferSupported == false)
            {
                Assert.Inconclusive("platform don't support P-Buffers");
            }

            using (INativePBuffer nativePBuffer = DeviceContext.CreatePBuffer(new DevicePixelFormat(24), 64, 64)) {
                using (DeviceContext deviceContext = DeviceContext.Create(nativePBuffer)) {
                    // The pixel format is already defined by INativePBuffer
                    Assert.IsTrue(deviceContext.IsPixelFormatSet);

                    IntPtr glContext = deviceContext.CreateContext(IntPtr.Zero);

                    deviceContext.MakeCurrent(glContext);
                    // Perform drawing...
                    deviceContext.MakeCurrent(IntPtr.Zero);
                    deviceContext.DeleteContext(glContext);
                }
            }
        }