mirror of
https://github.com/holub/mame
synced 2025-05-13 01:24:20 +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
98 lines
2.9 KiB
C++
98 lines
2.9 KiB
C++
/*
|
|
* Copyright 2013 Jeremie Roy. All rights reserved.
|
|
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
|
*/
|
|
|
|
#ifndef TEXT_BUFFER_MANAGER_H_HEADER_GUARD
|
|
#define TEXT_BUFFER_MANAGER_H_HEADER_GUARD
|
|
|
|
#include "font_manager.h"
|
|
|
|
BGFX_HANDLE(TextBufferHandle);
|
|
|
|
#define MAX_TEXT_BUFFER_COUNT 64
|
|
|
|
/// type of vertex and index buffer to use with a TextBuffer
|
|
struct BufferType
|
|
{
|
|
enum Enum
|
|
{
|
|
Static,
|
|
Dynamic,
|
|
Transient,
|
|
};
|
|
};
|
|
|
|
/// special style effect (can be combined)
|
|
enum TextStyleFlags
|
|
{
|
|
STYLE_NORMAL = 0,
|
|
STYLE_OVERLINE = 1,
|
|
STYLE_UNDERLINE = 1 << 1,
|
|
STYLE_STRIKE_THROUGH = 1 << 2,
|
|
STYLE_BACKGROUND = 1 << 3,
|
|
};
|
|
|
|
struct TextRectangle
|
|
{
|
|
float width, height;
|
|
};
|
|
|
|
class TextBuffer;
|
|
class TextBufferManager
|
|
{
|
|
public:
|
|
TextBufferManager(FontManager* _fontManager);
|
|
~TextBufferManager();
|
|
|
|
TextBufferHandle createTextBuffer(uint32_t _type, BufferType::Enum _bufferType);
|
|
void destroyTextBuffer(TextBufferHandle _handle);
|
|
void submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId _id, int32_t _depth = 0);
|
|
|
|
void setStyle(TextBufferHandle _handle, uint32_t _flags = STYLE_NORMAL);
|
|
void setTextColor(TextBufferHandle _handle, uint32_t _rgba = 0x000000FF);
|
|
void setBackgroundColor(TextBufferHandle _handle, uint32_t _rgba = 0x000000FF);
|
|
|
|
void setOverlineColor(TextBufferHandle _handle, uint32_t _rgba = 0x000000FF);
|
|
void setUnderlineColor(TextBufferHandle _handle, uint32_t _rgba = 0x000000FF);
|
|
void setStrikeThroughColor(TextBufferHandle _handle, uint32_t _rgba = 0x000000FF);
|
|
|
|
void setPenPosition(TextBufferHandle _handle, float _x, float _y);
|
|
|
|
/// Append an ASCII/utf-8 string to the buffer using current pen position and color.
|
|
void appendText(TextBufferHandle _handle, FontHandle _fontHandle, const char* _string, const char* _end = NULL);
|
|
|
|
/// Append a wide char unicode string to the buffer using current pen position and color.
|
|
void appendText(TextBufferHandle _handle, FontHandle _fontHandle, const wchar_t* _string, const wchar_t* _end = NULL);
|
|
|
|
/// Append a whole face of the atlas cube, mostly used for debugging and visualizing atlas.
|
|
void appendAtlasFace(TextBufferHandle _handle, uint16_t _faceIndex);
|
|
|
|
/// Clear the text buffer and reset its state (pen/color).
|
|
void clearTextBuffer(TextBufferHandle _handle);
|
|
|
|
/// Return the rectangular size of the current text buffer (including all its content).
|
|
TextRectangle getRectangle(TextBufferHandle _handle) const;
|
|
|
|
private:
|
|
struct BufferCache
|
|
{
|
|
uint16_t indexBufferHandleIdx;
|
|
uint16_t vertexBufferHandleIdx;
|
|
TextBuffer* textBuffer;
|
|
BufferType::Enum bufferType;
|
|
uint32_t fontType;
|
|
};
|
|
|
|
BufferCache* m_textBuffers;
|
|
bx::HandleAllocT<MAX_TEXT_BUFFER_COUNT> m_textBufferHandles;
|
|
FontManager* m_fontManager;
|
|
bgfx::VertexLayout m_vertexLayout;
|
|
bgfx::UniformHandle s_texColor;
|
|
bgfx::ProgramHandle m_basicProgram;
|
|
bgfx::ProgramHandle m_distanceProgram;
|
|
bgfx::ProgramHandle m_distanceSubpixelProgram;
|
|
};
|
|
|
|
#endif // TEXT_BUFFER_MANAGER_H_HEADER_GUARD
|