@@ -32,6 +32,9 @@ void bridge_retro_unload_game(void *f);
3232void bridge_retro_run(void *f);
3333void bridge_retro_reset(void *f);
3434void bridge_retro_frame_time_callback(retro_frame_time_callback_t f, retro_usec_t usec);
35+ void bridge_retro_hw_context_reset(retro_hw_context_reset_t f);
36+ uintptr_t bridge_retro_hw_get_current_framebuffer(retro_hw_get_current_framebuffer_t f);
37+ void bridge_retro_hw_context_destroy(retro_hw_context_reset_t f);
3538void bridge_retro_audio_callback(retro_audio_callback_t f);
3639void bridge_retro_audio_set_state(retro_audio_set_state_callback_t f, bool state);
3740
@@ -121,6 +124,22 @@ type FrameTimeCallback struct {
121124 Reference int64
122125}
123126
127+ // HWRenderCallback sets an interface to let a libretro core render with
128+ // hardware acceleration.
129+ type HWRenderCallback struct {
130+ HWContextType uint
131+ ContextReset func ()
132+ GetCurrentFramebuffer func () uintptr
133+ GetProcAddress func ()
134+ Depth bool
135+ Stencil bool
136+ BottomLeftOrigin bool
137+ VersionMajor , VersionMinor uint
138+ CacheContext bool
139+ ContextDestroy func ()
140+ DebugContext bool
141+ }
142+
124143// AudioCallback stores the audio callback itself and the SetState callback
125144type AudioCallback struct {
126145 Callback func ()
@@ -179,6 +198,7 @@ const (
179198 EnvironmentGetPerfInterface = uint32 (C .RETRO_ENVIRONMENT_GET_PERF_INTERFACE )
180199 EnvironmentSetFrameTimeCallback = uint32 (C .RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK )
181200 EnvironmentSetAudioCallback = uint32 (C .RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK )
201+ EnvironmentSetHWRenderer = uint32 (C .RETRO_ENVIRONMENT_SET_HW_RENDER )
182202)
183203
184204// Debug levels
@@ -531,6 +551,30 @@ func SetFrameTimeCallback(data unsafe.Pointer) FrameTimeCallback {
531551 return ftc
532552}
533553
554+ // SetHWRenderCallback is an environment callback helper to set the HWRenderCallback
555+ func SetHWRenderCallback (data unsafe.Pointer ) HWRenderCallback {
556+ c := * (* C .struct_retro_hw_render_callback )(data )
557+ hwrc := HWRenderCallback {}
558+ hwrc .HWContextType = uint (c .context_type )
559+ hwrc .ContextReset = func () {
560+ C .bridge_retro_hw_context_reset (c .context_reset )
561+ }
562+ hwrc .GetCurrentFramebuffer = func () uintptr {
563+ return uintptr (C .bridge_retro_hw_get_current_framebuffer (c .get_current_framebuffer ))
564+ }
565+ hwrc .Depth = bool (c .depth )
566+ hwrc .Stencil = bool (c .stencil )
567+ hwrc .BottomLeftOrigin = bool (c .bottom_left_origin )
568+ hwrc .VersionMajor = uint (c .version_major )
569+ hwrc .VersionMinor = uint (c .version_minor )
570+ hwrc .CacheContext = bool (c .cache_context )
571+ hwrc .ContextDestroy = func () {
572+ C .bridge_retro_hw_context_destroy (c .context_destroy )
573+ }
574+ hwrc .DebugContext = bool (c .debug_context )
575+ return hwrc
576+ }
577+
534578// SetAudioCallback is an environment callback helper to set the AudioCallback
535579func SetAudioCallback (data unsafe.Pointer ) AudioCallback {
536580 c := * (* C .struct_retro_audio_callback )(data )
0 commit comments