1 // Copyright 2021 Jean Pierre Cimalando
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // SPDX-License-Identifier: Apache-2.0
21 #if !defined(YSFX_NO_GFX)
22 struct ysfx_gfx_state_t
;
23 ysfx_gfx_state_t
*ysfx_gfx_state_new(ysfx_t
*fx
);
24 void ysfx_gfx_state_free(ysfx_gfx_state_t
*state
);
25 YSFX_DEFINE_AUTO_PTR(ysfx_gfx_state_u
, ysfx_gfx_state_t
, ysfx_gfx_state_free
);
26 void ysfx_gfx_state_set_bitmap(ysfx_gfx_state_t
*state
, uint8_t *data
, uint32_t w
, uint32_t h
, uint32_t stride
);
27 void ysfx_gfx_state_set_scale_factor(ysfx_gfx_state_t
*state
, ysfx_real scale
);
28 void ysfx_gfx_state_set_callback_data(ysfx_gfx_state_t
*state
, void *callback_data
);
29 void ysfx_gfx_state_set_show_menu_callback(ysfx_gfx_state_t
*state
, int (*callback
)(void *, const char *, int32_t, int32_t));
30 void ysfx_gfx_state_set_set_cursor_callback(ysfx_gfx_state_t
*state
, void (*callback
)(void *, int32_t));
31 void ysfx_gfx_state_set_get_drop_file_callback(ysfx_gfx_state_t
*state
, const char *(*callback
)(void *, int32_t));
32 bool ysfx_gfx_state_is_dirty(ysfx_gfx_state_t
*state
);
33 void ysfx_gfx_state_add_key(ysfx_gfx_state_t
*state
, uint32_t mods
, uint32_t key
, bool press
);
34 void ysfx_gfx_state_update_mouse(ysfx_gfx_state_t
*state
, uint32_t mods
, int xpos
, int ypos
, uint32_t buttons
, int wheel
, int hwheel
);
36 //------------------------------------------------------------------------------
37 void ysfx_gfx_enter(ysfx_t
*fx
, bool doinit
);
38 void ysfx_gfx_leave(ysfx_t
*fx
);
39 ysfx_gfx_state_t
*ysfx_gfx_get_context(ysfx_t
*fx
);
40 void ysfx_gfx_prepare(ysfx_t
*fx
);
42 struct ysfx_scoped_gfx_t
{
43 ysfx_scoped_gfx_t(ysfx_t
*fx
, bool doinit
) : m_fx(fx
) { ysfx_gfx_enter(fx
, doinit
); }
44 ~ysfx_scoped_gfx_t() { ysfx_gfx_leave(m_fx
); }
45 ysfx_t
*m_fx
= nullptr;
49 //------------------------------------------------------------------------------
50 void ysfx_api_init_gfx();