vlc | branch: master | Sebastien Zwickert <[email protected]> | Thu Sep 15 00:29:18 2011 +0200| [55bc237c2388bc4dde556954127ace97515bd612] | committer: Jean-Baptiste Kempf
OpenGL: enable shaders for MacOS and cleans some specific MacOS code. Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=55bc237c2388bc4dde556954127ace97515bd612 --- modules/video_output/opengl.c | 100 ++++++---------------------------------- 1 files changed, 15 insertions(+), 85 deletions(-) diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c index 5e6a0ef..b00157d 100644 --- a/modules/video_output/opengl.c +++ b/modules/video_output/opengl.c @@ -166,12 +166,19 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, /* Load extensions */ bool supports_fp = false; if (HasExtension(extensions, "GL_ARB_fragment_program")) { +#if !defined(MACOS_OPENGL) vgl->GenProgramsARB = (PFNGLGENPROGRAMSARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glGenProgramsARB"); vgl->BindProgramARB = (PFNGLBINDPROGRAMARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glBindProgramARB"); vgl->ProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glProgramStringARB"); vgl->DeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glDeleteProgramsARB"); vgl->ProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glProgramLocalParameter4fvARB"); - +#else + vgl->GenProgramsARB = glGenProgramsARB; + vgl->BindProgramARB = glBindProgramARB; + vgl->ProgramStringARB = glProgramStringARB; + vgl->DeleteProgramsARB = glDeleteProgramsARB; + vgl->ProgramLocalParameter4fvARB = glProgramLocalParameter4fvARB; +#endif supports_fp = vgl->GenProgramsARB && vgl->BindProgramARB && vgl->ProgramStringARB && @@ -182,9 +189,13 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, bool supports_multitexture = false; GLint max_texture_units = 0; if (HasExtension(extensions, "GL_ARB_multitexture")) { +#if !defined(MACOS_OPENGL) vgl->ActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glActiveTextureARB"); vgl->MultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glMultiTexCoord2fARB"); - +#else + vgl->ActiveTextureARB = glActiveTextureARB; + vgl->MultiTexCoord2fARB = glMultiTexCoord2fARB; +#endif supports_multitexture = vgl->ActiveTextureARB && vgl->MultiTexCoord2fARB; if (supports_multitexture) @@ -208,16 +219,6 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, vgl->tex_format = GL_RGB; vgl->tex_internal = GL_RGB; vgl->tex_type = GL_UNSIGNED_SHORT_5_6_5; -#elif defined(MACOS_OPENGL) -# if defined(WORDS_BIGENDIAN) - vgl->fmt.i_chroma = VLC_CODEC_YUYV; -# else - vgl->fmt.i_chroma = VLC_CODEC_UYVY; -# endif - vgl->tex_target = GL_TEXTURE_RECTANGLE_EXT; - vgl->tex_format = GL_YCBCR_422_APPLE; - vgl->tex_internal = GL_RGBA; - vgl->tex_type = GL_UNSIGNED_SHORT_8_8_APPLE; #else vgl->fmt.i_chroma = VLC_CODEC_RGB32; # if defined(WORDS_BIGENDIAN) @@ -272,8 +273,6 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, bool supports_npot = false; #if USE_OPENGL_ES == 2 supports_npot = true; -#elif defined(MACOS_OPENGL) - supports_npot = true; #else supports_npot |= HasExtension(extensions, "GL_APPLE_texture_2D_limited_npot") || HasExtension(extensions, "GL_ARB_texture_non_power_of_two"); @@ -395,7 +394,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, *fmt = vgl->fmt; if (subpicture_chromas) { *subpicture_chromas = NULL; -#if !defined(MACOS_OPENGL) && !USE_OPENGL_ES +#if !USE_OPENGL_ES if (supports_npot) *subpicture_chromas = gl_subpicture_chromas; #endif @@ -428,42 +427,6 @@ void vout_display_opengl_Delete(vout_display_opengl_t *vgl) free(vgl); } -#ifdef MACOS_OPENGL -struct picture_sys_t { - vout_display_opengl_t *vgl; - GLuint *texture; -}; - -/* Small helper */ -static inline GLuint PictureGetTexture(picture_t *picture) -{ - return *picture->p_sys->texture; -} - -static int PictureLock(picture_t *picture) -{ - if (!picture->p_sys) - return VLC_SUCCESS; - - vout_display_opengl_t *vgl = picture->p_sys->vgl; - if (!vlc_gl_Lock(vgl->gl)) { - glBindTexture(vgl->tex_target, PictureGetTexture(picture)); - glPixelStorei(GL_UNPACK_ROW_LENGTH, picture->p->i_pitch / picture->p->i_pixel_pitch); - glTexSubImage2D(vgl->tex_target, 0, - 0, 0, vgl->fmt.i_width, vgl->fmt.i_height, - vgl->tex_format, vgl->tex_type, picture->p[0].p_pixels); - - vlc_gl_Unlock(vgl->gl); - } - return VLC_SUCCESS; -} - -static void PictureUnlock(picture_t *picture) -{ - VLC_UNUSED(picture); -} -#endif - picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned requested_count) { if (vgl->pool) @@ -477,14 +440,6 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned picture[count] = picture_NewFromFormat(&vgl->fmt); if (!picture[count]) break; - -#ifdef MACOS_OPENGL - picture_sys_t *sys = picture[count]->p_sys = malloc(sizeof(*sys)); - if (sys) { - sys->vgl = vgl; - sys->texture = vgl->texture[count]; - } -#endif } if (count <= 0) return NULL; @@ -494,10 +449,6 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned memset(&cfg, 0, sizeof(cfg)); cfg.picture_count = count; cfg.picture = picture; -#ifdef MACOS_OPENGL - cfg.lock = PictureLock; - cfg.unlock = PictureUnlock; -#endif vgl->pool = picture_pool_NewExtended(&cfg); if (!vgl->pool) goto error; @@ -509,7 +460,6 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned for (int i = 0; i < VLCGL_TEXTURE_COUNT; i++) { glGenTextures(vgl->chroma->plane_count, vgl->texture[i]); for (unsigned j = 0; j < vgl->chroma->plane_count; j++) { - uint8_t *buffer = NULL; if (vgl->use_multitexture) vgl->ActiveTextureARB(GL_TEXTURE0_ARB + j); glBindTexture(vgl->tex_target, vgl->texture[i][j]); @@ -525,23 +475,10 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned glTexParameteri(vgl->tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(vgl->tex_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -#ifdef MACOS_OPENGL - /* Tell the driver not to make a copy of the texture but to use - our buffer */ - glEnable(GL_UNPACK_CLIENT_STORAGE_APPLE); - glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); - - buffer = picture[i]->p[j].p_pixels; - - /* Use AGP texturing */ - glTexParameteri(vgl->tex_target, GL_TEXTURE_STORAGE_HINT_APPLE, - GL_STORAGE_SHARED_APPLE); -#endif - /* Call glTexImage2D only once, and use glTexSubImage2D later */ glTexImage2D(vgl->tex_target, 0, vgl->tex_internal, vgl->tex_width[j], vgl->tex_height[j], - 0, vgl->tex_format, vgl->tex_type, buffer); + 0, vgl->tex_format, vgl->tex_type, NULL); } } @@ -577,10 +514,6 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, if (vlc_gl_Lock(vgl->gl)) return VLC_EGENERIC; -#ifdef MACOS_OPENGL - /* Bind to the texture for drawing */ - glBindTexture(vgl->tex_target, PictureGetTexture(picture)); -#else /* Update the texture */ for (unsigned j = 0; j < vgl->chroma->plane_count; j++) { const int plane = vgl->fmt.i_chroma == VLC_CODEC_YV12 && j > 0 ? (3 - j) : j; @@ -594,7 +527,6 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, vgl->fmt.i_height * vgl->chroma->p[plane].h.num / vgl->chroma->p[plane].h.den, vgl->tex_format, vgl->tex_type, picture->p[plane].p_pixels); } -#endif int last_count = vgl->region_count; gl_region_t *last = vgl->region; @@ -740,13 +672,11 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl, glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); #else -#if !defined(MACOS_OPENGL) for (unsigned j = 0; j < vgl->chroma->plane_count; j++) { if (vgl->use_multitexture) vgl->ActiveTextureARB(GL_TEXTURE0_ARB + j); glBindTexture(vgl->tex_target, vgl->texture[0][j]); } -#endif glBegin(GL_POLYGON); glTexCoord2f(left[0], top[0]); _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
