Search
lxdream.org :: lxdream/src/display.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/display.h
changeset 162:f7781f928f7e
prev144:7f0714e89aaa
next327:00d55a462af3
author nkeynes
date Tue Dec 19 09:51:35 2006 +0000 (17 years ago)
permissions -rw-r--r--
last change First cut of port 576890 (sysreset) and ide enable/disable
file annotate diff log raw
nkeynes@144
     1
/**
nkeynes@162
     2
 * $Id: display.h,v 1.2 2006-06-18 11:57:55 nkeynes Exp $
nkeynes@144
     3
 *
nkeynes@144
     4
 * The PC side of the video support (responsible for actually displaying / 
nkeynes@144
     5
 * rendering frames)
nkeynes@144
     6
 *
nkeynes@144
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@144
     8
 *
nkeynes@144
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@144
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@144
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@144
    12
 * (at your option) any later version.
nkeynes@144
    13
 *
nkeynes@144
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@144
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@144
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@144
    17
 * GNU General Public License for more details.
nkeynes@144
    18
 */
nkeynes@144
    19
nkeynes@144
    20
#ifndef dream_video_H
nkeynes@144
    21
#define dream_video_H
nkeynes@144
    22
nkeynes@144
    23
#include <stdint.h>
nkeynes@144
    24
#include <glib.h>
nkeynes@144
    25
nkeynes@144
    26
#ifdef __cplusplus
nkeynes@144
    27
extern "C" {
nkeynes@144
    28
#endif
nkeynes@144
    29
nkeynes@144
    30
/**
nkeynes@144
    31
 * Supported colour formats. Note that ARGB4444 is only ever used for texture
nkeynes@144
    32
 * rendering (it's not valid for display purposes).
nkeynes@144
    33
 */
nkeynes@144
    34
#define COLFMT_RGB565    1
nkeynes@144
    35
#define COLFMT_RGB888    4
nkeynes@144
    36
#define COLFMT_ARGB1555  0
nkeynes@144
    37
#define COLFMT_ARGB8888  5
nkeynes@144
    38
#define COLFMT_ARGB4444  2
nkeynes@144
    39
#define COLFMT_YUV422    3 /* 8-bit YUV (texture source only) */
nkeynes@144
    40
#define COLFMT_INDEX4    6 /* 4 bit indexed colour (texture source only) */
nkeynes@144
    41
#define COLFMT_INDEX8    7 /* 8-bit indexed colour (texture source only) */
nkeynes@144
    42
nkeynes@162
    43
extern int colour_format_bytes[];
nkeynes@162
    44
nkeynes@144
    45
typedef struct video_buffer {
nkeynes@144
    46
    uint32_t hres;
nkeynes@144
    47
    uint32_t vres;
nkeynes@144
    48
    uint32_t rowstride;
nkeynes@144
    49
    int colour_format;
nkeynes@144
    50
    char *data;
nkeynes@144
    51
} *video_buffer_t;
nkeynes@144
    52
nkeynes@144
    53
/**
nkeynes@144
    54
 * Core video driver - expected to directly support an OpenGL context
nkeynes@144
    55
 */
nkeynes@144
    56
typedef struct display_driver {
nkeynes@144
    57
    char *name;
nkeynes@144
    58
    /**
nkeynes@144
    59
     * Initialize the driver. This is called only once at startup time, and
nkeynes@144
    60
     * is guaranteed to be called before any other methods.
nkeynes@144
    61
     * @return TRUE if the driver was successfully initialized, otherwise
nkeynes@144
    62
     * FALSE.
nkeynes@144
    63
     */
nkeynes@144
    64
    gboolean (*init_driver)(void);
nkeynes@144
    65
nkeynes@144
    66
    /**
nkeynes@144
    67
     * Cleanly shutdown the driver. Normally only called at system shutdown
nkeynes@144
    68
     * time.
nkeynes@144
    69
     */
nkeynes@144
    70
    void (*shutdown_driver)(void);
nkeynes@144
    71
nkeynes@144
    72
    /**
nkeynes@144
    73
     * Given a particular keysym, return the keycode associated with it.
nkeynes@144
    74
     * @param keysym The keysym to be resolved, ie "Tab"
nkeynes@144
    75
     * @return the display-specific keycode, or 0 if the keysym cannot
nkeynes@144
    76
     * be resolved.
nkeynes@144
    77
     */
nkeynes@144
    78
    uint16_t (*resolve_keysym)( const gchar *keysym );
nkeynes@144
    79
nkeynes@144
    80
    /**
nkeynes@144
    81
     * Set the current display format to the specified values. This is
nkeynes@144
    82
     * called immediately prior to any display frame call where the
nkeynes@144
    83
     * parameters have changed from the previous frame
nkeynes@144
    84
     */
nkeynes@144
    85
    gboolean (*set_display_format)( uint32_t hres, uint32_t vres, 
nkeynes@144
    86
				    int colour_fmt );
nkeynes@144
    87
nkeynes@144
    88
    /**
nkeynes@144
    89
     * Set the current rendering format to the specified values. This is
nkeynes@144
    90
     * called immediately prior to starting rendering of a frame where the
nkeynes@144
    91
     * parameters have changed from the previous frame. Note that the driver
nkeynes@144
    92
     * is not required to precisely support the requested colour format.
nkeynes@144
    93
     *
nkeynes@144
    94
     * This method is also responsible for setting up an appropriate GL
nkeynes@144
    95
     * context for the main engine to render into.
nkeynes@144
    96
     *
nkeynes@144
    97
     * @param hres The horizontal resolution (ie 640)
nkeynes@144
    98
     * @param vres The vertical resolution (ie 480)
nkeynes@144
    99
     * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444)
nkeynes@144
   100
     * @param texture Flag indicating that the frame being rendered is a
nkeynes@144
   101
     * texture, rather than a display frame. 
nkeynes@144
   102
     */
nkeynes@144
   103
    gboolean (*set_render_format)( uint32_t hres, uint32_t vres,
nkeynes@144
   104
				   int colour_fmt, gboolean texture );
nkeynes@144
   105
    /**
nkeynes@144
   106
     * Display a single frame using the supplied pixmap data. Is assumed to
nkeynes@144
   107
     * invalidate the current GL front buffer (but not the back buffer).
nkeynes@144
   108
     */
nkeynes@144
   109
    gboolean (*display_frame)( video_buffer_t buffer );
nkeynes@144
   110
nkeynes@144
   111
    /**
nkeynes@144
   112
     * Display a single blanked frame using a fixed colour for the
nkeynes@144
   113
     * entire frame (specified in RGB888 format). Is assumed to invalidate
nkeynes@144
   114
     * the current GL front buffer (but not the back buffer).
nkeynes@144
   115
     */
nkeynes@144
   116
    gboolean (*display_blank_frame)( uint32_t rgb );
nkeynes@144
   117
nkeynes@144
   118
    /**
nkeynes@144
   119
     * Promote the current render back buffer to the front buffer
nkeynes@144
   120
     */
nkeynes@144
   121
    void (*display_back_buffer)( void );
nkeynes@144
   122
} *display_driver_t;
nkeynes@144
   123
nkeynes@144
   124
void video_open( void );
nkeynes@144
   125
void video_update_frame( void );
nkeynes@144
   126
void video_update_size( int, int, int );
nkeynes@144
   127
nkeynes@144
   128
extern uint32_t pvr2_frame_counter;
nkeynes@144
   129
nkeynes@144
   130
extern display_driver_t display_driver;
nkeynes@144
   131
nkeynes@144
   132
extern struct display_driver display_gtk_driver;
nkeynes@144
   133
extern struct display_driver display_null_driver;
nkeynes@144
   134
nkeynes@144
   135
/****************** Input methods **********************/
nkeynes@144
   136
nkeynes@144
   137
typedef void (*input_key_callback_t)( void *data, uint32_t value, gboolean isKeyDown );
nkeynes@144
   138
nkeynes@144
   139
gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,
nkeynes@144
   140
			     void *data, uint32_t value );
nkeynes@144
   141
nkeynes@144
   142
void input_unregister_key( const gchar *keysym );
nkeynes@144
   143
nkeynes@144
   144
gboolean input_is_key_valid( const gchar *keysym );
nkeynes@144
   145
nkeynes@144
   146
gboolean input_is_key_registered( const gchar *keysym );
nkeynes@144
   147
nkeynes@144
   148
void input_event_keydown( uint16_t keycode );
nkeynes@144
   149
nkeynes@144
   150
void input_event_keyup( uint16_t keycode );
nkeynes@144
   151
nkeynes@144
   152
nkeynes@144
   153
nkeynes@144
   154
#ifdef __cplusplus
nkeynes@144
   155
}
nkeynes@144
   156
#endif
nkeynes@144
   157
#endif
.