stw_st_destroy_framebuffer_locked(fb->stfb);
+ ReleaseDC(fb->hWnd, fb->hDC);
+
pipe_mutex_unlock( fb->mutex );
pipe_mutex_destroy( fb->mutex );
#if 0
debug_printf("\n");
+ debug_printf("%s: hwnd = %p\n", __FUNCTION__, fb->hWnd);
debug_printf("%s: client_position = (%li, %li)\n",
__FUNCTION__, client_pos.x, client_pos.y);
debug_printf("%s: window_rect = (%li, %li) - (%li, %li)\n",
if (fb == NULL)
return NULL;
- fb->hDC = hdc;
+ /* Applications use, create, destroy device contexts, so the hdc passed is. We create our own DC
+ * because we need one for single buffered visuals.
+ */
+ fb->hDC = GetDC(hWnd);
+
fb->hWnd = hWnd;
fb->iPixelFormat = iPixelFormat;
HDC hdc )
{
HWND hwnd;
- struct stw_framebuffer *fb;
- /*
- * Some applications create and use several HDCs for the same window, so
- * looking up the framebuffer by the HDC is not reliable. Use HWND whenever
- * possible.
- */
hwnd = WindowFromDC(hdc);
- if(hwnd)
- return stw_framebuffer_from_hwnd_locked(hwnd);
-
- for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
- if (fb->hDC == hdc) {
- pipe_mutex_lock(fb->mutex);
- break;
- }
+ if (!hwnd) {
+ return NULL;
+ }
- return fb;
+ return stw_framebuffer_from_hwnd_locked(hwnd);
}
stw_flush_current_locked(fb);
- return stw_st_swap_framebuffer_locked(fb->stfb);
+ return stw_st_swap_framebuffer_locked(hdc, fb->stfb);
}
* Present an attachment of the framebuffer.
*/
static boolean
-stw_st_framebuffer_present_locked(struct st_framebuffer_iface *stfb,
+stw_st_framebuffer_present_locked(HDC hdc,
+ struct st_framebuffer_iface *stfb,
enum st_attachment_type statt)
{
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
resource = stwfb->textures[statt];
if (resource) {
- stw_framebuffer_present_locked(stwfb->fb->hDC, stwfb->fb, resource);
+ stw_framebuffer_present_locked(hdc, stwfb->fb, resource);
}
return TRUE;
pipe_mutex_lock(stwfb->fb->mutex);
- return stw_st_framebuffer_present_locked(&stwfb->base, statt);
+ return stw_st_framebuffer_present_locked(stwfb->fb->hDC, &stwfb->base, statt);
}
/**
* Swap the buffers of the given framebuffer.
*/
boolean
-stw_st_swap_framebuffer_locked(struct st_framebuffer_iface *stfb)
+stw_st_swap_framebuffer_locked(HDC hdc, struct st_framebuffer_iface *stfb)
{
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
unsigned front = ST_ATTACHMENT_FRONT_LEFT, back = ST_ATTACHMENT_BACK_LEFT;
stwfb->texture_mask = mask;
front = ST_ATTACHMENT_FRONT_LEFT;
- return stw_st_framebuffer_present_locked(&stwfb->base, front);
+ return stw_st_framebuffer_present_locked(hdc, &stwfb->base, front);
}
/**
#ifndef STW_ST_H
#define STW_ST_H
+#include <windows.h>
+
#include "state_tracker/st_api.h"
struct stw_framebuffer;
stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb);
boolean
-stw_st_swap_framebuffer_locked(struct st_framebuffer_iface *stfb);
+stw_st_swap_framebuffer_locked(HDC hdc, struct st_framebuffer_iface *stfb);
#endif /* STW_ST_H */