mirror of
https://github.com/mpv-player/mpv
synced 2025-03-31 15:59:34 +00:00
Add support for Windows OpenGL rendering onto a device instead of into a window.
Has little use except for experimenting - on Windows 9x it could be used to render on monitors that were not managed by Windows, but that feature was removed in newer Windows versions. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29946 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
4198e9d45b
commit
4805ea9864
@ -1461,7 +1461,7 @@ static void *w32gpa(const GLubyte *procName) {
|
||||
int setGlWindow(int *vinfo, HGLRC *context, HWND win)
|
||||
{
|
||||
int new_vinfo;
|
||||
HDC windc = GetDC(win);
|
||||
HDC windc = vo_w32_get_dc(win);
|
||||
HGLRC new_context = 0;
|
||||
int keep_context = 0;
|
||||
int res = SET_WINDOW_FAILED;
|
||||
@ -1514,7 +1514,7 @@ int setGlWindow(int *vinfo, HGLRC *context, HWND win)
|
||||
res = SET_WINDOW_OK;
|
||||
|
||||
out:
|
||||
ReleaseDC(win, windc);
|
||||
vo_w32_release_dc(win, windc);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1528,9 +1528,9 @@ void releaseGlContext(int *vinfo, HGLRC *context) {
|
||||
}
|
||||
|
||||
void swapGlBuffers(void) {
|
||||
HDC vo_hdc = GetDC(vo_w32_window);
|
||||
HDC vo_hdc = vo_w32_get_dc(vo_w32_window);
|
||||
SwapBuffers(vo_hdc);
|
||||
ReleaseDC(vo_w32_window, vo_hdc);
|
||||
vo_w32_release_dc(vo_w32_window, vo_hdc);
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_LIBDL
|
||||
|
@ -117,7 +117,7 @@ static GLint getInternalFormat(void)
|
||||
{
|
||||
#ifdef GL_WIN32
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
HDC vo_hdc = GetDC(vo_w32_window);
|
||||
HDC vo_hdc = vo_w32_get_dc(vo_w32_window);
|
||||
int pf = GetPixelFormat(vo_hdc);
|
||||
if (!DescribePixelFormat(vo_hdc, pf, sizeof pfd, &pfd)) {
|
||||
r_sz = g_sz = b_sz = a_sz = 0;
|
||||
@ -127,7 +127,7 @@ static GLint getInternalFormat(void)
|
||||
b_sz = pfd.cBlueBits;
|
||||
a_sz = pfd.cAlphaBits;
|
||||
}
|
||||
ReleaseDC(vo_w32_window, vo_hdc);
|
||||
vo_w32_release_dc(vo_w32_window, vo_hdc);
|
||||
#else
|
||||
if (glXGetConfig(mDisplay, gl_vinfo, GLX_RED_SIZE, &r_sz) != 0) r_sz = 0;
|
||||
if (glXGetConfig(mDisplay, gl_vinfo, GLX_GREEN_SIZE, &g_sz) != 0) g_sz = 0;
|
||||
|
@ -51,6 +51,8 @@ static uint32_t o_dheight;
|
||||
static HINSTANCE hInstance;
|
||||
#define vo_window vo_w32_window
|
||||
HWND vo_window = 0;
|
||||
/** HDC used when rendering to a device instead of window */
|
||||
static HDC dev_hdc;
|
||||
static int event_flags;
|
||||
static int mon_cnt;
|
||||
|
||||
@ -328,7 +330,7 @@ static void resetMode(void) {
|
||||
static int createRenderingContext(void) {
|
||||
HWND layer = HWND_NOTOPMOST;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
HDC vo_hdc = GetDC(vo_window);
|
||||
HDC vo_hdc = vo_w32_get_dc(vo_window);
|
||||
RECT r;
|
||||
int pf;
|
||||
if (WinID < 0) {
|
||||
@ -395,7 +397,7 @@ static int createRenderingContext(void) {
|
||||
|
||||
mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen);
|
||||
|
||||
ReleaseDC(vo_window, vo_hdc);
|
||||
vo_w32_release_dc(vo_window, vo_hdc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -429,6 +431,18 @@ int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) {
|
||||
return createRenderingContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief return the name of the selected device if it is indepedant
|
||||
*/
|
||||
static char *get_display_name(void) {
|
||||
DISPLAY_DEVICE disp;
|
||||
disp.cb = sizeof(disp);
|
||||
EnumDisplayDevices(NULL, vo_adapter_num, &disp, 0);
|
||||
if (disp.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
|
||||
return NULL;
|
||||
return disp.DeviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Initialize w32_common framework.
|
||||
*
|
||||
@ -450,6 +464,7 @@ int vo_w32_init(void) {
|
||||
HICON mplayerIcon = 0;
|
||||
char exedir[MAX_PATH];
|
||||
HINSTANCE user32;
|
||||
char *dev;
|
||||
|
||||
if (vo_window)
|
||||
return 1;
|
||||
@ -497,6 +512,9 @@ int vo_w32_init(void) {
|
||||
myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA");
|
||||
myEnumDisplayMonitors = GetProcAddress(user32, "EnumDisplayMonitors");
|
||||
}
|
||||
dev_hdc = 0;
|
||||
dev = get_display_name();
|
||||
if (dev) dev_hdc = CreateDC(dev, NULL, NULL, NULL);
|
||||
updateScreenProperties();
|
||||
|
||||
return 1;
|
||||
@ -564,7 +582,29 @@ void vo_w32_uninit(void) {
|
||||
resetMode();
|
||||
ShowCursor(1);
|
||||
vo_depthonscreen = 0;
|
||||
if (dev_hdc) DeleteDC(dev_hdc);
|
||||
dev_hdc = 0;
|
||||
DestroyWindow(vo_window);
|
||||
vo_window = 0;
|
||||
UnregisterClass(classname, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get a device context to draw in
|
||||
*
|
||||
* \param wnd window the DC should belong to if it makes sense
|
||||
*/
|
||||
HDC vo_w32_get_dc(HWND wnd) {
|
||||
if (dev_hdc) return dev_hdc;
|
||||
return GetDC(wnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief release a device context
|
||||
*
|
||||
* \param wnd window the DC probably belongs to
|
||||
*/
|
||||
void vo_w32_release_dc(HWND wnd, HDC dc) {
|
||||
if (dev_hdc) return;
|
||||
ReleaseDC(wnd, dc);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user