/// <summary> /// All application initialization is performed here, before the main loop thread is executed and the render panel is displayed for the first time. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RenderForm_Load(object sender, EventArgs e) { OpenGL.PIXELFORMATDESCRIPTOR pixelformatdescriptor = new OpenGL.PIXELFORMATDESCRIPTOR(); pixelformatdescriptor.Init(); dc = OpenGL.GetDC(renderPanel.Handle); int pixelFormat = OpenGL.ChoosePixelFormat(dc, ref pixelformatdescriptor); if (!OpenGL.SetPixelFormat(dc, pixelFormat, ref pixelformatdescriptor)) { throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); } if ((hglrc = OpenGL.wglCreateContext(dc)) == IntPtr.Zero) { throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); } if (!OpenGL.wglMakeCurrent(dc, hglrc)) { OpenGL.wglDeleteContext(hglrc); MessageBox.Show("Failed to init OpenGL context\nMake sure you have an OpenGL 2.0 compatible graphics card with the latest drivers installed!\nAlso verify if the pipeline config file exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } if (!app.init()) { MessageBox.Show("Failed to init application.\nMake sure you have an OpenGL 2.0 compatible graphics card with the latest drivers installed!\nAlso verify if the pipeline config file exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); h3d.release(); OpenGL.wglDeleteContext(hglrc); Environment.Exit(0); } app.resize(renderPanel.Size.Width, renderPanel.Size.Height); }
/// <summary> /// All application initialization is performed here, before the main loop thread is executed and the render panel is displayed for the first time. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RenderForm_Load(object sender, EventArgs e) { if (!Horde3DUtils.initOpenGL(PInvoke.GetDC(renderPanel.Handle).ToInt32())) { throw new Exception("Failed to initialize OpenGL"); } if (!app.init()) { MessageBox.Show("Failed to init application.\nMake sure you have an OpenGL 2.0 compatible graphics card with the latest drivers installed!\nAlso verify if the pipeline config file exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Horde3D.release(); Horde3DUtils.releaseOpenGL(); Environment.Exit(0); } app.resize(renderPanel.Size.Width, renderPanel.Size.Height); }