static GraphicsMode() { lock (SyncRoot) { implementation = Platform.Factory.Default.CreateGraphicsMode(); } }
public void WithGraphicsMode(IGraphicsMode mode, Action inner) { if (mode == currentGraphicsMode) { inner(); return; } IGraphicsMode prevGraphicsMode = currentGraphicsMode; currentGraphicsMode = mode; if (prevGraphicsMode != null) { prevGraphicsMode.Uninitialize(); } try { mode.Initialize(); inner(); } finally { mode.Uninitialize(); currentGraphicsMode = prevGraphicsMode; if (currentGraphicsMode != null) { currentGraphicsMode.Initialize(); } } }
static WinGLContext() { // Dynamically load the OpenGL32.dll in order to use the extension loading capabilities of Wgl. if (opengl32Handle == IntPtr.Zero) { opengl32Handle = Functions.LoadLibrary(opengl32Name); if (opengl32Handle == IntPtr.Zero) throw new ApplicationException(String.Format("LoadLibrary(\"{0}\") call failed with code {1}", opengl32Name, Marshal.GetLastWin32Error())); Debug.WriteLine(String.Format("Loaded opengl32.dll: {0}", opengl32Handle)); } // We need to create a temp context in order to load // wgl extensions (e.g. for multisampling or GL3). // We cannot rely on OpenTK.Platform.Wgl until we // create the context and call Wgl.LoadAll(). Debug.Print("Creating temporary context for wgl extensions."); using (INativeWindow native = new NativeWindow()) { // Create temporary context and load WGL entry points WinWindowInfo window = native.WindowInfo as WinWindowInfo; ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); Wgl.Imports.MakeCurrent(window.DeviceContext, temp_context.Handle); Wgl.LoadAll(); // Query graphics modes ModeSelector = new WinGraphicsMode(temp_context, window.DeviceContext); // Destroy temporary context Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero); Wgl.Imports.DeleteContext(temp_context.Handle); wgl_loaded = true; } }
/* handling graphics modes */ public void UseGraphicsMode(IGraphicsMode mode) { if (currentGraphicsMode != null) { currentGraphicsMode.Uninitialize(); } currentGraphicsMode = mode; if (currentGraphicsMode != null) { currentGraphicsMode.Initialize(); } }
static GraphicsMode() { lock (SyncRoot) { #if RASPBERRYPI implementation = Platform.Factory.Embedded.CreateGraphicsMode(); #else implementation = Platform.Factory.Default.CreateGraphicsMode(); #endif } }
public void WithGraphicsMode(IGraphicsMode mode, Action inner) { if (mode == currentGraphicsMode) { inner(); return; } IGraphicsMode prevGraphicsMode = currentGraphicsMode; currentGraphicsMode = mode; if (prevGraphicsMode != null) { prevGraphicsMode.Uninitialize(); } try { mode.Initialize(); inner(); } finally { mode.Uninitialize(); currentGraphicsMode = prevGraphicsMode; if (currentGraphicsMode != null) currentGraphicsMode.Initialize(); } }
public EngineWindow() : base(800, 600, GraphicsMode.Default, "foo", GameWindowFlags.Default, null, 3, 0, GraphicsContextFlags.Default) { currentGraphicsMode = null; }
static GraphicsMode() { lock (GraphicsMode.SyncRoot) GraphicsMode.implementation = Factory.Default.CreateGraphicsMode(); }