changeset 16109:519a307e3ccf

OpenGL fixes for windows and vo_gl.c ported to windows.
author reimar
date Tue, 26 Jul 2005 13:47:18 +0000
parents ab2504f2d5d6
children 82990d1dce53
files libvo/gl_common.c libvo/gl_common.h libvo/vo_gl.c libvo/w32_common.c libvo/w32_common.h
diffstat 5 files changed, 48 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/gl_common.c	Tue Jul 26 13:32:32 2005 +0000
+++ b/libvo/gl_common.c	Tue Jul 26 13:47:18 2005 +0000
@@ -3,7 +3,7 @@
 void (APIENTRY *BindBuffer)(GLenum, GLuint);
 GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum); 
 GLboolean (APIENTRY *UnmapBuffer)(GLenum);
-void (APIENTRY *BufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum);
+void (APIENTRY *BufferData)(GLenum, intptr_t, const GLvoid *, GLenum);
 void (APIENTRY *CombinerParameterfv)(GLenum, const GLfloat *);
 void (APIENTRY *CombinerParameteri)(GLenum, GLint);
 void (APIENTRY *CombinerInput)(GLenum, GLenum, GLenum, GLenum, GLenum,
@@ -257,6 +257,10 @@
 }
 
 #ifdef GL_WIN32
+static void *w32gpa(const GLubyte *procName) {
+  return wglGetProcAddress(procName);
+}
+
 int setGlWindow(int *vinfo, HGLRC *context, HWND win)
 {
   int new_vinfo;
@@ -304,7 +308,7 @@
       wglDeleteContext(*context);
     *context = new_context;
     *vinfo = new_vinfo;
-    getProcAddress = wglGetProcAddress;
+    getProcAddress = w32gpa;
     getFunctions();
 
     // and inform that reinit is neccessary
--- a/libvo/gl_common.h	Tue Jul 26 13:32:32 2005 +0000
+++ b/libvo/gl_common.h	Tue Jul 26 13:47:18 2005 +0000
@@ -55,7 +55,7 @@
 extern void (APIENTRY *BindBuffer)(GLenum, GLuint);
 extern GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum); 
 extern GLboolean (APIENTRY *UnmapBuffer)(GLenum);
-extern void (APIENTRY *BufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum);
+extern void (APIENTRY *BufferData)(GLenum, intptr_t, const GLvoid *, GLenum);
 extern void (APIENTRY *CombinerParameterfv)(GLenum, const GLfloat *);
 extern void (APIENTRY *CombinerParameteri)(GLenum, GLint);
 extern void (APIENTRY *CombinerInput)(GLenum, GLenum, GLenum, GLenum, GLenum,
--- a/libvo/vo_gl.c	Tue Jul 26 13:32:32 2005 +0000
+++ b/libvo/vo_gl.c	Tue Jul 26 13:47:18 2005 +0000
@@ -30,6 +30,10 @@
 
 LIBVO_EXTERN(gl)
 
+#ifdef GL_WIN32
+static int gl_vinfo = 0;
+static HGLRC gl_context = 0;
+#else
 static XVisualInfo *gl_vinfo = NULL;
 static GLXContext gl_context = 0;
 static int                  wsGLXAttrib[] = { GLX_RGBA,
@@ -38,6 +42,7 @@
                                        GLX_BLUE_SIZE,1,
                                        GLX_DOUBLEBUFFER,
                                        None };
+#endif
 
 static int use_osd;
 static int scaled_osd;
@@ -76,11 +81,13 @@
 
 static void resize(int x,int y){
   mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
+#ifndef GL_WIN32
   if (WinID >= 0) {
     int top = 0, left = 0, w = x, h = y;
     geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight);
     glViewport(top, left, w, h);
   } else
+#endif
   glViewport( 0, 0, x, y );
 
   glMatrixMode(GL_PROJECTION);
@@ -198,6 +205,16 @@
     goto glconfig;
   }
 #endif
+#ifdef GL_WIN32
+  o_dwidth = d_width;
+  o_dheight = d_height;
+  vo_fs = flags & VOFLAG_FULLSCREEN;
+  vo_vm = flags & VOFLAG_MODESWITCHING;
+  vo_dwidth = d_width;
+  vo_dheight = d_height;
+  if (!createRenderingContext())
+    return -1;
+#else
   if (WinID >= 0) {
     Window win_tmp;
     int int_tmp;
@@ -270,6 +287,7 @@
   vo_x11_nofs_sizepos(vo_dx, vo_dy, d_width, d_height);
   if (vo_fs ^ (flags & VOFLAG_FULLSCREEN))
     vo_x11_fullscreen();
+#endif
 
 glconfig:
   setGlWindow(&gl_vinfo, &gl_context, vo_window);
@@ -280,7 +298,11 @@
 
 static void check_events(void)
 {
+#ifdef GL_WIN32
+    int e=vo_w32_check_events();
+#else
     int e=vo_x11_check_events(mDisplay);
+#endif
     if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
     if(e&VO_EVENT_EXPOSE && int_pause) flip_page();
 }
@@ -442,7 +464,11 @@
 
 //  glFlush();
   glFinish();
+#ifdef GL_WIN32
+  SwapBuffers(vo_hdc);
+#else
   glXSwapBuffers( mDisplay,vo_window );
+#endif
  
   if (vo_fs && use_aspect)
     glClear(GL_COLOR_BUFFER_BIT);
@@ -535,7 +561,11 @@
 {
   if ( !vo_config_count ) return;
   releaseGlContext(&gl_vinfo, &gl_context);
+#ifdef GL_WIN32
+  vo_w32_uninit();
+#else
   vo_x11_uninit();
+#endif
 }
 
 static opt_t subopts[] = {
@@ -606,10 +636,19 @@
   case VOCTRL_GUISUPPORT:
     return VO_TRUE;
   case VOCTRL_ONTOP:
+#ifdef GL_WIN32
+    vo_w32_ontop();
+#else
     vo_x11_ontop();
+#endif
     return VO_TRUE;
   case VOCTRL_FULLSCREEN:
+#ifdef GL_WIN32
+    vo_w32_fullscreen();
+    resize(vo_dwidth, vo_dheight);
+#else
     vo_x11_fullscreen();
+#endif
     return VO_TRUE;
   case VOCTRL_GET_PANSCAN:
     if (!use_aspect) return VO_NOTIMPL;
--- a/libvo/w32_common.c	Tue Jul 26 13:32:32 2005 +0000
+++ b/libvo/w32_common.c	Tue Jul 26 13:47:18 2005 +0000
@@ -180,7 +180,7 @@
     updateScreenProperties();
     vo_dwidth = vo_fs ? vo_screenwidth : o_dwidth;
     vo_dheight = vo_fs ? vo_screenheight : o_dheight;
-    SetWindowPos(vo_window, layer, vo_dx, vo_dy, vo_dwidth, vo_dheight, SWP_SHOWWINDOW);
+    SetWindowPos(vo_window, layer, vo_fs ? 0 : vo_dx, vo_fs ? 0 : vo_dy, vo_dwidth, vo_dheight, SWP_SHOWWINDOW);
 
     PIXELFORMATDESCRIPTOR pfd;
     memset(&pfd, 0, sizeof pfd);
--- a/libvo/w32_common.h	Tue Jul 26 13:32:32 2005 +0000
+++ b/libvo/w32_common.h	Tue Jul 26 13:47:18 2005 +0000
@@ -11,6 +11,7 @@
 
 extern int vo_init(void);
 extern void vo_w32_uninit(void);
+extern void vo_w32_ontop(void);
 extern void vo_w32_fullscreen(void);
 extern int vo_w32_check_events(void);
 extern int createRenderingContext(void);