1
mirror of https://github.com/mpv-player/mpv synced 2024-10-14 11:54:36 +02:00

OpenGL fixes for windows and vo_gl.c ported to windows.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16110 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2005-07-26 13:47:18 +00:00
parent df2887dd4a
commit 1feebc74c7
5 changed files with 48 additions and 4 deletions

View File

@ -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 @@ static void getFunctions() {
}
#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 @@ int setGlWindow(int *vinfo, HGLRC *context, HWND win)
wglDeleteContext(*context);
*context = new_context;
*vinfo = new_vinfo;
getProcAddress = wglGetProcAddress;
getProcAddress = w32gpa;
getFunctions();
// and inform that reinit is neccessary

View File

@ -55,7 +55,7 @@ void releaseGlContext(XVisualInfo **vinfo, GLXContext *context);
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,

View File

@ -30,6 +30,10 @@ static vo_info_t info =
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 @@ static int wsGLXAttrib[] = { GLX_RGBA,
GLX_BLUE_SIZE,1,
GLX_DOUBLEBUFFER,
None };
#endif
static int use_osd;
static int scaled_osd;
@ -76,11 +81,13 @@ static unsigned int slice_height = 1;
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 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
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 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
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 @@ glconfig:
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 @@ flip_page(void)
// 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 @@ uninit(void)
{
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 @@ static uint32_t control(uint32_t request, void *data, ...)
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;

View File

@ -180,7 +180,7 @@ int createRenderingContext(void) {
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);

View File

@ -11,6 +11,7 @@ extern int vo_ontop;
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);