public Game(string strDisplay, GameContextConfig pConfig, string title, WindowStyle style) { m_strDisplay = strDisplay; m_pContextConfig = pConfig; m_pGameWindow = new BaseGameWindow(this, title, style); m_pGameWindow.Create(); }
public glxNativeContext(IWindow handle, GameContextConfig pConfig) : base("OpenGL_Context_" + handle.Name.Remove(handle.Name.Length - 1), IntPtr.Zero) { m_pWindow = handle; m_bOwned = true; m_rDefaultViewport = Viewport; m_pGameConfig = pConfig; m_pConfigs = new FBConfigs(m_pWindow, pConfig); if (pConfig.GraphicConfigType == NativContextConfigTyp.Best) { m_pNativeConfig = m_pConfigs.Best; } else if (pConfig.GraphicConfigType == NativContextConfigTyp.Worst) { m_pNativeConfig = m_pConfigs.Worst; } else { m_pNativeConfig = m_pConfigs.Configs[pConfig.NormalGraphicConfigTypeNumber]; } LoadExtension(); }
internal static IGLNativeContext GetContext(IWindow handle, GameContextConfig pConfig) { #if LINUX return(new glxNativeContext(handle, pConfig)); #endif }
public unsafe FBConfigs(IWindow pWindow, GameContextConfig pConfig) { m_pConfigs = new List <INativContextConfig>(); int[] visual_attribs = { (int)GLX.X_RENDERABLE, (int)GL.TRUE, (int)GLX.DRAWABLE_TYPE, (int)GLX.WINDOW_BIT, (int)GLX.DOUBLEBUFFER, (int)GL.TRUE, (int)GLX.RENDER_TYPE, (int)GLX.RGBA_BIT, (int)GLX.X_VISUAL_TYPE, (int)GLX.TRUE_COLOR, (int)GLX.BUFFER_SIZE, pConfig.Color, (int)GLX.DEPTH_SIZE, pConfig.Depth, (int)GLX.STENCIL_SIZE, pConfig.Stencil, (int)GLX.DOUBLEBUFFER, (int)GL.TRUE, (int)GLX.SAMPLE_BUFFERS, pConfig.EnableSample ? (int)GL.TRUE : (int)GL.FALSE, 0 }; int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999; int fbcount; IntPtr *fbc = glxNativeContext.glXChooseFBConfig(pWindow.Display.RawHandle, pWindow.Display.Screen.ScreenNumber, visual_attribs, out fbcount); for (int i = 0; i < fbcount; i++) { IntPtr _config = fbc[i]; XVisualInfo *vi = glxNativeContext.glXGetVisualFromFBConfig(pWindow.Display.RawHandle, _config); if (vi != null) { int samp_buf = 0, samples = 0; glxNativeContext.glXGetFBConfigAttrib(pWindow.Display.RawHandle, fbc[i], (int)GLX.SAMPLE_BUFFERS, ref samp_buf); glxNativeContext.glXGetFBConfigAttrib(pWindow.Display.RawHandle, fbc[i], (int)GLX.SAMPLES, ref samples); if (vi->Depth == pConfig.Depth && ((pConfig.EnableSample && samp_buf >= 1) || (!pConfig.EnableSample && samp_buf == 0))) { //int iID, IntPtr pConfig, int iSampleBuf, int iSamples m_pConfigs.Add(new FBConfig(i, fbc[i], samp_buf, samples, *vi)); if (best_fbc < 0 || samp_buf == 1 && samples > best_num_samp) { best_fbc = i; best_num_samp = samples; } if (worst_fbc < 0 || samp_buf == 0 || samples < worst_num_samp) { worst_fbc = i; worst_num_samp = samples; } } } //X11._internal.Lib.XFree( vi ); } if (m_pConfigs.Count == 0) { throw new System.Exception("No Configs found"); } #if DEBUG m_pBest = this[best_fbc]; ((FBConfig)m_pBest).Typ = NativContextConfigTyp.Best; m_pWorst = this[worst_fbc]; ((FBConfig)m_pWorst).Typ = NativContextConfigTyp.Worst; ConsoleColor oldForground = Console.ForegroundColor; foreach (var item in m_pConfigs) { if (item.Typ == NativContextConfigTyp.Best) { Console.ForegroundColor = ConsoleColor.Green; } else if (item.Typ == NativContextConfigTyp.Worst) { Console.ForegroundColor = ConsoleColor.Blue; } else { Console.ForegroundColor = oldForground; } Console.WriteLine(item.ToString()); } Console.ForegroundColor = oldForground; #endif }