summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Courtier-Dutton <jcdutton@users.sourceforge.net>2004-06-06 02:30:37 +0000
committerJames Courtier-Dutton <jcdutton@users.sourceforge.net>2004-06-06 02:30:37 +0000
commit3a3d6e18eec4ce49d352f68fbe52305f10e8a33e (patch)
tree69eb5e12d9050e5d5cbbf10d4d0dd1e8f231fb06
parent6d0a15c5c157ccf8f46ae421e6bbb14fd49cb78d (diff)
downloadxine-lib-3a3d6e18eec4ce49d352f68fbe52305f10e8a33e.tar.gz
xine-lib-3a3d6e18eec4ce49d352f68fbe52305f10e8a33e.tar.bz2
From: Daniel Mack
Mac OSX video out support. CVS patchset: 6645 CVS date: 2004/06/06 02:30:37
-rw-r--r--configure.ac178
-rw-r--r--src/video_out/Makefile.am10
-rw-r--r--src/video_out/macosx/video_window.m335
3 files changed, 454 insertions, 69 deletions
diff --git a/configure.ac b/configure.ac
index 468855ca9..dfadcf8a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -386,28 +386,40 @@ dnl ---------------------------------------------
dnl Check for OpenGL & [GLut | GLU]
dnl ---------------------------------------------
-AC_CHECK_LIB(GL, glBegin,
- [AC_CHECK_HEADER(GL/gl.h,
- [ ac_have_opengl="yes"
- OPENGL_LIBS="-lGL"
- AC_CHECK_LIB(glut, glutInit, dnl check for glut
- [ ac_have_glut="yes"
- GLUT_LIBS="-lglut"
- AC_DEFINE(HAVE_GLUT,1,[Define this if you have GLut support available])
- AC_DEFINE(HAVE_OPENGL,1,[Define this if you have OpenGL support available]) ],
- [ ac_have_glut="no" dnl fallback, check for GLU
- AC_CHECK_LIB(GLU, gluPerspective,
- [ ac_have_glu="yes"
- GLU_LIBS="-lGLU -lm"
- AC_DEFINE(HAVE_GLU,1,[Define this if you have GLU support available])
- AC_DEFINE(HAVE_OPENGL,1,[Define this if you have OpenGL support available]) ],
- [ ac_have_glu="no" ],
- [$X_LIBS $X_PRE_LIBS $OPENGL_LIBS -lGLU -lm $X_EXTRA_LIBS])],
- [$X_LIBS $X_PRE_LIBS -lglut $X_EXTRA_LIBS])
- ],
- [])],
- [],
- [$X_LIBS $X_PRE_LIBS -lGL $X_EXTRA_LIBS])
+case "$host" in
+ *darwin*) dnl Use native interface
+ OPENGL_LIBS="-framework Carbon -framework AGL -framework OpenGL -framework AppKit"
+ OPENGL_CFLAGS="-framework Carbon -framework AGL -framework OpenGL -framework AppKit"
+ AC_SUBST(OPENGL_LIBS)
+ AC_SUBST(OPENGL_CFLAGS)
+ ;;
+ *)
+
+ AC_CHECK_LIB(GL, glBegin,
+ [AC_CHECK_HEADER(GL/gl.h,
+ [ ac_have_opengl="yes"
+ OPENGL_LIBS="-lGL"
+ AC_CHECK_LIB(glut, glutInit, dnl check for glut
+ [ ac_have_glut="yes"
+ GLUT_LIBS="-lglut"
+ AC_DEFINE(HAVE_GLUT,1,[Define this if you have GLut support available])
+ AC_DEFINE(HAVE_OPENGL,1,[Define this if you have OpenGL support available]) ],
+ [ ac_have_glut="no" dnl fallback, check for GLU
+ AC_CHECK_LIB(GLU, gluPerspective,
+ [ ac_have_glu="yes"
+ GLU_LIBS="-lGLU -lm"
+ AC_DEFINE(HAVE_GLU,1,[Define this if you have GLU support available])
+ AC_DEFINE(HAVE_OPENGL,1,[Define this if you have OpenGL support available]) ],
+ [ ac_have_glu="no" ],
+ [$X_LIBS $X_PRE_LIBS $OPENGL_LIBS -lGLU -lm $X_EXTRA_LIBS])],
+ [$X_LIBS $X_PRE_LIBS -lglut $X_EXTRA_LIBS])
+ ],
+ [])],
+ [],
+ [$X_LIBS $X_PRE_LIBS -lGL $X_EXTRA_LIBS])
+ ;;
+esac
+
AC_SUBST(OPENGL_LIBS)
AC_SUBST(GLUT_LIBS)
AC_SUBST(GLU_LIBS)
@@ -645,6 +657,13 @@ AC_ARG_ENABLE(fb, AC_HELP_STRING([--disable-fb], [do not build linux framebuffer
have_fb=$enableval)
AM_CONDITIONAL(HAVE_FB, [test x"$have_fb" = "xyes"])
+dnl ---------------------------------------------
+dnl Check whether to build MacOSX video output driver
+dnl ---------------------------------------------
+
+AC_ARG_ENABLE(macosx_video, AC_HELP_STRING([--enable-macosx-video], [enable support for MacOSX OpenGL video output]),
+ have_macosx_video=$enableval)
+AM_CONDITIONAL(HAVE_MACOSX_VIDEO, [test x"$have_macosx_video" = "xyes"])
dnl ---------------------------------------------
dnl Find pkg-config
@@ -1366,39 +1385,6 @@ AC_ARG_ENABLE(fpic, AC_HELP_STRING([--disable-fpic], [disable -fPIC on shared li
dnl ---------------------------------------------
-dnl Build xine plugins with only the "xine_plugin_info" symbol exported
-dnl (let the user disable this feature, in case libtool does not offer this
-dnl feature on the target platform)
-dnl ---------------------------------------------
-
-AC_ARG_ENABLE(min-symtab,
- AC_HELP_STRING([--disable-min-symtab], [export all global symbols from xine plugins]),
- [
- if test "x$enableval" = "xno" ; then
- XINE_PLUGIN_MIN_SYMS=""
- else
- XINE_PLUGIN_MIN_SYMS="-export-symbols-regex xine_plugin_info"
- fi
- ],
- XINE_PLUGIN_MIN_SYMS="-export-symbols-regex xine_plugin_info")
-
-if test "$with_gnu_ld" = yes; then
- dnl
- dnl -export-symbols-regex in libtool 1.4.X is broken, when GNU ld is
- dnl used for linking. libtool / gnu ld does not touch the dynamic
- dnl symbol table, but removes the unwanted symbols from the
- dnl symbol table => The debug versions of the the xine-lib plugins
- dnl cannot be debugged.
- dnl
- dnl Don't use libtool's -export-symbols-regex on such a platform for now
- dnl
- XINE_PLUGIN_MIN_SYMS=""
-fi
-
-AC_SUBST(XINE_PLUGIN_MIN_SYMS)
-
-
-dnl ---------------------------------------------
dnl Some extra checks.
dnl ---------------------------------------------
@@ -1620,6 +1606,27 @@ case "$host_or_hostalias" in
DEBUG_CFLAGS="-O3 -mieee $DEBUG_CFLAGS"
AC_DEFINE_UNQUOTED(FPM_64BIT,,[Define to select libmad fixed point arithmetic implementation])
;;
+
+ *darwin*)
+ AC_DEFINE_UNQUOTED(HOST_OS_DARWIN, 1, [Define this if built on MacOSX/Darwin])
+# AM_CONDITIONAL(HOST_OS_DARWIN, 1)
+ CFLAGS="-O3 -pipe -fomit-frame-pointer $m_wm $m_psb -fexpensive-optimizations $f_si $f_nsa -ffast-math -funroll-loops -finline-functions -no-cpp-precomp -D_INTL_REDIRECT_MACROS $CFLAGS"
+ CXXFLAGS="${CXXFLAGS} -no-cpp-precomp -D_INTL_REDIRECT_MACROS"
+ #EBUG_CFLAGS="-O3 $DEBUG_CFLAGS"
+ OBJCFLAGS="${CXXFLAGS} -fconstant-string-class=NSConstantString"
+ AC_SUBST(OBJCFLAGS)
+ dnl avoid ppc compilation crash
+ AS="$CC"
+ AC_DEFINE_UNQUOTED(FPM_PPC,,[Define to select libmad fixed point arithmetic implementation])
+ AC_DEFINE_UNQUOTED(ARCH_PPC,,[Define this if you're running PowerPC architecture])
+
+ OBJC='gcc'
+ AC_SUBST(OBJC)
+ OBJCDEPMODE="depmode=gcc3"
+ AC_SUBST(OBJCDEPMODE)
+
+ host_os_darwin="yes"
+ ;;
ppc-*-linux* | powerpc-*)
CFLAGS="-O3 -pipe -fomit-frame-pointer $m_wm $m_psb -fexpensive-optimizations $f_si $f_nsa -ffast-math -funroll-loops -finline-functions $CFLAGS"
@@ -1634,13 +1641,6 @@ case "$host_or_hostalias" in
CFLAGS="-Wa,-m7400 $CFLAGS"
DEBUG_CFLAGS="-Wa,-m7400 $DEBUG_CFLAGS"
fi
-
- dnl enable darwin (Mac OS X) specific build
- case "$host_or_hostalias" in
- *-darwin*)
- AC_DEFINE_UNQUOTED(HOST_OS_DARWIN, 1, [Define this if built on MacOSX/Darwin])
- ;;
- esac
;;
sparc*-*-linux*)
@@ -1761,7 +1761,7 @@ case "$host_or_hostalias" in
AC_DEFINE_UNQUOTED(FPM_ARM,,[Define to select libmad fixed point arithmetic implementation])
enable_armv4l="yes"
;;
-
+
*)
echo
echo "****************************** WARNING ******************************"
@@ -1795,6 +1795,53 @@ AC_SUBST(W32DLL_DEP)
AM_CONDITIONAL(HAVE_FFMMX, test x"$enable_ffmmx" = "xyes")
+dnl ---------------------------------------------
+dnl Build xine plugins with only the "xine_plugin_info" symbol exported
+dnl (let the user disable this feature, in case libtool does not offer this
+dnl feature on the target platform)
+dnl ---------------------------------------------
+
+AC_ARG_ENABLE(min-symtab,
+ AC_HELP_STRING([--disable-min-symtab], [export all global symbols from xine plugins]),
+ [
+ if test "x$enableval" = "xno" ; then
+ XINE_PLUGIN_MIN_SYMS=""
+ else
+ XINE_PLUGIN_MIN_SYMS="-export-symbols-regex xine_plugin_info"
+ fi
+ ],
+ XINE_PLUGIN_MIN_SYMS="-export-symbols-regex xine_plugin_info")
+
+if test "$with_gnu_ld" = yes; then
+ dnl
+ dnl -export-symbols-regex in libtool 1.4.X is broken, when GNU ld is
+ dnl used for linking. libtool / gnu ld does not touch the dynamic
+ dnl symbol table, but removes the unwanted symbols from the
+ dnl symbol table => The debug versions of the the xine-lib plugins
+ dnl cannot be debugged.
+ dnl
+ dnl Don't use libtool's -export-symbols-regex on such a platform for now
+ dnl
+ XINE_PLUGIN_MIN_SYMS=""
+fi
+
+if test "$host_os_darwin" = yes; then
+ dnl
+ dnl Darwins implementation of dlclose() likes to crash badly when trying
+ dnl to close a library that contains objective c code in it.
+ dnl Unfortunately, there is no way to figure out wheter we're dealing
+ dnl with such a file or not, so a dirty hack was made that add a
+ dnl dummy symbol to these called 'plugin_contains_objc_code' and omit
+ dnl closing such an module when this symbol is present.
+ dnl To make it beeing exported, XINE_PLUGIN_SYMS must be unset in this
+ dnl case.
+ dnl
+ XINE_PLUGIN_MIN_SYMS=""
+fi
+
+AC_SUBST(XINE_PLUGIN_MIN_SYMS)
+
+
dnl ---------------------------------------------
dnl HAVE_ARMV4L is currently used in libavcodec makefile.am
@@ -2018,6 +2065,7 @@ src/video_out/libdha/oth/Makefile
src/video_out/libdha/sysdep/Makefile
src/video_out/vidix/Makefile
src/video_out/vidix/drivers/Makefile
+src/video_out/macosx/Makefile
src/xine-utils/Makefile
src/xine-engine/Makefile
src/xine-engine/xineintl.h])
@@ -2310,6 +2358,10 @@ fi
if test x"$have_directx" = "xyes"; then
echo " - directx (DirectX video driver)"
fi
+if test x"$have_macosx_video" = "xyes"; then
+ echo " - MacOSX OpenGL"
+fi
+
echo ""
dnl Audio plugins
diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am
index 49f9cd406..dca4fb711 100644
--- a/src/video_out/Makefile.am
+++ b/src/video_out/Makefile.am
@@ -1,6 +1,6 @@
include $(top_srcdir)/misc/Makefile.common
-SUBDIRS = libdha vidix
+SUBDIRS = libdha vidix macosx
EXTRA_DIST = video_out_directfb.c video_out_opengl.c video_out_directx.c video_out_macosx.c
@@ -70,9 +70,9 @@ if HAVE_DIRECTX
directx_module = xineplug_vo_out_directx.la
endif
-#if HAVE_MACOSX_VIDEO
-#macosx_module = xineplug_vo_out_macosx.la
-#endif
+if HAVE_MACOSX_VIDEO
+macosx_module = xineplug_vo_out_macosx.la
+endif
# important:
@@ -165,13 +165,11 @@ xineplug_vo_out_none_la_SOURCES = video_out_none.c
xineplug_vo_out_none_la_LIBADD = $(XINE_LIB)
xineplug_vo_out_none_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-#if 0
xineplug_vo_out_macosx_la_SOURCES = alphablend.c video_out_macosx.m
xineplug_vo_out_macosx_la_LIBADD = $(MLIB_LIBS) $(OPENGL_LIBS) $(GLUT_LIBS) \
$(GLU_LIBS) $(X_LIBS) $(XINE_LIB) macosx/libxine_macosx_video.la
xineplug_vo_out_macosx_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@ -framework Cocoa -framework OpenGL -lobjc -umbrella AppKit
xineplug_vo_out_macosx_la_OBJCFLAGS = $(OBJCFLAGS) $(AM_CFLAGS)
-#endif
noinst_HEADERS = alphablend.h deinterlace.h video_out_syncfb.h \
yuv2rgb.h x11osd.h
diff --git a/src/video_out/macosx/video_window.m b/src/video_out/macosx/video_window.m
new file mode 100644
index 000000000..f068329e0
--- /dev/null
+++ b/src/video_out/macosx/video_window.m
@@ -0,0 +1,335 @@
+/*
+ * Copyright (C) 2004 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * $Id:
+ *
+ * Most parts of this code were taken from VLC, http://www.videolan.org
+ * Thanks for the good research, folks!
+ */
+
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/gl.h>
+#include <OpenGL/glext.h>
+#import "video_window.h"
+
+@implementation XineVideoWindow
+
+- (void) displayTexture {
+ if ([openGLView lockFocusIfCanDraw]) {
+ [openGLView drawRect: [openGLView bounds]];
+ [openGLView reloadTexture];
+ [openGLView unlockFocus];
+ }
+}
+
+- (void) setContentSize: (NSSize) size {
+ width = size.width;
+ height = size.height;
+
+ [openGLView setVideoSize: width : height];
+
+ [super setContentSize: size];
+}
+
+- (id) initWithContentRect: (NSRect)rect
+ styleMask:(unsigned int)styleMask
+ backing:(NSBackingStoreType)bufferingType
+ defer:(BOOL)flag
+ screen:(NSScreen *)aScreen {
+ self = [super initWithContentRect: rect
+ styleMask: styleMask
+ backing: bufferingType
+ defer: flag
+ screen: aScreen];
+
+ openGLView = [[XineOpenGLView alloc] initWithFrame:rect];
+ [self setContentView: openGLView];
+ [self setTitle: @"xine video output"];
+
+ return self;
+}
+
+- (XineOpenGLView *) getGLView {
+ return openGLView;
+}
+
+- (void) goFullScreen {
+ [openGLView goFullScreen];
+}
+
+- (void) exitFullScreen {
+ [openGLView exitFullScreen];
+}
+
+@end
+
+
+@implementation XineOpenGLView
+
+- (id) initWithFrame: (NSRect) frame {
+
+ NSOpenGLPixelFormatAttribute attribs[] = {
+ NSOpenGLPFAAccelerated,
+ NSOpenGLPFANoRecovery,
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFAColorSize, 24,
+ NSOpenGLPFAAlphaSize, 8,
+ NSOpenGLPFADepthSize, 24,
+ NSOpenGLPFAWindow,
+ 0
+ };
+
+ NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc]
+ initWithAttributes: attribs];
+
+ if (!fmt) {
+ printf ("Cannot create NSOpenGLPixelFormat\n");
+ return nil;
+ }
+
+ self = [super initWithFrame:frame pixelFormat: fmt];
+
+ currentContext = [self openGLContext];
+ [currentContext makeCurrentContext];
+ [currentContext update];
+
+ /* Black background */
+ glClearColor (0.0, 0.0, 0.0, 0.0);
+
+ i_texture = 0;
+ initDone = 0;
+ isFullScreen = 0;
+ width = frame.size.width;
+ height = frame.size.height;
+ texture_buffer = nil;
+
+ [self initTextures];
+
+ return self;
+}
+
+- (void) reshape {
+ if (!initDone)
+ return;
+
+ [currentContext makeCurrentContext];
+
+ NSRect bounds = [self bounds];
+ glViewport (0, 0, (GLint) bounds.size.width,
+ (GLint) bounds.size.height);
+
+ f_x = 1.0;
+ f_y = 1.0;
+}
+
+
+- (void) initTextures {
+ [currentContext makeCurrentContext];
+
+ /* Free previous texture if any */
+ if (i_texture)
+ glDeleteTextures (1, &i_texture);
+
+ if (texture_buffer)
+ texture_buffer = realloc (texture_buffer, sizeof (char) * width * height * 3);
+ else
+ texture_buffer = malloc (sizeof (char) * width * height * 3);
+
+ /* Create textures */
+ glGenTextures (1, &i_texture);
+
+ glEnable (GL_TEXTURE_RECTANGLE_EXT);
+ glEnable (GL_UNPACK_CLIENT_STORAGE_APPLE);
+
+ glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture);
+
+ /* Use VRAM texturing */
+ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
+ GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE);
+
+ /* Tell the driver not to make a copy of the texture but to use
+ our buffer */
+ glPixelStorei (GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+
+ /* Linear interpolation */
+ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
+ GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
+ GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ /* I have no idea what this exactly does, but it seems to be
+ necessary for scaling */
+ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
+ GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
+ GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+
+ glTexImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA,
+ width, height, 0,
+ GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE,
+ texture_buffer);
+
+ initDone = 1;
+}
+
+- (void) reloadTexture {
+ if (!initDone)
+ return;
+
+ [currentContext makeCurrentContext];
+
+ glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture);
+
+ /* glTexSubImage2D is faster than glTexImage2D
+ * http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/TextureRange/MainOpenGLView.m.htm
+ */
+ glTexSubImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0,
+ width, height,
+ GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE,
+ texture_buffer);
+}
+
+- (void) goFullScreen {
+ /* Create the new pixel format */
+ NSOpenGLPixelFormatAttribute attribs[] = {
+ NSOpenGLPFAAccelerated,
+ NSOpenGLPFANoRecovery,
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFAColorSize, 24,
+ NSOpenGLPFAAlphaSize, 8,
+ NSOpenGLPFADepthSize, 24,
+ NSOpenGLPFAFullScreen,
+ NSOpenGLPFAScreenMask,
+ CGDisplayIDToOpenGLDisplayMask (kCGDirectMainDisplay),
+ 0
+ };
+
+ NSOpenGLPixelFormat * fmt = [[NSOpenGLPixelFormat alloc]
+ initWithAttributes: attribs];
+ if (!fmt) {
+ printf ("Cannot create NSOpenGLPixelFormat\n");
+ return;
+ }
+
+ /* Create the new OpenGL context */
+ fullScreenContext = [[NSOpenGLContext alloc]
+ initWithFormat: fmt shareContext: nil];
+ if (!fullScreenContext) {
+ printf ("Failed to create new NSOpenGLContext\n");
+ return;
+ }
+ currentContext = fullScreenContext;
+
+ /* Capture display, switch to fullscreen */
+ if (CGCaptureAllDisplays() != CGDisplayNoErr) {
+ printf ("CGCaptureAllDisplays() failed\n");
+ return;
+ }
+ [fullScreenContext setFullScreen];
+ [fullScreenContext makeCurrentContext];
+
+ /* Fix ratio */
+ width = CGDisplayPixelsWide (kCGDirectMainDisplay);
+ height = CGDisplayPixelsHigh (kCGDirectMainDisplay);
+
+ f_x = 1.0;
+ f_y = 1.0;
+
+ /* Update viewport, re-init textures */
+ glViewport (0, 0, width, height);
+ [self initTextures];
+
+ /* Redraw the last picture */
+ [self setNeedsDisplay: YES];
+
+ isFullScreen = 1;
+}
+
+- (void) exitFullScreen {
+ /* Free current OpenGL context */
+ [NSOpenGLContext clearCurrentContext];
+ [fullScreenContext clearDrawable];
+ [fullScreenContext release];
+ CGReleaseAllDisplays();
+
+ currentContext = [self openGLContext];
+ [self initTextures];
+ [self reshape];
+
+ /* Redraw the last picture */
+ [self setNeedsDisplay: YES];
+
+ isFullScreen = 0;
+}
+
+- (void) drawQuad {
+ glBegin (GL_QUADS);
+ /* Top left */
+ glTexCoord2f (0.0, 0.0);
+ glVertex2f (-f_x, f_y);
+ /* Bottom left */
+ glTexCoord2f (0.0, (float) height);
+ glVertex2f (-f_x, -f_y);
+ /* Bottom right */
+ glTexCoord2f ((float) width, (float) height);
+ glVertex2f (f_x, - f_y);
+ /* Top right */
+ glTexCoord2f ((float) width, 0.0);
+ glVertex2f (f_x, f_y);
+ glEnd();
+}
+
+- (void) drawRect: (NSRect) rect {
+ [currentContext makeCurrentContext];
+
+ /* Swap buffers only during the vertical retrace of the monitor.
+ http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL/chap5/chapter_5_section_44.html */
+
+ long params[] = { 1 };
+ CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, params);
+
+ /* Black background */
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if (!initDone) {
+ [currentContext flushBuffer];
+ return;
+ }
+
+ /* Draw */
+ glBindTexture (GL_TEXTURE_RECTANGLE_EXT, i_texture);
+ [self drawQuad];
+
+ /* Wait for the job to be done */
+ [currentContext flushBuffer];
+}
+
+- (char *) getTextureBuffer {
+ return texture_buffer;
+}
+
+- (void) setVideoSize: (int) w : (int) h {
+ width = w;
+ height = h;
+ [self initTextures];
+}
+
+@end
+