if (ctx != stw_current_context())
return FALSE;
- if (stw_make_current( NULL, NULL, 0 ) == FALSE)
+ if (stw_make_current( NULL, NULL, NULL ) == FALSE)
return FALSE;
return TRUE;
}
BOOL
-stw_make_current(HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc)
+stw_make_current(HDC hDrawDC, HDC hReadDC, struct stw_context *ctx)
{
struct stw_context *old_ctx = NULL;
- struct stw_context *ctx = NULL;
BOOL ret = FALSE;
if (!stw_dev)
old_ctx = stw_current_context();
if (old_ctx != NULL) {
- if (old_ctx->dhglrc == dhglrc) {
+ if (old_ctx == ctx) {
if (old_ctx->hDrawDC == hDrawDC && old_ctx->hReadDC == hReadDC) {
/* Return if already current. */
return TRUE;
}
}
- if (dhglrc) {
+ if (ctx) {
struct stw_framebuffer *fb = NULL;
struct stw_framebuffer *fbRead = NULL;
- stw_lock_contexts(stw_dev);
- ctx = stw_lookup_context_locked( dhglrc );
- stw_unlock_contexts(stw_dev);
- if (!ctx) {
- goto fail;
- }
/* This call locks fb's mutex */
fb = stw_framebuffer_from_hdc( hDrawDC );
return ret;
}
+BOOL
+stw_make_current_by_handles(HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc)
+{
+ struct stw_context *ctx = stw_lookup_context(dhglrc);
+ if (dhglrc && !ctx) {
+ stw_make_current(NULL, NULL, NULL);
+ }
+ return stw_make_current(hDrawDC, hReadDC, ctx);
+}
+
/**
* Notify the current context that the framebuffer has become invalid.
{
PGLCLTPROCTABLE r = (PGLCLTPROCTABLE)&cpt;
- if (!stw_make_current(hdc, hdc, dhglrc))
+ if (!stw_make_current_by_handles(hdc, hdc, dhglrc))
r = NULL;
return r;
HDC stw_get_current_read_dc( void );
-BOOL stw_make_current( HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc );
+BOOL stw_make_current( HDC hDrawDC, HDC hReadDC, struct stw_context *ctx );
+
+BOOL stw_make_current_by_handles( HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc );
void stw_notify_current_locked( struct stw_framebuffer *fb );
pixelFormatSave = fb->iPixelFormat;
fb->iPixelFormat = curctx->iPixelFormat;
dc = wglGetPbufferDCARB(hPbuffer);
- retVal = stw_make_current(dc, dc, curctx->dhglrc);
+ retVal = stw_make_current(dc, dc, curctx);
fb->iPixelFormat = pixelFormatSave;
if (!retVal) {
debug_printf("stw_make_current(#1) failed in wglBindTexImageARB()\n");
fb->textureFace, texFormat);
/* rebind previous drawing surface */
- retVal = stw_make_current(prevDrawable, prevReadable, curctx->dhglrc);
+ retVal = stw_make_current(prevDrawable, prevReadable, curctx);
if (!retVal) {
debug_printf("stw_make_current(#2) failed in wglBindTexImageARB()\n");
}