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