summaryrefslogtreecommitdiffstats
path: root/libvo/gl_common.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-11 16:57:42 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-11 16:57:42 +0000
commit84fd90d3e4e24dd9aa5157e7201eba85143c93e6 (patch)
tree38b08e0f1d4bd9db62e722195be29248d3694eda /libvo/gl_common.c
parent3c88c6d150d804935518d9469bbd2467f3a378c4 (diff)
downloadmpv-84fd90d3e4e24dd9aa5157e7201eba85143c93e6.tar.bz2
mpv-84fd90d3e4e24dd9aa5157e7201eba85143c93e6.tar.xz
Improving gl2 under windows, moving some functionality to gl_common
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14143 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/gl_common.c')
-rw-r--r--libvo/gl_common.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index 884d6e8072..9dc7f79242 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -178,7 +178,70 @@ int glFindFormat(uint32_t fmt, uint32_t *bpp, GLenum *gl_texfmt,
return 1;
}
-#ifndef GL_WIN32
+#ifdef GL_WIN32
+int setGlWindow(int *vinfo, HGLRC *context, HWND win)
+{
+ int new_vinfo;
+ HDC windc = GetDC(win);
+ HGLRC new_context = 0;
+ int keep_context = 0;
+
+ // should only be needed when keeping context, but not doing glFinish
+ // can cause flickering even when we do not keep it.
+ glFinish();
+ new_vinfo = GetPixelFormat(windc);
+ if (*context && *vinfo && new_vinfo && *vinfo == new_vinfo) {
+ // we can keep the wglContext
+ new_context = *context;
+ keep_context = 1;
+ } else {
+ // create a context
+ new_context = wglCreateContext(windc);
+ if (!new_context) {
+ mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Could not create GL context!\n");
+ return SET_WINDOW_FAILED;
+ }
+ }
+
+ // set context
+ if (!wglMakeCurrent(windc, new_context)) {
+ mp_msg (MSGT_VO, MSGL_FATAL, "[gl] Could not set GL context!\n");
+ if (!keep_context) {
+ wglDeleteContext(new_context);
+ }
+ return SET_WINDOW_FAILED;
+ }
+
+ // set new values
+ vo_window = win;
+ vo_hdc = windc;
+ {
+ RECT rect;
+ GetClientRect(win, &rect);
+ vo_dwidth = rect.right;
+ vo_dheight = rect.bottom;
+ }
+ if (!keep_context) {
+ if (*context)
+ wglDeleteContext(*context);
+ *context = new_context;
+ *vinfo = new_vinfo;
+
+ // and inform that reinit is neccessary
+ return SET_WINDOW_REINIT;
+ }
+ return SET_WINDOW_OK;
+}
+
+void releaseGlContext(int *vinfo, HGLRC *context) {
+ *vinfo = 0;
+ if (*context) {
+ wglMakeCurrent(0, 0);
+ wglDeleteContext(*context);
+ }
+ *context = 0;
+}
+#else
/**
* Returns the XVisualInfo associated with Window win.
* \param win Window whose XVisualInfo is returne.