Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libretro: Add GET_CORE_DATA and SET_CORE_DATA environment callbacks #17012

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RobLoach
Copy link
Member

@RobLoach RobLoach commented Sep 17, 2024

This introduces two environment callbacks that allow setting a user data pointer for arbitrary core data. This is one step closer to allowing cores to avoid declaring their own global/static variables, or playing around with threads to determine their own local state.

Example in libretro-samples: libretro/libretro-samples#30

typedef struct core_data_t {
    uint32_t *screen;
} core_data_t;

// Set the core data
core_data_t* data = calloc(1, sizeof(core_data_t));
data->screen = calloc(320 * 240, sizeof(uint32_t));
environ_cb(RETRO_ENVIRONMENT_SET_CORE_DATA, data);

// Get the core data
core_data_t* data = NULL;
environ_cb(RETRO_ENVIRONMENT_GET_CORE_DATA, &data);
video_cb(data->screen, 320, 240, stride << 2);

@RobLoach RobLoach changed the title libretro: Add RETRO_ENVIRONMENT_GET_CORE_DATA and RETRO_ENVIRONMENT_SET_CORE_DATA libretro: Add RETRO_ENVIRONMENT_GET_CORE_DATA and RETRO_ENVIRONMENT_SET_CORE_DATA Sep 17, 2024
@RobLoach RobLoach changed the title libretro: Add RETRO_ENVIRONMENT_GET_CORE_DATA and RETRO_ENVIRONMENT_SET_CORE_DATA libretro: Add GET_CORE_DATA and SET_CORE_DATA environment callbacks Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants