Home | Info | Community | Development | myReactOS | Contact Us
[static]
Definition at line 290 of file directx.c.
Referenced by InitAdapters().
{ PIXELFORMATDESCRIPTOR pfd; int iPixelFormat; TRACE("getting context...\n"); ctx->restore_dc = pwglGetCurrentDC(); ctx->restore_gl_ctx = pwglGetCurrentContext(); /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */ ctx->wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window", WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL); if (!ctx->wnd) { ERR_(d3d_caps)("Failed to create a window.\n"); goto fail; } ctx->dc = GetDC(ctx->wnd); if (!ctx->dc) { ERR_(d3d_caps)("Failed to get a DC.\n"); goto fail; } /* PixelFormat selection */ ZeroMemory(&pfd, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW; /* PFD_GENERIC_ACCELERATED */ pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; pfd.iLayerType = PFD_MAIN_PLANE; iPixelFormat = ChoosePixelFormat(ctx->dc, &pfd); if (!iPixelFormat) { /* If this happens something is very wrong as ChoosePixelFormat barely fails. */ ERR_(d3d_caps)("Can't find a suitable iPixelFormat.\n"); goto fail; } DescribePixelFormat(ctx->dc, iPixelFormat, sizeof(pfd), &pfd); SetPixelFormat(ctx->dc, iPixelFormat, &pfd); /* Create a GL context. */ ctx->gl_ctx = pwglCreateContext(ctx->dc); if (!ctx->gl_ctx) { WARN_(d3d_caps)("Error creating default context for capabilities initialization.\n"); goto fail; } /* Make it the current GL context. */ if (!pwglMakeCurrent(ctx->dc, ctx->gl_ctx)) { ERR_(d3d_caps)("Failed to make fake GL context current.\n"); goto fail; } return TRUE; fail: if (ctx->gl_ctx) pwglDeleteContext(ctx->gl_ctx); ctx->gl_ctx = NULL; if (ctx->dc) ReleaseDC(ctx->wnd, ctx->dc); ctx->dc = NULL; if (ctx->wnd) DestroyWindow(ctx->wnd); ctx->wnd = NULL; if (ctx->restore_gl_ctx && !pwglMakeCurrent(ctx->restore_dc, ctx->restore_gl_ctx)) { ERR_(d3d_caps)("Failed to restore previous GL context.\n"); } return FALSE; }