Search
lxdream.org :: lxdream/src/display.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/display.h
changeset 352:f0df7a6d4703
prev335:fb890e1814c0
next370:3131ba1440fc
author nkeynes
date Sun Feb 11 10:09:32 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Bug 27: Implement opengl framebuffer objects
Rewrite much of the final video output stage. Now uses generic "render
buffers", implemented on GL using framebuffer objects + textures.
file annotate diff log raw
1.1 --- a/src/display.h Sat Jan 27 12:03:53 2007 +0000
1.2 +++ b/src/display.h Sun Feb 11 10:09:32 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: display.h,v 1.4 2007-01-27 12:03:53 nkeynes Exp $
1.6 + * $Id: display.h,v 1.5 2007-02-11 10:09:32 nkeynes Exp $
1.7 *
1.8 * The PC side of the video support (responsible for actually displaying /
1.9 * rendering frames)
1.10 @@ -20,6 +20,7 @@
1.11 #ifndef dream_video_H
1.12 #define dream_video_H
1.13
1.14 +#include "mem.h"
1.15 #include <stdint.h>
1.16 #include <glib.h>
1.17 #include <GL/gl.h>
1.18 @@ -50,17 +51,38 @@
1.19
1.20 extern int colour_format_bytes[];
1.21
1.22 -typedef struct video_buffer {
1.23 - uint32_t hres;
1.24 - uint32_t vres;
1.25 +/**
1.26 + * Structure to hold pixel data held in GL buffers.
1.27 + */
1.28 +typedef struct render_buffer {
1.29 + uint32_t width;
1.30 + uint32_t height;
1.31 uint32_t rowstride;
1.32 int colour_format;
1.33 - gboolean line_double;
1.34 - char *data;
1.35 -} *video_buffer_t;
1.36 + sh4addr_t address; /* Address buffer was rendered to, or -1 for unrendered */
1.37 + uint32_t size; /* Size of buffer in bytes, must be width*height*bpp */
1.38 + int scale;
1.39 + int buf_id; /* driver-specific buffer id, if applicable */
1.40 + gboolean flushed; /* True if the buffer has been flushed to vram */
1.41 +} *render_buffer_t;
1.42
1.43 /**
1.44 - * Core video driver - expected to directly support an OpenGL context
1.45 + * Structure to hold pixel data stored in pvr2 vram, as opposed to data in
1.46 + * GL buffers.
1.47 + */
1.48 +typedef struct frame_buffer {
1.49 + uint32_t width;
1.50 + uint32_t height;
1.51 + uint32_t rowstride;
1.52 + int colour_format;
1.53 + sh4addr_t address;
1.54 + uint32_t size; /* Size of buffer in bytes, must be width*height*bpp */
1.55 + char *data;
1.56 +} * frame_buffer_t;
1.57 +
1.58 +/**
1.59 + * Core video driver - exports function to setup a GL context, as well as handle
1.60 + * keyboard input and display resultant output.
1.61 */
1.62 typedef struct display_driver {
1.63 char *name;
1.64 @@ -87,47 +109,44 @@
1.65 uint16_t (*resolve_keysym)( const gchar *keysym );
1.66
1.67 /**
1.68 - * Set the current display format to the specified values. This is
1.69 - * called immediately prior to any display frame call where the
1.70 - * parameters have changed from the previous frame
1.71 + * Create a render target with the given width and height.
1.72 */
1.73 - gboolean (*set_display_format)( uint32_t hres, uint32_t vres,
1.74 - int colour_fmt );
1.75 + render_buffer_t (*create_render_buffer)( uint32_t width, uint32_t height );
1.76
1.77 /**
1.78 - * Set the current rendering format to the specified values. This is
1.79 - * called immediately prior to starting rendering of a frame where the
1.80 - * parameters have changed from the previous frame. Note that the driver
1.81 - * is not required to precisely support the requested colour format.
1.82 - *
1.83 - * This method is also responsible for setting up an appropriate GL
1.84 - * context for the main engine to render into.
1.85 - *
1.86 - * @param hres The horizontal resolution (ie 640)
1.87 - * @param vres The vertical resolution (ie 480)
1.88 - * @param colour_fmt The colour format of the buffer (ie COLFMT_ARGB4444)
1.89 - * @param texture Flag indicating that the frame being rendered is a
1.90 - * texture, rather than a display frame.
1.91 + * Destroy the specified render buffer and release any associated
1.92 + * resources.
1.93 */
1.94 - gboolean (*set_render_format)( uint32_t hres, uint32_t vres,
1.95 - int colour_fmt, gboolean texture );
1.96 + void (*destroy_render_buffer)( render_buffer_t buffer );
1.97 +
1.98 /**
1.99 - * Display a single frame using the supplied pixmap data. Is assumed to
1.100 - * invalidate the current GL front buffer (but not the back buffer).
1.101 + * Set the current rendering target to the specified buffer.
1.102 */
1.103 - gboolean (*display_frame)( video_buffer_t buffer );
1.104 + gboolean (*set_render_target)( render_buffer_t buffer );
1.105 +
1.106 + /**
1.107 + * Display a single frame using the supplied pixmap data.
1.108 + */
1.109 + gboolean (*display_frame_buffer)( frame_buffer_t buffer );
1.110 +
1.111 + /**
1.112 + * Display a single frame using a previously rendered GL buffer.
1.113 + */
1.114 + gboolean (*display_render_buffer)( render_buffer_t buffer );
1.115
1.116 /**
1.117 * Display a single blanked frame using a fixed colour for the
1.118 - * entire frame (specified in RGB888 format). Is assumed to invalidate
1.119 - * the current GL front buffer (but not the back buffer).
1.120 + * entire frame (specified in RGB888 format).
1.121 */
1.122 - gboolean (*display_blank_frame)( uint32_t rgb );
1.123 + gboolean (*display_blank)( uint32_t rgb );
1.124
1.125 /**
1.126 - * Promote the current render back buffer to the front buffer
1.127 + * Copy the image data from the GL buffer to the target memory buffer,
1.128 + * using the format etc from the buffer. This may force a glFinish()
1.129 + * but does not invalidate the buffer.
1.130 */
1.131 - void (*display_back_buffer)( void );
1.132 + gboolean (*read_render_buffer)( render_buffer_t buffer, char *target );
1.133 +
1.134 } *display_driver_t;
1.135
1.136 void video_open( void );
.