libdragon
display.h
Go to the documentation of this file.
1
6#ifndef __LIBDRAGON_DISPLAY_H
7#define __LIBDRAGON_DISPLAY_H
8
9#include <stdbool.h>
10#include <stdint.h>
11
39typedef struct surface_s surface_t;
41
53typedef struct {
55 int32_t width;
57 int32_t height;
61
63#define const static const /* fool doxygen to document these static members */
65
66const resolution_t RESOLUTION_256x240 = {256, 240, false};
68const resolution_t RESOLUTION_320x240 = {320, 240, false};
70const resolution_t RESOLUTION_512x240 = {512, 240, false};
72const resolution_t RESOLUTION_640x240 = {640, 240, false};
74const resolution_t RESOLUTION_512x480 = {512, 480, true};
76const resolution_t RESOLUTION_640x480 = {640, 480, true};
77#undef const
78
80typedef enum
81{
87
89typedef enum
90{
99
110typedef enum
111{
131
133
138typedef filter_options_t antialias_t;
143#define ANTIALIAS_OFF FILTERS_DISABLED
148#define ANTIALIAS_RESAMPLE FILTERS_RESAMPLE
153#define ANTIALIAS_RESAMPLE_FETCH_NEEDED FILTERS_RESAMPLE_ANTIALIAS
158#define ANTIALIAS_RESAMPLE_FETCH_ALWAYS FILTERS_RESAMPLE_ANTIALIAS_DEDITHER
159
161
168
169#ifdef __cplusplus
170extern "C" {
171#endif
172
194void display_init( resolution_t res, bitdepth_t bit, uint32_t num_buffers, gamma_t gamma, filter_options_t filters );
195
201void display_close();
202
221
231
243void display_show(surface_t* surf);
244
248uint32_t display_get_width(void);
249
253uint32_t display_get_height(void);
254
258uint32_t display_get_bitdepth(void);
259
263uint32_t display_get_num_buffers(void);
264
270float display_get_fps(void);
271
272
274__attribute__((deprecated("use display_get or display_try_get instead")))
275static inline surface_t* display_lock(void) {
276 return display_try_get();
277}
280#ifdef __cplusplus
281}
282#endif
283 /* display */
285
286#endif
int32_t width
Screen width (must be between 2 and 800)
Definition: display.h:55
bool interlaced
True if interlaced mode enabled.
Definition: display.h:59
int32_t height
Screen height (must be between 1 and 720)
Definition: display.h:57
const resolution_t RESOLUTION_256x240
256x240 mode
Definition: display.h:66
void display_init(resolution_t res, bitdepth_t bit, uint32_t num_buffers, gamma_t gamma, filter_options_t filters)
Initialize the display to a particular resolution and bit depth.
Definition: display.c:91
void display_close()
Close the display.
Definition: display.c:261
const resolution_t RESOLUTION_640x480
640x480 mode, interlaced
Definition: display.h:76
const resolution_t RESOLUTION_640x240
640x240 mode, high-res progressive
Definition: display.h:72
gamma_t
Valid gamma correction settings.
Definition: display.h:90
uint32_t display_get_num_buffers(void)
Get the currently configured number of buffers.
Definition: display.c:413
filter_options_t
Valid display filter options.
Definition: display.h:111
void display_show(surface_t *surf)
Display a buffer on the screen.
Definition: display.c:342
uint32_t display_get_width(void)
Get the currently configured width of the display in pixels.
Definition: display.c:398
float display_get_fps(void)
Get the current number of frames per second being rendered.
Definition: display.c:418
const resolution_t RESOLUTION_512x240
512x240 mode, high-res progressive
Definition: display.h:70
const resolution_t RESOLUTION_320x240
320x240 mode
Definition: display.h:68
surface_t * display_try_get(void)
Try getting a display surface.
Definition: display.c:297
surface_t * display_context_t
Display context (DEPRECATED: Use surface_t instead)
Definition: display.h:167
bitdepth_t
Valid bit depths.
Definition: display.h:81
const resolution_t RESOLUTION_512x480
512x480 mode, interlaced
Definition: display.h:74
uint32_t display_get_bitdepth(void)
Get the currently configured bitdepth of the display (in bytes per pixels)
Definition: display.c:408
surface_t * display_get(void)
Get a display buffer for rendering.
Definition: display.c:328
uint32_t display_get_height(void)
Get the currently configured height of the display in pixels.
Definition: display.c:403
@ GAMMA_CORRECT_DITHER
Corrected gamma with hardware dithered output.
Definition: display.h:97
@ GAMMA_CORRECT
Corrected gamma, should be used on a 32-bit framebuffer only when assets have been produced in linear...
Definition: display.h:95
@ GAMMA_NONE
Uncorrected gamma, should be used by default and with assets built by libdragon tools.
Definition: display.h:92
@ FILTERS_RESAMPLE_ANTIALIAS_DEDITHER
Resize the output image with a bilinear filter (see FILTERS_RESAMPLE). Add a video interface anti-ali...
Definition: display.h:129
@ FILTERS_RESAMPLE_ANTIALIAS
Resize the output image with a bilinear filter (see FILTERS_RESAMPLE). Add a video interface anti-ali...
Definition: display.h:125
@ FILTERS_DEDITHER
Reconstruct a 32-bit output from dithered 16-bit framebuffer.
Definition: display.h:120
@ FILTERS_RESAMPLE
Resize the output image with a bilinear filter. In general, VI is in charge of resizing the framebuff...
Definition: display.h:118
@ FILTERS_DISABLED
All display filters are disabled.
Definition: display.h:113
@ DEPTH_32_BPP
32 bits per pixel (8-8-8-8)
Definition: display.h:85
@ DEPTH_16_BPP
16 bits per pixel (5-5-5-1)
Definition: display.h:83
Video resolution structure.
Definition: display.h:53
A surface buffer for graphics.
Definition: surface.h:135