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