Search
lxdream.org :: lxdream/src/display.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/display.h
changeset 335:fb890e1814c0
prev327:00d55a462af3
next352:f0df7a6d4703
author nkeynes
date Sat Jan 27 12:03:53 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Start working towards more thorough interlaced support
view annotate diff log raw
     1 /**
     2  * $Id: display.h,v 1.4 2007-01-27 12:03:53 nkeynes Exp $
     3  *
     4  * The PC side of the video support (responsible for actually displaying / 
     5  * rendering frames)
     6  *
     7  * Copyright (c) 2005 Nathan Keynes.
     8  *
     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.
    13  *
    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.
    18  */
    20 #ifndef dream_video_H
    21 #define dream_video_H
    23 #include <stdint.h>
    24 #include <glib.h>
    25 #include <GL/gl.h>
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    31 /**
    32  * Supported colour formats. Note that ARGB4444 is only ever used for texture
    33  * rendering (it's not valid for display purposes).
    34  */
    35 #define COLFMT_ARGB1555  0
    36 #define COLFMT_RGB565    1
    37 #define COLFMT_ARGB4444  2
    38 #define COLFMT_YUV422    3 /* 8-bit YUV (texture source only) */
    39 #define COLFMT_RGB888    4 /* 24-bit RGB */
    40 #define COLFMT_ARGB8888  5
    41 #define COLFMT_INDEX4    6 /* 4 bit indexed colour (texture source only) */
    42 #define COLFMT_INDEX8    7 /* 8-bit indexed colour (texture source only) */
    43 #define COLFMT_RGB0888   8 /* 32-bit RGB */
    45 struct colour_format {
    46     GLint type, format, int_format;
    47     int bpp;
    48 };
    49 extern struct colour_format colour_formats[];
    51 extern int colour_format_bytes[];
    53 typedef struct video_buffer {
    54     uint32_t hres;
    55     uint32_t vres;
    56     uint32_t rowstride;
    57     int colour_format;
    58     gboolean line_double;
    59     char *data;
    60 } *video_buffer_t;
    62 /**
    63  * Core video driver - expected to directly support an OpenGL context
    64  */
    65 typedef struct display_driver {
    66     char *name;
    67     /**
    68      * Initialize the driver. This is called only once at startup time, and
    69      * is guaranteed to be called before any other methods.
    70      * @return TRUE if the driver was successfully initialized, otherwise
    71      * FALSE.
    72      */
    73     gboolean (*init_driver)(void);
    75     /**
    76      * Cleanly shutdown the driver. Normally only called at system shutdown
    77      * time.
    78      */
    79     void (*shutdown_driver)(void);
    81     /**
    82      * Given a particular keysym, return the keycode associated with it.
    83      * @param keysym The keysym to be resolved, ie "Tab"
    84      * @return the display-specific keycode, or 0 if the keysym cannot
    85      * be resolved.
    86      */
    87     uint16_t (*resolve_keysym)( const gchar *keysym );
    89     /**
    90      * Set the current display format to the specified values. This is
    91      * called immediately prior to any display frame call where the
    92      * parameters have changed from the previous frame
    93      */
    94     gboolean (*set_display_format)( uint32_t hres, uint32_t vres, 
    95 				    int colour_fmt );
    97     /**
    98      * Set the current rendering format to the specified values. This is
    99      * called immediately prior to starting rendering of a frame where the
   100      * parameters have changed from the previous frame. Note that the driver
   101      * is not required to precisely support the requested colour format.
   102      *
   103      * This method is also responsible for setting up an appropriate GL
   104      * context for the main engine to render into.
   105      *
   106      * @param hres The horizontal resolution (ie 640)
   107      * @param vres The vertical resolution (ie 480)
   108      * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444)
   109      * @param texture Flag indicating that the frame being rendered is a
   110      * texture, rather than a display frame. 
   111      */
   112     gboolean (*set_render_format)( uint32_t hres, uint32_t vres,
   113 				   int colour_fmt, gboolean texture );
   114     /**
   115      * Display a single frame using the supplied pixmap data. Is assumed to
   116      * invalidate the current GL front buffer (but not the back buffer).
   117      */
   118     gboolean (*display_frame)( video_buffer_t buffer );
   120     /**
   121      * Display a single blanked frame using a fixed colour for the
   122      * entire frame (specified in RGB888 format). Is assumed to invalidate
   123      * the current GL front buffer (but not the back buffer).
   124      */
   125     gboolean (*display_blank_frame)( uint32_t rgb );
   127     /**
   128      * Promote the current render back buffer to the front buffer
   129      */
   130     void (*display_back_buffer)( void );
   131 } *display_driver_t;
   133 void video_open( void );
   134 void video_update_frame( void );
   135 void video_update_size( int, int, int );
   137 extern uint32_t pvr2_frame_counter;
   139 extern display_driver_t display_driver;
   141 extern struct display_driver display_gtk_driver;
   142 extern struct display_driver display_null_driver;
   144 /****************** Input methods **********************/
   146 typedef void (*input_key_callback_t)( void *data, uint32_t value, gboolean isKeyDown );
   148 gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,
   149 			     void *data, uint32_t value );
   151 void input_unregister_key( const gchar *keysym );
   153 gboolean input_is_key_valid( const gchar *keysym );
   155 gboolean input_is_key_registered( const gchar *keysym );
   157 void input_event_keydown( uint16_t keycode );
   159 void input_event_keyup( uint16_t keycode );
   163 #ifdef __cplusplus
   164 }
   165 #endif
   166 #endif
.