Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4909

General • Re: Struggling with redefining a frame buffer.

$
0
0
If your need is "to determine the size of the buffer at runtime", then the description would be as follows:

Code:

#include <stdio.h>#include <stdlib.h>#include <pico/stdlib.h>typedef struct {    uint16_t vga_virtual_pixel_width;    uint16_t vga_virtual_pixel_height;} ScreenModeParams;uint16_t *rgbDataBufferEven;uint16_t *rgbDataBufferOdd;static void init_frame_buffers(ScreenModeParams *params) {    rgbDataBufferEven = aligned_alloc(4, params->vga_virtual_pixel_width);    rgbDataBufferOdd = aligned_alloc(4, params->vga_virtual_pixel_width);    memset(rgbDataBufferEven, 0, params->vga_virtual_pixel_width);    memset(rgbDataBufferOdd, 0, params->vga_virtual_pixel_width);}static void free_frame_buffers(void) {    free(rgbDataBufferEven);    free(rgbDataBufferOdd);}int main(void) {    ScreenModeParams params = {        .vga_virtual_pixel_width = 320,        .vga_virtual_pixel_height = 240,    };    init_frame_buffers(&params);    while (1)        ;    free_frame_buffers();}
If the need is "to dynamically redefine a statically defined buffer" I don't know.

Statistics: Posted by 0yama — Tue Jul 02, 2024 1:35 am



Viewing all articles
Browse latest Browse all 4909

Trending Articles