2 * $Id: display.h,v 1.2 2006-06-18 11:57:55 nkeynes Exp $
4 * The PC side of the video support (responsible for actually displaying /
7 * Copyright (c) 2005 Nathan Keynes.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
31 * Supported colour formats. Note that ARGB4444 is only ever used for texture
32 * rendering (it's not valid for display purposes).
34 #define COLFMT_RGB565 1
35 #define COLFMT_RGB888 4
36 #define COLFMT_ARGB1555 0
37 #define COLFMT_ARGB8888 5
38 #define COLFMT_ARGB4444 2
39 #define COLFMT_YUV422 3 /* 8-bit YUV (texture source only) */
40 #define COLFMT_INDEX4 6 /* 4 bit indexed colour (texture source only) */
41 #define COLFMT_INDEX8 7 /* 8-bit indexed colour (texture source only) */
43 extern int colour_format_bytes[];
45 typedef struct video_buffer {
54 * Core video driver - expected to directly support an OpenGL context
56 typedef struct display_driver {
59 * Initialize the driver. This is called only once at startup time, and
60 * is guaranteed to be called before any other methods.
61 * @return TRUE if the driver was successfully initialized, otherwise
64 gboolean (*init_driver)(void);
67 * Cleanly shutdown the driver. Normally only called at system shutdown
70 void (*shutdown_driver)(void);
73 * Given a particular keysym, return the keycode associated with it.
74 * @param keysym The keysym to be resolved, ie "Tab"
75 * @return the display-specific keycode, or 0 if the keysym cannot
78 uint16_t (*resolve_keysym)( const gchar *keysym );
81 * Set the current display format to the specified values. This is
82 * called immediately prior to any display frame call where the
83 * parameters have changed from the previous frame
85 gboolean (*set_display_format)( uint32_t hres, uint32_t vres,
89 * Set the current rendering format to the specified values. This is
90 * called immediately prior to starting rendering of a frame where the
91 * parameters have changed from the previous frame. Note that the driver
92 * is not required to precisely support the requested colour format.
94 * This method is also responsible for setting up an appropriate GL
95 * context for the main engine to render into.
97 * @param hres The horizontal resolution (ie 640)
98 * @param vres The vertical resolution (ie 480)
99 * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444)
100 * @param texture Flag indicating that the frame being rendered is a
101 * texture, rather than a display frame.
103 gboolean (*set_render_format)( uint32_t hres, uint32_t vres,
104 int colour_fmt, gboolean texture );
106 * Display a single frame using the supplied pixmap data. Is assumed to
107 * invalidate the current GL front buffer (but not the back buffer).
109 gboolean (*display_frame)( video_buffer_t buffer );
112 * Display a single blanked frame using a fixed colour for the
113 * entire frame (specified in RGB888 format). Is assumed to invalidate
114 * the current GL front buffer (but not the back buffer).
116 gboolean (*display_blank_frame)( uint32_t rgb );
119 * Promote the current render back buffer to the front buffer
121 void (*display_back_buffer)( void );
124 void video_open( void );
125 void video_update_frame( void );
126 void video_update_size( int, int, int );
128 extern uint32_t pvr2_frame_counter;
130 extern display_driver_t display_driver;
132 extern struct display_driver display_gtk_driver;
133 extern struct display_driver display_null_driver;
135 /****************** Input methods **********************/
137 typedef void (*input_key_callback_t)( void *data, uint32_t value, gboolean isKeyDown );
139 gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,
140 void *data, uint32_t value );
142 void input_unregister_key( const gchar *keysym );
144 gboolean input_is_key_valid( const gchar *keysym );
146 gboolean input_is_key_registered( const gchar *keysym );
148 void input_event_keydown( uint16_t keycode );
150 void input_event_keyup( uint16_t keycode );
.