filename | src/display.h |
changeset | 144:7f0714e89aaa |
next | 162:f7781f928f7e |
author | nkeynes |
date | Mon May 15 08:28:52 2006 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Rename video_driver to display_driver Add input source to display Implement configuration file support Hook controllers up to configuration |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/src/display.h Mon May 15 08:28:52 2006 +00001.3 @@ -0,0 +1,155 @@1.4 +/**1.5 + * $Id: display.h,v 1.1 2006-05-15 08:28:48 nkeynes Exp $1.6 + *1.7 + * The PC side of the video support (responsible for actually displaying /1.8 + * rendering frames)1.9 + *1.10 + * Copyright (c) 2005 Nathan Keynes.1.11 + *1.12 + * This program is free software; you can redistribute it and/or modify1.13 + * it under the terms of the GNU General Public License as published by1.14 + * the Free Software Foundation; either version 2 of the License, or1.15 + * (at your option) any later version.1.16 + *1.17 + * This program is distributed in the hope that it will be useful,1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1.20 + * GNU General Public License for more details.1.21 + */1.22 +1.23 +#ifndef dream_video_H1.24 +#define dream_video_H1.25 +1.26 +#include <stdint.h>1.27 +#include <glib.h>1.28 +1.29 +#ifdef __cplusplus1.30 +extern "C" {1.31 +#endif1.32 +1.33 +/**1.34 + * Supported colour formats. Note that ARGB4444 is only ever used for texture1.35 + * rendering (it's not valid for display purposes).1.36 + */1.37 +#define COLFMT_RGB565 11.38 +#define COLFMT_RGB888 41.39 +#define COLFMT_ARGB1555 01.40 +#define COLFMT_ARGB8888 51.41 +#define COLFMT_ARGB4444 21.42 +#define COLFMT_YUV422 3 /* 8-bit YUV (texture source only) */1.43 +#define COLFMT_INDEX4 6 /* 4 bit indexed colour (texture source only) */1.44 +#define COLFMT_INDEX8 7 /* 8-bit indexed colour (texture source only) */1.45 +1.46 +typedef struct video_buffer {1.47 + uint32_t hres;1.48 + uint32_t vres;1.49 + uint32_t rowstride;1.50 + int colour_format;1.51 + char *data;1.52 +} *video_buffer_t;1.53 +1.54 +/**1.55 + * Core video driver - expected to directly support an OpenGL context1.56 + */1.57 +typedef struct display_driver {1.58 + char *name;1.59 + /**1.60 + * Initialize the driver. This is called only once at startup time, and1.61 + * is guaranteed to be called before any other methods.1.62 + * @return TRUE if the driver was successfully initialized, otherwise1.63 + * FALSE.1.64 + */1.65 + gboolean (*init_driver)(void);1.66 +1.67 + /**1.68 + * Cleanly shutdown the driver. Normally only called at system shutdown1.69 + * time.1.70 + */1.71 + void (*shutdown_driver)(void);1.72 +1.73 + /**1.74 + * Given a particular keysym, return the keycode associated with it.1.75 + * @param keysym The keysym to be resolved, ie "Tab"1.76 + * @return the display-specific keycode, or 0 if the keysym cannot1.77 + * be resolved.1.78 + */1.79 + uint16_t (*resolve_keysym)( const gchar *keysym );1.80 +1.81 + /**1.82 + * Set the current display format to the specified values. This is1.83 + * called immediately prior to any display frame call where the1.84 + * parameters have changed from the previous frame1.85 + */1.86 + gboolean (*set_display_format)( uint32_t hres, uint32_t vres,1.87 + int colour_fmt );1.88 +1.89 + /**1.90 + * Set the current rendering format to the specified values. This is1.91 + * called immediately prior to starting rendering of a frame where the1.92 + * parameters have changed from the previous frame. Note that the driver1.93 + * is not required to precisely support the requested colour format.1.94 + *1.95 + * This method is also responsible for setting up an appropriate GL1.96 + * context for the main engine to render into.1.97 + *1.98 + * @param hres The horizontal resolution (ie 640)1.99 + * @param vres The vertical resolution (ie 480)1.100 + * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444)1.101 + * @param texture Flag indicating that the frame being rendered is a1.102 + * texture, rather than a display frame.1.103 + */1.104 + gboolean (*set_render_format)( uint32_t hres, uint32_t vres,1.105 + int colour_fmt, gboolean texture );1.106 + /**1.107 + * Display a single frame using the supplied pixmap data. Is assumed to1.108 + * invalidate the current GL front buffer (but not the back buffer).1.109 + */1.110 + gboolean (*display_frame)( video_buffer_t buffer );1.111 +1.112 + /**1.113 + * Display a single blanked frame using a fixed colour for the1.114 + * entire frame (specified in RGB888 format). Is assumed to invalidate1.115 + * the current GL front buffer (but not the back buffer).1.116 + */1.117 + gboolean (*display_blank_frame)( uint32_t rgb );1.118 +1.119 + /**1.120 + * Promote the current render back buffer to the front buffer1.121 + */1.122 + void (*display_back_buffer)( void );1.123 +} *display_driver_t;1.124 +1.125 +void video_open( void );1.126 +void video_update_frame( void );1.127 +void video_update_size( int, int, int );1.128 +1.129 +extern uint32_t pvr2_frame_counter;1.130 +1.131 +extern display_driver_t display_driver;1.132 +1.133 +extern struct display_driver display_gtk_driver;1.134 +extern struct display_driver display_null_driver;1.135 +1.136 +/****************** Input methods **********************/1.137 +1.138 +typedef void (*input_key_callback_t)( void *data, uint32_t value, gboolean isKeyDown );1.139 +1.140 +gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,1.141 + void *data, uint32_t value );1.142 +1.143 +void input_unregister_key( const gchar *keysym );1.144 +1.145 +gboolean input_is_key_valid( const gchar *keysym );1.146 +1.147 +gboolean input_is_key_registered( const gchar *keysym );1.148 +1.149 +void input_event_keydown( uint16_t keycode );1.150 +1.151 +void input_event_keyup( uint16_t keycode );1.152 +1.153 +1.154 +1.155 +#ifdef __cplusplus1.156 +}1.157 +#endif1.158 +#endif
.