Original Post
Hello!
Im using OpenGL in a .NET-based application (just for fun). As the title mentions in the following function wglCreateContext returns 0:
The errorcode is 2000 (incorrect pixelformat). SetPixelFormat returns true, and fmt is 4.
Isnt OpenGL running in FORMS-based applications?
Greetings
Plerion
Im using OpenGL in a .NET-based application (just for fun). As the title mentions in the following function wglCreateContext returns 0:
private void Form1_Load(object sender, EventArgs e) { GL.PIXELFORMATDESC desc = new GL.PIXELFORMATDESC(); desc.nSize = (ushort)Marshal.SizeOf(desc); desc.nVersion = 1; desc.dwFlags = (uint)(GL.PixelFormatDesc.PFD_DRAW_TO_WINDOW | GL.PixelFormatDesc.PFD_DOUBLEBUFFER | GL.PixelFormatDesc.PFD_SUPPORT_OPENGL); desc.iPixelType = (int)GL.PixelFormatDesc.PFD_TYPE_RGBA; desc.cColorBits = 24; desc.cAlphaBits = 8; // also tried with 0 desc.cDepthBits = 16; desc.iLayerType = (int)GL.PixelFormatDesc.PFD_MAIN_PLANE; hDCWindow = GL.GetDC(panel1.Handle); int fmt = GL.ChoosePixelFormat(hDCWindow, ref desc); if (GL.SetPixelFormat(hDCWindow, fmt, ref desc) == 0) MessageBox.Show(Marshal.GetLastWin32Error().ToString()); hGLRC = GL.wglCreateContext(hDCWindow); if(hGLRC == IntPtr.Zero) MessageBox.Show(Marshal.GetLastWin32Error().ToString()); GL.wglMakeCurrent(hDCWindow, hGLRC); timer.Interval = 22; timer.Tick += Render; timer.Start(); }The errorcode is 2000 (incorrect pixelformat). SetPixelFormat returns true, and fmt is 4.
Isnt OpenGL running in FORMS-based applications?
Greetings
Plerion