mirror of
https://github.com/holub/mame
synced 2025-04-19 23:12:11 +03:00
Update BGFX and BX (nw)
This commit is contained in:
parent
5c34b1ba40
commit
4172b54d84
@ -2,7 +2,7 @@
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright (c) 2014-2015 The Khronos Group Inc.
|
||||
** Copyright (c) 2014-2016 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@ -25,8 +25,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VK_PLATFORM_H_
|
||||
#define VK_PLATFORM_H_
|
||||
#ifndef __VK_PLATFORM_H__
|
||||
#define __VK_PLATFORM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@ -124,4 +124,4 @@ extern "C"
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // __VK_PLATFORM_H__
|
||||
|
14
3rdparty/bgfx/3rdparty/khronos/vulkan/vulkan.h
vendored
14
3rdparty/bgfx/3rdparty/khronos/vulkan/vulkan.h
vendored
@ -41,7 +41,7 @@ extern "C" {
|
||||
(((major) << 22) | ((minor) << 12) | (patch))
|
||||
|
||||
// Vulkan API version supported by this file
|
||||
#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 4)
|
||||
#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 5)
|
||||
|
||||
#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
|
||||
#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
|
||||
@ -142,6 +142,7 @@ typedef enum VkResult {
|
||||
VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
|
||||
VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
|
||||
VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
|
||||
VK_ERROR_INVALID_SHADER_NV = -1000012000,
|
||||
VK_RESULT_BEGIN_RANGE = VK_ERROR_FORMAT_NOT_SUPPORTED,
|
||||
VK_RESULT_END_RANGE = VK_INCOMPLETE,
|
||||
VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FORMAT_NOT_SUPPORTED + 1),
|
||||
@ -979,7 +980,7 @@ typedef enum VkShaderStageFlagBits {
|
||||
VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010,
|
||||
VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020,
|
||||
VK_SHADER_STAGE_ALL_GRAPHICS = 0x1F,
|
||||
VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
|
||||
VK_SHADER_STAGE_ALL = 0x7FFFFFFF,
|
||||
} VkShaderStageFlagBits;
|
||||
typedef VkFlags VkPipelineVertexInputStateCreateFlags;
|
||||
@ -992,7 +993,7 @@ typedef enum VkCullModeFlagBits {
|
||||
VK_CULL_MODE_NONE = 0,
|
||||
VK_CULL_MODE_FRONT_BIT = 0x00000001,
|
||||
VK_CULL_MODE_BACK_BIT = 0x00000002,
|
||||
VK_CULL_MODE_FRONT_AND_BACK = 0x3,
|
||||
VK_CULL_MODE_FRONT_AND_BACK = 0x00000003,
|
||||
} VkCullModeFlagBits;
|
||||
typedef VkFlags VkCullModeFlags;
|
||||
typedef VkFlags VkPipelineMultisampleStateCreateFlags;
|
||||
@ -1083,7 +1084,7 @@ typedef VkFlags VkCommandBufferResetFlags;
|
||||
typedef enum VkStencilFaceFlagBits {
|
||||
VK_STENCIL_FACE_FRONT_BIT = 0x00000001,
|
||||
VK_STENCIL_FACE_BACK_BIT = 0x00000002,
|
||||
VK_STENCIL_FRONT_AND_BACK = 0x3,
|
||||
VK_STENCIL_FRONT_AND_BACK = 0x00000003,
|
||||
} VkStencilFaceFlagBits;
|
||||
typedef VkFlags VkStencilFaceFlags;
|
||||
|
||||
@ -3774,6 +3775,11 @@ VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(
|
||||
const char* pMessage);
|
||||
#endif
|
||||
|
||||
#define VK_NV_glsl_shader 1
|
||||
#define VK_NV_GLSL_SHADER_SPEC_VERSION 1
|
||||
#define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
263
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
263
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -19,9 +19,10 @@
|
||||
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
||||
- How can I help?
|
||||
- How do I update to a newer version of ImGui?
|
||||
- What is ImTextureID and how do I display an image?
|
||||
- Can I have multiple widgets with the same label? Can I have widget without a label? (Yes) / A primer on the use of labels/IDs in ImGui.
|
||||
- I integrated ImGui in my engine and the text or lines are blurry..
|
||||
- I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
||||
- I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
- How can I load a different font than the default?
|
||||
- How can I load multiple fonts?
|
||||
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
@ -78,6 +79,7 @@
|
||||
- your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention on your side, no state duplication, less sync, less bugs.
|
||||
- call and read ImGui::ShowTestWindow() for demo code demonstrating most features.
|
||||
- see examples/ folder for standalone sample applications. Prefer reading examples/opengl_example/ first at it is the simplest.
|
||||
you may be able to grab and copy a ready made imgui_impl_*** file from the examples/.
|
||||
- customization: PushStyleColor()/PushStyleVar() or the style editor to tweak the look of the interface (e.g. if you want a more compact UI or a different color scheme).
|
||||
|
||||
- getting started:
|
||||
@ -85,12 +87,13 @@
|
||||
- init: call io.Fonts->GetTexDataAsRGBA32(...) and load the font texture pixels into graphics memory.
|
||||
- every frame:
|
||||
1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the fields marked 'Input'
|
||||
2/ call ImGui::NewFrame().
|
||||
2/ call ImGui::NewFrame() as early as you can!
|
||||
3/ use any ImGui function you want between NewFrame() and Render()
|
||||
4/ call ImGui::Render() to render all the accumulated command-lists. it will call your RenderDrawListFn handler that you set in the IO structure.
|
||||
4/ call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your RenderDrawListFn handler that you set in the IO structure.
|
||||
(if you don't need to render, you still need to call Render() and ignore the callback, or call EndFrame() instead. if you call neither some aspects of windows focusing/moving will appear broken.)
|
||||
- all rendering information are stored into command-lists until ImGui::Render() is called.
|
||||
- ImGui never touches or know about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you must provide.
|
||||
- effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases.
|
||||
- ImGui never touches or know about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide.
|
||||
- effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases of your own application.
|
||||
- refer to the examples applications in the examples/ folder for instruction on how to setup your code.
|
||||
- a typical application skeleton may be:
|
||||
|
||||
@ -107,7 +110,7 @@
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(pixels, &width, &height);
|
||||
// TODO: At this points you've got a texture pointed to by 'pixels' and you need to upload that your your graphic system
|
||||
// TODO: At this points you've got a texture pointed to by 'pixels' and you need to upload that your your graphic system
|
||||
// TODO: Store your texture pointer/identifier (whatever your engine uses) in 'io.Fonts->TexID'
|
||||
|
||||
// Application main loop
|
||||
@ -134,7 +137,7 @@
|
||||
|
||||
// 4) render & swap video buffers
|
||||
ImGui::Render();
|
||||
// swap video buffer, etc.
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
- after calling ImGui::NewFrame() you can read back flags from the IO structure to tell how ImGui intends to use your inputs.
|
||||
@ -149,6 +152,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete).
|
||||
- 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert.
|
||||
- 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you.
|
||||
- 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis.
|
||||
@ -257,6 +261,18 @@
|
||||
Check the "API BREAKING CHANGES" sections for a list of occasional API breaking changes. If you have a problem with a function, search for its name
|
||||
in the code, there will likely be a comment about it. Please report any issue to the GitHub page!
|
||||
|
||||
|
||||
Q: What is ImTextureID and how do I display an image?
|
||||
A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
|
||||
ImGui knows nothing about what those bits represent, it just passes them around. It is up to you to decide what you want the void* to carry!
|
||||
It could be an identifier to your OpenGL texture (cast GLuint to void*), a pointer to your custom engine material (cast MyMaterial* to void*), etc.
|
||||
At the end of the chain, your renderer takes this void* to cast it back into whatever it needs to select a current texture to render.
|
||||
Refer to examples applications, where each renderer (in a imgui_impl_xxxx.cpp file) is treating ImTextureID as a different thing.
|
||||
(c++ tip: OpenGL uses integers to identify textures. You can safely store an integer into a void*, just cast it to void*, don't take it's address!)
|
||||
To display a custom image/texture within an ImGui window, you may use ImGui::Image(), ImGui::ImageButton(), ImDrawList::AddImage() functions.
|
||||
ImGui will generate the geometry and draw calls using the ImTextureID that you passed and which your renderer can use.
|
||||
It is your responsibility to get textures uploaded to your GPU.
|
||||
|
||||
Q: Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
|
||||
A: Yes. A primer on the use of labels/IDs in ImGui..
|
||||
|
||||
@ -295,7 +311,7 @@
|
||||
|
||||
Button("Hello###ID"; // Label = "Hello", ID = hash of "ID"
|
||||
Button("World###ID"; // Label = "World", ID = hash of "ID" (same as above)
|
||||
|
||||
|
||||
sprintf(buf, "My game (%f FPS)###MyGame");
|
||||
Begin(buf); // Variable label, ID = hash of "MyGame"
|
||||
|
||||
@ -354,8 +370,8 @@
|
||||
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
||||
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
||||
|
||||
Q. I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
||||
Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
|
||||
Q: I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||
A: Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
|
||||
|
||||
Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
|
||||
A: Use the font atlas to load the TTF file you want:
|
||||
@ -424,7 +440,6 @@
|
||||
- window: get size/pos helpers given names (see discussion in #249)
|
||||
- window: a collapsed window can be stuck behind the main menu bar?
|
||||
- window: detect extra End() call that pop the "Debug" window out and assert at call site instead of later.
|
||||
- window: consider renaming "GetWindowFont" which conflict with old Windows #define (#340)
|
||||
- window/tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||
- window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd.
|
||||
- draw-list: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
|
||||
@ -434,7 +449,7 @@
|
||||
- widgets: clean up widgets internal toward exposing everything.
|
||||
- widgets: add disabled and read-only modes (#211)
|
||||
- main: considering adding EndFrame()/Init(). some constructs are awkward in the implementation because of the lack of them.
|
||||
- main: make it so that a frame with no window registered won't refocus every window on subsequent frames (~bump LastFrameActive of all windows).
|
||||
- main: make it so that a frame with no window registered won't refocus every window on subsequent frames (~bump LastFrameActive of all windows).
|
||||
- main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
|
||||
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
|
||||
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
|
||||
@ -591,7 +606,6 @@
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char* text_end = NULL);
|
||||
static const char* FindTextDisplayEnd(const char* text, const char* text_end = NULL);
|
||||
|
||||
static void PushMultiItemsWidths(int components, float w_full = 0.0f);
|
||||
static float GetDraggedColumnOffset(int column_index);
|
||||
@ -641,7 +655,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size);
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size);
|
||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2);
|
||||
static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format);
|
||||
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Platform dependent default implementations
|
||||
@ -973,7 +987,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
|
||||
if ((*str & 0xf0) == 0xe0)
|
||||
{
|
||||
*out_char = 0xFFFD; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
|
||||
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
|
||||
if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
|
||||
if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
|
||||
c = (unsigned int)((*str++ & 0x0f) << 12);
|
||||
@ -2377,7 +2391,7 @@ void ImGui::EndFrame()
|
||||
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
||||
if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.OsImePosRequest - g.OsImePosSet) > 0.0001f)
|
||||
{
|
||||
g.IO.ImeSetInputScreenPosFn((int)g.OsImePosRequest.x, (int)g.OsImePosRequest.y);
|
||||
g.IO.ImeSetInputScreenPosFn((int)g.OsImePosRequest.x, (int)g.OsImePosRequest.y);
|
||||
g.OsImePosSet = g.OsImePosRequest;
|
||||
}
|
||||
|
||||
@ -2510,8 +2524,7 @@ void ImGui::Render()
|
||||
}
|
||||
}
|
||||
|
||||
// Find the optional ## from which we stop displaying text.
|
||||
static const char* FindTextDisplayEnd(const char* text, const char* text_end)
|
||||
const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
|
||||
{
|
||||
const char* text_display_end = text;
|
||||
if (!text_end)
|
||||
@ -2550,7 +2563,7 @@ static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char*
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindowRead();
|
||||
|
||||
if (!text_end)
|
||||
text_end = FindTextDisplayEnd(text, text_end);
|
||||
text_end = ImGui::FindRenderedTextEnd(text, text_end);
|
||||
|
||||
const bool log_new_line = ref_pos.y > window->DC.LogLinePosY+1;
|
||||
window->DC.LogLinePosY = ref_pos.y;
|
||||
@ -2604,7 +2617,7 @@ void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool
|
||||
const char* text_display_end;
|
||||
if (hide_text_after_hash)
|
||||
{
|
||||
text_display_end = FindTextDisplayEnd(text, text_end);
|
||||
text_display_end = FindRenderedTextEnd(text, text_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2643,7 +2656,7 @@ void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end
|
||||
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align, const ImVec2* clip_min, const ImVec2* clip_max)
|
||||
{
|
||||
// Hide anything after a '##' string
|
||||
const char* text_display_end = FindTextDisplayEnd(text, text_end);
|
||||
const char* text_display_end = FindRenderedTextEnd(text, text_end);
|
||||
const int text_len = (int)(text_display_end - text);
|
||||
if (text_len == 0)
|
||||
return;
|
||||
@ -2750,7 +2763,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
|
||||
|
||||
const char* text_display_end;
|
||||
if (hide_text_after_double_hash)
|
||||
text_display_end = FindTextDisplayEnd(text, text_end); // Hide anything after a '##' string
|
||||
text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
|
||||
else
|
||||
text_display_end = text_end;
|
||||
|
||||
@ -2829,13 +2842,13 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
||||
// Test if mouse cursor is hovering given rectangle
|
||||
// NB- Rectangle is clipped by our current clip setting
|
||||
// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
|
||||
// Clip
|
||||
ImRect rect_clipped(pos_min, pos_max);
|
||||
ImRect rect_clipped(r_min, r_max);
|
||||
if (clip)
|
||||
rect_clipped.Clip(window->ClipRect);
|
||||
|
||||
@ -3131,7 +3144,7 @@ static bool IsPopupOpen(ImGuiID id)
|
||||
return opened;
|
||||
}
|
||||
|
||||
// Mark popup as open (toggle toward open state).
|
||||
// Mark popup as open (toggle toward open state).
|
||||
// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
|
||||
// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
|
||||
@ -3309,11 +3322,11 @@ void ImGui::EndPopup()
|
||||
}
|
||||
|
||||
// This is a helper to handle the most simple case of associating one named popup to one given widget.
|
||||
// 1. If you have many possible popups (for different "instances" of a same widget, or for wholly different widgets), you may be better off handling
|
||||
// 1. If you have many possible popups (for different "instances" of a same widget, or for wholly different widgets), you may be better off handling
|
||||
// this yourself so you can store data relative to the widget that opened the popup instead of choosing different popup identifiers.
|
||||
// 2. If you want right-clicking on the same item to reopen the popup at new location, use the same code replacing IsItemHovered() with IsItemHoveredRect()
|
||||
// and passing true to the OpenPopupEx().
|
||||
// Because: hovering an item in a window below the popup won't normally trigger is hovering behavior/coloring. The pattern of ignoring the fact that
|
||||
// Because: hovering an item in a window below the popup won't normally trigger is hovering behavior/coloring. The pattern of ignoring the fact that
|
||||
// the item isn't interactable (because it is blocked by the active popup) may useful in some situation when e.g. large canvas as one item, content of menu
|
||||
// driven by click position.
|
||||
bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
|
||||
@ -3472,7 +3485,7 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size,
|
||||
|
||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
{
|
||||
// FIXME-OPT: Store sorted hashes -> pointers so we can do a bissection in a contiguous block
|
||||
// FIXME-OPT: Store sorted hashes -> pointers so we can do a bissection in a contiguous block
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiID id = ImHash(name, 0);
|
||||
for (int i = 0; i < g.Windows.Size; i++)
|
||||
@ -3605,7 +3618,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
g.CurrentPopupStack.push_back(popup_ref);
|
||||
window->PopupID = popup_ref.PopupID;
|
||||
}
|
||||
|
||||
|
||||
const bool window_appearing_after_being_hidden = (window->HiddenFrames == 1);
|
||||
|
||||
// Process SetNextWindow***() calls
|
||||
@ -3753,7 +3766,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
else
|
||||
{
|
||||
size_auto_fit = ImClamp(window->SizeContents + window->WindowPadding, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding));
|
||||
|
||||
|
||||
// Handling case of auto fit window not fitting in screen on one axis, we are growing auto fit size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding.
|
||||
if (size_auto_fit.x < window->SizeContents.x && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar))
|
||||
size_auto_fit.y += style.ScrollbarSize;
|
||||
@ -4832,16 +4845,19 @@ ImDrawList* ImGui::GetWindowDrawList()
|
||||
return window->DrawList;
|
||||
}
|
||||
|
||||
ImFont* ImGui::GetWindowFont()
|
||||
ImFont* ImGui::GetFont()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
return g.Font;
|
||||
return GImGui->Font;
|
||||
}
|
||||
|
||||
float ImGui::GetWindowFontSize()
|
||||
float ImGui::GetFontSize()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
return g.FontSize;
|
||||
return GImGui->FontSize;
|
||||
}
|
||||
|
||||
ImVec2 ImGui::GetFontTexUvWhitePixel()
|
||||
{
|
||||
return GImGui->FontTexUvWhitePixel;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowFontScale(float scale)
|
||||
@ -5625,7 +5641,7 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
|
||||
label = str_id;
|
||||
const bool label_hide_text_after_double_hash = (label == str_id); // Only search and hide text after ## if we have passed label and ID separately, otherwise allow "##" within format string.
|
||||
const ImGuiID id = window->GetID(str_id);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, label_hide_text_after_double_hash);
|
||||
const ImVec2 label_size = CalcTextSize(label, NULL, label_hide_text_after_double_hash);
|
||||
|
||||
// We vertically grow up to current line height up the typical widget height.
|
||||
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset - padding.y); // Latch before ItemSize changes it
|
||||
@ -5919,7 +5935,7 @@ static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const
|
||||
}
|
||||
|
||||
// User can input math operators (e.g. +100) to edit a numerical values.
|
||||
static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
|
||||
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
|
||||
{
|
||||
while (ImCharIsSpace(*buf))
|
||||
buf++;
|
||||
@ -5938,41 +5954,47 @@ static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
op = 0;
|
||||
}
|
||||
if (!buf[0])
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (data_type == ImGuiDataType_Int)
|
||||
{
|
||||
if (!scalar_format)
|
||||
scalar_format = "%d";
|
||||
int* v = (int*)data_ptr;
|
||||
int ref_v = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
|
||||
return;
|
||||
const int old_v = *v;
|
||||
int arg0 = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &arg0) < 1)
|
||||
return false;
|
||||
|
||||
// Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
|
||||
float op_v = 0.0f;
|
||||
if (op == '+') { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v + op_v); } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v * op_v); } // Multiply
|
||||
else if (op == '/') { if (sscanf(buf, "%f", &op_v) == 1 && op_v != 0.0f) *v = (int)(ref_v / op_v); }// Divide
|
||||
else { if (sscanf(buf, scalar_format, &ref_v) == 1) *v = ref_v; } // Assign constant
|
||||
float arg1 = 0.0f;
|
||||
if (op == '+') { if (sscanf(buf, "%f", &arg1) == 1) *v = (int)(arg0 + arg1); } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { if (sscanf(buf, "%f", &arg1) == 1) *v = (int)(arg0 * arg1); } // Multiply
|
||||
else if (op == '/') { if (sscanf(buf, "%f", &arg1) == 1 && arg1 != 0.0f) *v = (int)(arg0 / arg1); }// Divide
|
||||
else { if (sscanf(buf, scalar_format, &arg0) == 1) *v = arg0; } // Assign constant
|
||||
return (old_v != *v);
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
{
|
||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||
scalar_format = "%f";
|
||||
float* v = (float*)data_ptr;
|
||||
float ref_v = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
|
||||
return;
|
||||
float op_v = 0.0f;
|
||||
if (sscanf(buf, scalar_format, &op_v) < 1)
|
||||
return;
|
||||
const float old_v = *v;
|
||||
float arg0 = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &arg0) < 1)
|
||||
return false;
|
||||
|
||||
if (op == '+') { *v = ref_v + op_v; } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { *v = ref_v * op_v; } // Multiply
|
||||
else if (op == '/') { if (op_v != 0.0f) *v = ref_v / op_v; } // Divide
|
||||
else { *v = op_v; } // Assign constant
|
||||
float arg1 = 0.0f;
|
||||
if (sscanf(buf, scalar_format, &arg1) < 1)
|
||||
return false;
|
||||
if (op == '+') { *v = arg0 + arg1; } // Add (use "+-" to subtract)
|
||||
else if (op == '*') { *v = arg0 * arg1; } // Multiply
|
||||
else if (op == '/') { if (arg1 != 0.0f) *v = arg0 / arg1; } // Divide
|
||||
else { *v = arg1; } // Assign constant
|
||||
return (old_v != *v);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create text input in place of a slider (when CTRL+Clicking on slider)
|
||||
@ -5988,7 +6010,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
||||
|
||||
char buf[32];
|
||||
DataTypeFormatString(data_type, data_ptr, decimal_precision, buf, IM_ARRAYSIZE(buf));
|
||||
bool value_changed = InputTextEx(label, buf, IM_ARRAYSIZE(buf), aabb.GetSize(), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll);
|
||||
bool text_value_changed = InputTextEx(label, buf, IM_ARRAYSIZE(buf), aabb.GetSize(), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll);
|
||||
if (g.ScalarAsInputTextId == 0)
|
||||
{
|
||||
// First frame
|
||||
@ -6001,9 +6023,9 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
||||
// Release
|
||||
g.ScalarAsInputTextId = 0;
|
||||
}
|
||||
if (value_changed)
|
||||
DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, NULL);
|
||||
return value_changed;
|
||||
if (text_value_changed)
|
||||
return DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse display precision back from the display format string
|
||||
@ -6336,7 +6358,7 @@ bool ImGui::SliderFloatN(const char* label, float* v, int components, float v_mi
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6378,7 +6400,7 @@ bool ImGui::SliderIntN(const char* label, int* v, int components, int v_min, int
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6558,7 +6580,7 @@ bool ImGui::DragFloatN(const char* label, float* v, int components, float v_spee
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6597,7 +6619,7 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
ImGui::PopID();
|
||||
|
||||
@ -6636,7 +6658,7 @@ bool ImGui::DragIntN(const char* label, int* v, int components, float v_speed, i
|
||||
}
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -6675,7 +6697,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
ImGui::PopID();
|
||||
|
||||
@ -6853,7 +6875,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
||||
ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction*100+0.01f);
|
||||
overlay = overlay_buf;
|
||||
}
|
||||
|
||||
|
||||
ImVec2 overlay_size = CalcTextSize(overlay, NULL);
|
||||
if (overlay_size.x > 0.0f)
|
||||
RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImGuiAlign_Left|ImGuiAlign_VCenter, &bb.Min, &bb.Max);
|
||||
@ -6909,12 +6931,16 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
||||
|
||||
bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value)
|
||||
{
|
||||
bool v = (*flags & flags_value) ? true : false;
|
||||
bool v = ((*flags & flags_value) == flags_value);
|
||||
bool pressed = ImGui::Checkbox(label, &v);
|
||||
if (v)
|
||||
*flags |= flags_value;
|
||||
else
|
||||
*flags &= ~flags_value;
|
||||
if (pressed)
|
||||
{
|
||||
if (v)
|
||||
*flags |= flags_value;
|
||||
else
|
||||
*flags &= ~flags_value;
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@ -7749,7 +7775,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
|
||||
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
|
||||
if (is_editable)
|
||||
g.OsImePosRequest = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
|
||||
g.OsImePosRequest = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7821,10 +7847,7 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
|
||||
extra_flags |= ImGuiInputTextFlags_CharsDecimal;
|
||||
extra_flags |= ImGuiInputTextFlags_AutoSelectAll;
|
||||
if (ImGui::InputText("", buf, IM_ARRAYSIZE(buf), extra_flags))
|
||||
{
|
||||
DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, scalar_format);
|
||||
value_changed = true;
|
||||
}
|
||||
value_changed = DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, scalar_format);
|
||||
|
||||
// Step buttons
|
||||
if (step_ptr)
|
||||
@ -7895,7 +7918,7 @@ bool ImGui::InputFloatN(const char* label, float* v, int components, int decimal
|
||||
ImGui::PopID();
|
||||
|
||||
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -7938,7 +7961,7 @@ bool ImGui::InputIntN(const char* label, int* v, int components, ImGuiInputTextF
|
||||
ImGui::PopID();
|
||||
|
||||
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
|
||||
ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
||||
ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
|
||||
ImGui::EndGroup();
|
||||
|
||||
return value_changed;
|
||||
@ -8029,10 +8052,12 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
|
||||
const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
bool popup_opened = IsPopupOpen(id);
|
||||
bool popup_opened_now = false;
|
||||
|
||||
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
||||
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_opened || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
||||
RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);
|
||||
|
||||
if (*current_item >= 0 && *current_item < items_count)
|
||||
@ -8045,7 +8070,6 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
if (label_size.x > 0)
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
||||
bool menu_toggled = false;
|
||||
if (hovered)
|
||||
{
|
||||
SetHoveredID(id);
|
||||
@ -8059,8 +8083,8 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
else
|
||||
{
|
||||
FocusWindow(window);
|
||||
ImGui::OpenPopup(label);
|
||||
menu_toggled = true;
|
||||
OpenPopup(label);
|
||||
popup_opened = popup_opened_now = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8073,8 +8097,15 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
height_in_items = 7;
|
||||
|
||||
float popup_height = (label_size.y + style.ItemSpacing.y) * ImMin(items_count, height_in_items) + (style.FramePadding.y * 3);
|
||||
ImRect popup_rect(ImVec2(frame_bb.Min.x, frame_bb.Max.y), ImVec2(frame_bb.Max.x, frame_bb.Max.y + popup_height));
|
||||
popup_rect.Max.y = ImMin(popup_rect.Max.y, g.IO.DisplaySize.y - style.DisplaySafeAreaPadding.y); // Adhoc height limit for Combo. Ideally should be handled in Begin() along with other popups size, we want to have the possibility of moving the popup above as well.
|
||||
float popup_y1 = frame_bb.Max.y;
|
||||
float popup_y2 = ImClamp(popup_y1 + popup_height, popup_y1, g.IO.DisplaySize.y - style.DisplaySafeAreaPadding.y);
|
||||
if ((popup_y2 - popup_y1) < ImMin(popup_height, frame_bb.Min.y - style.DisplaySafeAreaPadding.y))
|
||||
{
|
||||
// Position our combo ABOVE because there's more space to fit! (FIXME: Handle in Begin() or use a shared helper. We have similar code in Begin() for popup placement)
|
||||
popup_y1 = ImClamp(frame_bb.Min.y - popup_height, style.DisplaySafeAreaPadding.y, frame_bb.Min.y);
|
||||
popup_y2 = frame_bb.Min.y;
|
||||
}
|
||||
ImRect popup_rect(ImVec2(frame_bb.Min.x, popup_y1), ImVec2(frame_bb.Max.x, popup_y2));
|
||||
ImGui::SetNextWindowPos(popup_rect.Min);
|
||||
ImGui::SetNextWindowSize(popup_rect.GetSize());
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
||||
@ -8097,7 +8128,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
value_changed = true;
|
||||
*current_item = i;
|
||||
}
|
||||
if (item_selected && menu_toggled)
|
||||
if (item_selected && popup_opened_now)
|
||||
ImGui::SetScrollHere();
|
||||
ImGui::PopID();
|
||||
}
|
||||
@ -8636,7 +8667,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
|
||||
const ImVec4 col_display(col[0], col[1], col[2], 1.0f);
|
||||
if (ImGui::ColorButton(col_display))
|
||||
g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!
|
||||
|
||||
|
||||
// Recreate our own tooltip over's ColorButton() one because we want to display correct alpha here
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Color:\n(%.2f,%.2f,%.2f,%.2f)\n#%02X%02X%02X%02X", col[0], col[1], col[2], col[3], IM_F32_TO_INT8(col[0]), IM_F32_TO_INT8(col[1]), IM_F32_TO_INT8(col[2]), IM_F32_TO_INT8(col[3]));
|
||||
@ -8649,7 +8680,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
|
||||
g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!
|
||||
}
|
||||
|
||||
const char* label_display_end = FindTextDisplayEnd(label);
|
||||
const char* label_display_end = FindRenderedTextEnd(label);
|
||||
if (label != label_display_end)
|
||||
{
|
||||
ImGui::SameLine(0, (window->DC.ColorEditMode == ImGuiColorEditMode_UserSelectShowButton) ? -1.0f : style.ItemInnerSpacing.x);
|
||||
@ -8733,7 +8764,7 @@ void ImGui::Dummy(const ImVec2& size)
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
ItemSize(bb);
|
||||
ItemAdd(bb, NULL);
|
||||
@ -8798,33 +8829,31 @@ void ImGui::EndGroup()
|
||||
}
|
||||
|
||||
// Gets back to previous line and continue with horizontal layout
|
||||
// local_pos_x == 0 : follow on previous item
|
||||
// local_pos_x != 0 : align to specified column
|
||||
// pos_x == 0 : follow on previous item
|
||||
// pos_x != 0 : align to specified column
|
||||
// spacing_w < 0 : use default spacing if column_x==0, no spacing if column_x!=0
|
||||
// spacing_w >= 0 : enforce spacing
|
||||
void ImGui::SameLine(float local_pos_x, float spacing_w)
|
||||
void ImGui::SameLine(float pos_x, float spacing_w)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiState& g = *GImGui;
|
||||
float x, y;
|
||||
if (local_pos_x != 0.0f)
|
||||
if (pos_x != 0.0f)
|
||||
{
|
||||
if (spacing_w < 0.0f) spacing_w = 0.0f;
|
||||
x = window->Pos.x - window->Scroll.x + local_pos_x + spacing_w;
|
||||
y = window->DC.CursorPosPrevLine.y;
|
||||
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + pos_x + spacing_w;
|
||||
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x;
|
||||
x = window->DC.CursorPosPrevLine.x + spacing_w;
|
||||
y = window->DC.CursorPosPrevLine.y;
|
||||
window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w;
|
||||
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
||||
}
|
||||
window->DC.CurrentLineHeight = window->DC.PrevLineHeight;
|
||||
window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset;
|
||||
window->DC.CursorPos = ImVec2(x, y);
|
||||
}
|
||||
|
||||
void ImGui::NextColumn()
|
||||
@ -8997,9 +9026,9 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
}
|
||||
}
|
||||
|
||||
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
|
||||
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
|
||||
// In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer.
|
||||
ImGui::PushID(0x11223347 + (id ? 0 : columns_count));
|
||||
ImGui::PushID(0x11223347 + (id ? 0 : columns_count));
|
||||
window->DC.ColumnsSetID = window->GetID(id ? id : "columns");
|
||||
ImGui::PopID();
|
||||
|
||||
@ -9264,10 +9293,14 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored(ImColor(255,100,100), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
|
||||
if (node_opened) ImGui::TreePop();
|
||||
return;
|
||||
}
|
||||
if (!node_opened)
|
||||
return;
|
||||
|
||||
ImDrawList* overlay_draw_list = &GImGui->OverlayDrawList; // Render additional visuals into the top-most draw list
|
||||
overlay_draw_list->PushClipRectFullScreen();
|
||||
int elem_offset = 0;
|
||||
for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
|
||||
{
|
||||
@ -9276,7 +9309,7 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
|
||||
continue;
|
||||
}
|
||||
ImGui::BulletText("Draw %-4d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
|
||||
bool draw_opened = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "Draw %-4d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
|
||||
if (show_clip_rects && ImGui::IsItemHovered())
|
||||
{
|
||||
ImRect clip_rect = pcmd->ClipRect;
|
||||
@ -9284,12 +9317,28 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
|
||||
for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
|
||||
vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
|
||||
GImGui->OverlayDrawList.PushClipRectFullScreen();
|
||||
clip_rect.Round(); GImGui->OverlayDrawList.AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
|
||||
vtxs_rect.Round(); GImGui->OverlayDrawList.AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
|
||||
GImGui->OverlayDrawList.PopClipRect();
|
||||
clip_rect.Round(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
|
||||
vtxs_rect.Round(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
|
||||
}
|
||||
if (!draw_opened)
|
||||
continue;
|
||||
for (int i = elem_offset; i+2 < elem_offset + (int)pcmd->ElemCount; i += 3)
|
||||
{
|
||||
ImVec2 triangles_pos[3];
|
||||
char buf[300], *buf_p = buf;
|
||||
for (int n = 0; n < 3; n++)
|
||||
{
|
||||
ImDrawVert& v = draw_list->VtxBuffer[(draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data[i+n] : i+n];
|
||||
triangles_pos[n] = v.pos;
|
||||
buf_p += sprintf(buf_p, "vtx %04d { pos = (%8.2f,%8.2f), uv = (%.6f,%.6f), col = %08X }\n", i+n, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col);
|
||||
}
|
||||
ImGui::Selectable(buf, false);
|
||||
if (ImGui::IsItemHovered())
|
||||
overlay_draw_list->AddPolyline(triangles_pos, 3, ImColor(255,255,0), true, 1.0f, false); // Add triangle without AA, more readable for large-thin triangle
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
overlay_draw_list->PopClipRect();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
64
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
64
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
@ -58,7 +58,7 @@ struct ImGuiListClipper; // Helper to manually clip large list of ite
|
||||
// Enumerations (declared as int for compatibility and to not pollute the top of this file)
|
||||
typedef unsigned int ImU32;
|
||||
typedef unsigned short ImWchar; // character for keyboard input/display
|
||||
typedef void* ImTextureID; // user data to refer to a texture (e.g. store your texture handle/id)
|
||||
typedef void* ImTextureID; // user data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
|
||||
typedef ImU32 ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
|
||||
typedef int ImGuiCol; // a color identifier for styling // enum ImGuiCol_
|
||||
typedef int ImGuiStyleVar; // a variable identifier for styling // enum ImGuiStyleVar_
|
||||
@ -103,14 +103,15 @@ namespace ImGui
|
||||
// Main
|
||||
IMGUI_API ImGuiIO& GetIO();
|
||||
IMGUI_API ImGuiStyle& GetStyle();
|
||||
IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
|
||||
IMGUI_API void NewFrame();
|
||||
IMGUI_API void Render();
|
||||
IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
|
||||
IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until NewFrame()/Render().
|
||||
IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render()!
|
||||
IMGUI_API void Render(); // ends the ImGui frame, finalize rendering data, then call your io.RenderDrawListsFn() function if set.
|
||||
IMGUI_API void Shutdown();
|
||||
IMGUI_API void ShowUserGuide(); // help block
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block
|
||||
IMGUI_API void ShowTestWindow(bool* opened = NULL); // test window, demonstrate ImGui features
|
||||
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging imgui
|
||||
IMGUI_API void ShowTestWindow(bool* opened = NULL); // test window demonstrating ImGui features
|
||||
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging ImGui
|
||||
|
||||
// Window
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||
@ -124,22 +125,20 @@ namespace ImGui
|
||||
IMGUI_API float GetContentRegionAvailWidth(); //
|
||||
IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates
|
||||
IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
|
||||
IMGUI_API float GetWindowContentRegionWidth(); //
|
||||
IMGUI_API float GetWindowContentRegionWidth(); //
|
||||
IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
|
||||
IMGUI_API ImFont* GetWindowFont();
|
||||
IMGUI_API float GetWindowFontSize(); // size (also height in pixels) of current font with current scale applied
|
||||
IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows
|
||||
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api)
|
||||
IMGUI_API ImVec2 GetWindowSize(); // get current window size
|
||||
IMGUI_API float GetWindowWidth();
|
||||
IMGUI_API float GetWindowHeight();
|
||||
IMGUI_API bool IsWindowCollapsed();
|
||||
IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows
|
||||
|
||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set next window position. call before Begin()
|
||||
IMGUI_API void SetNextWindowPosCenter(ImGuiSetCond cond = 0); // set next window position to be centered on screen. call before Begin()
|
||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
||||
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (enforce the range of scrollbars). set axis to 0.0f to leave it automatic. call before Begin()
|
||||
IMGUI_API void SetNextWindowContentWidth(float width); // set next window content width (enforce the range of horizontal scrollbar). call before Begin()
|
||||
IMGUI_API void SetNextWindowContentWidth(float width); // set next window content width (enforce the range of horizontal scrollbar). call before Begin()
|
||||
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set next window collapsed state. call before Begin()
|
||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin()
|
||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set current window position - call within Begin()/End(). may incur tearing
|
||||
@ -171,6 +170,9 @@ namespace ImGui
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
|
||||
IMGUI_API void PopStyleVar(int count = 1);
|
||||
IMGUI_API ImFont* GetFont(); // get current font
|
||||
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
|
||||
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
||||
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier
|
||||
IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied
|
||||
|
||||
@ -189,18 +191,11 @@ namespace ImGui
|
||||
IMGUI_API void BeginGroup(); // lock horizontal starting position. once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc.
|
||||
IMGUI_API void EndGroup();
|
||||
IMGUI_API void Separator(); // horizontal line
|
||||
IMGUI_API void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void Spacing(); // add spacing
|
||||
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
|
||||
IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
|
||||
IMGUI_API void Unindent(); // move content position back to the left (cancel Indent)
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); // setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1).
|
||||
IMGUI_API void NextColumn(); // next column
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this
|
||||
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
||||
IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset())
|
||||
IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns())
|
||||
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
|
||||
IMGUI_API float GetCursorPosX(); // "
|
||||
IMGUI_API float GetCursorPosY(); // "
|
||||
@ -215,6 +210,16 @@ namespace ImGui
|
||||
IMGUI_API float GetTextLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
|
||||
IMGUI_API float GetItemsLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y
|
||||
|
||||
// Columns
|
||||
// You can also use SameLine(pos_x) for simplified columning. The columns API is still work-in-progress.
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); // setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1).
|
||||
IMGUI_API void NextColumn(); // next column
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this
|
||||
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
||||
IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset())
|
||||
IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns())
|
||||
|
||||
// ID scopes
|
||||
// If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
|
||||
// You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details.
|
||||
@ -330,7 +335,7 @@ namespace ImGui
|
||||
IMGUI_API void ValueColor(const char* prefix, const ImVec4& v);
|
||||
IMGUI_API void ValueColor(const char* prefix, unsigned int v);
|
||||
|
||||
// Tooltip
|
||||
// Tooltips
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
|
||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args);
|
||||
IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text
|
||||
@ -346,8 +351,8 @@ namespace ImGui
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
|
||||
|
||||
// Popup
|
||||
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
// Popups
|
||||
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
IMGUI_API bool BeginPopup(const char* str_id); // return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true!
|
||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_opened = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (can't close them by clicking outside)
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // helper to open and begin popup when clicked on last item. read comments in .cpp!
|
||||
@ -407,7 +412,7 @@ namespace ImGui
|
||||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||
IMGUI_API bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window). disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup)
|
||||
IMGUI_API bool IsMouseHoveringAnyWindow(); // is mouse hovering any visible window
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into
|
||||
@ -432,6 +437,8 @@ namespace ImGui
|
||||
|
||||
// Obsolete (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
|
||||
static inline float GetWindowFontSize() { return GetFontSize(); } // OBSOLETE 1.48+
|
||||
static inline void OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpened(open, 0); } // OBSOLETE 1.34+
|
||||
static inline bool GetWindowIsFocused() { return ImGui::IsWindowFocused(); } // OBSOLETE 1.36+
|
||||
static inline bool GetWindowCollapsed() { return ImGui::IsWindowCollapsed(); } // OBSOLETE 1.39+
|
||||
@ -707,7 +714,7 @@ struct ImGuiIO
|
||||
// User Functions
|
||||
//------------------------------------------------------------------
|
||||
|
||||
// Rendering function, will be called in Render().
|
||||
// Rendering function, will be called in Render().
|
||||
// Alternatively you can keep this to NULL and call GetDrawData() after Render() to get the same pointer.
|
||||
// See example applications if you are unsure of how to implement this.
|
||||
void (*RenderDrawListsFn)(ImDrawData* data);
|
||||
@ -1124,11 +1131,12 @@ struct ImDrawList
|
||||
|
||||
// Primitives
|
||||
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
|
||||
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F, float thickness = 1.0f); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
|
||||
IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
|
||||
IMGUI_API void AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness = 1.0f);
|
||||
IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
|
||||
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
||||
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
|
||||
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
||||
@ -1258,7 +1266,7 @@ struct ImFontAtlas
|
||||
int TexWidth; // Texture width calculated during Build().
|
||||
int TexHeight; // Texture height calculated during Build().
|
||||
int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
|
||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block)
|
||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
|
||||
ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
|
||||
|
||||
// Private
|
||||
|
@ -443,7 +443,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
||||
|
||||
ImGui::Text("Password input");
|
||||
static char bufpass[64] = "password123";
|
||||
static char bufpass[64] = "password123";
|
||||
ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
||||
ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
||||
ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
|
||||
@ -454,7 +454,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
if (ImGui::TreeNode("Multi-line Text Input"))
|
||||
{
|
||||
static bool read_only = false;
|
||||
static char text[1024*16] =
|
||||
static char text[1024*16] =
|
||||
"/*\n"
|
||||
" The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
|
||||
" the hexadecimal encoding of one offending instruction,\n"
|
||||
@ -816,7 +816,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
if (ImGui::TreeNode("Widgets Width"))
|
||||
{
|
||||
static float f = 0.0f;
|
||||
ImGui::Text("PushItemWidth(100)");
|
||||
ImGui::Text("PushItemWidth(100)");
|
||||
ImGui::SameLine(); ShowHelpMarker("Fixed width.");
|
||||
ImGui::PushItemWidth(100);
|
||||
ImGui::DragFloat("float##1", &f);
|
||||
@ -996,8 +996,8 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
|
||||
// Tree
|
||||
const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
ImGui::Button("Button##1");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::Button("Button##1");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
|
||||
@ -1006,8 +1006,8 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
if (tree_opened) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
|
||||
// Bullet
|
||||
ImGui::Button("Button##3");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::Button("Button##3");
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::BulletText("Bullet text");
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
@ -1086,7 +1086,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::PopStyleVar(2);
|
||||
float scroll_x_delta = 0.0f;
|
||||
ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f;
|
||||
ImGui::SameLine(); ImGui::Text("Scroll from code"); ImGui::SameLine();
|
||||
ImGui::SameLine(); ImGui::Text("Scroll from code"); ImGui::SameLine();
|
||||
ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f;
|
||||
if (scroll_x_delta != 0.0f)
|
||||
{
|
||||
@ -1108,7 +1108,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::InvisibleButton("##dummy", size);
|
||||
if (ImGui::IsItemActive() && ImGui::IsMouseDragging()) { offset.x += ImGui::GetIO().MouseDelta.x; offset.y += ImGui::GetIO().MouseDelta.y; }
|
||||
ImGui::GetWindowDrawList()->AddRectFilled(pos, ImVec2(pos.x+size.x,pos.y+size.y), ImColor(90,90,120,255));
|
||||
ImGui::GetWindowDrawList()->AddText(ImGui::GetWindowFont(), ImGui::GetWindowFontSize()*2.0f, ImVec2(pos.x+offset.x,pos.y+offset.y), ImColor(255,255,255,255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
|
||||
ImGui::GetWindowDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize()*2.0f, ImVec2(pos.x+offset.x,pos.y+offset.y), ImColor(255,255,255,255), "Line 1 hello\nLine 2 clip me!", NULL, 0.0f, &clip_rect);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
@ -1181,7 +1181,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
|
||||
ImGui::Separator();
|
||||
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
|
||||
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
|
||||
// To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
|
||||
// would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
|
||||
ImGui::PushID("foo");
|
||||
@ -1396,7 +1396,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::SameLine(); ShowHelpMarker("NB: Tree node must be poped before ending the cell.\nThere's no storage of state per-cell.");
|
||||
if (node_opened)
|
||||
{
|
||||
ImGui::Columns(2, "tree items");
|
||||
ImGui::Columns(2, "tree items");
|
||||
ImGui::Separator();
|
||||
if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
|
||||
if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
|
||||
@ -1513,7 +1513,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
ImGui::Button("Holding me clears the\nthe keyboard capture flag");
|
||||
if (ImGui::IsItemActive())
|
||||
ImGui::CaptureKeyboardFromApp(false);
|
||||
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
@ -1798,30 +1798,32 @@ static void ShowExampleAppCustomRendering(bool* opened)
|
||||
ImGui::Text("Primitives");
|
||||
static float sz = 36.0f;
|
||||
static ImVec4 col = ImVec4(1.0f,1.0f,0.4f,1.0f);
|
||||
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
||||
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
||||
ImGui::ColorEdit3("Color", &col.x);
|
||||
{
|
||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
const ImU32 col32 = ImColor(col);
|
||||
float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
|
||||
draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32); x += spacing;
|
||||
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, 1.0f);
|
||||
x = p.x + 4;
|
||||
y += sz+spacing;
|
||||
for (int n = 0; n < 2; n++)
|
||||
{
|
||||
float thickness = (n == 0) ? 1.0f : 4.0f;
|
||||
draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, thickness); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ~0, thickness); x += sz+spacing;
|
||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ~0, thickness); x += sz+spacing;
|
||||
draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, thickness); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, thickness); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, thickness); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, thickness); x += spacing;
|
||||
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, thickness);
|
||||
x = p.x + 4;
|
||||
y += sz+spacing;
|
||||
}
|
||||
draw_list->AddCircleFilled(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 32); x += sz+spacing;
|
||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32); x += sz+spacing;
|
||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, 4.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 4.0f); x += sz+spacing;
|
||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, 4.0f); x += spacing;
|
||||
draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, 4.0f); x += sz+spacing;
|
||||
draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing;
|
||||
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), ImColor(0,0,0), ImColor(255,0,0), ImColor(255,255,0), ImColor(0,255,0));
|
||||
ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*2));
|
||||
ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
|
||||
}
|
||||
ImGui::Separator();
|
||||
{
|
||||
@ -2303,7 +2305,7 @@ static void ShowExampleAppPropertyEditor(bool* p_opened)
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::Text("my sailor is rich");
|
||||
ImGui::NextColumn();
|
||||
if (opened)
|
||||
if (opened)
|
||||
{
|
||||
static float dummy_members[8] = { 0.0f,0.0f,1.0f,3.1416f,100.0f,999.0f };
|
||||
for (int i = 0; i < 8; i++)
|
||||
@ -2336,7 +2338,7 @@ static void ShowExampleAppPropertyEditor(bool* p_opened)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Iterate dummy objects with dummy members (all the same data)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "imgui_internal.h"
|
||||
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#if !defined(alloca) && !defined(__FreeBSD__)
|
||||
#if !defined(alloca) && !defined(__FreeBSD__) && !defined(__DragonFly__)
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h> // alloca
|
||||
#else
|
||||
@ -203,7 +203,7 @@ void ImDrawList::UpdateTextureID()
|
||||
AddDrawCmd();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Try to merge with previous command if it matches, else use current command
|
||||
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
|
||||
if (prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL)
|
||||
@ -704,11 +704,11 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
||||
{
|
||||
float dx = x4 - x1;
|
||||
float dy = y4 - y1;
|
||||
float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
|
||||
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||
float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
|
||||
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||
d2 = (d2 >= 0) ? d2 : -d2;
|
||||
d3 = (d3 >= 0) ? d3 : -d3;
|
||||
if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
||||
if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
||||
{
|
||||
path->push_back(ImVec2(x4, y4));
|
||||
}
|
||||
@ -721,8 +721,8 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
||||
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
||||
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
||||
|
||||
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
||||
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
||||
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
||||
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -786,12 +786,12 @@ void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thic
|
||||
}
|
||||
|
||||
// a: upper-left, b: lower-right. we don't render 1 px sized rectangles properly.
|
||||
void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners)
|
||||
void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners, float thickness)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.5f,0.5f), rounding, rounding_corners);
|
||||
PathStroke(col, true);
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners)
|
||||
@ -825,6 +825,17 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32
|
||||
PrimWriteVtx(ImVec2(a.x, c.y), uv, col_bot_left);
|
||||
}
|
||||
|
||||
void ImDrawList::AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
PathLineTo(a);
|
||||
PathLineTo(b);
|
||||
PathLineTo(c);
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
@ -836,14 +847,14 @@ void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec
|
||||
PathFill(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments)
|
||||
void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments, float thickness)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||
PathArcTo(centre, radius-0.5f, 0.0f, a_max, num_segments);
|
||||
PathStroke(col, true);
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments)
|
||||
@ -856,14 +867,14 @@ void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col,
|
||||
PathFill(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
||||
{
|
||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
PathLineTo(pos0);
|
||||
PathBezierCurveTo(cp0, cp1, pos1, num_segments);
|
||||
PathStroke(col, false, thickness);
|
||||
PathLineTo(pos0);
|
||||
PathBezierCurveTo(cp0, cp1, pos1, num_segments);
|
||||
PathStroke(col, false, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||
@ -876,6 +887,13 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||
if (text_begin == text_end)
|
||||
return;
|
||||
|
||||
// Note: This is one of the few instance of breaking the encapsulation of ImDrawList, as we pull this from ImGui state, but it is just SO useful.
|
||||
// Might just move Font/FontSize to ImDrawList?
|
||||
if (font == NULL)
|
||||
font = GImGui->Font;
|
||||
if (font_size == 0.0f)
|
||||
font_size = GImGui->FontSize;
|
||||
|
||||
IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
|
||||
|
||||
// reserve vertices for worse case (over-reserving is useful and easily amortized)
|
||||
@ -908,12 +926,8 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||
_VtxCurrentIdx = (unsigned int)VtxBuffer.Size;
|
||||
}
|
||||
|
||||
// This is one of the few function breaking the encapsulation of ImDrawLst, but it is just so useful.
|
||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
AddText(GImGui->Font, GImGui->FontSize, pos, col, text_begin, text_end);
|
||||
}
|
||||
|
||||
@ -1123,7 +1137,7 @@ static unsigned int stb_decompress_length(unsigned char *input);
|
||||
static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length);
|
||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
{
|
||||
while (*src)
|
||||
{
|
||||
@ -1994,10 +2008,10 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
|
||||
{
|
||||
char_width = glyph->XAdvance * scale;
|
||||
|
||||
// Clipping on Y is more likely
|
||||
// Arbitrarily assume that both space and tabs are empty glyphs as an optimization
|
||||
if (c != ' ' && c != '\t')
|
||||
{
|
||||
// We don't do a second finer clipping test on the Y axis (TODO: do some measurement see if it is worth it, probably not)
|
||||
// We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
|
||||
float y1 = (float)(y + glyph->Y0 * scale);
|
||||
float y2 = (float)(y + glyph->Y1 * scale);
|
||||
|
||||
@ -2041,8 +2055,8 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
|
||||
}
|
||||
}
|
||||
|
||||
// NB: we are not calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
|
||||
// inlined:
|
||||
// We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
|
||||
// Inlined here:
|
||||
{
|
||||
idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
|
||||
idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
|
||||
|
@ -356,7 +356,7 @@ struct ImGuiState
|
||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
|
||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
|
||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvForWhite
|
||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvWhitePixel
|
||||
|
||||
float Time;
|
||||
int FrameCount;
|
||||
@ -683,8 +683,6 @@ namespace ImGui
|
||||
IMGUI_API void SetHoveredID(ImGuiID id);
|
||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||
|
||||
IMGUI_API void EndFrame(); // Automatically called by Render()
|
||||
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
||||
@ -708,6 +706,7 @@ namespace ImGui
|
||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||
IMGUI_API void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||
|
||||
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_existing_clip_rect = true);
|
||||
IMGUI_API void PopClipRect();
|
||||
|
6
3rdparty/bgfx/CONTRUBUTING.md
vendored
6
3rdparty/bgfx/CONTRUBUTING.md
vendored
@ -4,6 +4,12 @@ Everyone is welcome to contribute to bgfx by submitting bug reports, testing on
|
||||
different platforms, writing examples, improving documentation, profiling and
|
||||
optimizing, helping newcomers, telling others about bgfx, etc.
|
||||
|
||||
## Submitting bugs
|
||||
|
||||
Unless bug is trivial, and easy to explain and understand, the fastest way to
|
||||
fix bug is to get repro case. In most of cases it's enough to modify existing
|
||||
example (with minimal number of changes) and reproduce bug there.
|
||||
|
||||
## Contributing code
|
||||
|
||||
**When contributing to the bgfx project you must agree to the BSD 2-clause
|
||||
|
8
3rdparty/bgfx/README.md
vendored
8
3rdparty/bgfx/README.md
vendored
@ -21,6 +21,7 @@ Supported rendering backends:
|
||||
* OpenGL ES 2
|
||||
* OpenGL ES 3.1
|
||||
* WebGL 1.0
|
||||
* WebGL 2.0
|
||||
|
||||
Supported HMD:
|
||||
|
||||
@ -128,6 +129,13 @@ http://makingartstudios.itch.io/dls - DLS the digital logic simulator game.
|
||||

|
||||
|
||||
https://github.com/mamedev/mame MAME - Multiple Arcade Machine Emulator
|
||||
[Try MAME in Browser!](http://fos.textfiles.com/dfjustin/pacman/pacman/)
|
||||

|
||||
|
||||
https://blackshift.itch.io/blackshift - Blackshift is a grid-based, space-themed
|
||||
action puzzle game which isn't afraid of complexity — think Chip's Challenge on
|
||||
crack.
|
||||

|
||||
|
||||
[License (BSD 2-clause)](https://bkaradzic.github.io/bgfx/license.html)
|
||||
-----------------------------------------------------------------------
|
||||
|
189
3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
vendored
189
3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
vendored
@ -7,6 +7,7 @@
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
#include "logo.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
class ExampleHelloWorld : public entry::AppI
|
||||
{
|
||||
@ -28,23 +29,111 @@ class ExampleHelloWorld : public entry::AppI
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 0x000000ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
imguiCreate();
|
||||
ImGui::GetIO().FontGlobalScale = 1.5;
|
||||
}
|
||||
|
||||
virtual int shutdown() BX_OVERRIDE
|
||||
{
|
||||
// Cleanup.
|
||||
imguiDestroy();
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void displayMainMenu()
|
||||
{
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Left"))
|
||||
{
|
||||
if (ImGui::MenuItem("Brief", "CTRL+1")) {}
|
||||
if (ImGui::MenuItem("Medium", "CTRL+2")) {}
|
||||
if (ImGui::MenuItem("Two columns", "CTRL+3")) {}
|
||||
if (ImGui::MenuItem("Full (name)", "CTRL+4")) {}
|
||||
if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {}
|
||||
if (ImGui::MenuItem("Full (access)", "CTRL+6")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("Sort mode"))
|
||||
{
|
||||
ImGui::MenuItem("Name");
|
||||
ImGui::MenuItem("Extension");
|
||||
ImGui::MenuItem("Modif. Time");
|
||||
ImGui::MenuItem("Size");
|
||||
ImGui::MenuItem("Unsorted");
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::MenuItem("Change source")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Files"))
|
||||
{
|
||||
if (ImGui::MenuItem("User menu", "F2")) {}
|
||||
if (ImGui::MenuItem("View", "F3")) {}
|
||||
if (ImGui::MenuItem("Edit", "F4")) {}
|
||||
if (ImGui::MenuItem("Copy", "F5")) {}
|
||||
if (ImGui::MenuItem("Rename or move", "F6")) {}
|
||||
if (ImGui::MenuItem("Make directory", "F7")) {}
|
||||
if (ImGui::MenuItem("Delete", "F8")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("File attributes", "CTRL+A")) {}
|
||||
if (ImGui::MenuItem("Apply command", "CTRL+G")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Select group")) {}
|
||||
if (ImGui::MenuItem("Unselect group")) {}
|
||||
if (ImGui::MenuItem("Invert selection")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Commands"))
|
||||
{
|
||||
if (ImGui::MenuItem("Find file", "ALT+F7")) {}
|
||||
if (ImGui::MenuItem("History", "ALT+F8")) {}
|
||||
if (ImGui::MenuItem("Maximize window", "ALT+F9")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Panel on/off", "CTRL+O")) {}
|
||||
if (ImGui::MenuItem("Equal panels", "CTRL+=")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
if (ImGui::MenuItem("Settings")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Right"))
|
||||
{
|
||||
if (ImGui::MenuItem("Brief", "CTRL+1")) {}
|
||||
if (ImGui::MenuItem("Medium", "CTRL+2")) {}
|
||||
if (ImGui::MenuItem("Two columns", "CTRL+3")) {}
|
||||
if (ImGui::MenuItem("Full (name)", "CTRL+4")) {}
|
||||
if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {}
|
||||
if (ImGui::MenuItem("Full (access)", "CTRL+6")) {}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("Sort mode"))
|
||||
{
|
||||
ImGui::MenuItem("Name");
|
||||
ImGui::MenuItem("Extension");
|
||||
ImGui::MenuItem("Modif. Time");
|
||||
ImGui::MenuItem("Size");
|
||||
ImGui::MenuItem("Unsorted");
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::MenuItem("Change source")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
bool update() BX_OVERRIDE
|
||||
{
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
@ -53,18 +142,91 @@ class ExampleHelloWorld : public entry::AppI
|
||||
// if no other draw calls are submitted to view 0.
|
||||
bgfx::touch(0);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextImage(bx::uint16_max(m_width /2/8, 20)-20
|
||||
, bx::uint16_max(m_height/2/16, 6)-6
|
||||
, 40
|
||||
, 12
|
||||
, s_logo
|
||||
, 160
|
||||
);
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
|
||||
imguiBeginFrame(m_mouseState.m_mx
|
||||
, m_mouseState.m_my
|
||||
, (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
|
||||
| (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
|
||||
, m_mouseState.m_mz
|
||||
, m_width
|
||||
, m_height
|
||||
);
|
||||
displayMainMenu();
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 32));
|
||||
ImGui::SetNextWindowSize(ImVec2(m_width/2, m_height - 32));
|
||||
if (ImGui::Begin("Window1", nullptr, ImVec2(m_width/2, m_height-32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f);
|
||||
ImGui::BeginChild("Sub1", ImVec2(0, m_height - 48), true);
|
||||
|
||||
|
||||
ImGui::Columns(4, "mycolumns");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("ID"); ImGui::NextColumn();
|
||||
ImGui::Text("Name"); ImGui::NextColumn();
|
||||
ImGui::Text("Path"); ImGui::NextColumn();
|
||||
ImGui::Text("Flags"); ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
const char* names[3] = { "One", "Two", "Three" };
|
||||
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
||||
static int selected = -1;
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
char label[32];
|
||||
sprintf(label, "%04d", i);
|
||||
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(names[i%3]); ImGui::NextColumn();
|
||||
ImGui::Text(paths[i % 3]); ImGui::NextColumn();
|
||||
ImGui::Text("...."); ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextWindowPos(ImVec2(m_width / 2, 32));
|
||||
ImGui::SetNextWindowSize(ImVec2(m_width / 2, m_height - 32));
|
||||
if (ImGui::Begin("Window2", nullptr, ImVec2(m_width/2, m_height - 32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f);
|
||||
ImGui::BeginChild("Sub2", ImVec2(0, m_height - 48), true);
|
||||
|
||||
ImGui::Columns(4, "mycolumns");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("ID"); ImGui::NextColumn();
|
||||
ImGui::Text("Name"); ImGui::NextColumn();
|
||||
ImGui::Text("Path"); ImGui::NextColumn();
|
||||
ImGui::Text("Flags"); ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
const char* names[3] = { "One", "Two", "Three" };
|
||||
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
||||
static int selected = -1;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
char label[32];
|
||||
sprintf(label, "%04d", i);
|
||||
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(names[i]); ImGui::NextColumn();
|
||||
ImGui::Text(paths[i]); ImGui::NextColumn();
|
||||
ImGui::Text("...."); ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::End();
|
||||
imguiEndFrame();
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
@ -79,6 +241,7 @@ class ExampleHelloWorld : public entry::AppI
|
||||
uint32_t m_height;
|
||||
uint32_t m_debug;
|
||||
uint32_t m_reset;
|
||||
entry::MouseState m_mouseState;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld);
|
||||
|
200
3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
vendored
Normal file
200
3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp
vendored
Normal file
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
#include <entry/cmd.h>
|
||||
#include <entry/input.h>
|
||||
#include "camera.h"
|
||||
|
||||
#include <bx/uint32_t.h>
|
||||
|
||||
#include "../common/debugdraw/debugdraw.h"
|
||||
|
||||
class DebugDrawApp : public entry::AppI
|
||||
{
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
m_width = 1280;
|
||||
m_height = 720;
|
||||
m_debug = BGFX_DEBUG_TEXT;
|
||||
m_reset = BGFX_RESET_VSYNC | BGFX_RESET_MSAA_X16;
|
||||
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(m_width, m_height, m_reset);
|
||||
|
||||
// Enable m_debug text.
|
||||
bgfx::setDebug(m_debug);
|
||||
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
m_timeOffset = bx::getHPCounter();
|
||||
|
||||
cameraCreate();
|
||||
|
||||
const float initialPos[3] = { 0.0f, 2.0f, -12.0f };
|
||||
cameraSetPosition(initialPos);
|
||||
cameraSetVerticalAngle(0.0f);
|
||||
|
||||
ddInit();
|
||||
}
|
||||
|
||||
virtual int shutdown() BX_OVERRIDE
|
||||
{
|
||||
ddShutdown();
|
||||
|
||||
cameraDestroy();
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool update() BX_OVERRIDE
|
||||
{
|
||||
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
|
||||
{
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, m_width, m_height);
|
||||
|
||||
int64_t now = bx::getHPCounter() - m_timeOffset;
|
||||
static int64_t last = now;
|
||||
const int64_t frameTime = now - last;
|
||||
last = now;
|
||||
const double freq = double(bx::getHPFrequency() );
|
||||
const double toMs = 1000.0/freq;
|
||||
const float deltaTime = float(frameTime/freq);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/29-debugdraw");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Debug draw.");
|
||||
bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
// Update camera.
|
||||
cameraUpdate(deltaTime, m_mouseState);
|
||||
|
||||
float view[16];
|
||||
cameraGetViewMtx(view);
|
||||
|
||||
float proj[16];
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
float zero[3] = {};
|
||||
|
||||
float mvp[16];
|
||||
float eye[] = { 5.0f, 10.0f, 5.0f };
|
||||
bx::mtxLookAt(view, eye, zero);
|
||||
bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f);
|
||||
bx::mtxMul(mvp, view, proj);
|
||||
|
||||
ddBegin(0);
|
||||
ddDrawAxis(0.0f, 0.0f, 0.0f);
|
||||
|
||||
ddPush();
|
||||
ddSetColor(0xff00ff00);
|
||||
|
||||
Aabb aabb =
|
||||
{
|
||||
{ 5.0f, 1.0f, 1.0f },
|
||||
{ 10.0f, 5.0f, 5.0f },
|
||||
};
|
||||
ddDraw(aabb);
|
||||
ddPop();
|
||||
|
||||
float time = float(now/freq);
|
||||
|
||||
Obb obb;
|
||||
bx::mtxRotateX(obb.m_mtx, time);
|
||||
ddSetWireframe(true);
|
||||
ddDraw(obb);
|
||||
|
||||
ddSetColor(0xffffffff);
|
||||
bx::mtxSRT(obb.m_mtx, 1.0f, 1.0f, 1.0f, 0.0f, time, 0.0f, 3.0f, 0.0f, 0.0f);
|
||||
ddSetWireframe(false);
|
||||
ddDraw(obb);
|
||||
|
||||
ddSetTranslate(0.0f, -2.0f, 0.0f);
|
||||
ddDrawGrid(Axis::Y, zero, 20, 1.0f);
|
||||
ddSetTransform(NULL);
|
||||
|
||||
ddDrawFrustum(mvp);
|
||||
|
||||
ddPush();
|
||||
Sphere sphere = { { 0.0f, 5.0f, 0.0f }, 1.0f };
|
||||
ddSetColor(0xfff0c0ff);
|
||||
ddSetWireframe(true);
|
||||
ddSetLod(3);
|
||||
ddDraw(sphere);
|
||||
ddSetWireframe(false);
|
||||
|
||||
ddSetColor(0xf0ffc0ff);
|
||||
sphere.m_center[0] = -2.0f;
|
||||
ddSetLod(2);
|
||||
ddDraw(sphere);
|
||||
|
||||
ddSetColor(0xc0f0ffff);
|
||||
sphere.m_center[0] = -4.0f;
|
||||
ddSetLod(1);
|
||||
ddDraw(sphere);
|
||||
|
||||
ddSetColor(0xffc0ff00);
|
||||
sphere.m_center[0] = -6.0f;
|
||||
ddSetLod(0);
|
||||
ddDraw(sphere);
|
||||
ddPop();
|
||||
|
||||
ddSetColor(0xffffffff);
|
||||
|
||||
ddPush();
|
||||
ddSetStipple(true, 1.0f, time*0.1f);
|
||||
ddSetColor(0xff0000ff);
|
||||
{
|
||||
float normal[3] = { 0.0f, 0.0f, 1.0f };
|
||||
float center[3] = { -8.0f, 0.0f, 0.0f };
|
||||
ddDrawCircle(normal, center, 1.0f, 0.5f + bx::fsin(time*10.0f) );
|
||||
}
|
||||
ddPop();
|
||||
|
||||
ddPush();
|
||||
ddSetStipple(true, 1.0f, -time*0.1f);
|
||||
ddDrawCircle(Axis::Z, -8.0f, 0.0f, 0.0f, 1.25f, 2.0f);
|
||||
ddPop();
|
||||
|
||||
ddDrawOrb(-11.0f, 0.0f, 0.0f, 1.0f);
|
||||
ddEnd();
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
entry::MouseState m_mouseState;
|
||||
|
||||
int64_t m_timeOffset;
|
||||
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t m_debug;
|
||||
uint32_t m_reset;
|
||||
};
|
||||
|
||||
ENTRY_IMPLEMENT_MAIN(DebugDrawApp);
|
BIN
3rdparty/bgfx/examples/assets/textures/normalmap.png
vendored
Normal file
BIN
3rdparty/bgfx/examples/assets/textures/normalmap.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 225 KiB |
@ -324,13 +324,15 @@ static bgfx::ShaderHandle createEmbeddedShader(bgfx::RendererType::Enum _type, u
|
||||
struct DebugDraw
|
||||
{
|
||||
DebugDraw()
|
||||
: m_state(State::Count)
|
||||
: m_depthTestLess(true)
|
||||
, m_state(State::Count)
|
||||
{
|
||||
}
|
||||
|
||||
void init(bx::AllocatorI* _allocator)
|
||||
void init(bool _depthTestLess, bx::AllocatorI* _allocator)
|
||||
{
|
||||
m_allocator = _allocator;
|
||||
m_depthTestLess = _depthTestLess;
|
||||
|
||||
#if BX_CONFIG_ALLOCATOR_CRT
|
||||
if (NULL == _allocator)
|
||||
@ -502,9 +504,9 @@ struct DebugDraw
|
||||
Attrib& attrib = m_attrib[0];
|
||||
attrib.m_state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| (m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER)
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
;
|
||||
attrib.m_scale = 1.0f;
|
||||
attrib.m_offset = 0.0f;
|
||||
@ -533,7 +535,10 @@ struct DebugDraw
|
||||
void pop()
|
||||
{
|
||||
BX_CHECK(State::Count != m_state);
|
||||
if (m_attrib[m_stack].m_stipple != m_attrib[m_stack-1].m_stipple)
|
||||
const Attrib& curr = m_attrib[m_stack];
|
||||
const Attrib& prev = m_attrib[m_stack-1];
|
||||
if (curr.m_stipple != prev.m_stipple
|
||||
|| curr.m_state != prev.m_state)
|
||||
{
|
||||
flush();
|
||||
}
|
||||
@ -570,15 +575,20 @@ struct DebugDraw
|
||||
|
||||
void setState(bool _depthTest, bool _depthWrite, bool _clockwise)
|
||||
{
|
||||
const uint64_t depthTest = m_depthTestLess
|
||||
? BGFX_STATE_DEPTH_TEST_LESS
|
||||
: BGFX_STATE_DEPTH_TEST_GREATER
|
||||
;
|
||||
|
||||
m_attrib[m_stack].m_state &= ~(0
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_CULL_CCW
|
||||
);
|
||||
|
||||
m_attrib[m_stack].m_state |= _depthTest
|
||||
? BGFX_STATE_DEPTH_TEST_LESS
|
||||
? depthTest
|
||||
: 0
|
||||
;
|
||||
|
||||
@ -1266,7 +1276,7 @@ private:
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_PT_LINES
|
||||
| BGFX_STATE_DEPTH_TEST_LEQUAL
|
||||
| (m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LEQUAL : BGFX_STATE_DEPTH_TEST_GEQUAL)
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_LINEAA
|
||||
| BGFX_STATE_BLEND_ALPHA
|
||||
@ -1306,6 +1316,7 @@ private:
|
||||
uint16_t m_vertexPos;
|
||||
uint8_t m_viewId;
|
||||
uint8_t m_stack;
|
||||
bool m_depthTestLess;
|
||||
|
||||
struct Attrib
|
||||
{
|
||||
@ -1335,9 +1346,9 @@ private:
|
||||
|
||||
static DebugDraw s_dd;
|
||||
|
||||
void ddInit(bx::AllocatorI* _allocator)
|
||||
void ddInit(bool _depthTestLess, bx::AllocatorI* _allocator)
|
||||
{
|
||||
s_dd.init(_allocator);
|
||||
s_dd.init(_depthTestLess, _allocator);
|
||||
}
|
||||
|
||||
void ddShutdown()
|
||||
|
@ -22,7 +22,7 @@ struct Axis
|
||||
};
|
||||
|
||||
///
|
||||
void ddInit(bx::AllocatorI* _allocator = NULL);
|
||||
void ddInit(bool _depthTestLess = true, bx::AllocatorI* _allocator = NULL);
|
||||
|
||||
///
|
||||
void ddShutdown();
|
||||
|
9
3rdparty/bgfx/include/bgfx/bgfx.h
vendored
9
3rdparty/bgfx/include/bgfx/bgfx.h
vendored
@ -2361,7 +2361,14 @@ namespace bgfx
|
||||
, uint32_t _flags = UINT32_MAX
|
||||
);
|
||||
|
||||
/// Touch view.
|
||||
/// Submit an empty primitive for rendering. Uniforms and draw state
|
||||
/// will be applied but no geometry will be submitted.
|
||||
///
|
||||
/// These empty draw calls will sort before ordinary draw calls.
|
||||
///
|
||||
/// @param[in] _id View id.
|
||||
/// @returns Number of draw calls.
|
||||
///
|
||||
uint32_t touch(uint8_t _id);
|
||||
|
||||
/// Submit primitive for rendering.
|
||||
|
1
3rdparty/bgfx/scripts/genie.lua
vendored
1
3rdparty/bgfx/scripts/genie.lua
vendored
@ -422,6 +422,7 @@ exampleProject("24-nbody")
|
||||
exampleProject("26-occlusion")
|
||||
exampleProject("27-terrain")
|
||||
exampleProject("28-wireframe")
|
||||
exampleProject("29-debugdraw")
|
||||
|
||||
-- C99 source doesn't compile under WinRT settings
|
||||
if not premake.vstudio.iswinrt() then
|
||||
|
22
3rdparty/bgfx/scripts/shader.mk
vendored
22
3rdparty/bgfx/scripts/shader.mk
vendored
@ -25,38 +25,38 @@ all:
|
||||
else
|
||||
|
||||
ifeq ($(TARGET), 0)
|
||||
VS_FLAGS=--platform windows -p vs_3_0 -O 3 --debug
|
||||
FS_FLAGS=--platform windows -p ps_3_0 -O 3 --debug
|
||||
SHADER_PATH=bgfx/shaders/dx9
|
||||
VS_FLAGS=--platform windows -p vs_3_0 -O 3
|
||||
FS_FLAGS=--platform windows -p ps_3_0 -O 3
|
||||
SHADER_PATH=shaders/dx9
|
||||
else
|
||||
ifeq ($(TARGET), 1)
|
||||
VS_FLAGS=--platform windows -p vs_4_0 -O 3 --debug
|
||||
FS_FLAGS=--platform windows -p ps_4_0 -O 3 --debug
|
||||
CS_FLAGS=--platform windows -p cs_5_0 -O 1 --debug
|
||||
SHADER_PATH=bgfx/shaders/dx11
|
||||
VS_FLAGS=--platform windows -p vs_4_0 -O 3
|
||||
FS_FLAGS=--platform windows -p ps_4_0 -O 3
|
||||
CS_FLAGS=--platform windows -p cs_5_0 -O 1
|
||||
SHADER_PATH=shaders/dx11
|
||||
else
|
||||
ifeq ($(TARGET), 2)
|
||||
VS_FLAGS=--platform nacl
|
||||
FS_FLAGS=--platform nacl
|
||||
SHADER_PATH=bgfx/shaders/gles
|
||||
SHADER_PATH=shaders/gles
|
||||
else
|
||||
ifeq ($(TARGET), 3)
|
||||
VS_FLAGS=--platform android
|
||||
FS_FLAGS=--platform android
|
||||
CS_FLAGS=--platform android
|
||||
SHADER_PATH=bgfx/shaders/gles
|
||||
SHADER_PATH=shaders/gles
|
||||
else
|
||||
ifeq ($(TARGET), 4)
|
||||
VS_FLAGS=--platform linux -p 120
|
||||
FS_FLAGS=--platform linux -p 120
|
||||
CS_FLAGS=--platform linux -p 430
|
||||
SHADER_PATH=bgfx/shaders/glsl
|
||||
SHADER_PATH=shaders/glsl
|
||||
else
|
||||
ifeq ($(TARGET), 5)
|
||||
VS_FLAGS=--platform osx -p metal
|
||||
FS_FLAGS=--platform osx -p metal
|
||||
CS_FLAGS=--platform osx -p metal
|
||||
SHADER_PATH=bgfx/shaders/metal
|
||||
SHADER_PATH=shaders/metal
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
34
3rdparty/bgfx/src/bgfx_shader.sh
vendored
34
3rdparty/bgfx/src/bgfx_shader.sh
vendored
@ -29,6 +29,7 @@
|
||||
#endif // BGFX_SHADER_LANGUAGE_HLSL > 3 && BGFX_SHADER_TYPE_FRAGMENT
|
||||
|
||||
#if BGFX_SHADER_LANGUAGE_HLSL
|
||||
# define CONST(_x) static const _x
|
||||
# define dFdx(_x) ddx(_x)
|
||||
# define dFdy(_y) ddy(-_y)
|
||||
# define inversesqrt(_x) rsqrt(_x)
|
||||
@ -109,6 +110,12 @@ vec4 bgfxTexture2DProj(BgfxSampler2D _sampler, vec4 _coord)
|
||||
return _sampler.m_texture.Sample(_sampler.m_sampler, coord);
|
||||
}
|
||||
|
||||
struct BgfxSampler2DMS
|
||||
{
|
||||
SamplerState m_sampler;
|
||||
Texture2DMS m_texture;
|
||||
};
|
||||
|
||||
struct BgfxSampler2DShadow
|
||||
{
|
||||
SamplerComparisonState m_sampler;
|
||||
@ -182,6 +189,21 @@ vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level)
|
||||
return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level);
|
||||
}
|
||||
|
||||
vec4 bgfxTexelFetch(BgfxSampler2D _sampler, ivec2 _coord, int _lod)
|
||||
{
|
||||
return _sampler.m_texture.Load(ivec3(_coord, _lod) );
|
||||
}
|
||||
|
||||
vec4 bgfxTexelFetch(BgfxSampler2DMS _sampler, ivec2 _coord, int _sampleIdx)
|
||||
{
|
||||
return _sampler.m_texture.Load(_coord, _sampleIdx);
|
||||
}
|
||||
|
||||
vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod)
|
||||
{
|
||||
return _sampler.m_texture.Load(ivec4(_coord, _lod) );
|
||||
}
|
||||
|
||||
# define SAMPLER2D(_name, _reg) \
|
||||
uniform SamplerState _name ## Sampler : register(s[_reg]); \
|
||||
uniform Texture2D _name ## Texture : register(t[_reg]); \
|
||||
@ -191,6 +213,13 @@ vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level)
|
||||
# define texture2DLod(_sampler, _coord, _level) bgfxTexture2DLod(_sampler, _coord, _level)
|
||||
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
|
||||
|
||||
# define SAMPLER2DMS(_name, _reg) \
|
||||
uniform SamplerState _name ## Sampler : register(s[_reg]); \
|
||||
uniform Texture2DMS _name ## Texture : register(t[_reg]); \
|
||||
static BgfxSampler2DMS _name = { _name ## Sampler, _name ## Texture }
|
||||
# define sampler2DMS BgfxSampler2DMS
|
||||
# define texture2DMS(_sampler, _coord, _idx) bgfxTexture2DMS(_sampler, _coord, _idx)
|
||||
|
||||
# define SAMPLER2DSHADOW(_name, _reg) \
|
||||
uniform SamplerComparisonState _name ## Sampler : register(s[_reg]); \
|
||||
uniform Texture2D _name ## Texture : register(t[_reg]); \
|
||||
@ -220,6 +249,8 @@ vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level)
|
||||
# define samplerCube BgfxSamplerCube
|
||||
# define textureCube(_sampler, _coord) bgfxTextureCube(_sampler, _coord)
|
||||
# define textureCubeLod(_sampler, _coord, _level) bgfxTextureCubeLod(_sampler, _coord, _level)
|
||||
|
||||
# define texelFetch(_sampler, _coord, _lod) bgfxTexelFetch(_sampler, _coord, _lod)
|
||||
# else
|
||||
|
||||
# define sampler2DShadow sampler2D
|
||||
@ -256,6 +287,7 @@ float bgfxShadow2DProj(sampler2DShadow _sampler, vec4 _coord)
|
||||
}
|
||||
|
||||
# define SAMPLER2D(_name, _reg) uniform sampler2D _name : register(s ## _reg)
|
||||
# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name : register(s ## _reg)
|
||||
# define texture2D(_sampler, _coord) tex2D(_sampler, _coord)
|
||||
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
|
||||
|
||||
@ -321,10 +353,12 @@ vec3 mod(vec3 _a, vec3 _b) { return _a - _b * floor(_a / _b); }
|
||||
vec4 mod(vec4 _a, vec4 _b) { return _a - _b * floor(_a / _b); }
|
||||
|
||||
#else
|
||||
# define CONST(_x) const _x
|
||||
# define atan2(_x, _y) atan(_x, _y)
|
||||
# define mul(_a, _b) ( (_a) * (_b) )
|
||||
# define saturate(_x) clamp(_x, 0.0, 1.0)
|
||||
# define SAMPLER2D(_name, _reg) uniform sampler2D _name
|
||||
# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name
|
||||
# define SAMPLER3D(_name, _reg) uniform sampler3D _name
|
||||
# define SAMPLERCUBE(_name, _reg) uniform samplerCube _name
|
||||
# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name
|
||||
|
2
3rdparty/bgfx/src/config.h
vendored
2
3rdparty/bgfx/src/config.h
vendored
@ -266,7 +266,7 @@
|
||||
#endif // BGFX_CONFIG_MAX_TEXTURE_SAMPLERS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_FRAME_BUFFERS
|
||||
# define BGFX_CONFIG_MAX_FRAME_BUFFERS 64
|
||||
# define BGFX_CONFIG_MAX_FRAME_BUFFERS 128
|
||||
#endif // BGFX_CONFIG_MAX_FRAME_BUFFERS
|
||||
|
||||
#ifndef BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
|
||||
|
6
3rdparty/bgfx/src/glcontext_egl.cpp
vendored
6
3rdparty/bgfx/src/glcontext_egl.cpp
vendored
@ -252,6 +252,8 @@ EGL_IMPORT
|
||||
const bool hasEglKhrCreateContext = !!bx::findIdentifierMatch(extensions, "EGL_KHR_create_context");
|
||||
const bool hasEglKhrNoError = !!bx::findIdentifierMatch(extensions, "EGL_KHR_create_context_no_error");
|
||||
|
||||
const uint32_t gles = BGFX_CONFIG_RENDERER_OPENGLES;
|
||||
|
||||
for (uint32_t ii = 0; ii < 2; ++ii)
|
||||
{
|
||||
bx::StaticMemoryBlockWriter writer(s_contextAttrs, sizeof(s_contextAttrs) );
|
||||
@ -264,10 +266,10 @@ EGL_IMPORT
|
||||
if (hasEglKhrCreateContext)
|
||||
{
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR) );
|
||||
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES / 10) );
|
||||
bx::write(&writer, EGLint(gles / 10) );
|
||||
|
||||
bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR) );
|
||||
bx::write(&writer, EGLint(BGFX_CONFIG_RENDERER_OPENGLES % 10) );
|
||||
bx::write(&writer, EGLint(gles % 10) );
|
||||
|
||||
flags |= BGFX_CONFIG_DEBUG && hasEglKhrNoError ? 0
|
||||
| EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR
|
||||
|
8
3rdparty/bgfx/src/glimports.h
vendored
8
3rdparty/bgfx/src/glimports.h
vendored
@ -65,6 +65,7 @@ typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat
|
||||
typedef void (GL_APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble d);
|
||||
typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d);
|
||||
typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s);
|
||||
typedef void (GL_APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth);
|
||||
typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
||||
typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
|
||||
typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
|
||||
@ -169,6 +170,7 @@ typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode);
|
||||
typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
|
||||
typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
|
||||
@ -181,7 +183,9 @@ typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face,
|
||||
typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass);
|
||||
typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat* param);
|
||||
typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
|
||||
@ -249,6 +253,7 @@ GL_IMPORT______(false, PFNGLCLEARPROC, glClear);
|
||||
GL_IMPORT______(true, PFNGLCLEARBUFFERFVPROC, glClearBufferfv);
|
||||
GL_IMPORT______(false, PFNGLCLEARCOLORPROC, glClearColor);
|
||||
GL_IMPORT______(false, PFNGLCLEARSTENCILPROC, glClearStencil);
|
||||
GL_IMPORT______(true, PFNGLCLIPCONTROLPROC, glClipControl);
|
||||
GL_IMPORT______(false, PFNGLCOLORMASKPROC, glColorMask);
|
||||
GL_IMPORT______(false, PFNGLCOMPILESHADERPROC, glCompileShader);
|
||||
GL_IMPORT______(false, PFNGLCOMPRESSEDTEXIMAGE2DPROC, glCompressedTexImage2D);
|
||||
@ -354,6 +359,7 @@ GL_IMPORT______(true, PFNGLREADBUFFERPROC, glReadBuffer)
|
||||
GL_IMPORT______(false, PFNGLREADPIXELSPROC, glReadPixels);
|
||||
GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEPROC, glRenderbufferStorage);
|
||||
GL_IMPORT______(true, PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC, glRenderbufferStorageMultisample);
|
||||
GL_IMPORT______(true, PFNGLSAMPLEMASKIPROC, glSampleMaski);
|
||||
GL_IMPORT______(true, PFNGLSAMPLERPARAMETERIPROC, glSamplerParameteri);
|
||||
GL_IMPORT______(true, PFNGLSAMPLERPARAMETERFPROC, glSamplerParameterf);
|
||||
GL_IMPORT______(true, PFNGLSAMPLERPARAMETERFVPROC, glSamplerParameterfv);
|
||||
@ -366,7 +372,9 @@ GL_IMPORT______(true, PFNGLSTENCILMASKSEPARATEPROC, glStencilMask
|
||||
GL_IMPORT______(false, PFNGLSTENCILOPPROC, glStencilOp);
|
||||
GL_IMPORT______(true, PFNGLSTENCILOPSEPARATEPROC, glStencilOpSeparate);
|
||||
GL_IMPORT______(false, PFNGLTEXIMAGE2DPROC, glTexImage2D);
|
||||
GL_IMPORT______(true, PFNGLTEXIMAGE2DMULTISAMPLEPROC, glTexImage2DMultisample);
|
||||
GL_IMPORT______(true, PFNGLTEXIMAGE3DPROC, glTexImage3D);
|
||||
GL_IMPORT______(true, PFNGLTEXIMAGE3DMULTISAMPLEPROC, glTexImage3DMultisample);
|
||||
GL_IMPORT______(false, PFNGLTEXPARAMETERIPROC, glTexParameteri);
|
||||
GL_IMPORT______(false, PFNGLTEXPARAMETERIVPROC, glTexParameteriv);
|
||||
GL_IMPORT______(false, PFNGLTEXPARAMETERFPROC, glTexParameterf);
|
||||
|
12
3rdparty/bgfx/src/renderer_d3d11.cpp
vendored
12
3rdparty/bgfx/src/renderer_d3d11.cpp
vendored
@ -2705,11 +2705,15 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
m_blendStateCache.add(hash, bs);
|
||||
}
|
||||
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
|
||||
bool hasFactor = false
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FACTOR;
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_INV_FACTOR;
|
||||
const uint64_t f2 = BGFX_STATE_BLEND_FACTOR<<4;
|
||||
const uint64_t f3 = BGFX_STATE_BLEND_INV_FACTOR<<4;
|
||||
bool hasFactor = 0
|
||||
|| f0 == (_state & f0)
|
||||
|| f1 == (_state & f1)
|
||||
|| f2 == (_state & f2)
|
||||
|| f3 == (_state & f3)
|
||||
;
|
||||
|
||||
float blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
@ -2798,6 +2802,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
{
|
||||
uint32_t cull = (_state&BGFX_STATE_CULL_MASK)>>BGFX_STATE_CULL_SHIFT;
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
if (m_deviceInterfaceVersion >= 3)
|
||||
{
|
||||
D3D11_RASTERIZER_DESC2 desc;
|
||||
@ -2821,6 +2826,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
DX_CHECK(device3->CreateRasterizerState2(&desc, reinterpret_cast<ID3D11RasterizerState2**>(&rs) ) );
|
||||
}
|
||||
else
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
{
|
||||
D3D11_RASTERIZER_DESC desc;
|
||||
desc.FillMode = _wireframe ? D3D11_FILL_WIREFRAME : D3D11_FILL_SOLID;
|
||||
|
8
3rdparty/bgfx/src/renderer_d3d12.cpp
vendored
8
3rdparty/bgfx/src/renderer_d3d12.cpp
vendored
@ -4629,8 +4629,10 @@ data.NumQualityLevels = 0;
|
||||
m_backBufferColorIdx = m_swapChain->GetCurrentBackBufferIndex();
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR);
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR);
|
||||
const uint64_t f0 = BGFX_STATE_BLEND_FACTOR;
|
||||
const uint64_t f1 = BGFX_STATE_BLEND_INV_FACTOR;
|
||||
const uint64_t f2 = BGFX_STATE_BLEND_FACTOR<<4;
|
||||
const uint64_t f3 = BGFX_STATE_BLEND_INV_FACTOR<<4;
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle;
|
||||
ScratchBufferD3D12& scratchBuffer = m_scratchBuffer[m_backBufferColorIdx];
|
||||
@ -5029,6 +5031,8 @@ data.NumQualityLevels = 0;
|
||||
bool hasFactor = 0
|
||||
|| f0 == (state & f0)
|
||||
|| f1 == (state & f1)
|
||||
|| f2 == (state & f2)
|
||||
|| f3 == (state & f3)
|
||||
;
|
||||
|
||||
const VertexBufferD3D12& vb = m_vertexBuffers[draw.m_vertexBuffer.idx];
|
||||
|
48
3rdparty/bgfx/src/renderer_gl.cpp
vendored
48
3rdparty/bgfx/src/renderer_gl.cpp
vendored
@ -186,9 +186,9 @@ namespace bgfx { namespace gl
|
||||
|
||||
static const GLenum s_textureFilterMin[][3] =
|
||||
{
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR },
|
||||
{ GL_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_NEAREST },
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR },
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST },
|
||||
{ GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_NEAREST },
|
||||
{ GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST },
|
||||
};
|
||||
|
||||
struct TextureFormatInfo
|
||||
@ -465,6 +465,7 @@ namespace bgfx { namespace gl
|
||||
APPLE_texture_format_BGRA8888,
|
||||
APPLE_texture_max_level,
|
||||
|
||||
ARB_clip_control,
|
||||
ARB_compute_shader,
|
||||
ARB_conservative_depth,
|
||||
ARB_copy_image,
|
||||
@ -540,6 +541,7 @@ namespace bgfx { namespace gl
|
||||
EXT_framebuffer_blit,
|
||||
EXT_framebuffer_object,
|
||||
EXT_framebuffer_sRGB,
|
||||
EXT_gpu_shader4,
|
||||
EXT_multi_draw_indirect,
|
||||
EXT_occlusion_query_boolean,
|
||||
EXT_packed_float,
|
||||
@ -673,6 +675,7 @@ namespace bgfx { namespace gl
|
||||
{ "APPLE_texture_format_BGRA8888", false, true },
|
||||
{ "APPLE_texture_max_level", false, true },
|
||||
|
||||
{ "ARB_clip_control", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
|
||||
{ "ARB_compute_shader", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
|
||||
{ "ARB_conservative_depth", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
|
||||
{ "ARB_copy_image", BGFX_CONFIG_RENDERER_OPENGL >= 42, true },
|
||||
@ -748,6 +751,7 @@ namespace bgfx { namespace gl
|
||||
{ "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "EXT_framebuffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "EXT_framebuffer_sRGB", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
|
||||
{ "EXT_gpu_shader4", false, true },
|
||||
{ "EXT_multi_draw_indirect", false, true }, // GLES3.1 extension.
|
||||
{ "EXT_occlusion_query_boolean", false, true }, // GLES2 extension.
|
||||
{ "EXT_packed_float", BGFX_CONFIG_RENDERER_OPENGL >= 33, true },
|
||||
@ -899,6 +903,21 @@ namespace bgfx { namespace gl
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char* s_texelFetch[] =
|
||||
{
|
||||
"texelFetch",
|
||||
"texelFetchOffset",
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char* s_ARB_texture_multisample[] =
|
||||
{
|
||||
"sampler2DMS",
|
||||
"isampler2DMS",
|
||||
"usampler2DMS",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/)
|
||||
{
|
||||
}
|
||||
@ -4437,11 +4456,11 @@ namespace bgfx { namespace gl
|
||||
&& !s_textureFilter[m_textureFormat])
|
||||
{
|
||||
// Force point sampling when texture format doesn't support linear sampling.
|
||||
_flags &= 0
|
||||
_flags &= ~(0
|
||||
| BGFX_TEXTURE_MIN_MASK
|
||||
| BGFX_TEXTURE_MAG_MASK
|
||||
| BGFX_TEXTURE_MIP_MASK
|
||||
;
|
||||
);
|
||||
_flags |= 0
|
||||
| BGFX_TEXTURE_MIN_POINT
|
||||
| BGFX_TEXTURE_MAG_POINT
|
||||
@ -4819,16 +4838,18 @@ namespace bgfx { namespace gl
|
||||
else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|
||||
&& BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL <= 21) )
|
||||
{
|
||||
bool usesTextureLod = true
|
||||
const bool usesTextureLod = true
|
||||
&& s_extension[Extension::ARB_shader_texture_lod].m_supported
|
||||
&& bx::findIdentifierMatch(code, s_ARB_shader_texture_lod)
|
||||
;
|
||||
const bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
|
||||
const bool usesTexelFetch = !!bx::findIdentifierMatch(code, s_texelFetch);
|
||||
const bool usesTextureMS = !!bx::findIdentifierMatch(code, s_ARB_texture_multisample);
|
||||
|
||||
bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
|
||||
|
||||
uint32_t version = usesIUsamplers
|
||||
? 130
|
||||
: (usesTextureLod ? 120 : 0)
|
||||
uint32_t version =
|
||||
usesIUsamplers || usesTexelFetch || usesTextureMS ? 130
|
||||
: usesTextureLod ? 120
|
||||
: 0
|
||||
;
|
||||
|
||||
if (0 != version)
|
||||
@ -4844,6 +4865,11 @@ namespace bgfx { namespace gl
|
||||
}
|
||||
}
|
||||
|
||||
if (usesTextureMS)
|
||||
{
|
||||
writeString(&writer, "#extension GL_ARB_texture_multisample : enable\n");
|
||||
}
|
||||
|
||||
if (130 <= version)
|
||||
{
|
||||
if (m_type == GL_FRAGMENT_SHADER)
|
||||
|
4
3rdparty/bgfx/src/shader.cpp
vendored
4
3rdparty/bgfx/src/shader.cpp
vendored
@ -42,13 +42,13 @@ namespace bgfx
|
||||
uint32_t magic;
|
||||
bx::peek(_reader, magic);
|
||||
|
||||
if (magic == 0x07230203)
|
||||
if (magic == SPV_CHUNK_HEADER)
|
||||
{
|
||||
SpirV spirv;
|
||||
read(_reader, spirv, _err);
|
||||
parse(spirv.shader, printAsm, _writer, _err);
|
||||
}
|
||||
else if (magic == BX_MAKEFOURCC('D', 'X', 'B', 'C') )
|
||||
else if (magic == DXBC_CHUNK_HEADER)
|
||||
{
|
||||
DxbcContext dxbc;
|
||||
read(_reader, dxbc, _err);
|
||||
|
1
3rdparty/bgfx/src/shader_dxbc.cpp
vendored
1
3rdparty/bgfx/src/shader_dxbc.cpp
vendored
@ -1735,7 +1735,6 @@ namespace bgfx
|
||||
return size;
|
||||
}
|
||||
|
||||
#define DXBC_CHUNK_HEADER BX_MAKEFOURCC('D', 'X', 'B', 'C')
|
||||
#define DXBC_CHUNK_SHADER BX_MAKEFOURCC('S', 'H', 'D', 'R')
|
||||
#define DXBC_CHUNK_SHADER_EX BX_MAKEFOURCC('S', 'H', 'E', 'X')
|
||||
|
||||
|
2
3rdparty/bgfx/src/shader_dxbc.h
vendored
2
3rdparty/bgfx/src/shader_dxbc.h
vendored
@ -8,6 +8,8 @@
|
||||
|
||||
#include <bx/readerwriter.h>
|
||||
|
||||
#define DXBC_CHUNK_HEADER BX_MAKEFOURCC('D', 'X', 'B', 'C')
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
struct DxbcOpcode
|
||||
|
115
3rdparty/bgfx/src/shader_spirv.cpp
vendored
115
3rdparty/bgfx/src/shader_spirv.cpp
vendored
@ -706,54 +706,54 @@ namespace bgfx
|
||||
SpvOperand::Enum operands[2];
|
||||
};
|
||||
|
||||
// static const SpvDecorationInfo s_spvDecorationInfo[] =
|
||||
// {
|
||||
// { /* RelaxedPrecision */ SPV_OPERAND(_) },
|
||||
// { /* SpecId */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Block */ SPV_OPERAND(_) },
|
||||
// { /* BufferBlock */ SPV_OPERAND(_) },
|
||||
// { /* RowMajor */ SPV_OPERAND(_) },
|
||||
// { /* ColMajor */ SPV_OPERAND(_) },
|
||||
// { /* ArrayStride */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* MatrixStride */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* GLSLShared */ SPV_OPERAND(_) },
|
||||
// { /* GLSLPacked */ SPV_OPERAND(_) },
|
||||
// { /* CPacked */ SPV_OPERAND(_) },
|
||||
// { /* BuiltIn */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Unknown12 */ SPV_OPERAND(_) },
|
||||
// { /* NoPerspective */ SPV_OPERAND(_) },
|
||||
// { /* Flat */ SPV_OPERAND(_) },
|
||||
// { /* Patch */ SPV_OPERAND(_) },
|
||||
// { /* Centroid */ SPV_OPERAND(_) },
|
||||
// { /* Sample */ SPV_OPERAND(_) },
|
||||
// { /* Invariant */ SPV_OPERAND(_) },
|
||||
// { /* Restrict */ SPV_OPERAND(_) },
|
||||
// { /* Aliased */ SPV_OPERAND(_) },
|
||||
// { /* Volatile */ SPV_OPERAND(_) },
|
||||
// { /* Constant */ SPV_OPERAND(_) },
|
||||
// { /* Coherent */ SPV_OPERAND(_) },
|
||||
// { /* NonWritable */ SPV_OPERAND(_) },
|
||||
// { /* NonReadable */ SPV_OPERAND(_) },
|
||||
// { /* Uniform */ SPV_OPERAND(_) },
|
||||
// { /* Unknown27 */ SPV_OPERAND(_) },
|
||||
// { /* SaturatedConversion */ SPV_OPERAND(_) },
|
||||
// { /* Stream */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Location */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Component */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Index */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Binding */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* DescriptorSet */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Offset */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* XfbBuffer */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* XfbStride */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* FuncParamAttr */ SPV_OPERAND(_) },
|
||||
// { /* FPRoundingMode */ SPV_OPERAND(_) },
|
||||
// { /* FPFastMathMode */ SPV_OPERAND(_) },
|
||||
// { /* LinkageAttributes */ SPV_OPERAND(LiteralString, LinkageType) },
|
||||
// { /* NoContraction */ SPV_OPERAND(_) },
|
||||
// { /* InputAttachmentIndex */ SPV_OPERAND(LiteralNumber) },
|
||||
// { /* Alignment */ SPV_OPERAND(LiteralNumber) },
|
||||
// };
|
||||
static const SpvDecorationInfo s_spvDecorationInfo[] =
|
||||
{
|
||||
{ /* RelaxedPrecision */ SPV_OPERAND(_) },
|
||||
{ /* SpecId */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Block */ SPV_OPERAND(_) },
|
||||
{ /* BufferBlock */ SPV_OPERAND(_) },
|
||||
{ /* RowMajor */ SPV_OPERAND(_) },
|
||||
{ /* ColMajor */ SPV_OPERAND(_) },
|
||||
{ /* ArrayStride */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* MatrixStride */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* GLSLShared */ SPV_OPERAND(_) },
|
||||
{ /* GLSLPacked */ SPV_OPERAND(_) },
|
||||
{ /* CPacked */ SPV_OPERAND(_) },
|
||||
{ /* BuiltIn */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Unknown12 */ SPV_OPERAND(_) },
|
||||
{ /* NoPerspective */ SPV_OPERAND(_) },
|
||||
{ /* Flat */ SPV_OPERAND(_) },
|
||||
{ /* Patch */ SPV_OPERAND(_) },
|
||||
{ /* Centroid */ SPV_OPERAND(_) },
|
||||
{ /* Sample */ SPV_OPERAND(_) },
|
||||
{ /* Invariant */ SPV_OPERAND(_) },
|
||||
{ /* Restrict */ SPV_OPERAND(_) },
|
||||
{ /* Aliased */ SPV_OPERAND(_) },
|
||||
{ /* Volatile */ SPV_OPERAND(_) },
|
||||
{ /* Constant */ SPV_OPERAND(_) },
|
||||
{ /* Coherent */ SPV_OPERAND(_) },
|
||||
{ /* NonWritable */ SPV_OPERAND(_) },
|
||||
{ /* NonReadable */ SPV_OPERAND(_) },
|
||||
{ /* Uniform */ SPV_OPERAND(_) },
|
||||
{ /* Unknown27 */ SPV_OPERAND(_) },
|
||||
{ /* SaturatedConversion */ SPV_OPERAND(_) },
|
||||
{ /* Stream */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Location */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Component */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Index */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Binding */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* DescriptorSet */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Offset */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* XfbBuffer */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* XfbStride */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* FuncParamAttr */ SPV_OPERAND(_) },
|
||||
{ /* FPRoundingMode */ SPV_OPERAND(_) },
|
||||
{ /* FPFastMathMode */ SPV_OPERAND(_) },
|
||||
{ /* LinkageAttributes */ SPV_OPERAND(LiteralString, LinkageType) },
|
||||
{ /* NoContraction */ SPV_OPERAND(_) },
|
||||
{ /* InputAttachmentIndex */ SPV_OPERAND(LiteralNumber) },
|
||||
{ /* Alignment */ SPV_OPERAND(LiteralNumber) },
|
||||
};
|
||||
|
||||
static const char* s_spvDecoration[] =
|
||||
{
|
||||
@ -808,6 +808,7 @@ namespace bgfx
|
||||
|
||||
const char* getName(SpvDecoration::Enum _enum)
|
||||
{
|
||||
BX_UNUSED(s_spvDecorationInfo);
|
||||
BX_CHECK(_enum <= SpvDecoration::Count, "Unknown decoration id %d.", _enum);
|
||||
return _enum <= SpvDecoration::Count
|
||||
? s_spvDecoration[_enum]
|
||||
@ -920,7 +921,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
size += bx::read(_reader, _operand.data[0], _err);
|
||||
size += bx::read(_reader, _operand.data, _err);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1046,7 +1047,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%sAddressingModel(%d)"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1054,7 +1055,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s%s"
|
||||
, 0 == ii ? " " : ", "
|
||||
, getName(SpvDecoration::Enum(operand.data[0]) )
|
||||
, getName(SpvDecoration::Enum(operand.data) )
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1062,7 +1063,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s0x%08x"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1070,7 +1071,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s%d"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1086,7 +1087,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%sMemoryModel(%d)"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1094,7 +1095,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s%s"
|
||||
, 0 == ii ? " " : ", "
|
||||
, getName(SpvStorageClass::Enum(operand.data[0]) )
|
||||
, getName(SpvStorageClass::Enum(operand.data) )
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1102,7 +1103,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%s__%d__"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
@ -1110,7 +1111,7 @@ namespace bgfx
|
||||
size += bx::snprintf(&_out[size], bx::uint32_imax(0, _size-size)
|
||||
, "%sr%d"
|
||||
, 0 == ii ? " " : ", "
|
||||
, operand.data[0]
|
||||
, operand.data
|
||||
);
|
||||
break;
|
||||
|
||||
|
5
3rdparty/bgfx/src/shader_spirv.h
vendored
5
3rdparty/bgfx/src/shader_spirv.h
vendored
@ -11,6 +11,8 @@
|
||||
BX_ERROR_RESULT(BGFX_SHADER_SPIRV_INVALID_HEADER, BX_MAKEFOURCC('S', 'H', 0, 1) );
|
||||
BX_ERROR_RESULT(BGFX_SHADER_SPIRV_INVALID_INSTRUCTION, BX_MAKEFOURCC('S', 'H', 0, 2) );
|
||||
|
||||
#define SPV_CHUNK_HEADER BX_MAKEFOURCC(0x03, 0x02, 0x23, 0x07)
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
// Reference: https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html
|
||||
@ -581,9 +583,8 @@ namespace bgfx
|
||||
};
|
||||
|
||||
Enum type;
|
||||
uint32_t data[4];
|
||||
uint32_t data;
|
||||
|
||||
uint32_t target;
|
||||
stl::string literalString;
|
||||
};
|
||||
|
||||
|
45
3rdparty/bgfx/tools/shaderc/shaderc.cpp
vendored
45
3rdparty/bgfx/tools/shaderc/shaderc.cpp
vendored
@ -98,6 +98,14 @@ namespace bgfx
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char* s_ARB_texture_multisample[] =
|
||||
{
|
||||
"sampler2DMS",
|
||||
"isampler2DMS",
|
||||
"usampler2DMS",
|
||||
NULL
|
||||
};
|
||||
|
||||
const char* s_uniformTypeName[UniformType::Count] =
|
||||
{
|
||||
"int",
|
||||
@ -1058,6 +1066,20 @@ namespace bgfx
|
||||
memset(&data[size+1], 0, padding);
|
||||
fclose(file);
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
// To avoid commented code being recognized as used feature,
|
||||
// first preprocess pass is used to strip all comments before
|
||||
// substituting code.
|
||||
preprocessor.run(data);
|
||||
delete [] data;
|
||||
|
||||
size = (uint32_t)preprocessor.m_preprocessed.size();
|
||||
data = new char[size+padding+1];
|
||||
memcpy(data, preprocessor.m_preprocessed.c_str(), size);
|
||||
memset(&data[size], 0, padding+1);
|
||||
}
|
||||
|
||||
strNormalizeEol(data);
|
||||
|
||||
input = const_cast<char*>(bx::strws(data) );
|
||||
@ -1090,21 +1112,6 @@ namespace bgfx
|
||||
|
||||
input = const_cast<char*>(bx::strws(input) );
|
||||
}
|
||||
|
||||
if (!raw)
|
||||
{
|
||||
// To avoid commented code being recognized as used feature,
|
||||
// first preprocess pass is used to strip all comments before
|
||||
// substituting code.
|
||||
preprocessor.run(input);
|
||||
delete [] data;
|
||||
|
||||
size = (uint32_t)preprocessor.m_preprocessed.size();
|
||||
data = new char[size+padding+1];
|
||||
memcpy(data, preprocessor.m_preprocessed.c_str(), size);
|
||||
memset(&data[size], 0, padding+1);
|
||||
input = data;
|
||||
}
|
||||
}
|
||||
|
||||
if (raw)
|
||||
@ -1726,6 +1733,7 @@ namespace bgfx
|
||||
const bool hasTextureLod = NULL != bx::findIdentifierMatch(input, s_ARB_shader_texture_lod /*EXT_shader_texture_lod*/);
|
||||
const bool hasShader5 = NULL != bx::findIdentifierMatch(input, s_ARB_gpu_shader5);
|
||||
const bool hasShaderPacking = NULL != bx::findIdentifierMatch(input, s_ARB_shading_language_packing);
|
||||
const bool hasTextureMS = NULL != bx::findIdentifierMatch(input, s_ARB_texture_multisample);
|
||||
|
||||
if (0 == essl)
|
||||
{
|
||||
@ -1768,6 +1776,13 @@ namespace bgfx
|
||||
, "#extension GL_ARB_shader_texture_lod : enable\n"
|
||||
);
|
||||
}
|
||||
|
||||
if (hasTextureMS)
|
||||
{
|
||||
bx::stringPrintf(code
|
||||
, "#extension GL_ARB_texture_multisample : enable\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
3
3rdparty/bx/3rdparty/UnitTest++/src/Config.h
vendored
3
3rdparty/bx/3rdparty/UnitTest++/src/Config.h
vendored
@ -22,7 +22,8 @@
|
||||
|| defined(__NetBSD__) \
|
||||
|| defined(__OpenBSD__) \
|
||||
|| defined(__FreeBSD__) \
|
||||
|| defined(__native_client__)
|
||||
|| defined(__native_client__) \
|
||||
|| defined(__riscv)
|
||||
# define UNITTEST_POSIX
|
||||
#endif
|
||||
|
||||
|
9
3rdparty/bx/include/bx/config.h
vendored
9
3rdparty/bx/include/bx/config.h
vendored
@ -24,6 +24,15 @@
|
||||
# define BX_CONFIG_CRT_FILE_READER_WRITER !(BX_PLATFORM_NACL)
|
||||
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
|
||||
|
||||
#ifndef BX_CONFIG_CRT_PROCESS
|
||||
# define BX_CONFIG_CRT_PROCESS !(0 \
|
||||
|| BX_PLATFORM_EMSCRIPTEN \
|
||||
|| BX_PLATFORM_NACL \
|
||||
|| BX_PLATFORM_WINRT \
|
||||
|| BX_PLATFORM_XBOXONE \
|
||||
)
|
||||
#endif // BX_CONFIG_CRT_PROCESS
|
||||
|
||||
#ifndef BX_CONFIG_SEMAPHORE_PTHREAD
|
||||
# define BX_CONFIG_SEMAPHORE_PTHREAD (BX_PLATFORM_OSX || BX_PLATFORM_IOS)
|
||||
#endif // BX_CONFIG_SEMAPHORE_PTHREAD
|
||||
|
111
3rdparty/bx/include/bx/crtimpl.h
vendored
111
3rdparty/bx/include/bx/crtimpl.h
vendored
@ -192,6 +192,117 @@ namespace bx
|
||||
};
|
||||
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
|
||||
|
||||
#if BX_CONFIG_CRT_PROCESS
|
||||
|
||||
#if BX_COMPILER_MSVC_COMPATIBLE
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
#endif // BX_COMPILER_MSVC_COMPATIBLE
|
||||
|
||||
class ProcessReader : public ReaderOpenI, public CloserI, public ReaderI
|
||||
{
|
||||
public:
|
||||
ProcessReader()
|
||||
: m_file(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
~ProcessReader()
|
||||
{
|
||||
BX_CHECK(NULL == m_file, "Process not closed!");
|
||||
}
|
||||
|
||||
virtual bool open(const char* _command, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
||||
|
||||
m_file = popen(_command, "r");
|
||||
if (NULL == m_file)
|
||||
{
|
||||
BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessReader: Failed to open process.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void close() BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != m_file, "Process not open!");
|
||||
pclose(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
|
||||
virtual int32_t read(void* _data, int32_t _size, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
|
||||
|
||||
int32_t size = (int32_t)fread(_data, 1, _size, m_file);
|
||||
if (size != _size)
|
||||
{
|
||||
return size >= 0 ? size : 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
};
|
||||
|
||||
class ProcessWriter : public WriterOpenI, public CloserI, public WriterI
|
||||
{
|
||||
public:
|
||||
ProcessWriter()
|
||||
: m_file(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
~ProcessWriter()
|
||||
{
|
||||
BX_CHECK(NULL == m_file, "Process not closed!");
|
||||
}
|
||||
|
||||
virtual bool open(const char* _command, bool, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
||||
|
||||
m_file = popen(_command, "w");
|
||||
if (NULL == m_file)
|
||||
{
|
||||
BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "ProcessWriter: Failed to open process.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void close() BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != m_file, "Process not open!");
|
||||
pclose(m_file);
|
||||
m_file = NULL;
|
||||
}
|
||||
|
||||
virtual int32_t write(const void* _data, int32_t _size, Error* _err) BX_OVERRIDE
|
||||
{
|
||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
|
||||
|
||||
int32_t size = (int32_t)fwrite(_data, 1, _size, m_file);
|
||||
if (size != _size)
|
||||
{
|
||||
return size >= 0 ? size : 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
};
|
||||
|
||||
#endif // BX_CONFIG_CRT_PROCESS
|
||||
|
||||
} // namespace bx
|
||||
|
||||
#endif // BX_CRTIMPL_H_HEADER_GUARD
|
||||
|
290
3rdparty/bx/include/bx/fpumath.h
vendored
290
3rdparty/bx/include/bx/fpumath.h
vendored
@ -14,10 +14,28 @@
|
||||
|
||||
namespace bx
|
||||
{
|
||||
static const float pi = 3.14159265358979323846f;
|
||||
static const float invPi = 1.0f/3.14159265358979323846f;
|
||||
static const float piHalf = 1.57079632679489661923f;
|
||||
static const float sqrt2 = 1.41421356237309504880f;
|
||||
static const float pi = 3.14159265358979323846f;
|
||||
static const float invPi = 1.0f/3.14159265358979323846f;
|
||||
static const float piHalf = 1.57079632679489661923f;
|
||||
static const float sqrt2 = 1.41421356237309504880f;
|
||||
|
||||
struct Handness
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
};
|
||||
};
|
||||
|
||||
struct NearFar
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
Default,
|
||||
Reverse,
|
||||
};
|
||||
};
|
||||
|
||||
inline float toRad(float _deg)
|
||||
{
|
||||
@ -631,7 +649,8 @@ namespace bx
|
||||
mtxLookAtLh(_result, _eye, _at, _up);
|
||||
}
|
||||
|
||||
inline void mtxProjRhXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float diff = _far-_near;
|
||||
const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
|
||||
@ -640,14 +659,15 @@ namespace bx
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = _width;
|
||||
_result[ 5] = _height;
|
||||
_result[ 8] = _x;
|
||||
_result[ 9] = _y;
|
||||
_result[10] = -aa;
|
||||
_result[11] = -1.0f;
|
||||
_result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
|
||||
_result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
|
||||
_result[10] = (Handness::Right == HandnessT) ? -aa : aa;
|
||||
_result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
|
||||
_result[14] = -bb;
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float invDiffRl = 1.0f/(_rt - _lt);
|
||||
const float invDiffUd = 1.0f/(_ut - _dt);
|
||||
@ -655,76 +675,197 @@ namespace bx
|
||||
const float height = 2.0f*_near * invDiffUd;
|
||||
const float xx = (_rt + _lt) * invDiffRl;
|
||||
const float yy = (_ut + _dt) * invDiffUd;
|
||||
mtxProjRhXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc);
|
||||
mtxProjXYWH<HandnessT>(_result, xx, yy, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjRh(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
|
||||
mtxProj_impl<HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
||||
const float width = height * 1.0f/_aspect;
|
||||
mtxProjRhXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLhXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float diff = _far-_near;
|
||||
const float aa = _oglNdc ? (_far+_near)/diff : _far/diff;
|
||||
const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa;
|
||||
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = _width;
|
||||
_result[ 5] = _height;
|
||||
_result[ 8] = -_x;
|
||||
_result[ 9] = -_y;
|
||||
_result[10] = aa;
|
||||
_result[11] = 1.0f;
|
||||
_result[14] = -bb;
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float invDiffRl = 1.0f/(_rt - _lt);
|
||||
const float invDiffUd = 1.0f/(_ut - _dt);
|
||||
const float width = 2.0f*_near * invDiffRl;
|
||||
const float height = 2.0f*_near * invDiffUd;
|
||||
const float xx = (_rt + _lt) * invDiffRl;
|
||||
const float yy = (_ut + _dt) * invDiffUd;
|
||||
mtxProjLhXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
||||
const float width = height * 1.0f/_aspect;
|
||||
mtxProjLhXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
||||
mtxProjXYWH<HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _fov, _near, _far, _oglNdc);
|
||||
mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjLh(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Left>(_result, _fov, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Left>(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Right>(_result, _fov, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
|
||||
{
|
||||
mtxProj_impl<Handness::Right>(_result, _fovy, _aspect, _near, _far, _oglNdc);
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc = false)
|
||||
{
|
||||
float aa;
|
||||
float bb;
|
||||
if (BX_ENABLED(NearFar::Reverse == NearFarT) )
|
||||
{
|
||||
aa = _oglNdc ? -1.0f : 0.0f;
|
||||
bb = _oglNdc ? -2.0f*_near : -_near;
|
||||
}
|
||||
else
|
||||
{
|
||||
aa = 1.0f;
|
||||
bb = _oglNdc ? 2.0f*_near : _near;
|
||||
}
|
||||
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = _width;
|
||||
_result[ 5] = _height;
|
||||
_result[ 8] = (Handness::Right == HandnessT) ? _x : -_x;
|
||||
_result[ 9] = (Handness::Right == HandnessT) ? _y : -_y;
|
||||
_result[10] = (Handness::Right == HandnessT) ? -aa : aa;
|
||||
_result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f;
|
||||
_result[14] = -bb;
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
const float invDiffRl = 1.0f/(_rt - _lt);
|
||||
const float invDiffUd = 1.0f/(_ut - _dt);
|
||||
const float width = 2.0f*_near * invDiffRl;
|
||||
const float height = 2.0f*_near * invDiffUd;
|
||||
const float xx = (_rt + _lt) * invDiffRl;
|
||||
const float yy = (_ut + _dt) * invDiffUd;
|
||||
mtxProjInfXYWH<NearFarT,HandnessT>(_result, xx, yy, width, height, _near, _oglNdc);
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFarT,HandnessT>(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc);
|
||||
}
|
||||
|
||||
template <NearFar::Enum NearFarT, Handness::Enum HandnessT>
|
||||
inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
|
||||
const float width = height * 1.0f/_aspect;
|
||||
mtxProjInfXYWH<NearFarT,HandnessT>(_result, 0.0f, 0.0f, width, height, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Default,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Left>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _ut, _dt, _lt, _rt, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fov, _near, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false)
|
||||
{
|
||||
mtxProjInf_impl<NearFar::Reverse,Handness::Right>(_result, _fovy, _aspect, _near, _oglNdc);
|
||||
}
|
||||
|
||||
template <Handness::Enum HandnessT>
|
||||
inline void mtxOrtho_impl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
const float aa = 2.0f/(_right - _left);
|
||||
const float bb = 2.0f/(_top - _bottom);
|
||||
@ -736,26 +877,7 @@ namespace bx
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = aa;
|
||||
_result[ 5] = bb;
|
||||
_result[10] = cc;
|
||||
_result[12] = dd + _offset;
|
||||
_result[13] = ee;
|
||||
_result[14] = ff;
|
||||
_result[15] = 1.0f;
|
||||
}
|
||||
|
||||
inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
const float aa = 2.0f/(_right - _left);
|
||||
const float bb = 2.0f/(_top - _bottom);
|
||||
const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near);
|
||||
const float dd = (_left + _right)/(_left - _right);
|
||||
const float ee = (_top + _bottom)/(_bottom - _top);
|
||||
const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far);
|
||||
|
||||
memset(_result, 0, sizeof(float)*16);
|
||||
_result[ 0] = aa;
|
||||
_result[ 5] = bb;
|
||||
_result[10] = -cc;
|
||||
_result[10] = (Handness::Right == HandnessT) ? -cc : cc;
|
||||
_result[12] = dd + _offset;
|
||||
_result[13] = ee;
|
||||
_result[14] = ff;
|
||||
@ -764,7 +886,17 @@ namespace bx
|
||||
|
||||
inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
return mtxOrthoLh(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
mtxOrtho_impl<Handness::Left>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false)
|
||||
{
|
||||
mtxOrtho_impl<Handness::Right>(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc);
|
||||
}
|
||||
|
||||
inline void mtxRotateX(float* _result, float _ax)
|
||||
|
34
3rdparty/bx/include/bx/platform.h
vendored
34
3rdparty/bx/include/bx/platform.h
vendored
@ -28,11 +28,12 @@
|
||||
#define BX_PLATFORM_XBOX360 0
|
||||
#define BX_PLATFORM_XBOXONE 0
|
||||
|
||||
#define BX_CPU_ARM 0
|
||||
#define BX_CPU_JIT 0
|
||||
#define BX_CPU_MIPS 0
|
||||
#define BX_CPU_PPC 0
|
||||
#define BX_CPU_X86 0
|
||||
#define BX_CPU_ARM 0
|
||||
#define BX_CPU_JIT 0
|
||||
#define BX_CPU_MIPS 0
|
||||
#define BX_CPU_PPC 0
|
||||
#define BX_CPU_RISCV 0
|
||||
#define BX_CPU_X86 0
|
||||
|
||||
#define BX_ARCH_32BIT 0
|
||||
#define BX_ARCH_64BIT 0
|
||||
@ -84,6 +85,12 @@
|
||||
# undef BX_CPU_PPC
|
||||
# define BX_CPU_PPC 1
|
||||
# define BX_CACHE_LINE_SIZE 128
|
||||
#elif defined(__riscv) || \
|
||||
defined(__riscv__) || \
|
||||
defined(RISCVEL)
|
||||
# undef BX_CPU_RISCV
|
||||
# define BX_CPU_RISCV 1
|
||||
# define BX_CACHE_LINE_SIZE 64
|
||||
#elif defined(_M_IX86) || \
|
||||
defined(_M_X64) || \
|
||||
defined(__i386__) || \
|
||||
@ -103,7 +110,8 @@
|
||||
defined(__64BIT__) || \
|
||||
defined(__mips64) || \
|
||||
defined(__powerpc64__) || \
|
||||
defined(__ppc64__)
|
||||
defined(__ppc64__) || \
|
||||
defined(__LP64__)
|
||||
# undef BX_ARCH_64BIT
|
||||
# define BX_ARCH_64BIT 64
|
||||
#else
|
||||
@ -171,10 +179,12 @@
|
||||
// RaspberryPi compiler defines __linux__
|
||||
# undef BX_PLATFORM_RPI
|
||||
# define BX_PLATFORM_RPI 1
|
||||
#elif defined(__linux__)
|
||||
#elif defined(__linux__) \
|
||||
|| defined(__riscv__)
|
||||
# undef BX_PLATFORM_LINUX
|
||||
# define BX_PLATFORM_LINUX 1
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) \
|
||||
|| defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
# undef BX_PLATFORM_IOS
|
||||
# define BX_PLATFORM_IOS 1
|
||||
#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
@ -183,7 +193,7 @@
|
||||
# define BX_PLATFORM_OSX __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
|
||||
# else
|
||||
# define BX_PLATFORM_OSX 1
|
||||
# endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED)
|
||||
# endif // defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
# undef BX_PLATFORM_EMSCRIPTEN
|
||||
# define BX_PLATFORM_EMSCRIPTEN 1
|
||||
@ -283,12 +293,14 @@
|
||||
|
||||
#if BX_CPU_ARM
|
||||
# define BX_CPU_NAME "ARM"
|
||||
#elif BX_CPU_JIT
|
||||
# define BX_CPU_NAME "JIT-VM"
|
||||
#elif BX_CPU_MIPS
|
||||
# define BX_CPU_NAME "MIPS"
|
||||
#elif BX_CPU_PPC
|
||||
# define BX_CPU_NAME "PowerPC"
|
||||
#elif BX_CPU_JIT
|
||||
# define BX_CPU_NAME "JIT-VM"
|
||||
#elif BX_CPU_RISCV
|
||||
# define BX_CPU_NAME "RISC-V"
|
||||
#elif BX_CPU_X86
|
||||
# define BX_CPU_NAME "x86"
|
||||
#endif // BX_CPU_
|
||||
|
45
3rdparty/bx/include/bx/readerwriter.h
vendored
45
3rdparty/bx/include/bx/readerwriter.h
vendored
@ -230,38 +230,59 @@ namespace bx
|
||||
{
|
||||
};
|
||||
|
||||
struct BX_NO_VTABLE FileReaderI : public ReaderSeekerI
|
||||
struct BX_NO_VTABLE ReaderOpenI
|
||||
{
|
||||
virtual ~ReaderOpenI() = 0;
|
||||
virtual bool open(const char* _filePath, Error* _err) = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
|
||||
struct BX_NO_VTABLE FileWriterI : public WriterSeekerI
|
||||
inline ReaderOpenI::~ReaderOpenI()
|
||||
{
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE WriterOpenI
|
||||
{
|
||||
virtual ~WriterOpenI() = 0;
|
||||
virtual bool open(const char* _filePath, bool _append, Error* _err) = 0;
|
||||
};
|
||||
|
||||
inline WriterOpenI::~WriterOpenI()
|
||||
{
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE CloserI
|
||||
{
|
||||
virtual ~CloserI() = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
|
||||
inline bool open(FileReaderI* _reader, const char* _filePath, Error* _err = NULL)
|
||||
inline CloserI::~CloserI()
|
||||
{
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE FileReaderI : public ReaderOpenI, public CloserI, public ReaderSeekerI
|
||||
{
|
||||
};
|
||||
|
||||
struct BX_NO_VTABLE FileWriterI : public WriterOpenI, public CloserI, public WriterSeekerI
|
||||
{
|
||||
};
|
||||
|
||||
inline bool open(ReaderOpenI* _reader, const char* _filePath, Error* _err = NULL)
|
||||
{
|
||||
BX_ERROR_USE_TEMP_WHEN_NULL(_err);
|
||||
return _reader->open(_filePath, _err);
|
||||
}
|
||||
|
||||
inline void close(FileReaderI* _reader)
|
||||
{
|
||||
_reader->close();
|
||||
}
|
||||
|
||||
inline bool open(FileWriterI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL)
|
||||
inline bool open(WriterOpenI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL)
|
||||
{
|
||||
BX_ERROR_USE_TEMP_WHEN_NULL(_err);
|
||||
return _writer->open(_filePath, _append, _err);
|
||||
}
|
||||
|
||||
inline void close(FileWriterI* _writer)
|
||||
inline void close(CloserI* _reader)
|
||||
{
|
||||
_writer->close();
|
||||
_reader->close();
|
||||
}
|
||||
|
||||
struct BX_NO_VTABLE MemoryBlockI
|
||||
|
20
3rdparty/bx/scripts/toolchain.lua
vendored
20
3rdparty/bx/scripts/toolchain.lua
vendored
@ -37,6 +37,7 @@ function toolchain(_buildDir, _libDir)
|
||||
{ "ps4", "PS4" },
|
||||
{ "qnx-arm", "QNX/Blackberry - ARM" },
|
||||
{ "rpi", "RaspberryPi" },
|
||||
{ "riscv", "RISC-V" },
|
||||
},
|
||||
}
|
||||
|
||||
@ -336,6 +337,13 @@ function toolchain(_buildDir, _libDir)
|
||||
|
||||
elseif "rpi" == _OPTIONS["gcc"] then
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
|
||||
|
||||
elseif "riscv" == _OPTIONS["gcc"] then
|
||||
premake.gcc.cc = "/opt/riscv/bin/riscv64-unknown-elf-gcc"
|
||||
premake.gcc.cxx = "/opt/riscv/bin/riscv64-unknown-elf-g++"
|
||||
premake.gcc.ar = "/opt/riscv/bin/riscv64-unknown-elf-ar"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-riscv"))
|
||||
|
||||
end
|
||||
elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then
|
||||
|
||||
@ -1128,6 +1136,17 @@ function toolchain(_buildDir, _libDir)
|
||||
"-Wl,--gc-sections",
|
||||
}
|
||||
|
||||
configuration { "riscv" }
|
||||
targetdir (path.join(_buildDir, "riscv/bin"))
|
||||
objdir (path.join(_buildDir, "riscv/obj"))
|
||||
buildoptions {
|
||||
"-Wunused-value",
|
||||
"-Wundef",
|
||||
}
|
||||
buildoptions_cpp {
|
||||
"-std=c++0x",
|
||||
}
|
||||
|
||||
configuration {} -- reset configuration
|
||||
|
||||
return true
|
||||
@ -1191,6 +1210,7 @@ function strip()
|
||||
-- .. "-s EMTERPRETIFY_ASYNC=1 "
|
||||
.. "-s TOTAL_MEMORY=268435456 "
|
||||
-- .. "-s ALLOW_MEMORY_GROWTH=1 "
|
||||
-- .. "-s USE_WEBGL2=1 "
|
||||
.. "--memory-init-file 1 "
|
||||
.. "\"$(TARGET)\" -o \"$(TARGET)\".html "
|
||||
-- .. "--preload-file ../../../examples/runtime@/"
|
||||
|
2
3rdparty/bx/scripts/unittest++.lua
vendored
2
3rdparty/bx/scripts/unittest++.lua
vendored
@ -15,7 +15,7 @@ project "UnitTest++"
|
||||
"../3rdparty/UnitTest++/src/*.h",
|
||||
}
|
||||
|
||||
configuration { "linux or osx or android-* or *nacl* or ps4" }
|
||||
configuration { "linux or osx or android-* or *nacl* or ps4 or rpi or riscv" }
|
||||
files {
|
||||
"../3rdparty/UnitTest++/src/Posix/**.cpp",
|
||||
"../3rdparty/UnitTest++/src/Posix/**.h",
|
||||
|
BIN
3rdparty/bx/tools/bin/darwin/genie
vendored
BIN
3rdparty/bx/tools/bin/darwin/genie
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/darwin/ninja
vendored
Normal file
BIN
3rdparty/bx/tools/bin/darwin/ninja
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bx/tools/bin/linux/genie
vendored
BIN
3rdparty/bx/tools/bin/linux/genie
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/linux/ninja
vendored
Normal file
BIN
3rdparty/bx/tools/bin/linux/ninja
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bx/tools/bin/windows/genie.exe
vendored
BIN
3rdparty/bx/tools/bin/windows/genie.exe
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/windows/ninja.exe
vendored
Normal file
BIN
3rdparty/bx/tools/bin/windows/ninja.exe
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user