Can OpenGL be used on a window that already uses GDI +?

Basically my name is for an off-screen DC rendering that is configured (I'm not sure how) to use GDI +. When I try to bind an OpenGL context to a DC it just fails (i.e. it returns zero, but no error). SetPixelFormat also fails (perhaps because it's already configured?), Again returning zero, not an error.

Does anyone know if it is possible, given a situation like this (e.g. an off-screen context for a window that someone is using GDI + on), to create an OpenGL context and use OpenGL for my own rendering? (And if it's possible, why might wglCreateContext fail?)

0


a source to share


1 answer


This article shows all the steps to connect a GDI window: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01

Essentially, you should:

  • Create window
  • Register window
  • Get the device context of a window's decoration region
  • Setting the pixel format for device context
  • Calling wglCreateContext
  • Calling wglMakeCurrent
  • Show window


If you already have access to the device context, skip the first two steps.

In your case, you can see that wglMakeCurrent is all you need. Otherwise, you can submit more details on the errors and behavior you are experiencing.

+1


a source







All Articles