mirror of
https://github.com/holub/mame
synced 2025-05-10 16:21:42 +03:00

* Sync with bgfx upstream revision b91d0b6 * Sync with bx upstream revision d60912b * Sync with bimg upstream revision bd81f60 * Add astc-codec decoder * Rename VertexDecl to VertexLayout * Rename UniformType enum Int1 to Sampler. * Add NVN stub * Fix unused-const-variable error on macOS * Drop redundant explicit language parameters buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only applied to objective c++ files. As such, hardcoding -x offers no benefit while preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on macOS) from working. * Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning * Build bgfx as Objective-C++ on macOS It is needed due to included headers * Enable Direct3D12 and Vulkan bgfx rendering backends * Enable building of spirv shaders * Properly escape /c in cmd call * Comment out dx12 bgfx renderer * Honor VERBOSE setting during shaders build * Only invert hlsl shader XYZ_TO_sRGB matrix for opengl * Add spirv shaders * OpenGL ES needs transposed matrix too * Metal needs transposed matrix as well
122 lines
3.8 KiB
C++
122 lines
3.8 KiB
C++
/*
|
|
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
|
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
|
*/
|
|
|
|
#ifndef IMGUI_H_HEADER_GUARD
|
|
#define IMGUI_H_HEADER_GUARD
|
|
|
|
#include <bgfx/bgfx.h>
|
|
#include <dear-imgui/imgui.h>
|
|
#include <iconfontheaders/icons_kenney.h>
|
|
#include <iconfontheaders/icons_font_awesome.h>
|
|
|
|
#define IMGUI_MBUT_LEFT 0x01
|
|
#define IMGUI_MBUT_RIGHT 0x02
|
|
#define IMGUI_MBUT_MIDDLE 0x04
|
|
|
|
inline uint32_t imguiRGBA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255)
|
|
{
|
|
return 0
|
|
| (uint32_t(_r) << 0)
|
|
| (uint32_t(_g) << 8)
|
|
| (uint32_t(_b) << 16)
|
|
| (uint32_t(_a) << 24)
|
|
;
|
|
}
|
|
|
|
namespace bx { struct AllocatorI; }
|
|
|
|
void imguiCreate(float _fontSize = 18.0f, bx::AllocatorI* _allocator = NULL);
|
|
void imguiDestroy();
|
|
|
|
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, int _inputChar = -1, bgfx::ViewId _view = 255);
|
|
void imguiEndFrame();
|
|
|
|
namespace entry { class AppI; }
|
|
void showExampleDialog(entry::AppI* _app, const char* _errorText = NULL);
|
|
|
|
namespace ImGui
|
|
{
|
|
#define IMGUI_FLAGS_NONE UINT8_C(0x00)
|
|
#define IMGUI_FLAGS_ALPHA_BLEND UINT8_C(0x01)
|
|
|
|
// Helper function for passing bgfx::TextureHandle to ImGui::Image.
|
|
inline void Image(bgfx::TextureHandle _handle
|
|
, uint8_t _flags
|
|
, uint8_t _mip
|
|
, const ImVec2& _size
|
|
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
|
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
|
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
|
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
|
)
|
|
{
|
|
union { struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; ImTextureID ptr; } texture;
|
|
texture.s.handle = _handle;
|
|
texture.s.flags = _flags;
|
|
texture.s.mip = _mip;
|
|
Image(texture.ptr, _size, _uv0, _uv1, _tintCol, _borderCol);
|
|
}
|
|
|
|
// Helper function for passing bgfx::TextureHandle to ImGui::Image.
|
|
inline void Image(bgfx::TextureHandle _handle
|
|
, const ImVec2& _size
|
|
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
|
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
|
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
|
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
|
)
|
|
{
|
|
Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _tintCol, _borderCol);
|
|
}
|
|
|
|
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
|
|
inline bool ImageButton(bgfx::TextureHandle _handle
|
|
, uint8_t _flags
|
|
, uint8_t _mip
|
|
, const ImVec2& _size
|
|
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
|
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
|
, int _framePadding = -1
|
|
, const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
|
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
|
)
|
|
{
|
|
union { struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; ImTextureID ptr; } texture;
|
|
texture.s.handle = _handle;
|
|
texture.s.flags = _flags;
|
|
texture.s.mip = _mip;
|
|
return ImageButton(texture.ptr, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
|
}
|
|
|
|
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
|
|
inline bool ImageButton(bgfx::TextureHandle _handle
|
|
, const ImVec2& _size
|
|
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
|
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
|
, int _framePadding = -1
|
|
, const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
|
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
|
)
|
|
{
|
|
return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
|
}
|
|
|
|
inline void NextLine()
|
|
{
|
|
SetCursorPosY(GetCursorPosY() + GetTextLineHeightWithSpacing() );
|
|
}
|
|
|
|
inline bool MouseOverArea()
|
|
{
|
|
return false
|
|
|| ImGui::IsAnyItemHovered()
|
|
|| ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)
|
|
;
|
|
}
|
|
|
|
} // namespace ImGui
|
|
|
|
#endif // IMGUI_H_HEADER_GUARD
|