/*****************************************************************************
* vout_glide.c: 3dfx video output display method for 3dfx cards
*****************************************************************************
- * Copyright (C) 2000 VideoLAN
+ * Copyright (C) 2000, 2001 VideoLAN
+ * $Id: vout_glide.c,v 1.7 2001/05/30 17:03:12 sam Exp $
*
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME glide
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <conio.h> /* for glide ? */
#endif
#include <glide.h>
+#include <linutil.h> /* Glide kbhit() and getch() */
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
-#include "plugins.h"
+#include "tests.h"
#include "video.h"
#include "video_output.h"
#include "intf_msg.h"
+#include "interface.h"
+
#include "main.h"
-#define WIDTH 640
-#define HEIGHT 480
-#define BITS_PER_PLANE 16
-#define BYTES_PER_PIXEL 2
+#include "modules.h"
+#include "modules_export.h"
+
+#define GLIDE_WIDTH 800
+#define GLIDE_HEIGHT 600
+#define GLIDE_BITS_PER_PLANE 16
+#define GLIDE_BYTES_PER_PIXEL 2
/*****************************************************************************
* vout_sys_t: Glide video output method descriptor
} vout_sys_t;
/*****************************************************************************
- * Local prototypes
+ * Local prototypes.
+ *****************************************************************************/
+static int vout_Probe ( probedata_t *p_data );
+static int vout_Create ( struct vout_thread_s * );
+static int vout_Init ( struct vout_thread_s * );
+static void vout_End ( struct vout_thread_s * );
+static void vout_Destroy ( struct vout_thread_s * );
+static int vout_Manage ( struct vout_thread_s * );
+static void vout_Display ( struct vout_thread_s * );
+
+static int GlideOpenDisplay ( vout_thread_t *p_vout );
+static void GlideCloseDisplay ( vout_thread_t *p_vout );
+
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
+ *****************************************************************************/
+void _M( vout_getfunctions )( function_list_t * p_function_list )
+{
+ p_function_list->pf_probe = vout_Probe;
+ p_function_list->functions.vout.pf_create = vout_Create;
+ p_function_list->functions.vout.pf_init = vout_Init;
+ p_function_list->functions.vout.pf_end = vout_End;
+ p_function_list->functions.vout.pf_destroy = vout_Destroy;
+ p_function_list->functions.vout.pf_manage = vout_Manage;
+ p_function_list->functions.vout.pf_display = vout_Display;
+ p_function_list->functions.vout.pf_setpalette = NULL;
+}
+
+/*****************************************************************************
+ * vout_Probe: probe the video driver and return a score
+ *****************************************************************************
+ * This function tries to initialize SDL and returns a score to the
+ * plugin manager so that it can select the best plugin.
*****************************************************************************/
-static int GlideOpenDisplay ( vout_thread_t *p_vout );
-static void GlideCloseDisplay ( vout_thread_t *p_vout );
+static int vout_Probe( probedata_t *p_data )
+{
+ if( TestMethod( VOUT_METHOD_VAR, "glide" ) )
+ {
+ return( 999 );
+ }
+
+ /* We could do a grSstQueryBoards( GrHwConfiguration *hwConfig ) at
+ * this point, but if the user didn't configure his 3dfx card, we
+ * have great chances to segfault here. So we'd better assume
+ * everything is fine and worry only if we really need to use Glide */
+ return( 20 );
+}
/*****************************************************************************
- * vout_SysCreate: allocates Glide video thread output method
+ * vout_Create: allocates Glide video thread output method
*****************************************************************************
* This function allocates and initializes a Glide vout method.
*****************************************************************************/
-int vout_SysCreate( vout_thread_t *p_vout, char *psz_display,
- int i_root_window, void *p_data )
+int vout_Create( vout_thread_t *p_vout )
{
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
- intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
+ intf_ErrMsg("error: %s", strerror(ENOMEM) );
return( 1 );
}
/* Open and initialize device */
if( GlideOpenDisplay( p_vout ) )
{
- intf_ErrMsg("vout error: can't open display\n");
+ intf_ErrMsg("vout error: can't open display");
free( p_vout->p_sys );
return( 1 );
}
}
/*****************************************************************************
- * vout_SysInit: initialize Glide video thread output method
+ * vout_Init: initialize Glide video thread output method
*****************************************************************************/
-int vout_SysInit( vout_thread_t *p_vout )
+int vout_Init( vout_thread_t *p_vout )
{
return( 0 );
}
/*****************************************************************************
- * vout_SysEnd: terminate Glide video thread output method
+ * vout_End: terminate Glide video thread output method
*****************************************************************************/
-void vout_SysEnd( vout_thread_t *p_vout )
+void vout_End( vout_thread_t *p_vout )
{
;
}
/*****************************************************************************
- * vout_SysDestroy: destroy Glide video thread output method
+ * vout_Destroy: destroy Glide video thread output method
*****************************************************************************
* Terminate an output method created by vout_CreateOutputMethod
*****************************************************************************/
-void vout_SysDestroy( vout_thread_t *p_vout )
+void vout_Destroy( vout_thread_t *p_vout )
{
GlideCloseDisplay( p_vout );
free( p_vout->p_sys );
}
/*****************************************************************************
- * vout_SysManage: handle Glide events
+ * vout_Manage: handle Glide events
*****************************************************************************
* This function should be called regularly by video output thread. It manages
* console events. It returns a non null value on error.
*****************************************************************************/
-int vout_SysManage( vout_thread_t *p_vout )
+int vout_Manage( vout_thread_t *p_vout )
{
+ int buf;
+
+ /* very Linux specific - see tlib.c in Glide for other versions */
+ while( kbhit() )
+ {
+ buf = getch();
+
+ switch( (char)buf )
+ {
+ case 'q':
+ p_main->p_intf->b_die = 1;
+ break;
+
+ default:
+ break;
+ }
+ }
+
return 0;
}
/*****************************************************************************
- * vout_SysDisplay: displays previously rendered output
+ * vout_Display: displays previously rendered output
*****************************************************************************
* This function send the currently rendered image to Glide image, waits until
* it is displayed and switch the two rendering buffers, preparing next frame.
*****************************************************************************/
-void vout_SysDisplay( vout_thread_t *p_vout )
+void vout_Display( vout_thread_t *p_vout )
{
grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER );
GR_LFBWRITEMODE_565, GR_ORIGIN_UPPER_LEFT, FXFALSE,
&p_vout->p_sys->p_buffer_info) == FXFALSE )
{
- intf_ErrMsg( "vout error: can't take 3dfx back buffer lock\n" );
+ intf_ErrMsg( "vout error: can't take 3dfx back buffer lock" );
}
}
{
static char version[80];
GrHwConfiguration hwconfig;
- GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
+ GrScreenResolution_t resolution = GR_RESOLUTION_800x600;
GrLfbInfo_t p_front_buffer_info; /* front buffer info */
- p_vout->i_width = WIDTH;
- p_vout->i_height = HEIGHT;
- p_vout->i_screen_depth = BITS_PER_PLANE;
- p_vout->i_bytes_per_pixel = BYTES_PER_PIXEL;
+ p_vout->i_width = GLIDE_WIDTH;
+ p_vout->i_height = GLIDE_HEIGHT;
+ p_vout->i_screen_depth = GLIDE_BITS_PER_PLANE;
+ p_vout->i_bytes_per_pixel = GLIDE_BYTES_PER_PIXEL;
/* bytes per line value overriden later */
- p_vout->i_bytes_per_line = 1024 * BYTES_PER_PIXEL;
+ p_vout->i_bytes_per_line = 1024 * GLIDE_BYTES_PER_PIXEL;
- p_vout->p_sys->i_page_size = WIDTH * HEIGHT * BYTES_PER_PIXEL;
+ p_vout->p_sys->i_page_size = GLIDE_WIDTH * GLIDE_HEIGHT
+ * GLIDE_BYTES_PER_PIXEL;
p_vout->i_red_mask = 0xf800;
p_vout->i_green_mask = 0x07e0;
p_vout->p_sys->p_video = malloc( p_vout->p_sys->i_page_size * 2 );
if( (int)p_vout->p_sys->p_video == -1 )
{
- intf_ErrMsg( "vout error: can't map video memory (%s)\n", strerror(errno) );
+ intf_ErrMsg( "vout error: can't map video memory (%s)",
+ strerror(errno) );
return( 1 );
}
if( !grSstQueryHardware(&hwconfig) )
{
- intf_ErrMsg( "vout error: can't get 3dfx hardware config\n" );
+ intf_ErrMsg( "vout error: can't get 3dfx hardware config" );
return( 1 );
}
if( !grSstWinOpen(0, resolution, GR_REFRESH_60Hz,
GR_COLORFORMAT_ABGR, GR_ORIGIN_UPPER_LEFT, 2, 1) )
{
- intf_ErrMsg( "vout error: can't open 3dfx screen\n" );
+ intf_ErrMsg( "vout error: can't open 3dfx screen" );
return( 1 );
}
GR_LFBWRITEMODE_565, GR_ORIGIN_UPPER_LEFT, FXFALSE,
&p_front_buffer_info) == FXFALSE )
{
- intf_ErrMsg( "vout error: can't take 3dfx front buffer lock\n" );
+ intf_ErrMsg( "vout error: can't take 3dfx front buffer lock" );
grGlideShutdown();
return( 1 );
}
GR_LFBWRITEMODE_565, GR_ORIGIN_UPPER_LEFT, FXFALSE,
&p_vout->p_sys->p_buffer_info) == FXFALSE )
{
- intf_ErrMsg( "vout error: can't take 3dfx back buffer lock\n" );
+ intf_ErrMsg( "vout error: can't take 3dfx back buffer lock" );
grGlideShutdown();
return( 1 );
}
grBufferClear( 0, 0, 0 );
/* Set and initialize buffers */
- vout_SetBuffers( p_vout, p_vout->p_sys->p_buffer_info.lfbPtr,
- p_front_buffer_info.lfbPtr );
+ p_vout->pf_setbuffers( p_vout, p_vout->p_sys->p_buffer_info.lfbPtr,
+ p_front_buffer_info.lfbPtr );
return( 0 );
}