Search
lxdream.org :: lxdream/src/display.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/display.h
changeset 144:7f0714e89aaa
next162:f7781f928f7e
author nkeynes
date Wed May 24 11:50:19 2006 +0000 (17 years ago)
permissions -rw-r--r--
last change Add load/save/reset state, and general tidy up
file annotate diff log raw
nkeynes@144
     1
/**
nkeynes@144
     2
 * $Id: display.h,v 1.1 2006-05-15 08:28:48 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@144
    43
typedef struct video_buffer {
nkeynes@144
    44
    uint32_t hres;
nkeynes@144
    45
    uint32_t vres;
nkeynes@144
    46
    uint32_t rowstride;
nkeynes@144
    47
    int colour_format;
nkeynes@144
    48
    char *data;
nkeynes@144
    49
} *video_buffer_t;
nkeynes@144
    50
nkeynes@144
    51
/**
nkeynes@144
    52
 * Core video driver - expected to directly support an OpenGL context
nkeynes@144
    53
 */
nkeynes@144
    54
typedef struct display_driver {
nkeynes@144
    55
    char *name;
nkeynes@144
    56
    /**
nkeynes@144
    57
     * Initialize the driver. This is called only once at startup time, and
nkeynes@144
    58
     * is guaranteed to be called before any other methods.
nkeynes@144
    59
     * @return TRUE if the driver was successfully initialized, otherwise
nkeynes@144
    60
     * FALSE.
nkeynes@144
    61
     */
nkeynes@144
    62
    gboolean (*init_driver)(void);
nkeynes@144
    63
nkeynes@144
    64
    /**
nkeynes@144
    65
     * Cleanly shutdown the driver. Normally only called at system shutdown
nkeynes@144
    66
     * time.
nkeynes@144
    67
     */
nkeynes@144
    68
    void (*shutdown_driver)(void);
nkeynes@144
    69
nkeynes@144
    70
    /**
nkeynes@144
    71
     * Given a particular keysym, return the keycode associated with it.
nkeynes@144
    72
     * @param keysym The keysym to be resolved, ie "Tab"
nkeynes@144
    73
     * @return the display-specific keycode, or 0 if the keysym cannot
nkeynes@144
    74
     * be resolved.
nkeynes@144
    75
     */
nkeynes@144
    76
    uint16_t (*resolve_keysym)( const gchar *keysym );
nkeynes@144
    77
nkeynes@144
    78
    /**
nkeynes@144
    79
     * Set the current display format to the specified values. This is
nkeynes@144
    80
     * called immediately prior to any display frame call where the
nkeynes@144
    81
     * parameters have changed from the previous frame
nkeynes@144
    82
     */
nkeynes@144
    83
    gboolean (*set_display_format)( uint32_t hres, uint32_t vres, 
nkeynes@144
    84
				    int colour_fmt );
nkeynes@144
    85
nkeynes@144
    86
    /**
nkeynes@144
    87
     * Set the current rendering format to the specified values. This is
nkeynes@144
    88
     * called immediately prior to starting rendering of a frame where the
nkeynes@144
    89
     * parameters have changed from the previous frame. Note that the driver
nkeynes@144
    90
     * is not required to precisely support the requested colour format.
nkeynes@144
    91
     *
nkeynes@144
    92
     * This method is also responsible for setting up an appropriate GL
nkeynes@144
    93
     * context for the main engine to render into.
nkeynes@144
    94
     *
nkeynes@144
    95
     * @param hres The horizontal resolution (ie 640)
nkeynes@144
    96
     * @param vres The vertical resolution (ie 480)
nkeynes@144
    97
     * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444)
nkeynes@144
    98
     * @param texture Flag indicating that the frame being rendered is a
nkeynes@144
    99
     * texture, rather than a display frame. 
nkeynes@144
   100
     */
nkeynes@144
   101
    gboolean (*set_render_format)( uint32_t hres, uint32_t vres,
nkeynes@144
   102
				   int colour_fmt, gboolean texture );
nkeynes@144
   103
    /**
nkeynes@144
   104
     * Display a single frame using the supplied pixmap data. Is assumed to
nkeynes@144
   105
     * invalidate the current GL front buffer (but not the back buffer).
nkeynes@144
   106
     */
nkeynes@144
   107
    gboolean (*display_frame)( video_buffer_t buffer );
nkeynes@144
   108
nkeynes@144
   109
    /**
nkeynes@144
   110
     * Display a single blanked frame using a fixed colour for the
nkeynes@144
   111
     * entire frame (specified in RGB888 format). Is assumed to invalidate
nkeynes@144
   112
     * the current GL front buffer (but not the back buffer).
nkeynes@144
   113
     */
nkeynes@144
   114
    gboolean (*display_blank_frame)( uint32_t rgb );
nkeynes@144
   115
nkeynes@144
   116
    /**
nkeynes@144
   117
     * Promote the current render back buffer to the front buffer
nkeynes@144
   118
     */
nkeynes@144
   119
    void (*display_back_buffer)( void );
nkeynes@144
   120
} *display_driver_t;
nkeynes@144
   121
nkeynes@144
   122
void video_open( void );
nkeynes@144
   123
void video_update_frame( void );
nkeynes@144
   124
void video_update_size( int, int, int );
nkeynes@144
   125
nkeynes@144
   126
extern uint32_t pvr2_frame_counter;
nkeynes@144
   127
nkeynes@144
   128
extern display_driver_t display_driver;
nkeynes@144
   129
nkeynes@144
   130
extern struct display_driver display_gtk_driver;
nkeynes@144
   131
extern struct display_driver display_null_driver;
nkeynes@144
   132
nkeynes@144
   133
/****************** Input methods **********************/
nkeynes@144
   134
nkeynes@144
   135
typedef void (*input_key_callback_t)( void *data, uint32_t value, gboolean isKeyDown );
nkeynes@144
   136
nkeynes@144
   137
gboolean input_register_key( const gchar *keysym, input_key_callback_t callback,
nkeynes@144
   138
			     void *data, uint32_t value );
nkeynes@144
   139
nkeynes@144
   140
void input_unregister_key( const gchar *keysym );
nkeynes@144
   141
nkeynes@144
   142
gboolean input_is_key_valid( const gchar *keysym );
nkeynes@144
   143
nkeynes@144
   144
gboolean input_is_key_registered( const gchar *keysym );
nkeynes@144
   145
nkeynes@144
   146
void input_event_keydown( uint16_t keycode );
nkeynes@144
   147
nkeynes@144
   148
void input_event_keyup( uint16_t keycode );
nkeynes@144
   149
nkeynes@144
   150
nkeynes@144
   151
nkeynes@144
   152
#ifdef __cplusplus
nkeynes@144
   153
}
nkeynes@144
   154
#endif
nkeynes@144
   155
#endif
.