libctru
v2.4.1
|
Simple framebuffer API. More...
Go to the source code of this file.
Macros | |
#define | RGB565(r, g, b) (((b)&0x1f)|(((g)&0x3f)<<5)|(((r)&0x1f)<<11)) |
Converts red, green, and blue components to packed RGB565. | |
#define | RGB8_to_565(r, g, b) (((b)>>3)&0x1f)|((((g)>>2)&0x3f)<<5)|((((r)>>3)&0x1f)<<11) |
Converts packed RGB8 to packed RGB565. | |
Enumerations | |
enum | gfxScreen_t { GFX_TOP = GSP_SCREEN_TOP , GFX_BOTTOM = GSP_SCREEN_BOTTOM } |
Screen IDs. More... | |
enum | gfx3dSide_t { GFX_LEFT = 0 , GFX_RIGHT = 1 } |
Top screen framebuffer side. More... | |
Functions | |
Initialization and deinitialization | |
void | gfxInitDefault (void) |
Initializes the LCD framebuffers with default parameters This is equivalent to calling: More... | |
void | gfxInit (GSPGPU_FramebufferFormat topFormat, GSPGPU_FramebufferFormat bottomFormat, bool vrambuffers) |
Initializes the LCD framebuffers. More... | |
void | gfxExit (void) |
Deinitializes and frees the LCD framebuffers. More... | |
Control | |
void | gfxSet3D (bool enable) |
Enables or disables the 3D stereoscopic effect on the top screen. More... | |
bool | gfxIs3D (void) |
Retrieves the status of the 3D stereoscopic effect on the top screen. More... | |
bool | gfxIsWide (void) |
Retrieves the status of the 800px (double-height) high resolution display mode of the top screen. More... | |
void | gfxSetWide (bool enable) |
Enables or disables the 800px (double-height) high resolution display mode of the top screen. More... | |
void | gfxSetScreenFormat (gfxScreen_t screen, GSPGPU_FramebufferFormat format) |
Changes the pixel format of a screen. More... | |
GSPGPU_FramebufferFormat | gfxGetScreenFormat (gfxScreen_t screen) |
Retrieves the current pixel format of a screen. More... | |
void | gfxSetDoubleBuffering (gfxScreen_t screen, bool enable) |
Enables or disables double buffering on a screen. More... | |
Rendering and presentation | |
u8 * | gfxGetFramebuffer (gfxScreen_t screen, gfx3dSide_t side, u16 *width, u16 *height) |
Retrieves the framebuffer of the specified screen to which graphics should be rendered. More... | |
void | gfxFlushBuffers (void) |
Flushes the data cache for the current framebuffers. More... | |
void | gfxScreenSwapBuffers (gfxScreen_t scr, bool hasStereo) |
Updates the configuration of the specified screen, swapping the buffers if double buffering is enabled. More... | |
CTR_DEPRECATED void | gfxConfigScreen (gfxScreen_t scr, bool immediate) |
Same as gfxScreenSwapBuffers, but with hasStereo set to true. More... | |
void | gfxSwapBuffers (void) |
Updates the configuration of both screens. More... | |
void | gfxSwapBuffersGpu (void) |
Same as gfxSwapBuffers (formerly different). | |
Simple framebuffer API.
This API provides basic functionality needed to bring up framebuffers for both screens, as well as managing display mode (stereoscopic 3D) and double buffering. It is mainly an abstraction over the gsp service.
Please note that the 3DS uses portrait screens rotated 90 degrees counterclockwise. Width/height refer to the physical dimensions of the screen; that is, the top screen is 240 pixels wide and 400 pixels tall; while the bottom screen is 240x320.
enum gfx3dSide_t |
Top screen framebuffer side.
This is only meaningful when stereoscopic 3D is enabled on the top screen. In any other case, use GFX_LEFT.
Enumerator | |
---|---|
GFX_LEFT | Left eye framebuffer. |
GFX_RIGHT | Right eye framebuffer. |
enum gfxScreen_t |
CTR_DEPRECATED void gfxConfigScreen | ( | gfxScreen_t | scr, |
bool | immediate | ||
) |
Same as gfxScreenSwapBuffers, but with hasStereo set to true.
scr | Screen ID (see gfxScreen_t) |
immediate | This parameter no longer has any effect and is thus ignored. |
void gfxExit | ( | void | ) |
Deinitializes and frees the LCD framebuffers.
void gfxFlushBuffers | ( | void | ) |
Flushes the data cache for the current framebuffers.
u8* gfxGetFramebuffer | ( | gfxScreen_t | screen, |
gfx3dSide_t | side, | ||
u16 * | width, | ||
u16 * | height | ||
) |
Retrieves the framebuffer of the specified screen to which graphics should be rendered.
screen | Screen ID (see gfxScreen_t) |
side | Framebuffer side (see gfx3dSide_t) (pass GFX_LEFT if not using stereoscopic 3D) |
width | Pointer that will hold the width of the framebuffer in pixels. |
height | Pointer that will hold the height of the framebuffer in pixels. |
Please remember that the returned pointer will change every frame if double buffering is enabled.
GSPGPU_FramebufferFormat gfxGetScreenFormat | ( | gfxScreen_t | screen | ) |
Retrieves the current pixel format of a screen.
screen | Screen ID (see gfxScreen_t) |
void gfxInit | ( | GSPGPU_FramebufferFormat | topFormat, |
GSPGPU_FramebufferFormat | bottomFormat, | ||
bool | vrambuffers | ||
) |
Initializes the LCD framebuffers.
topFormat | The format of the top screen framebuffers. |
bottomFormat | The format of the bottom screen framebuffers. |
vramBuffers | Whether to allocate the framebuffers in VRAM. |
This function allocates memory for the framebuffers in the specified memory region. Initially, stereoscopic 3D is disabled and double buffering is enabled.
void gfxInitDefault | ( | void | ) |
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
bool gfxIs3D | ( | void | ) |
Retrieves the status of the 3D stereoscopic effect on the top screen.
bool gfxIsWide | ( | void | ) |
Retrieves the status of the 800px (double-height) high resolution display mode of the top screen.
void gfxScreenSwapBuffers | ( | gfxScreen_t | scr, |
bool | hasStereo | ||
) |
Updates the configuration of the specified screen, swapping the buffers if double buffering is enabled.
scr | Screen ID (see gfxScreen_t) |
hasStereo | For the top screen in 3D mode: true if the framebuffer contains individual images for both eyes, or false if the left image should be duplicated to the right eye. |
void gfxSet3D | ( | bool | enable | ) |
Enables or disables the 3D stereoscopic effect on the top screen.
enable | Pass true to enable, false to disable. |
void gfxSetDoubleBuffering | ( | gfxScreen_t | screen, |
bool | enable | ||
) |
Enables or disables double buffering on a screen.
screen | Screen ID (see gfxScreen_t) |
enable | Pass true to enable, false to disable. |
void gfxSetScreenFormat | ( | gfxScreen_t | screen, |
GSPGPU_FramebufferFormat | format | ||
) |
Changes the pixel format of a screen.
screen | Screen ID (see gfxScreen_t) |
format | Pixel format (see GSPGPU_FramebufferFormat) |
void gfxSetWide | ( | bool | enable | ) |
Enables or disables the 800px (double-height) high resolution display mode of the top screen.
enable | Pass true to enable, false to disable. |
void gfxSwapBuffers | ( | void | ) |
Updates the configuration of both screens.