wglCreateContextAttribsARB fails on NVIDIA Hardware

让人想犯罪 __ 提交于 2019-12-05 13:58:37

Remove from 'attribList' the following pairs:

  • WGL_ACCELERATION_ARB
  • WGL_DRAW_TO_WINDOW_ARB
  • WGL_SUPPORT_OPENGL_ARB (obvious that support OpenGL!)
  • WGL_DOUBLE_BUFFER_ARB
  • WGL_PIXEL_TYPE_ARB
  • WGL_COLOR_BITS_ARB
  • WGL_DEPTH_BITS_ARB

Those attribute names are already specified by the '*m_hdc*' handle (infact you call SetPixelFormat on it).

I create a valid context without those flags on NVIDIA platforms.

Valid attribute names for CreateContextAttribsARB are:

WGL_CONTEXT_MAJOR_VERSION_ARB       0x2091
WGL_CONTEXT_MINOR_VERSION_ARB       0x2092
WGL_CONTEXT_LAYER_PLANE_ARB     0x2093
WGL_CONTEXT_FLAGS_ARB           0x2094
WGL_CONTEXT_PROFILE_MASK_ARB        0x9126

Furthermore, what error is returning wglCreateContextAttribsARB?

Instance example:

int err = Gl.GetError();

switch (err) {
    case Gl.INVALID_OPERATION:
        throw new InvalidOperationException(String.Format("unable to create context {0}.{1} ({2})", sVersionDb[version].GLMajor, sVersionDb[version].GLMinor, "invalid operation"));
    case Wgl.ERROR_INVALID_VERSION_ARB:
        throw new InvalidOperationException(String.Format("unable to create context {0}.{1} ({2})", sVersionDb[version].GLMajor, sVersionDb[version].GLMinor, "invalid version"));
    case Wgl.ERROR_INVALID_PROFILE_ARB:
        throw new InvalidOperationException(String.Format("unable to create context {0}.{1} ({2})", sVersionDb[version].GLMajor, sVersionDb[version].GLMinor, "invalid profile"));
    case Wgl.ERROR_INVALID_PIXEL_TYPE_ARB:
        throw new InvalidOperationException(String.Format("unable to create context {0}.{1} ({2})", sVersionDb[version].GLMajor, sVersionDb[version].GLMinor, "invalid pixel format"));
    default:
        throw new InvalidOperationException(String.Format("unable to create context {0}.{1} ({2})", sVersionDb[version].GLMajor, sVersionDb[version].GLMinor, "unknown error " + err));
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!