Search
lxdream.org :: lxdream/src/video.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/video.h
changeset 103:9b9cfc5855e0
prev94:8d80d9c7cc7d
next106:9048bac046c3
author nkeynes
date Mon Mar 13 12:39:07 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change More rendering work in progress. Almost there now...
file annotate diff log raw
nkeynes@31
     1
/**
nkeynes@103
     2
 * $Id: video.h,v 1.5 2006-03-13 12:39:03 nkeynes Exp $
nkeynes@31
     3
 *
nkeynes@31
     4
 * The PC side of the video support (responsible for actually displaying / 
nkeynes@31
     5
 * rendering frames)
nkeynes@31
     6
 *
nkeynes@31
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@31
     8
 *
nkeynes@31
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@31
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@31
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@31
    12
 * (at your option) any later version.
nkeynes@31
    13
 *
nkeynes@31
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@31
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@31
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@31
    17
 * GNU General Public License for more details.
nkeynes@31
    18
 */
nkeynes@31
    19
nkeynes@31
    20
#ifndef dream_video_H
nkeynes@31
    21
#define dream_video_H
nkeynes@31
    22
nkeynes@31
    23
#include <stdint.h>
nkeynes@94
    24
#include <glib.h>
nkeynes@31
    25
nkeynes@31
    26
#ifdef __cplusplus
nkeynes@31
    27
extern "C" {
nkeynes@31
    28
#endif
nkeynes@1
    29
nkeynes@103
    30
/**
nkeynes@103
    31
 * Supported colour formats. Note that ARGB4444 is only ever used for texture
nkeynes@103
    32
 * rendering (it's not valid for display purposes).
nkeynes@103
    33
 */
nkeynes@103
    34
#define COLFMT_RGB565    1
nkeynes@103
    35
#define COLFMT_RGB888    4
nkeynes@103
    36
#define COLFMT_ARGB1555  0
nkeynes@103
    37
#define COLFMT_ARGB8888  5
nkeynes@103
    38
#define COLFMT_ARGB4444  2
nkeynes@103
    39
#define COLFMT_YUV422    3 /* 8-bit YUV (texture source only) */
nkeynes@103
    40
#define COLFMT_INDEX4    6 /* 4 bit indexed colour (texture source only) */
nkeynes@103
    41
#define COLFMT_INDEX8    7 /* 8-bit indexed colour (texture source only) */
nkeynes@94
    42
nkeynes@94
    43
typedef struct video_buffer {
nkeynes@94
    44
    uint32_t hres;
nkeynes@94
    45
    uint32_t vres;
nkeynes@94
    46
    uint32_t rowstride;
nkeynes@94
    47
    int colour_format;
nkeynes@94
    48
    char *data;
nkeynes@94
    49
} *video_buffer_t;
nkeynes@94
    50
nkeynes@103
    51
/**
nkeynes@103
    52
 * Core video driver - expected to directly support an OpenGL context
nkeynes@103
    53
 */
nkeynes@94
    54
typedef struct video_driver {
nkeynes@94
    55
    char *name;
nkeynes@103
    56
    /**
nkeynes@103
    57
     * Initialize the driver. This is called only once at startup time, and
nkeynes@103
    58
     * is guaranteed to be called before any other methods.
nkeynes@103
    59
     * @return TRUE if the driver was successfully initialized, otherwise
nkeynes@103
    60
     * FALSE.
nkeynes@103
    61
     */
nkeynes@103
    62
    gboolean (*init_driver)(void);
nkeynes@103
    63
nkeynes@103
    64
    /**
nkeynes@103
    65
     * Cleanly shutdown the driver. Normally only called at system shutdown
nkeynes@103
    66
     * time.
nkeynes@103
    67
     */
nkeynes@103
    68
    void (*shutdown_driver)(void);
nkeynes@103
    69
nkeynes@103
    70
    /**
nkeynes@103
    71
     * Set the current display format to the specified values. This is
nkeynes@103
    72
     * called immediately prior to any display frame call where the
nkeynes@103
    73
     * parameters have changed from the previous frame
nkeynes@103
    74
     */
nkeynes@103
    75
    gboolean (*set_display_format)( uint32_t hres, uint32_t vres, 
nkeynes@103
    76
				    int colour_fmt );
nkeynes@103
    77
nkeynes@103
    78
    /**
nkeynes@103
    79
     * Set the current rendering format to the specified values. This is
nkeynes@103
    80
     * called immediately prior to starting rendering of a frame where the
nkeynes@103
    81
     * parameters have changed from the previous frame. Note that the driver
nkeynes@103
    82
     * is not required to precisely support the requested colour format.
nkeynes@103
    83
     *
nkeynes@103
    84
     * This method is also responsible for setting up an appropriate GL
nkeynes@103
    85
     * context for the main engine to render into.
nkeynes@103
    86
     *
nkeynes@103
    87
     * @param hres The horizontal resolution (ie 640)
nkeynes@103
    88
     * @param vres The vertical resolution (ie 480)
nkeynes@103
    89
     * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444)
nkeynes@103
    90
     * @param texture Flag indicating that the frame being rendered is a
nkeynes@103
    91
     * texture, rather than a display frame. 
nkeynes@103
    92
     */
nkeynes@103
    93
    gboolean (*set_render_format)( uint32_t hres, uint32_t vres,
nkeynes@103
    94
				   int colour_fmt, gboolean texture );
nkeynes@103
    95
    /**
nkeynes@103
    96
     * Display a single frame using the supplied pixmap data. Is assumed to
nkeynes@103
    97
     * invalidate the current GL front buffer (but not the back buffer).
nkeynes@103
    98
     */
nkeynes@94
    99
    gboolean (*display_frame)( video_buffer_t buffer );
nkeynes@103
   100
nkeynes@103
   101
    /**
nkeynes@103
   102
     * Display a single blanked frame using a fixed colour for the
nkeynes@103
   103
     * entire frame (specified in RGB888 format). Is assumed to invalidate
nkeynes@103
   104
     * the current GL front buffer (but not the back buffer).
nkeynes@103
   105
     */
nkeynes@94
   106
    gboolean (*display_blank_frame)( uint32_t rgb );
nkeynes@103
   107
nkeynes@103
   108
    /**
nkeynes@103
   109
     * Promote the current render back buffer to the front buffer
nkeynes@103
   110
     */
nkeynes@103
   111
    void (*display_back_buffer)( void );
nkeynes@94
   112
} *video_driver_t;
nkeynes@94
   113
nkeynes@1
   114
void video_open( void );
nkeynes@1
   115
void video_update_frame( void );
nkeynes@1
   116
void video_update_size( int, int, int );
nkeynes@1
   117
nkeynes@94
   118
extern uint32_t pvr2_frame_counter;
nkeynes@94
   119
nkeynes@94
   120
extern struct video_driver video_gtk_driver;
nkeynes@31
   121
nkeynes@31
   122
#ifdef __cplusplus
nkeynes@31
   123
}
nkeynes@31
   124
#endif
nkeynes@31
   125
#endif
.