nkeynes@144: /** nkeynes@162: * $Id: display.h,v 1.2 2006-06-18 11:57:55 nkeynes Exp $ nkeynes@144: * nkeynes@144: * The PC side of the video support (responsible for actually displaying / nkeynes@144: * rendering frames) nkeynes@144: * nkeynes@144: * Copyright (c) 2005 Nathan Keynes. nkeynes@144: * nkeynes@144: * This program is free software; you can redistribute it and/or modify nkeynes@144: * it under the terms of the GNU General Public License as published by nkeynes@144: * the Free Software Foundation; either version 2 of the License, or nkeynes@144: * (at your option) any later version. nkeynes@144: * nkeynes@144: * This program is distributed in the hope that it will be useful, nkeynes@144: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@144: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@144: * GNU General Public License for more details. nkeynes@144: */ nkeynes@144: nkeynes@144: #ifndef dream_video_H nkeynes@144: #define dream_video_H nkeynes@144: nkeynes@144: #include nkeynes@144: #include nkeynes@144: nkeynes@144: #ifdef __cplusplus nkeynes@144: extern "C" { nkeynes@144: #endif nkeynes@144: nkeynes@144: /** nkeynes@144: * Supported colour formats. Note that ARGB4444 is only ever used for texture nkeynes@144: * rendering (it's not valid for display purposes). nkeynes@144: */ nkeynes@144: #define COLFMT_RGB565 1 nkeynes@144: #define COLFMT_RGB888 4 nkeynes@144: #define COLFMT_ARGB1555 0 nkeynes@144: #define COLFMT_ARGB8888 5 nkeynes@144: #define COLFMT_ARGB4444 2 nkeynes@144: #define COLFMT_YUV422 3 /* 8-bit YUV (texture source only) */ nkeynes@144: #define COLFMT_INDEX4 6 /* 4 bit indexed colour (texture source only) */ nkeynes@144: #define COLFMT_INDEX8 7 /* 8-bit indexed colour (texture source only) */ nkeynes@144: nkeynes@162: extern int colour_format_bytes[]; nkeynes@162: nkeynes@144: typedef struct video_buffer { nkeynes@144: uint32_t hres; nkeynes@144: uint32_t vres; nkeynes@144: uint32_t rowstride; nkeynes@144: int colour_format; nkeynes@144: char *data; nkeynes@144: } *video_buffer_t; nkeynes@144: nkeynes@144: /** nkeynes@144: * Core video driver - expected to directly support an OpenGL context nkeynes@144: */ nkeynes@144: typedef struct display_driver { nkeynes@144: char *name; nkeynes@144: /** nkeynes@144: * Initialize the driver. This is called only once at startup time, and nkeynes@144: * is guaranteed to be called before any other methods. nkeynes@144: * @return TRUE if the driver was successfully initialized, otherwise nkeynes@144: * FALSE. nkeynes@144: */ nkeynes@144: gboolean (*init_driver)(void); nkeynes@144: nkeynes@144: /** nkeynes@144: * Cleanly shutdown the driver. Normally only called at system shutdown nkeynes@144: * time. nkeynes@144: */ nkeynes@144: void (*shutdown_driver)(void); nkeynes@144: nkeynes@144: /** nkeynes@144: * Given a particular keysym, return the keycode associated with it. nkeynes@144: * @param keysym The keysym to be resolved, ie "Tab" nkeynes@144: * @return the display-specific keycode, or 0 if the keysym cannot nkeynes@144: * be resolved. nkeynes@144: */ nkeynes@144: uint16_t (*resolve_keysym)( const gchar *keysym ); nkeynes@144: nkeynes@144: /** nkeynes@144: * Set the current display format to the specified values. This is nkeynes@144: * called immediately prior to any display frame call where the nkeynes@144: * parameters have changed from the previous frame nkeynes@144: */ nkeynes@144: gboolean (*set_display_format)( uint32_t hres, uint32_t vres, nkeynes@144: int colour_fmt ); nkeynes@144: nkeynes@144: /** nkeynes@144: * Set the current rendering format to the specified values. This is nkeynes@144: * called immediately prior to starting rendering of a frame where the nkeynes@144: * parameters have changed from the previous frame. Note that the driver nkeynes@144: * is not required to precisely support the requested colour format. nkeynes@144: * nkeynes@144: * This method is also responsible for setting up an appropriate GL nkeynes@144: * context for the main engine to render into. nkeynes@144: * nkeynes@144: * @param hres The horizontal resolution (ie 640) nkeynes@144: * @param vres The vertical resolution (ie 480) nkeynes@144: * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444) nkeynes@144: * @param texture Flag indicating that the frame being rendered is a nkeynes@144: * texture, rather than a display frame. nkeynes@144: */ nkeynes@144: gboolean (*set_render_format)( uint32_t hres, uint32_t vres, nkeynes@144: int colour_fmt, gboolean texture ); nkeynes@144: /** nkeynes@144: * Display a single frame using the supplied pixmap data. Is assumed to nkeynes@144: * invalidate the current GL front buffer (but not the back buffer). nkeynes@144: */ nkeynes@144: gboolean (*display_frame)( video_buffer_t buffer ); nkeynes@144: nkeynes@144: /** nkeynes@144: * Display a single blanked frame using a fixed colour for the nkeynes@144: * entire frame (specified in RGB888 format). Is assumed to invalidate nkeynes@144: * the current GL front buffer (but not the back buffer). nkeynes@144: */ nkeynes@144: gboolean (*display_blank_frame)( uint32_t rgb ); nkeynes@144: nkeynes@144: /** nkeynes@144: * Promote the current render back buffer to the front buffer nkeynes@144: */ nkeynes@144: void (*display_back_buffer)( void ); nkeynes@144: } *display_driver_t; nkeynes@144: nkeynes@144: void video_open( void ); nkeynes@144: void video_update_frame( void ); nkeynes@144: void video_update_size( int, int, int ); nkeynes@144: nkeynes@144: extern uint32_t pvr2_frame_counter; nkeynes@144: nkeynes@144: extern display_driver_t display_driver; nkeynes@144: nkeynes@144: extern struct display_driver display_gtk_driver; nkeynes@144: extern struct display_driver display_null_driver; nkeynes@144: nkeynes@144: /****************** Input methods **********************/ nkeynes@144: nkeynes@144: typedef void (*input_key_callback_t)( void *data, uint32_t value, gboolean isKeyDown ); nkeynes@144: nkeynes@144: gboolean input_register_key( const gchar *keysym, input_key_callback_t callback, nkeynes@144: void *data, uint32_t value ); nkeynes@144: nkeynes@144: void input_unregister_key( const gchar *keysym ); nkeynes@144: nkeynes@144: gboolean input_is_key_valid( const gchar *keysym ); nkeynes@144: nkeynes@144: gboolean input_is_key_registered( const gchar *keysym ); nkeynes@144: nkeynes@144: void input_event_keydown( uint16_t keycode ); nkeynes@144: nkeynes@144: void input_event_keyup( uint16_t keycode ); nkeynes@144: nkeynes@144: nkeynes@144: nkeynes@144: #ifdef __cplusplus nkeynes@144: } nkeynes@144: #endif nkeynes@144: #endif