BGFX and BX update (nw)

This commit is contained in:
Miodrag Milanovic 2016-06-08 19:50:19 +02:00
parent e8cb3e06d0
commit a3af73bafc
62 changed files with 34175 additions and 1055 deletions

View File

@ -20,6 +20,10 @@ indent_size = 4
indent_style = space
indent_size = 4
[ocornut-imgui/*.inl]
indent_style = space
indent_size = 4
[pvrtc/*]
indent_style = space
indent_size = 4

View File

@ -1,98 +0,0 @@
//
// File: vk_lunarg_debug_marker.h
//
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and/or associated documentation files (the "Materials"), to
* deal in the Materials without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Materials, and to permit persons to whom the Materials are
* furnished to do so, subject to the following conditions:
*
* The above copyright notice(s) and this permission notice shall be included in
* all copies or substantial portions of the Materials.
*
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
* USE OR OTHER DEALINGS IN THE MATERIALS.
*
* Authors:
* Jon Ashburn <jon@lunarg.com>
* Courtney Goeltzenleuchter <courtney@lunarg.com>
*/
#ifndef __VK_DEBUG_MARKER_H__
#define __VK_DEBUG_MARKER_H__
#include "vulkan.h"
#define VK_DEBUG_MARKER_EXTENSION_NUMBER 6
#define VK_DEBUG_MARKER_EXTENSION_REVISION 1
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/*
***************************************************************************************************
* DebugMarker Vulkan Extension API
***************************************************************************************************
*/
#define DEBUG_MARKER_EXTENSION_NAME "VK_LUNARG_DEBUG_MARKER"
// ------------------------------------------------------------------------------------------------
// Enumerations
#define VK_DEBUG_MARKER_ENUM_EXTEND(type, id) \
((type)(VK_DEBUG_MARKER_EXTENSION_NUMBER * -1000 + (id)))
#define VK_OBJECT_INFO_TYPE_DBG_OBJECT_TAG \
VK_DEBUG_MARKER_ENUM_EXTEND(VkDbgObjectInfoType, 0)
#define VK_OBJECT_INFO_TYPE_DBG_OBJECT_NAME \
VK_DEBUG_MARKER_ENUM_EXTEND(VkDbgObjectInfoType, 1)
// ------------------------------------------------------------------------------------------------
// API functions
typedef void(VKAPI_PTR *PFN_vkCmdDbgMarkerBegin)(VkCommandBuffer commandBuffer,
const char *pMarker);
typedef void(VKAPI_PTR *PFN_vkCmdDbgMarkerEnd)(VkCommandBuffer commandBuffer);
typedef VkResult(VKAPI_PTR *PFN_vkDbgSetObjectTag)(
VkDevice device, VkDebugReportObjectTypeEXT objType, uint64_t object,
size_t tagSize, const void *pTag);
typedef VkResult(VKAPI_PTR *PFN_vkDbgSetObjectName)(
VkDevice device, VkDebugReportObjectTypeEXT objType, uint64_t object,
size_t nameSize, const char *pName);
#ifndef VK_NO_PROTOTYPES
// DebugMarker extension entrypoints
VKAPI_ATTR void VKAPI_CALL
vkCmdDbgMarkerBegin(VkCommandBuffer commandBuffer, const char *pMarker);
VKAPI_ATTR void VKAPI_CALL vkCmdDbgMarkerEnd(VkCommandBuffer commandBuffer);
VKAPI_ATTR VkResult VKAPI_CALL
vkDbgSetObjectTag(VkDevice device, VkDebugReportObjectTypeEXT objType,
uint64_t object, size_t tagSize, const void *pTag);
VKAPI_ATTR VkResult VKAPI_CALL
vkDbgSetObjectName(VkDevice device, VkDebugReportObjectTypeEXT objType,
uint64_t object, size_t nameSize, const char *pName);
#endif // VK_NO_PROTOTYPES
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // __VK_DEBUG_MARKER_H__

View File

@ -4,24 +4,17 @@
/*
** Copyright (c) 2014-2015 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
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
** http://www.apache.org/licenses/LICENSE-2.0
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

View File

@ -8,24 +8,17 @@ extern "C" {
/*
** Copyright (c) 2015-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
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
** http://www.apache.org/licenses/LICENSE-2.0
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
/*
@ -50,7 +43,7 @@ extern "C" {
#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff)
// Version of this file
#define VK_HEADER_VERSION 8
#define VK_HEADER_VERSION 13
#define VK_NULL_HANDLE 0
@ -217,6 +210,10 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000,
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000,
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000,
VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000,
VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001,
VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002,
VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO,
VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO,
VK_STRUCTURE_TYPE_RANGE_SIZE = (VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1),
@ -3175,13 +3172,14 @@ VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
#define VK_KHR_SURFACE_SPEC_VERSION 25
#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface"
#define VK_COLORSPACE_SRGB_NONLINEAR_KHR VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
typedef enum VkColorSpaceKHR {
VK_COLORSPACE_SRGB_NONLINEAR_KHR = 0,
VK_COLOR_SPACE_BEGIN_RANGE_KHR = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_END_RANGE_KHR = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_RANGE_SIZE_KHR = (VK_COLORSPACE_SRGB_NONLINEAR_KHR - VK_COLORSPACE_SRGB_NONLINEAR_KHR + 1),
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0,
VK_COLOR_SPACE_BEGIN_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_END_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_RANGE_SIZE_KHR = (VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - VK_COLOR_SPACE_SRGB_NONLINEAR_KHR + 1),
VK_COLOR_SPACE_MAX_ENUM_KHR = 0x7FFFFFFF
} VkColorSpaceKHR;
@ -3278,7 +3276,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(
#define VK_KHR_swapchain 1
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR)
#define VK_KHR_SWAPCHAIN_SPEC_VERSION 67
#define VK_KHR_SWAPCHAIN_SPEC_VERSION 68
#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain"
typedef VkFlags VkSwapchainCreateFlagsKHR;
@ -3434,7 +3432,7 @@ typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)(VkPhys
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlanePropertiesKHR* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneSupportedDisplaysKHR)(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t* pDisplayCount, VkDisplayKHR* pDisplays);
typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModePropertiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModePropertiesKHR* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayModeKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR*pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode);
typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayModeKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode);
typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR* pCapabilities);
typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayPlaneSurfaceKHR)(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
@ -3835,6 +3833,85 @@ VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(
#define VK_IMG_FILTER_CUBIC_EXTENSION_NAME "VK_IMG_filter_cubic"
#define VK_AMD_rasterization_order 1
#define VK_AMD_RASTERIZATION_ORDER_SPEC_VERSION 1
#define VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME "VK_AMD_rasterization_order"
typedef enum VkRasterizationOrderAMD {
VK_RASTERIZATION_ORDER_STRICT_AMD = 0,
VK_RASTERIZATION_ORDER_RELAXED_AMD = 1,
VK_RASTERIZATION_ORDER_BEGIN_RANGE_AMD = VK_RASTERIZATION_ORDER_STRICT_AMD,
VK_RASTERIZATION_ORDER_END_RANGE_AMD = VK_RASTERIZATION_ORDER_RELAXED_AMD,
VK_RASTERIZATION_ORDER_RANGE_SIZE_AMD = (VK_RASTERIZATION_ORDER_RELAXED_AMD - VK_RASTERIZATION_ORDER_STRICT_AMD + 1),
VK_RASTERIZATION_ORDER_MAX_ENUM_AMD = 0x7FFFFFFF
} VkRasterizationOrderAMD;
typedef struct VkPipelineRasterizationStateRasterizationOrderAMD {
VkStructureType sType;
const void* pNext;
VkRasterizationOrderAMD rasterizationOrder;
} VkPipelineRasterizationStateRasterizationOrderAMD;
#define VK_EXT_debug_marker 1
#define VK_EXT_DEBUG_MARKER_SPEC_VERSION 3
#define VK_EXT_DEBUG_MARKER_EXTENSION_NAME "VK_EXT_debug_marker"
typedef struct VkDebugMarkerObjectNameInfoEXT {
VkStructureType sType;
const void* pNext;
VkDebugReportObjectTypeEXT objectType;
uint64_t object;
const char* pObjectName;
} VkDebugMarkerObjectNameInfoEXT;
typedef struct VkDebugMarkerObjectTagInfoEXT {
VkStructureType sType;
const void* pNext;
VkDebugReportObjectTypeEXT objectType;
uint64_t object;
uint64_t tagName;
size_t tagSize;
const void* pTag;
} VkDebugMarkerObjectTagInfoEXT;
typedef struct VkDebugMarkerMarkerInfoEXT {
VkStructureType sType;
const void* pNext;
const char* pMarkerName;
float color[4];
} VkDebugMarkerMarkerInfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectTagEXT)(VkDevice device, VkDebugMarkerObjectTagInfoEXT* pTagInfo);
typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectNameEXT)(VkDevice device, VkDebugMarkerObjectNameInfoEXT* pNameInfo);
typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerBeginEXT)(VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerEndEXT)(VkCommandBuffer commandBuffer);
typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerInsertEXT)(VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT(
VkDevice device,
VkDebugMarkerObjectTagInfoEXT* pTagInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT(
VkDevice device,
VkDebugMarkerObjectNameInfoEXT* pNameInfo);
VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT(
VkCommandBuffer commandBuffer,
VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerEndEXT(
VkCommandBuffer commandBuffer);
VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT(
VkCommandBuffer commandBuffer,
VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,10 @@
LodePNG
-------
PNG encoder and decoder in C and C++.
Home page: http://lodev.org/lodepng/
Only two files are needed to allow your program to read and write PNG files: lodepng.cpp and lodepng.h.
The other files in the project are just examples, unit tests, etc...

6224
3rdparty/bgfx/3rdparty/lodepng/lodepng.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

1759
3rdparty/bgfx/3rdparty/lodepng/lodepng.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -24,10 +24,10 @@
#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//---- Include imgui_user.inl at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions.
//#define IMGUI_INCLUDE_IMGUI_USER_INL
#define IMGUI_INCLUDE_IMGUI_USER_INL
//---- Include imgui_user.h at the end of imgui.h
//#define IMGUI_INCLUDE_IMGUI_USER_H
#define IMGUI_INCLUDE_IMGUI_USER_H
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// dear imgui, v1.49 WIP
// dear imgui, v1.50 WIP
// (headers)
// See imgui.cpp file for documentation.
@ -16,7 +16,7 @@
#include <stddef.h> // ptrdiff_t, NULL
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
#define IMGUI_VERSION "1.49 WIP"
#define IMGUI_VERSION "1.50 WIP"
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
#ifndef IMGUI_API
@ -36,6 +36,11 @@
#define IM_PRINTFARGS(FMT)
#endif
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
// Forward declarations
struct ImDrawChannel; // Temporary storage for outputting drawing commands out of order, used by ImDrawList::ChannelsSplit()
struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call)
@ -140,15 +145,15 @@ namespace ImGui
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 SetNextWindowSizeConstraint(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints.
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints.
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 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
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set current window collapsed state
IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / front-most. prefer using SetNextWindowFocus().
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position.
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); // set named window collapsed state
@ -195,10 +200,10 @@ namespace ImGui
IMGUI_API void Separator(); // horizontal line
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 NewLine(); // undo a SameLine()
IMGUI_API void Spacing(); // add spacing
IMGUI_API void Spacing(); // add vertical 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 Indent(float indent_w = 0.0f); // move content position toward the right, by style.IndentSpacing or indent_w if >0
IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by style.IndentSpacing or indent_w if >0
IMGUI_API void BeginGroup(); // lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
IMGUI_API void EndGroup();
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
@ -208,7 +213,7 @@ namespace ImGui
IMGUI_API void SetCursorPosX(float x); // "
IMGUI_API void SetCursorPosY(float y); // "
IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position
IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize]
IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
IMGUI_API void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets
IMGUI_API float GetTextLineHeight(); // height of font == GetWindowFontSize()
@ -216,7 +221,7 @@ namespace ImGui
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.
// You can also use SameLine(pos_x) for simplified columning. The columns API is still work-in-progress and rather lacking.
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
@ -249,10 +254,10 @@ namespace ImGui
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text
IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2); // display text+label aligned the same way as value+label widgets
IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args);
IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance you by the same distance as an empty TreeNode() call.
IMGUI_API void BulletText(const char* fmt, ...) IM_PRINTFARGS(1);
IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
IMGUI_API void BulletText(const char* fmt, ...) IM_PRINTFARGS(1); // shortcut for Bullet()+Text()
IMGUI_API void BulletTextV(const char* fmt, va_list args);
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0));
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0)
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size);
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
@ -267,7 +272,7 @@ namespace ImGui
IMGUI_API bool ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true);
IMGUI_API bool ColorEdit3(const char* label, float col[3]); // Hint: 'float col[3]' function argument is same as 'float* col'. You can pass address of first element out of a contiguous set, e.g. &myvector.x
IMGUI_API bool ColorEdit4(const char* label, float col[4], bool show_alpha = true); // "
IMGUI_API void ColorEditMode(ImGuiColorEditMode mode); // FIXME-OBSOLETE: This is inconsistent with most of the API and should be obsoleted.
IMGUI_API void ColorEditMode(ImGuiColorEditMode mode); // FIXME-OBSOLETE: This is inconsistent with most of the API and will be obsoleted/replaced.
IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float));
IMGUI_API void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0));
IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float));
@ -323,12 +328,13 @@ namespace ImGui
IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_PRINTFARGS(3);
IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args);
IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args);
IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layout purpose
IMGUI_API void TreePush(const char* str_id = NULL); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call Push/Pop yourself for layout purpose
IMGUI_API void TreePush(const void* ptr_id = NULL); // "
IMGUI_API void TreePop();
IMGUI_API void TreePop(); // ~ Unindent()+PopId()
IMGUI_API void TreeAdvanceToLabelPos(); // advance cursor x position by GetTreeNodeToLabelSpacing()
IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceeding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode
IMGUI_API void SetNextTreeNodeOpen(bool is_open, ImGuiSetCond cond = 0); // set next TreeNode/CollapsingHeader open state.
IMGUI_API float GetTreeNodeToLabelSpacing(ImGuiTreeNodeFlags flags = 0); // return horizontal distance between cursor and text label due to collapsing node. == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode
IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. user doesn't have to call TreePop().
IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop().
IMGUI_API bool CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags flags = 0); // when 'p_open' isn't NULL, display an additional small close button on upper right of the header
// Widgets: Selectable / Lists
@ -458,7 +464,7 @@ namespace ImGui
// Obsolete (will be removed)
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
static inline bool CollapsingHeader(const char* label, const char* str_id, bool display_frame = true, bool default_open = false) { (void)str_id; (void)display_frame; ImGuiTreeNodeFlags default_open_flags = 1<<5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
static inline bool CollapsingHeader(const char* label, const char* str_id, bool framed = true, bool default_open = false) { (void)str_id; (void)framed; ImGuiTreeNodeFlags default_open_flags = 1<<5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
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::SetNextTreeNodeOpen(open, 0); } // OBSOLETE 1.34+
@ -530,7 +536,7 @@ enum ImGuiInputTextFlags_
ImGuiInputTextFlags_Multiline = 1 << 20 // For internal use by InputTextMultiline()
};
// Flags for ImGui::TreeNode*(), ImGui::CollapsingHeader*()
// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*()
enum ImGuiTreeNodeFlags_
{
ImGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected
@ -541,10 +547,10 @@ enum ImGuiTreeNodeFlags_
ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open
ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node
ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
ImGuiTreeNodeFlags_AlwaysOpen = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
//ImGuiTreeNodeFlags_UnindentArrow = 1 << 9, // FIXME: TODO: Unindent tree so that Label is aligned to current X position
ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 10, // FIXME: TODO: Extend hit box horizontally even if not framed
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 11, // FIXME: TODO: Automatically scroll on TreePop() if node got just open and contents is not visible
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 11, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoAutoOpenOnLog
};
@ -660,6 +666,7 @@ enum ImGuiAlign_
};
// Enumeration for ColorEditMode()
// FIXME-OBSOLETE: Will be replaced by future color/picker api
enum ImGuiColorEditMode_
{
ImGuiColorEditMode_UserSelect = -2,
@ -880,6 +887,7 @@ public:
{
if (new_capacity <= Capacity) return;
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
memset(&new_data[Size], 0, (size_t)(new_capacity - Size) * sizeof(value_type)); // BK - clear garbage so that 0 initialized ImString works properly.
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
ImGui::MemFree(Data);
Data = new_data;
@ -1034,11 +1042,11 @@ struct ImGuiTextEditCallbackData
bool HasSelection() const { return SelectionStart != SelectionEnd; }
};
// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraint(). Callback is called during the next Begin().
// NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraint() parameters are enough.
// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin().
// NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraints() parameters are enough.
struct ImGuiSizeConstraintCallbackData
{
void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraint()
void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraints()
ImVec2 Pos; // Read-only. Window position, for reference.
ImVec2 CurrentSize; // Read-only. Current window size.
ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
@ -1353,7 +1361,7 @@ struct ImFont
ImVec2 DisplayOffset; // = (0.f,1.f) // Offset font rendering by xx pixels
ImVector<Glyph> Glyphs; // // All glyphs.
ImVector<float> IndexXAdvance; // // Sparse. Glyphs->XAdvance in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
ImVector<short> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
ImVector<unsigned short> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
float FallbackXAdvance; // == FallbackGlyph->XAdvance
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
@ -1386,6 +1394,10 @@ struct ImFont
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
};
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
//---- Include imgui_user.h at the end of imgui.h
//---- So you can include code that extends ImGui using any of the types declared above.
//---- (also convenient for user to only explicitly include vanilla imgui.h)

View File

@ -1,4 +1,4 @@
// dear imgui, v1.49 WIP
// dear imgui, v1.50 WIP
// (demo code)
// Don't remove this file from your project! It is useful reference code that you can execute.
@ -11,7 +11,7 @@
#include "imgui.h"
#include <ctype.h> // toupper, isprint
#include <math.h> // sqrtf, fabsf, fmodf, powf, cosf, sinf, floorf, ceilf
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
#include <stdio.h> // vsnprintf, sscanf, printf
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
@ -251,34 +251,53 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::TreePop();
}
if (ImGui::TreeNode("With selectable nodes"))
if (ImGui::TreeNode("Advanced, with Selectable nodes"))
{
ShowHelpMarker("Click to select, CTRL+Click to toggle, click on arrows to open");
static int selection_mask = 0x02; // Dumb representation of what may be user-side selection state. You may carry selection state inside or outside your objects in whatever format you see fit.
int node_clicked = -1;
ShowHelpMarker("This is a more standard looking tree with selectable nodes.\nClick to select, CTRL+Click to toggle, click on arrows or double-click to open.");
static bool align_label_with_current_x_position = false;
ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position);
ImGui::Text("Hello!");
if (align_label_with_current_x_position)
ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing());
static int selection_mask = (1 << 2); // Dumb representation of what may be user-side selection state. You may carry selection state inside or outside your objects in whatever format you see fit.
int node_clicked = -1; // Temporary storage of what node we have clicked to process selection at the end of the loop. May be a pointer to your own node type, etc.
ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, ImGui::GetFontSize()*3); // Increase spacing to differentiate leaves from expanded contents.
for (int i = 0; i < 6; i++)
{
ImGuiTreeNodeFlags node_flags = ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0) | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
if (i >= 3)
node_flags |= ImGuiTreeNodeFlags_AlwaysOpen;
bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable %s %d", (i >= 3) ? "Leaf" : "Node", i);
if (ImGui::IsItemClicked())
node_clicked = i;
if (node_open)
// Disable the default open on single-click behavior and pass in Selected flag according to our selection state.
ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0);
if (i < 3)
{
ImGui::Text("Selectable Blah blah");
ImGui::Text("Blah blah");
ImGui::TreePop();
// Node
bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
if (ImGui::IsItemClicked())
node_clicked = i;
if (node_open)
{
ImGui::Text("Blah blah\nBlah Blah");
ImGui::TreePop();
}
}
else
{
// Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text().
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, "Selectable Leaf %d", i);
if (ImGui::IsItemClicked())
node_clicked = i;
}
}
if (node_clicked != -1)
{
// Update selection state. Process outside of tree loop to avoid visual inconsistencies during the clicking-frame.
if (ImGui::GetIO().KeyCtrl)
selection_mask ^= (1 << node_clicked); // CTRL+click to toggle
else
selection_mask = (1 << node_clicked); // Click to single-select
selection_mask ^= (1 << node_clicked); // CTRL+click to toggle
else //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, this commented bit preserve selection when clicking on item that is part of the selection
selection_mask = (1 << node_clicked); // Click to single-select
}
ImGui::PopStyleVar();
if (align_label_with_current_x_position)
ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing());
ImGui::TreePop();
}
ImGui::TreePop();
@ -423,6 +442,19 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes");
ImGui::TreePop();
}
if (ImGui::TreeNode("In columns"))
{
ImGui::Columns(3, NULL, false);
static bool selected[16] = { 0 };
for (int i = 0; i < 16; i++)
{
char label[32]; sprintf(label, "Item %d", i);
if (ImGui::Selectable(label, &selected[i])) {}
ImGui::NextColumn();
}
ImGui::Columns(1);
ImGui::TreePop();
}
if (ImGui::TreeNode("Grid"))
{
static bool selected[16] = { true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, true };
@ -1293,7 +1325,22 @@ void ImGui::ShowTestWindow(bool* p_open)
// Basic columns
if (ImGui::TreeNode("Basic"))
{
ImGui::Columns(4, "mycolumns");
ImGui::Text("Without border:");
ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border
ImGui::Separator();
for (int n = 0; n < 14; n++)
{
char label[32];
sprintf(label, "Item %d", n);
if (ImGui::Selectable(label)) {}
//if (ImGui::Button(label, ImVec2(-1,0))) {}
ImGui::NextColumn();
}
ImGui::Columns(1);
ImGui::Separator();
ImGui::Text("With border:");
ImGui::Columns(4, "mycolumns"); // 4-ways, with border
ImGui::Separator();
ImGui::Text("ID"); ImGui::NextColumn();
ImGui::Text("Name"); ImGui::NextColumn();
@ -1807,12 +1854,12 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
};
static int type = 0;
if (type == 0) ImGui::SetNextWindowSizeConstraint(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only
if (type == 1) ImGui::SetNextWindowSizeConstraint(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only
if (type == 2) ImGui::SetNextWindowSizeConstraint(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
if (type == 3) ImGui::SetNextWindowSizeConstraint(ImVec2(300, 0), ImVec2(400, FLT_MAX)); // Width 300-400
if (type == 4) ImGui::SetNextWindowSizeConstraint(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
if (type == 5) ImGui::SetNextWindowSizeConstraint(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)100);// Fixed Step
if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only
if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only
if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100
if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(300, 0), ImVec2(400, FLT_MAX)); // Width 300-400
if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)100);// Fixed Step
if (ImGui::Begin("Example: Constrained Resize", p_open))
{

View File

@ -1,4 +1,4 @@
// dear imgui, v1.49 WIP
// dear imgui, v1.50 WIP
// (drawing and font code)
// Contains implementation for
@ -1697,7 +1697,7 @@ void ImFont::BuildLookupTable()
for (int i = 0; i != Glyphs.Size; i++)
max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);
IM_ASSERT(Glyphs.Size < 32*1024);
IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved
IndexXAdvance.clear();
IndexLookup.clear();
GrowIndex(max_codepoint + 1);
@ -1705,7 +1705,7 @@ void ImFont::BuildLookupTable()
{
int codepoint = (int)Glyphs[i].Codepoint;
IndexXAdvance[codepoint] = Glyphs[i].XAdvance;
IndexLookup[codepoint] = (short)i;
IndexLookup[codepoint] = (unsigned short)i;
}
// Create a glyph to handle TAB
@ -1719,7 +1719,7 @@ void ImFont::BuildLookupTable()
tab_glyph.Codepoint = '\t';
tab_glyph.XAdvance *= 4;
IndexXAdvance[(int)tab_glyph.Codepoint] = (float)tab_glyph.XAdvance;
IndexLookup[(int)tab_glyph.Codepoint] = (short)(Glyphs.Size-1);
IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1);
}
FallbackGlyph = NULL;
@ -1747,7 +1747,7 @@ void ImFont::GrowIndex(int new_size)
for (int i = old_size; i < new_size; i++)
{
IndexXAdvance[i] = -1.0f;
IndexLookup[i] = (short)-1;
IndexLookup[i] = (unsigned short)-1;
}
}
@ -1756,13 +1756,13 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
int index_size = IndexLookup.Size;
if (dst < index_size && IndexLookup.Data[dst] == -1 && !overwrite_dst) // 'dst' already exists
if (dst < index_size && IndexLookup.Data[dst] == (unsigned short)-1 && !overwrite_dst) // 'dst' already exists
return;
if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op
return;
GrowIndex(dst + 1);
IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : -1;
IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (unsigned short)-1;
IndexXAdvance[dst] = (src < index_size) ? IndexXAdvance.Data[src] : 1.0f;
}
@ -1770,8 +1770,8 @@ const ImFont::Glyph* ImFont::FindGlyph(unsigned short c) const
{
if (c < IndexLookup.Size)
{
const short i = IndexLookup[c];
if (i != -1)
const unsigned short i = IndexLookup[c];
if (i != (unsigned short)-1)
return &Glyphs.Data[i];
}
return FallbackGlyph;

View File

@ -1,4 +1,4 @@
// dear imgui, v1.49 WIP
// dear imgui, v1.50 WIP
// (internals)
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
@ -12,13 +12,20 @@
#endif
#include <stdio.h> // FILE*
#include <math.h> // sqrtf()
#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
//-----------------------------------------------------------------------------
// Forward Declarations
//-----------------------------------------------------------------------------
@ -47,12 +54,6 @@ typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
namespace ImGuiStb
{
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#endif
#undef STB_TEXTEDIT_STRING
#undef STB_TEXTEDIT_CHARTYPE
#define STB_TEXTEDIT_STRING ImGuiTextEditState
@ -60,10 +61,6 @@ namespace ImGuiStb
#define STB_TEXTEDIT_GETWIDTH_NEWLINE -1.0f
#include "stb_textedit.h"
#ifdef __clang__
#pragma clang diagnostic pop
#endif
} // namespace ImGuiStb
//-----------------------------------------------------------------------------
@ -607,6 +604,7 @@ struct IMGUI_API ImGuiWindow
ImVec2 SizeFull; // Size when non collapsed
ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
ImGuiID MoveID; // == window->GetID("#MOVE")
ImVec2 Scroll;
@ -745,7 +743,11 @@ namespace ImGui
IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
IMGUI_API float RoundScalar(float value, int decimal_precision);
} // namespace ImGuiP
} // namespace ImGui
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning (pop)

View File

@ -0,0 +1,46 @@
#include <stdint.h>
#include <inttypes.h>
namespace ImGui
{
struct Font
{
enum Enum
{
Regular,
Mono,
Count
};
};
void PushFont(Font::Enum _font);
// BK - simple string class for convenience.
class ImString
{
public:
ImString();
ImString(const ImString& rhs);
ImString(const char* rhs);
~ImString();
ImString& operator=(const ImString& rhs);
ImString& operator=(const char* rhs);
void Clear();
bool IsEmpty() const;
const char* CStr() const
{
return NULL == Ptr ? "" : Ptr;
}
private:
char* Ptr;
};
} // namespace ImGui
#include "widgets/file_list.h"
#include "widgets/memory_editor.h"

View File

@ -0,0 +1,76 @@
namespace ImGui
{
ImString::ImString()
: Ptr(NULL)
{
}
ImString::ImString(const ImString& rhs)
: Ptr(NULL)
{
if (NULL != rhs.Ptr
&& 0 != strcmp(rhs.Ptr, ""))
{
Ptr = ImStrdup(rhs.Ptr);
}
}
ImString::ImString(const char* rhs)
: Ptr(NULL)
{
if (NULL != rhs
&& 0 != strcmp(rhs, ""))
{
Ptr = ImStrdup(rhs);
}
}
ImString::~ImString()
{
Clear();
}
ImString& ImString::operator=(const ImString& rhs)
{
if (this != &rhs)
{
*this = rhs.Ptr;
}
return *this;
}
ImString& ImString::operator=(const char* rhs)
{
if (Ptr != rhs)
{
Clear();
if (NULL != rhs
&& 0 != strcmp(rhs, ""))
{
Ptr = ImStrdup(rhs);
}
}
return *this;
}
void ImString::Clear()
{
if (NULL != Ptr)
{
MemFree(Ptr);
Ptr = NULL;
}
}
bool ImString::IsEmpty() const
{
return NULL == Ptr;
}
} // namespace
#include "widgets/file_list.inl"
#include "widgets/memory_editor.inl"

View File

@ -1,210 +0,0 @@
// Mini memory editor for ImGui (to embed in your game/tools)
// v0.10
//
// You can adjust the keyboard repeat delay/rate in ImGuiIO.
// The code assume a mono-space font for simplicity! If you don't use the default font, use ImGui::PushFont()/PopFont() to switch to a mono-space font before caling this.
//
// Usage:
// static MemoryEditor memory_editor; // save your state somewhere
// memory_editor.Draw("Memory Editor", mem_block, mem_block_size, (size_t)mem_block); // run
//
// TODO: better resizing policy (ImGui doesn't have flexible window resizing constraints yet)
struct MemoryEditor
{
bool Open;
bool AllowEdits;
int Rows;
int DataEditingAddr;
bool DataEditingTakeFocus;
char DataInput[32];
char AddrInput[32];
MemoryEditor()
{
Open = true;
Rows = 16;
DataEditingAddr = -1;
DataEditingTakeFocus = false;
strcpy(DataInput, "");
strcpy(AddrInput, "");
AllowEdits = true;
}
void Draw(const char* title, unsigned char* mem_data, int mem_size, size_t base_display_addr = 0)
{
if (ImGui::Begin(title, &Open))
{
ImGui::BeginChild("##scrolling", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
int addr_digits_count = 0;
for (int n = base_display_addr + mem_size - 1; n > 0; n >>= 4)
addr_digits_count++;
float glyph_width = ImGui::CalcTextSize("F").x;
float cell_width = glyph_width * 3; // "FF " we include trailing space in the width to easily catch clicks everywhere
float line_height = ImGui::GetTextLineHeight();
int line_total_count = (int)((mem_size + Rows-1) / Rows);
ImGuiListClipper clipper(line_total_count, line_height);
int visible_start_addr = clipper.DisplayStart * Rows;
int visible_end_addr = clipper.DisplayEnd * Rows;
bool data_next = false;
if (!AllowEdits || DataEditingAddr >= mem_size)
DataEditingAddr = -1;
int data_editing_addr_backup = DataEditingAddr;
if (DataEditingAddr != -1)
{
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)) && DataEditingAddr >= Rows) { DataEditingAddr -= Rows; DataEditingTakeFocus = true; }
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)) && DataEditingAddr < mem_size - Rows) { DataEditingAddr += Rows; DataEditingTakeFocus = true; }
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)) && DataEditingAddr > 0) { DataEditingAddr -= 1; DataEditingTakeFocus = true; }
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow)) && DataEditingAddr < mem_size - 1) { DataEditingAddr += 1; DataEditingTakeFocus = true; }
}
if ((DataEditingAddr / Rows) != (data_editing_addr_backup / Rows))
{
// Track cursor movements
float scroll_offset = ((DataEditingAddr / Rows) - (data_editing_addr_backup / Rows)) * line_height;
bool scroll_desired = (scroll_offset < 0.0f && DataEditingAddr < visible_start_addr + Rows*2) || (scroll_offset > 0.0f && DataEditingAddr > visible_end_addr - Rows*2);
if (scroll_desired)
ImGui::SetScrollY(ImGui::GetScrollY() + scroll_offset);
}
bool draw_separator = true;
for (int line_i = clipper.DisplayStart; line_i < clipper.DisplayEnd; line_i++) // display only visible items
{
int addr = line_i * Rows;
ImGui::Text("%0*X: ", addr_digits_count, base_display_addr+addr);
ImGui::SameLine();
// Draw Hexadecimal
float line_start_x = ImGui::GetCursorPosX();
for (int n = 0; n < Rows && addr < mem_size; n++, addr++)
{
ImGui::SameLine(line_start_x + cell_width * n);
if (DataEditingAddr == addr)
{
// Display text input on current byte
ImGui::PushID(addr);
struct FuncHolder
{
// FIXME: We should have a way to retrieve the text edit cursor position more easily in the API, this is rather tedious.
static int Callback(ImGuiTextEditCallbackData* data)
{
int* p_cursor_pos = (int*)data->UserData;
if (!data->HasSelection())
*p_cursor_pos = data->CursorPos;
return 0;
}
};
int cursor_pos = -1;
bool data_write = false;
if (DataEditingTakeFocus)
{
ImGui::SetKeyboardFocusHere();
sprintf(AddrInput, "%0*X", addr_digits_count, base_display_addr+addr);
sprintf(DataInput, "%02X", mem_data[addr]);
}
ImGui::PushItemWidth(ImGui::CalcTextSize("FF").x);
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CharsHexadecimal|ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_AutoSelectAll|ImGuiInputTextFlags_NoHorizontalScroll|ImGuiInputTextFlags_AlwaysInsertMode|ImGuiInputTextFlags_CallbackAlways;
if (ImGui::InputText("##data", DataInput, 32, flags, FuncHolder::Callback, &cursor_pos))
data_write = data_next = true;
else if (!DataEditingTakeFocus && !ImGui::IsItemActive())
DataEditingAddr = -1;
DataEditingTakeFocus = false;
ImGui::PopItemWidth();
if (cursor_pos >= 2)
data_write = data_next = true;
if (data_write)
{
int data;
if (sscanf(DataInput, "%X", &data) == 1)
mem_data[addr] = (unsigned char)data;
}
ImGui::PopID();
}
else
{
ImGui::Text("%02X ", mem_data[addr]);
if (AllowEdits && ImGui::IsItemHovered() && ImGui::IsMouseClicked(0))
{
DataEditingTakeFocus = true;
DataEditingAddr = addr;
}
}
}
ImGui::SameLine(line_start_x + cell_width * Rows + glyph_width * 2);
if (draw_separator)
{
ImVec2 screen_pos = ImGui::GetCursorScreenPos();
ImGui::GetWindowDrawList()->AddLine(ImVec2(screen_pos.x - glyph_width, screen_pos.y - 9999), ImVec2(screen_pos.x - glyph_width, screen_pos.y + 9999), ImColor(ImGui::GetStyle().Colors[ImGuiCol_Border]));
draw_separator = false;
}
// Draw ASCII values
addr = line_i * Rows;
for (int n = 0; n < Rows && addr < mem_size; n++, addr++)
{
if (n > 0) ImGui::SameLine();
int c = mem_data[addr];
ImGui::Text("%c", (c >= 32 && c < 128) ? c : '.');
}
}
clipper.End();
ImGui::PopStyleVar(2);
ImGui::EndChild();
if (data_next && DataEditingAddr < mem_size)
{
DataEditingAddr = DataEditingAddr + 1;
DataEditingTakeFocus = true;
}
ImGui::Separator();
ImGui::AlignFirstTextHeightToWidgets();
ImGui::PushItemWidth(50);
ImGui::PushAllowKeyboardFocus(false);
int rows_backup = Rows;
if (ImGui::DragInt("##rows", &Rows, 0.2f, 4, 32, "%.0f rows"))
{
ImVec2 new_window_size = ImGui::GetWindowSize();
new_window_size.x += (Rows - rows_backup) * (cell_width + glyph_width);
ImGui::SetWindowSize(new_window_size);
}
ImGui::PopAllowKeyboardFocus();
ImGui::PopItemWidth();
ImGui::SameLine();
ImGui::Text("Range %0*X..%0*X", addr_digits_count, (int)base_display_addr, addr_digits_count, (int)base_display_addr+mem_size-1);
ImGui::SameLine();
ImGui::PushItemWidth(70);
if (ImGui::InputText("##addr", AddrInput, 32, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue))
{
int goto_addr;
if (sscanf(AddrInput, "%X", &goto_addr) == 1)
{
goto_addr -= base_display_addr;
if (goto_addr >= 0 && goto_addr < mem_size)
{
ImGui::BeginChild("##scrolling");
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + (goto_addr / Rows) * ImGui::GetTextLineHeight());
ImGui::EndChild();
DataEditingAddr = goto_addr;
DataEditingTakeFocus = true;
}
}
}
ImGui::PopItemWidth();
}
ImGui::End();
}
};

View File

@ -0,0 +1,28 @@
namespace ImGui
{
struct ImFileInfo
{
ImFileInfo(const char* name, int64_t size);
~ImFileInfo();
ImString Name;
int64_t Size;
};
struct ImFileList
{
typedef ImVector<ImFileInfo> FileInfoArray;
FileInfoArray FileList;
int Pos;
ImFileList(const char* path = ".")
: Pos(0)
{
ChDir(path);
}
void ChDir(const char* path);
void Draw();
};
} // namespace ImGui

View File

@ -0,0 +1,119 @@
#include <dirent.h>
#include <sys/stat.h>
namespace ImGui
{
ImFileInfo::ImFileInfo(const char* name, int64_t size)
: Name(name)
, Size(size)
{
}
ImFileInfo::~ImFileInfo()
{
}
void ImFileList::ChDir(const char* path)
{
DIR* dir = opendir(path);
if (NULL != dir)
{
FileList.clear();
for (dirent* item = readdir(dir); NULL != item; item = readdir(dir) )
{
if (0 == ImStricmp(item->d_name, "..") )
{
FileList.push_back(ImFileInfo(item->d_name, -1) );
}
else if (0 != ImStricmp(item->d_name, ".") )
{
if (item->d_type & DT_DIR)
{
FileList.push_back(ImFileInfo(item->d_name, -1) );
}
else
{
struct stat statbuf;
stat(item->d_name, &statbuf);
FileList.push_back(ImFileInfo(item->d_name, statbuf.st_size) );
}
}
}
closedir(dir);
}
}
void ImFileList::Draw()
{
BeginChild("##file_list", ImVec2(0.0f, 0.0f) );
PushFont(Font::Mono);
PushItemWidth(-1);
if (ListBoxHeader("##empty", ImVec2(0.0f, 0.0f) ) )
{
const float lineHeight = GetTextLineHeightWithSpacing();
ImString chdir;
int pos = 0;
ImGuiListClipper clipper(FileList.size(), lineHeight);
for (FileInfoArray::const_iterator it = FileList.begin(), itEnd = FileList.end()
; it != itEnd
; ++it
)
{
if (pos >= clipper.DisplayStart
&& pos < clipper.DisplayEnd)
{
PushID(pos);
const bool isDir = -1 == it->Size;
bool isSelected = Pos == pos;
bool clicked = Selectable(it->Name.CStr(), &isSelected);
SameLine(150);
if (isDir)
{
Text("%10s", "<DIR>");
}
else
{
Text("%10" PRId64, it->Size);
}
if (clicked)
{
if (0 == strcmp(it->Name.CStr(), "..") )
{
chdir = it->Name;
}
Pos = pos;
if (isDir)
{
chdir = it->Name;
}
}
PopID();
}
++pos;
}
clipper.End();
ListBoxFooter();
if (!chdir.IsEmpty() )
{
ChDir(chdir.CStr() );
}
}
PopFont();
EndChild();
}
} // namespace ImGui

View File

@ -0,0 +1,27 @@
namespace ImGui
{
struct MemoryEditor
{
bool AllowEdits;
bool HexII;
int Rows;
int DataEditingAddr;
bool DataEditingTakeFocus;
char DataInput[32];
char AddrInput[32];
MemoryEditor()
{
AllowEdits = true;
HexII = true;
Rows = 16;
DataEditingAddr = -1;
DataEditingTakeFocus = false;
strcpy(DataInput, "");
strcpy(AddrInput, "");
}
void Draw(void* mem_data, int mem_size, int base_display_addr = 0);
void Draw(const void* mem_data, int mem_size, int base_display_addr = 0);
};
} // namespace ImGui

View File

@ -0,0 +1,249 @@
#ifdef _MSC_VER
# define snprintf _snprintf
#endif
namespace ImGui
{
// const char* title;
// if (Begin(title, &Open))
// {
// End();
// }
void MemoryEditor::Draw(void* mem_data_void, int mem_size, int base_display_addr)
{
PushFont(Font::Mono);
unsigned char* mem_data = (unsigned char*)mem_data_void;
BeginChild("##scrolling", ImVec2(0, -GetItemsLineHeightWithSpacing()));
if (ImGui::BeginPopupContextWindow() )
{
ImGui::Checkbox("HexII", &HexII);
ImGui::EndPopup();
}
PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f) );
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f) );
int addr_digits_count = 0;
for (int n = base_display_addr + mem_size - 1; n > 0; n >>= 4)
{
addr_digits_count++;
}
float glyph_width = CalcTextSize("F").x;
float cell_width = glyph_width * 3; // "FF " we include trailing space in the width to easily catch clicks everywhere
float line_height = GetTextLineHeight();
int line_total_count = (int)((mem_size + Rows-1) / Rows);
ImGuiListClipper clipper(line_total_count, line_height);
int visible_start_addr = clipper.DisplayStart * Rows;
int visible_end_addr = clipper.DisplayEnd * Rows;
bool data_next = false;
if (!AllowEdits || DataEditingAddr >= mem_size)
{
DataEditingAddr = -1;
}
int data_editing_addr_backup = DataEditingAddr;
if (DataEditingAddr != -1)
{
if (IsKeyPressed(GetKeyIndex(ImGuiKey_UpArrow)) && DataEditingAddr >= Rows) { DataEditingAddr -= Rows; DataEditingTakeFocus = true; }
else if (IsKeyPressed(GetKeyIndex(ImGuiKey_DownArrow)) && DataEditingAddr < mem_size - Rows) { DataEditingAddr += Rows; DataEditingTakeFocus = true; }
else if (IsKeyPressed(GetKeyIndex(ImGuiKey_LeftArrow)) && DataEditingAddr > 0) { DataEditingAddr -= 1; DataEditingTakeFocus = true; }
else if (IsKeyPressed(GetKeyIndex(ImGuiKey_RightArrow)) && DataEditingAddr < mem_size - 1) { DataEditingAddr += 1; DataEditingTakeFocus = true; }
}
if ((DataEditingAddr / Rows) != (data_editing_addr_backup / Rows))
{
// Track cursor movements
float scroll_offset = ((DataEditingAddr / Rows) - (data_editing_addr_backup / Rows)) * line_height;
bool scroll_desired = (scroll_offset < 0.0f && DataEditingAddr < visible_start_addr + Rows*2) || (scroll_offset > 0.0f && DataEditingAddr > visible_end_addr - Rows*2);
if (scroll_desired)
{
SetScrollY(GetScrollY() + scroll_offset);
}
}
bool draw_separator = true;
for (int line_i = clipper.DisplayStart; line_i < clipper.DisplayEnd; line_i++) // display only visible items
{
int addr = line_i * Rows;
Text("%0*x: ", addr_digits_count, base_display_addr+addr);
SameLine();
// Draw Hexadecimal
float line_start_x = GetCursorPosX();
for (int n = 0; n < Rows && addr < mem_size; n++, addr++)
{
SameLine(line_start_x + cell_width * n);
if (DataEditingAddr == addr)
{
// Display text input on current byte
PushID(addr);
struct FuncHolder
{
// FIXME: We should have a way to retrieve the text edit cursor position more easily in the API, this is rather tedious.
static int Callback(ImGuiTextEditCallbackData* data)
{
int* p_cursor_pos = (int*)data->UserData;
if (!data->HasSelection())
{
*p_cursor_pos = data->CursorPos;
}
return 0;
}
};
int cursor_pos = -1;
bool data_write = false;
if (DataEditingTakeFocus)
{
SetKeyboardFocusHere();
snprintf(AddrInput, sizeof(AddrInput), "%0*x", addr_digits_count, base_display_addr+addr);
snprintf(DataInput, sizeof(DataInput), "%02x", mem_data[addr]);
}
PushItemWidth(CalcTextSize("FF").x);
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CharsHexadecimal|ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_AutoSelectAll|ImGuiInputTextFlags_NoHorizontalScroll|ImGuiInputTextFlags_AlwaysInsertMode|ImGuiInputTextFlags_CallbackAlways;
if (InputText("##data", DataInput, 32, flags, FuncHolder::Callback, &cursor_pos))
{
data_write = data_next = true;
}
else if (!DataEditingTakeFocus && !IsItemActive())
{
DataEditingAddr = -1;
}
DataEditingTakeFocus = false;
PopItemWidth();
if (cursor_pos >= 2)
{
data_write = data_next = true;
}
if (data_write)
{
int data;
if (sscanf(DataInput, "%X", &data) == 1)
{
mem_data[addr] = (unsigned char)data;
}
}
PopID();
}
else
{
if (HexII)
{
unsigned char byte = mem_data[addr];
if (isprint(byte) )
{
Text(".%c ", byte);
}
else if (0x00 == byte)
{
Text(" ");
}
else if (0xff == byte)
{
Text("## ");
}
else
{
Text("%02x ", byte);
}
}
else
{
Text("%02x ", mem_data[addr]);
}
if (AllowEdits && IsItemHovered() && IsMouseClicked(0))
{
DataEditingTakeFocus = true;
DataEditingAddr = addr;
}
}
}
SameLine(line_start_x + cell_width * Rows + glyph_width * 2);
if (draw_separator)
{
ImVec2 screen_pos = GetCursorScreenPos();
GetWindowDrawList()->AddLine(ImVec2(screen_pos.x - glyph_width, screen_pos.y - 9999), ImVec2(screen_pos.x - glyph_width, screen_pos.y + 9999), ImColor(GetStyle().Colors[ImGuiCol_Border]));
draw_separator = false;
}
// Draw ASCII values
addr = line_i * Rows;
for (int n = 0; n < Rows && addr < mem_size; n++, addr++)
{
if (n > 0) { SameLine(); }
int c = mem_data[addr];
Text("%c", (c >= 32 && c < 128) ? c : '.');
}
}
clipper.End();
PopStyleVar(2);
EndChild();
if (data_next && DataEditingAddr < mem_size)
{
DataEditingAddr = DataEditingAddr + 1;
DataEditingTakeFocus = true;
}
Separator();
AlignFirstTextHeightToWidgets();
PushItemWidth(50);
PushAllowKeyboardFocus(false);
int rows_backup = Rows;
if (DragInt("##rows", &Rows, 0.2f, 4, 32, "%.0f rows"))
{
ImVec2 new_window_size = GetWindowSize();
new_window_size.x += (Rows - rows_backup) * (cell_width + glyph_width);
SetWindowSize(new_window_size);
}
PopAllowKeyboardFocus();
PopItemWidth();
SameLine();
Text("Range %0*x..%0*x", addr_digits_count, (int)base_display_addr, addr_digits_count, (int)base_display_addr+mem_size-1);
SameLine();
PushItemWidth(70);
if (InputText("##addr", AddrInput, 32, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue))
{
int goto_addr;
if (sscanf(AddrInput, "%X", &goto_addr) == 1)
{
goto_addr -= base_display_addr;
if (goto_addr >= 0 && goto_addr < mem_size)
{
BeginChild("##scrolling");
SetScrollFromPosY(GetCursorStartPos().y + (goto_addr / Rows) * GetTextLineHeight());
EndChild();
DataEditingAddr = goto_addr;
DataEditingTakeFocus = true;
}
}
}
PopItemWidth();
PopFont();
}
void MemoryEditor::Draw(const void* mem_data, int mem_size, int base_display_addr)
{
Draw(const_cast<void*>(mem_data), mem_size, base_display_addr);
}
} // namespace ImGui

View File

@ -1,3 +1,8 @@
// [ImGui] this is a slightly modified version of stb_truetype.h 1.8
// [ImGui] - fixed a crash bug in stb_textedit_discard_redo (#681)
// [ImGui] - fixed some minor warnings
// [ImGui] - added STB_TEXTEDIT_MOVEWORDLEFT/STB_TEXTEDIT_MOVEWORDRIGHT custom handler (#473)
// stb_textedit.h - v1.8 - public domain - Sean Barrett
// Development of this library was sponsored by RAD Game Tools
//
@ -148,15 +153,17 @@
// STB_TEXTEDIT_K_REDO keyboard input to perform redo
//
// Optional:
// STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode
// STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'),
// required for WORDLEFT/WORDRIGHT
// STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT
// STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT
// STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line
// STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line
// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text
// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text
// STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode
// STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'),
// required for default WORDLEFT/WORDRIGHT handlers
// STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to
// STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to
// STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT
// STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT
// STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line
// STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line
// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text
// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text
//
// Todo:
// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page
@ -615,9 +622,9 @@ static int is_word_boundary( STB_TEXTEDIT_STRING *_str, int _idx )
return _idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(_str,_idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(_str, _idx) ) ) : 1;
}
static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *_str, STB_TexteditState *_state )
#ifndef STB_TEXTEDIT_MOVEWORDLEFT
static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *_str, int c )
{
int c = _state->cursor - 1;
while( c >= 0 && !is_word_boundary( _str, c ) )
--c;
@ -626,11 +633,13 @@ static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *_str, STB_Te
return c;
}
#define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous
#endif
static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *_str, STB_TexteditState *_state )
#ifndef STB_TEXTEDIT_MOVEWORDRIGHT
static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *_str, int c )
{
const int len = STB_TEXTEDIT_STRINGLEN(_str);
int c = _state->cursor+1;
while( c < len && !is_word_boundary( _str, c ) )
++c;
@ -639,6 +648,9 @@ static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *_str, STB_Texted
return c;
}
#define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next
#endif
#endif
// update selection and cursor to match each other
@ -760,21 +772,12 @@ retry:
state->has_preferred_x = 0;
break;
#ifdef STB_TEXTEDIT_IS_SPACE
#ifdef STB_TEXTEDIT_MOVEWORDLEFT
case STB_TEXTEDIT_K_WORDLEFT:
if (STB_TEXT_HAS_SELECTION(state))
stb_textedit_move_to_first(state);
else {
state->cursor = stb_textedit_move_to_word_previous(str, state);
stb_textedit_clamp( str, state );
}
break;
case STB_TEXTEDIT_K_WORDRIGHT:
if (STB_TEXT_HAS_SELECTION(state))
stb_textedit_move_to_last(str, state);
else {
state->cursor = stb_textedit_move_to_word_next(str, state);
state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor-1);
stb_textedit_clamp( str, state );
}
break;
@ -783,17 +786,28 @@ retry:
if( !STB_TEXT_HAS_SELECTION( state ) )
stb_textedit_prep_selection_at_cursor(state);
state->cursor = stb_textedit_move_to_word_previous(str, state);
state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor-1);
state->select_end = state->cursor;
stb_textedit_clamp( str, state );
break;
#endif
#ifdef STB_TEXTEDIT_MOVEWORDRIGHT
case STB_TEXTEDIT_K_WORDRIGHT:
if (STB_TEXT_HAS_SELECTION(state))
stb_textedit_move_to_last(str, state);
else {
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor+1);
stb_textedit_clamp( str, state );
}
break;
case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT:
if( !STB_TEXT_HAS_SELECTION( state ) )
stb_textedit_prep_selection_at_cursor(state);
state->cursor = stb_textedit_move_to_word_next(str, state);
state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor+1);
state->select_end = state->cursor;
stb_textedit_clamp( str, state );
@ -1058,13 +1072,13 @@ static void stb_textedit_discard_undo(StbUndoState *state)
int n = state->undo_rec[0].insert_length, i;
// delete n characters from all other records
state->undo_char_point = state->undo_char_point - (short) n; // vsnet05
STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) ((size_t)state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE)));
for (i=0; i < state->undo_point; ++i)
if (state->undo_rec[i].char_storage >= 0)
state->undo_rec[i].char_storage = state->undo_rec[i].char_storage - (short) n; // vsnet05 // @OPTIMIZE: get rid of char_storage and infer it
}
--state->undo_point;
STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0])));
STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) ((size_t)state->undo_point*sizeof(state->undo_rec[0])));
}
}
@ -1082,13 +1096,13 @@ static void stb_textedit_discard_redo(StbUndoState *state)
int n = state->undo_rec[k].insert_length, i;
// delete n characters from all other records
state->redo_char_point = state->redo_char_point + (short) n; // vsnet05
STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
for (i=state->redo_point; i < k; ++i)
if (state->undo_rec[i].char_storage >= 0)
state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05
}
++state->redo_point;
STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point-1, state->undo_rec + state->redo_point, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point)*sizeof(state->undo_rec[0])));
}
}

View File

@ -8031,7 +8031,7 @@ bool hufBuildDecTable(const long long *hcode, // i : encoding table
HufDec *pl = hdecod + (c << (HUF_DECBITS - l));
for (long long i = 1 << (HUF_DECBITS - l); i > 0; i--, pl++) {
for (long long i = (long long)1 << (HUF_DECBITS - l); i > 0; i--, pl++) {
if (pl->len || pl->p) {
//
// Error: a short code or a long code has

View File

@ -63,7 +63,7 @@ int _main_(int _argc, char** _argv)
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx_frame();
bgfx_frame(false);
}
// Shutdown bgfx.

View File

@ -14,12 +14,21 @@ namespace stl = tinystl;
#include <bgfx/bgfx.h>
#include <bx/commandline.h>
#include <bx/endian.h>
#include <bx/fpumath.h>
#include <bx/readerwriter.h>
#include <bx/string.h>
#include "entry/entry.h"
#include <ib-compress/indexbufferdecompression.h>
#define LODEPNG_NO_COMPILE_ENCODER
#define LODEPNG_NO_COMPILE_DISK
#define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS
#define LODEPNG_NO_COMPILE_ERROR_TEXT
#define LODEPNG_NO_COMPILE_ALLOCATORS
#define LODEPNG_NO_COMPILE_CPP
#include <lodepng/lodepng.h>
#include "bgfx_utils.h"
void* load(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _filePath, uint32_t* _size)
@ -154,7 +163,9 @@ bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName)
}
typedef unsigned char stbi_uc;
extern "C" stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
extern "C" stbi_uc* stbi_load_from_memory(stbi_uc const* _buffer, int _len, int* _x, int* _y, int* _comp, int _req_comp);
extern "C" void stbi_image_free(void* _ptr);
extern void lodepng_free(void* _ptr);
bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info)
{
@ -180,24 +191,125 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath,
void* data = loadMem(_reader, allocator, _filePath, &size);
if (NULL != data)
{
int width = 0;
int height = 0;
int comp = 0;
bgfx::TextureFormat::Enum format = bgfx::TextureFormat::RGBA8;
uint32_t bpp = 32;
uint8_t* img = NULL;
img = stbi_load_from_memory( (uint8_t*)data, size, &width, &height, &comp, 4);
uint32_t width = 0;
uint32_t height = 0;
typedef void (*ReleaseFn)(void* _ptr);
ReleaseFn release = stbi_image_free;
uint8_t* out = NULL;
static uint8_t pngMagic[] = { 0x89, 0x50, 0x4E, 0x47, 0x0d, 0x0a };
if (0 == memcmp(data, pngMagic, sizeof(pngMagic) ) )
{
release = lodepng_free;
unsigned error;
LodePNGState state;
lodepng_state_init(&state);
state.decoder.color_convert = 0;
error = lodepng_decode(&out, &width, &height, &state, (uint8_t*)data, size);
if (0 == error)
{
switch (state.info_raw.bitdepth)
{
case 8:
switch (state.info_raw.colortype)
{
case LCT_GREY:
format = bgfx::TextureFormat::R8;
bpp = 8;
break;
case LCT_GREY_ALPHA:
format = bgfx::TextureFormat::RG8;
bpp = 16;
break;
case LCT_RGB:
format = bgfx::TextureFormat::RGB8;
bpp = 24;
break;
case LCT_RGBA:
format = bgfx::TextureFormat::RGBA8;
bpp = 32;
break;
case LCT_PALETTE:
break;
}
break;
case 16:
switch (state.info_raw.colortype)
{
case LCT_GREY:
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
{
uint16_t* rgba = (uint16_t*)out + ii*4;
rgba[0] = bx::toHostEndian(rgba[0], false);
}
format = bgfx::TextureFormat::R16;
bpp = 16;
break;
case LCT_GREY_ALPHA:
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
{
uint16_t* rgba = (uint16_t*)out + ii*4;
rgba[0] = bx::toHostEndian(rgba[0], false);
rgba[1] = bx::toHostEndian(rgba[1], false);
}
format = bgfx::TextureFormat::R16;
bpp = 16;
break;
case LCT_RGBA:
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
{
uint16_t* rgba = (uint16_t*)out + ii*4;
rgba[0] = bx::toHostEndian(rgba[0], false);
rgba[1] = bx::toHostEndian(rgba[1], false);
rgba[2] = bx::toHostEndian(rgba[2], false);
rgba[3] = bx::toHostEndian(rgba[3], false);
}
format = bgfx::TextureFormat::RGBA16;
bpp = 64;
break;
case LCT_RGB:
case LCT_PALETTE:
break;
}
break;
default:
break;
}
}
lodepng_state_cleanup(&state);
}
else
{
int comp = 0;
out = stbi_load_from_memory( (uint8_t*)data, size, (int*)&width, (int*)&height, &comp, 4);
}
BX_FREE(allocator, data);
if (NULL != img)
if (NULL != out)
{
handle = bgfx::createTexture2D(uint16_t(width), uint16_t(height), 1
, bgfx::TextureFormat::RGBA8
, format
, _flags
, bgfx::copy(img, width*height*4)
, bgfx::copy(out, width*height*bpp/8)
);
free(img);
release(out);
if (NULL != _info)
{
@ -207,7 +319,7 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath,
, 0
, false
, 1
, bgfx::TextureFormat::RGBA8
, format
);
}
}

View File

@ -279,26 +279,7 @@ void calcMinBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _num
void calcPlaneUv(const Plane& _plane, float* _udir, float* _vdir)
{
const float nx = _plane.m_normal[0];
const float ny = _plane.m_normal[1];
const float nz = _plane.m_normal[2];
if (bx::fabsolute(nx) > bx::fabsolute(nz) )
{
float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz);
_udir[0] = -nz * invLen;
_udir[1] = 0.0f;
_udir[2] = nx * invLen;
}
else
{
float invLen = 1.0f / bx::fsqrt(ny*ny + nz*nz);
_udir[0] = 0.0f;
_udir[1] = nz * invLen;
_udir[2] = -ny * invLen;
}
bx::vec3Cross(_vdir, _plane.m_normal, _udir);
bx::vec3TangentFrame(_plane.m_normal, _udir, _vdir);
}
void buildFrustumPlanes(Plane* _result, const float* _viewProj)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@
#include "fs_imgui_image_swizz.bin.h"
// embedded font
#include "droidsans.ttf.h"
#include "roboto_regular.ttf.h"
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4244); // warning C4244: '=' : conversion from '' to '', possible loss of data
@ -451,7 +451,7 @@ struct Imgui
return bgfx::createTexture2D(uint16_t(_width), uint16_t(_height), 0, bgfx::TextureFormat::BGRA8, 0, mem);
}
ImguiFontHandle create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
ImguiFontHandle create(float _fontSize, bx::AllocatorI* _allocator)
{
m_allocator = _allocator;
@ -463,16 +463,10 @@ struct Imgui
}
#endif // BX_CONFIG_ALLOCATOR_CRT
if (NULL == _data)
{
_data = s_droidSansTtf;
_size = sizeof(s_droidSansTtf);
}
IMGUI_create(_data, _size, _fontSize, m_allocator);
IMGUI_create(_fontSize, m_allocator);
m_nvg = nvgCreate(1, m_view, m_allocator);
nvgCreateFontMem(m_nvg, "default", (unsigned char*)_data, INT32_MAX, 0);
nvgCreateFontMem(m_nvg, "default", (unsigned char*)s_robotoRegularTtf, INT32_MAX, 0);
nvgFontSize(m_nvg, _fontSize);
nvgFontFace(m_nvg, "default");
@ -606,7 +600,7 @@ struct Imgui
m_missingTexture = genMissingTexture(256, 256, 0.04f);
#if !USE_NANOVG_FONT
const ImguiFontHandle handle = createFont(_data, _fontSize);
const ImguiFontHandle handle = createFont(s_robotoRegularTtf, _fontSize);
m_currentFontIdx = handle.idx;
#else
const ImguiFontHandle handle = { bgfx::invalidHandle };
@ -879,7 +873,10 @@ struct Imgui
bgfx::setViewRect(_view, 0, 0, _width, _height);
}
updateInput(mx, my, _button, _scroll, _inputChar);
if (!ImGui::IsMouseHoveringAnyWindow() )
{
updateInput(mx, my, _button, _scroll, _inputChar);
}
m_hot = m_hotToBe;
m_hotToBe = 0;
@ -3262,9 +3259,9 @@ void imguiFree(void* _ptr, void*)
BX_FREE(s_imgui.m_allocator, _ptr);
}
ImguiFontHandle imguiCreate(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
ImguiFontHandle imguiCreate(const void*, uint32_t, float _fontSize, bx::AllocatorI* _allocator)
{
return s_imgui.create(_data, _size, _fontSize, _allocator);
return s_imgui.create(_fontSize, _allocator);
}
void imguiDestroy()
@ -3573,7 +3570,10 @@ float imguiGetTextLength(const char* _text, ImguiFontHandle _handle)
bool imguiMouseOverArea()
{
return s_imgui.m_insideArea;
return s_imgui.m_insideArea
|| ImGui::IsAnyItemHovered()
|| ImGui::IsMouseHoveringAnyWindow()
;
}
bgfx::ProgramHandle imguiGetImageProgram(uint8_t _mip)

View File

@ -29,6 +29,8 @@
#include <bgfx/bgfx.h>
#include <ocornut-imgui/imgui.h>
#include <ocornut-imgui/imgui_wm.h>
#include <iconfontheaders/icons_kenney.h>
#include <iconfontheaders/icons_font_awesome.h>
#define IMGUI_MBUT_LEFT 0x01
#define IMGUI_MBUT_RIGHT 0x02
@ -131,13 +133,13 @@ inline uint32_t imguiRGBA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255)
BGFX_HANDLE(ImguiFontHandle);
ImguiFontHandle imguiCreateFont(const void* _data, float _fontSize=15.0f);
ImguiFontHandle imguiCreateFont(const void* _data, float _fontSize = 18.0f);
void imguiSetFont(ImguiFontHandle _handle);
ImguiFontHandle imguiGetCurrentFont();
namespace bx { struct AllocatorI; }
ImguiFontHandle imguiCreate(const void* _data = NULL, uint32_t _size = 0, float _fontSize = 15.0f, bx::AllocatorI* _allocator = NULL);
ImguiFontHandle imguiCreate(const void* _data = NULL, uint32_t _size = 0, float _fontSize = 18.0f, bx::AllocatorI* _allocator = NULL);
void imguiDestroy();
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar = 0, uint8_t _view = 255);

View File

@ -8,5 +8,23 @@ include ../../../scripts/shader-embeded.mk
droidsans.ttf.h: ../../runtime/font/droidsans.ttf
@bin2c -f $(<) -o $(@) -n s_droidSansTtf
rebuild: droidsans.ttf.h
roboto_regular.ttf.h: ../../runtime/font/roboto-regular.ttf
@bin2c -f $(<) -o $(@) -n s_robotoRegularTtf
robotomono_regular.ttf.h: ../../runtime/font/robotomono-regular.ttf
@bin2c -f $(<) -o $(@) -n s_robotoMonoRegularTtf
icons_font_awesome.ttf.h: ../../runtime/font/fontawesome-webfont.ttf
@bin2c -f $(<) -o $(@) -n s_iconsFontAwesomeTtf
icons_kenney.ttf.h: ../../runtime/font/kenney-icon-font.ttf
@bin2c -f $(<) -o $(@) -n s_iconsKenneyTtf
fonts: droidsans.ttf.h \
roboto_regular.ttf.h \
robotomono_regular.ttf.h \
icons_font_awesome.ttf.h \
icons_kenney.ttf.h
rebuild: fonts
@make -s --no-print-directory clean all

View File

@ -11,7 +11,6 @@
#include <ocornut-imgui/imgui_wm.h>
#include "imgui.h"
#include "ocornut_imgui.h"
#include <stb/stb_image.c>
#ifndef USE_ENTRY
# if defined(SCI_NAMESPACE)
@ -33,6 +32,24 @@
#include "vs_ocornut_imgui.bin.h"
#include "fs_ocornut_imgui.bin.h"
#include "roboto_regular.ttf.h"
#include "robotomono_regular.ttf.h"
#include "icons_kenney.ttf.h"
#include "icons_font_awesome.ttf.h"
struct FontRangeMerge
{
const void* data;
size_t size;
ImWchar ranges[3];
};
static FontRangeMerge s_fontRangeMerge[] =
{
{ s_iconsKenneyTtf, sizeof(s_iconsKenneyTtf), { ICON_MIN_KI, ICON_MAX_KI, 0 } },
{ s_iconsFontAwesomeTtf, sizeof(s_iconsFontAwesomeTtf), { ICON_MIN_FA, ICON_MAX_FA, 0 } },
};
class PlatformWindow : public ImGuiWM::PlatformWindow
{
typedef ImGuiWM::PlatformWindow Super;
@ -345,7 +362,7 @@ struct OcornutImguiContext
}
}
void create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
void create(float _fontSize, bx::AllocatorI* _allocator)
{
m_viewId = 255;
m_allocator = _allocator;
@ -430,9 +447,28 @@ struct OcornutImguiContext
int32_t width;
int32_t height;
{
void* font = ImGui::MemAlloc(_size);
memcpy(font, _data, _size);
io.Fonts->AddFontFromMemoryTTF(font, _size, _fontSize);
ImFontConfig config;
config.FontDataOwnedByAtlas = false;
config.MergeMode = false;
// config.MergeGlyphCenterV = true;
m_font[ImGui::Font::Regular] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoRegularTtf, sizeof(s_robotoRegularTtf), _fontSize, &config);
m_font[ImGui::Font::Mono ] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoMonoRegularTtf, sizeof(s_robotoMonoRegularTtf), _fontSize-3.0f, &config);
config.MergeMode = true;
config.DstFont = m_font[ImGui::Font::Regular];
for (uint32_t ii = 0; ii < BX_COUNTOF(s_fontRangeMerge); ++ii)
{
const FontRangeMerge& frm = s_fontRangeMerge[ii];
io.Fonts->AddFontFromMemoryTTF( (void*)frm.data
, (int)frm.size
, _fontSize-3.0f
, &config
, frm.ranges
);
}
}
io.Fonts->GetTexDataAsRGBA32(&data, &width, &height);
@ -445,9 +481,6 @@ struct OcornutImguiContext
, bgfx::copy(data, width*height*4)
);
ImGuiStyle& style = ImGui::GetStyle();
style.FrameRounding = 4.0f;
m_wm = BX_NEW(m_allocator, WindowManager);
m_wm->Init();
@ -517,6 +550,8 @@ struct OcornutImguiContext
// https://gist.github.com/dougbinks/8089b4bbaccaaf6fa204236978d165a9
ImGuiStyle& style = ImGui::GetStyle();
style.FrameRounding = 4.0f;
// light style from Pacome Danhiez (user itamago)
// https://github.com/ocornut/imgui/pull/511#issuecomment-175719267
style.Colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
@ -624,9 +659,24 @@ struct OcornutImguiContext
#endif // 0
#if 0
extern void ShowExampleAppCustomNodeGraph(bool* opened);
bool opened = true;
ShowExampleAppCustomNodeGraph(&opened);
{
static ImGui::MemoryEditor me;
bool open = true;
if (ImGui::Begin("HexII", &open))
{
me.Draw(s_iconsKenneyTtf, sizeof(s_iconsKenneyTtf) );
ImGui::End();
}
}
#endif // 0
#if 0
{
extern void ShowExampleAppCustomNodeGraph(bool* opened);
bool opened = true;
ShowExampleAppCustomNodeGraph(&opened);
}
#endif // 0
}
@ -642,6 +692,7 @@ struct OcornutImguiContext
bgfx::ProgramHandle m_program;
bgfx::TextureHandle m_texture;
bgfx::UniformHandle s_tex;
ImFont* m_font[ImGui::Font::Count];
WindowManager* m_wm;
int64_t m_last;
int32_t m_lastScroll;
@ -765,9 +816,9 @@ void OcornutImguiContext::renderDrawLists(ImDrawData* _drawData)
s_ctx.render(_drawData);
}
void IMGUI_create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
void IMGUI_create(float _fontSize, bx::AllocatorI* _allocator)
{
s_ctx.create(_data, _size, _fontSize, _allocator);
s_ctx.create(_fontSize, _allocator);
}
void IMGUI_destroy()
@ -784,3 +835,11 @@ void IMGUI_endFrame()
{
s_ctx.endFrame();
}
namespace ImGui
{
void PushFont(Font::Enum _font)
{
PushFont(s_ctx.m_font[_font]);
}
} // namespace ImGui

View File

@ -10,7 +10,7 @@
namespace bx { struct AllocatorI; }
void IMGUI_create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator);
void IMGUI_create(float _fontSize, bx::AllocatorI* _allocator);
void IMGUI_destroy();
void IMGUI_beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId);
void IMGUI_endFrame();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -34,10 +34,39 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Wunused-result");
#include "fontstash.h"
BX_PRAGMA_DIAGNOSTIC_POP();
BX_PRAGMA_DIAGNOSTIC_PUSH();
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4127) // warning C4127: conditional expression is constant
#define LODEPNG_NO_COMPILE_ENCODER
#define LODEPNG_NO_COMPILE_DISK
#define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS
#define LODEPNG_NO_COMPILE_ERROR_TEXT
#define LODEPNG_NO_COMPILE_ALLOCATORS
#define LODEPNG_NO_COMPILE_CPP
#include <lodepng/lodepng.cpp>
BX_PRAGMA_DIAGNOSTIC_POP();
void* lodepng_malloc(size_t _size)
{
return ::malloc(_size);
}
void* lodepng_realloc(void* _ptr, size_t _size)
{
return ::realloc(_ptr, _size);
}
void lodepng_free(void* _ptr)
{
::free(_ptr);
}
BX_PRAGMA_DIAGNOSTIC_PUSH();
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wmissing-field-initializers");
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wshadow");
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wint-to-pointer-cast")
#define STBI_MALLOC(_size) lodepng_malloc(_size)
#define STBI_REALLOC(_ptr, _size) lodepng_realloc(_ptr, _size)
#define STBI_FREE(_ptr) lodepng_free(_ptr)
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.c>
BX_PRAGMA_DIAGNOSTIC_POP();

Binary file not shown.

Binary file not shown.

View File

@ -938,13 +938,15 @@ namespace bgfx
/// just swaps internal buffers, kicks render thread, and returns. In
/// singlethreaded renderer this call does frame rendering.
///
/// @param[in] _capture Capture frame with graphics debugger.
///
/// @returns Current frame number. This might be used in conjunction with
/// double/multi buffering data outside the library and passing it to
/// library via `bgfx::makeRef` calls.
///
/// @attention C99 equivalent is `bgfx_frame`.
///
uint32_t frame();
uint32_t frame(bool _capture = false);
/// Returns current renderer backend API type.
///
@ -1671,11 +1673,13 @@ namespace bgfx
/// @param[in] _handle Texture handle.
/// @param[in] _data Destination buffer.
///
/// @returns Frame number when the result will be available. See: `bgfx::frame`.
///
/// @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
/// @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
/// @attention C99 equivalent is `bgfx_read_texture`.
///
void readTexture(TextureHandle _handle, void* _data);
uint32_t readTexture(TextureHandle _handle, void* _data);
/// Read back texture content.
///
@ -1683,11 +1687,13 @@ namespace bgfx
/// @param[in] _attachment Frame buffer attachment index.
/// @param[in] _data Destination buffer.
///
/// @returns Frame number when the result will be available. See: `bgfx::frame`.
///
/// @attention Texture must be created with `BGFX_TEXTURE_READ_BACK` flag.
/// @attention Availability depends on: `BGFX_CAPS_TEXTURE_READ_BACK`.
/// @attention C99 equivalent is `bgfx_read_frame_buffer`.
///
void readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data);
uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data);
/// Destroy texture.
///
@ -1709,6 +1715,8 @@ namespace bgfx
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
/// sampling.
///
/// @returns Handle to frame buffer object.
///
/// @attention C99 equivalent is `bgfx_create_frame_buffer`.
///
FrameBufferHandle createFrameBuffer(
@ -1731,6 +1739,8 @@ namespace bgfx
/// - `BGFX_TEXTURE_[MIN/MAG/MIP]_[POINT/ANISOTROPIC]` - Point or anisotropic
/// sampling.
///
/// @returns Handle to frame buffer object.
///
/// @attention C99 equivalent is `bgfx_create_frame_buffer_scaled`.
///
FrameBufferHandle createFrameBuffer(
@ -1746,6 +1756,8 @@ namespace bgfx
/// @param[in] _destroyTextures If true, textures will be destroyed when
/// frame buffer is destroyed.
///
/// @returns Handle to frame buffer object.
///
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
///
FrameBufferHandle createFrameBuffer(
@ -1761,6 +1773,8 @@ namespace bgfx
/// @param[in] _destroyTextures If true, textures will be destroyed when
/// frame buffer is destroyed.
///
/// @returns Handle to frame buffer object.
///
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
///
FrameBufferHandle createFrameBuffer(

View File

@ -6,7 +6,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_API_VERSION UINT32_C(14)
#define BGFX_API_VERSION UINT32_C(16)
///
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.

View File

@ -238,11 +238,11 @@ typedef enum bgfx_topology_convert
#define BGFX_HANDLE_T(_name) \
typedef struct _name { uint16_t idx; } _name##_t
BGFX_HANDLE_T(bgfx_indirect_buffer_handle);
BGFX_HANDLE_T(bgfx_dynamic_index_buffer_handle);
BGFX_HANDLE_T(bgfx_dynamic_vertex_buffer_handle);
BGFX_HANDLE_T(bgfx_frame_buffer_handle);
BGFX_HANDLE_T(bgfx_index_buffer_handle);
BGFX_HANDLE_T(bgfx_indirect_buffer_handle);
BGFX_HANDLE_T(bgfx_occlusion_query_handle);
BGFX_HANDLE_T(bgfx_program_handle);
BGFX_HANDLE_T(bgfx_shader_handle);
@ -505,7 +505,7 @@ BGFX_C_API void bgfx_shutdown();
BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags);
/**/
BGFX_C_API uint32_t bgfx_frame();
BGFX_C_API uint32_t bgfx_frame(bool _capture);
/**/
BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type();
@ -655,10 +655,10 @@ BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _m
BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch);
/**/
BGFX_C_API void bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data);
BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data);
/**/
BGFX_C_API void bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data);
BGFX_C_API uint32_t bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data);
/**/
BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle);

View File

@ -85,7 +85,7 @@ typedef struct bgfx_interface_vtbl
bool (*init)(bgfx_renderer_type_t _type, uint16_t _vendorId, uint16_t _deviceId, bgfx_callback_interface_t* _callback, bgfx_allocator_interface_t* _allocator);
void (*shutdown)();
void (*reset)(uint32_t _width, uint32_t _height, uint32_t _flags);
uint32_t (*frame)();
uint32_t (*frame)(bool _capture);
bgfx_renderer_type_t (*get_renderer_type)();
const bgfx_caps_t* (*get_caps)();
const bgfx_hmd_t* (*get_hmd)();

View File

@ -1471,7 +1471,7 @@ namespace bgfx
}
}
uint32_t Context::frame()
uint32_t Context::frame(bool _capture)
{
BX_CHECK(0 == m_instBufferCount, "Instance buffer allocated, but not used. This is incorrect, and causes memory leak.");
@ -1480,6 +1480,8 @@ namespace bgfx
m_occlusionQuerySet.clear();
}
m_submit->m_capture = _capture;
BGFX_PROFILER_SCOPE(bgfx, main_thread_frame, 0xff2040ff);
// wait for render thread to finish
renderSemWait();
@ -2510,10 +2512,10 @@ namespace bgfx
s_ctx->reset(_width, _height, _flags);
}
uint32_t frame()
uint32_t frame(bool _capture)
{
BGFX_CHECK_MAIN_THREAD();
return s_ctx->frame();
return s_ctx->frame(_capture);
}
const Caps* getCaps()
@ -3114,20 +3116,20 @@ namespace bgfx
}
}
void readTexture(TextureHandle _handle, void* _data)
uint32_t readTexture(TextureHandle _handle, void* _data)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _data, "_data can't be NULL");
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_READ_BACK, "Texture read-back is not supported!");
s_ctx->readTexture(_handle, _data);
return s_ctx->readTexture(_handle, _data);
}
void readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data)
uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _data, "_data can't be NULL");
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_READ_BACK, "Texture read-back is not supported!");
s_ctx->readTexture(_handle, _attachment, _data);
return s_ctx->readTexture(_handle, _attachment, _data);
}
FrameBufferHandle createFrameBuffer(uint16_t _width, uint16_t _height, TextureFormat::Enum _format, uint32_t _textureFlags)
@ -3859,9 +3861,9 @@ BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags)
bgfx::reset(_width, _height, _flags);
}
BGFX_C_API uint32_t bgfx_frame()
BGFX_C_API uint32_t bgfx_frame(bool _capture)
{
return bgfx::frame();
return bgfx::frame(_capture);
}
BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type()
@ -4167,16 +4169,16 @@ BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t
bgfx::updateTextureCube(handle.cpp, _side, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch);
}
BGFX_C_API void bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data)
BGFX_C_API uint32_t bgfx_read_texture(bgfx_texture_handle_t _handle, void* _data)
{
union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
bgfx::readTexture(handle.cpp, _data);
return bgfx::readTexture(handle.cpp, _data);
}
BGFX_C_API void bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data)
BGFX_C_API uint32_t bgfx_read_frame_buffer(bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, void* _data)
{
union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle };
bgfx::readTexture(handle.cpp, _attachment, _data);
return bgfx::readTexture(handle.cpp, _attachment, _data);
}
BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle)

View File

@ -1375,6 +1375,8 @@ namespace bgfx
, m_waitSubmit(0)
, m_waitRender(0)
, m_hmdInitialized(false)
, m_capture(false)
, m_discard(false)
{
SortKey term;
term.reset();
@ -1428,6 +1430,7 @@ namespace bgfx
m_cmdPre.start();
m_cmdPost.start();
m_uniformBuffer->reset();
m_capture = false;
m_discard = false;
}
@ -1836,6 +1839,7 @@ namespace bgfx
int64_t m_waitRender;
bool m_hmdInitialized;
bool m_capture;
bool m_discard;
};
@ -3125,20 +3129,21 @@ namespace bgfx
textureDecRef(_handle);
}
BGFX_API_FUNC(void readTexture(TextureHandle _handle, void* _data) )
BGFX_API_FUNC(uint32_t readTexture(TextureHandle _handle, void* _data) )
{
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::ReadTexture);
cmdbuf.write(_handle);
cmdbuf.write(_data);
return m_frames + 2;
}
BGFX_API_FUNC(void readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data) )
BGFX_API_FUNC(uint32_t readTexture(FrameBufferHandle _handle, uint8_t _attachment, void* _data) )
{
const FrameBufferRef& ref = m_frameBufferRef[_handle.idx];
BX_CHECK(!ref.m_window, "Can't sample window frame buffer.");
TextureHandle textureHandle = ref.un.m_th[_attachment];
BX_CHECK(isValid(textureHandle), "Frame buffer texture %d is invalid.", _attachment);
readTexture(textureHandle, _data);
return readTexture(textureHandle, _data);
}
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height)
@ -3865,7 +3870,7 @@ namespace bgfx
blit(_id, _dst, _dstMip, _dstX, _dstY, _dstZ, textureHandle, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
}
BGFX_API_FUNC(uint32_t frame() );
BGFX_API_FUNC(uint32_t frame(bool _capture = false) );
void dumpViewStats();
void freeDynamicBuffers();

View File

@ -56,7 +56,7 @@ namespace bgfx
}
pRENDERDOC_GetAPI RENDERDOC_GetAPI;
static RENDERDOC_API_1_0_0* s_renderDoc;
static RENDERDOC_API_1_0_1* s_renderDoc;
void* loadRenderDoc()
{
@ -105,6 +105,14 @@ namespace bgfx
}
}
void renderDocTriggerCapture()
{
if (NULL != s_renderDoc)
{
s_renderDoc->TriggerCapture();
}
}
} // namespace bgfx
#else
@ -121,6 +129,10 @@ namespace bgfx
{
}
void renderDocTriggerCapture()
{
}
} // namespace bgfx
#endif // BGFX_CONFIG_DEBUG_PIX && (BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX)

View File

@ -10,6 +10,7 @@ namespace bgfx
{
void* loadRenderDoc();
void unloadRenderDoc(void*);
void renderDocTriggerCapture();
} // namespace bgfx

View File

@ -123,7 +123,7 @@ EGL_IMPORT
~SwapChainGL()
{
eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(m_display, m_context);
eglDestroySurface(m_display, m_surface);
}
@ -324,7 +324,7 @@ EGL_IMPORT
{
if (NULL != m_display)
{
eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(m_display, m_context);
eglDestroySurface(m_display, m_surface);
eglTerminate(m_display);
@ -344,7 +344,7 @@ EGL_IMPORT
if (NULL != m_display)
{
EGLNativeWindowType nwh = (EGLNativeWindowType )g_platformData.nwh;
eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroySurface(m_display, m_surface);
m_surface = eglCreateWindowSurface(m_display, m_config, nwh, NULL);
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");

View File

@ -10,92 +10,93 @@ namespace bgfx
{
static const ImageBlockInfo s_imageBlockInfo[] =
{
// +------------------------------- bits per pixel
// | +---------------------------- block width
// | | +------------------------- block height
// | | | +--------------------- block size
// | | | | +------------------ min blocks x
// | | | | | +--------------- min blocks y
// | | | | | | +----------- depth bits
// | | | | | | | +-------- stencil bits
// | | | | | | | | +----- encoding type
// | | | | | | | | |
{ 4, 4, 4, 8, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BC1
{ 8, 4, 4, 16, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BC2
{ 8, 4, 4, 16, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BC3
{ 4, 4, 4, 8, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BC4
{ 8, 4, 4, 16, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BC5
{ 8, 4, 4, 16, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BC6H
{ 8, 4, 4, 16, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BC7
{ 4, 4, 4, 8, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC1
{ 4, 4, 4, 8, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2
{ 8, 4, 4, 16, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2A
{ 4, 4, 4, 8, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2A1
{ 2, 8, 4, 8, 2, 2, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC12
{ 4, 4, 4, 8, 2, 2, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC14
{ 2, 8, 4, 8, 2, 2, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC12A
{ 4, 4, 4, 8, 2, 2, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC14A
{ 2, 8, 4, 8, 2, 2, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC22
{ 4, 4, 4, 8, 2, 2, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC24
{ 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Count) }, // Unknown
{ 1, 8, 1, 1, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // R1
{ 8, 1, 1, 1, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // A8
{ 8, 1, 1, 1, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // R8
{ 8, 1, 1, 1, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // R8I
{ 8, 1, 1, 1, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // R8U
{ 8, 1, 1, 1, 1, 1, 0, 0, uint8_t(EncodingType::Snorm) }, // R8S
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // R16
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // R16I
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // R16U
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Float) }, // R16F
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Snorm) }, // R16S
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // R32I
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // R32U
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Float) }, // R32F
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RG8
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // RG8I
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // RG8U
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Snorm) }, // RG8S
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RG16
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // RG16I
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // RG16U
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Float) }, // RG16F
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Snorm) }, // RG16S
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // RG32I
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // RG32U
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Float) }, // RG32F
{ 24, 1, 1, 3, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RGB8
{ 24, 1, 1, 3, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // RGB8I
{ 24, 1, 1, 3, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // RGB8U
{ 24, 1, 1, 3, 1, 1, 0, 0, uint8_t(EncodingType::Snorm) }, // RGB8S
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Float) }, // RGB9E5F
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // BGRA8
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RGBA8
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // RGBA8I
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // RGBA8U
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Snorm) }, // RGBA8S
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RGBA16
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // RGBA16I
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // RGBA16U
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Float) }, // RGBA16F
{ 64, 1, 1, 8, 1, 1, 0, 0, uint8_t(EncodingType::Snorm) }, // RGBA16S
{ 128, 1, 1, 16, 1, 1, 0, 0, uint8_t(EncodingType::Int ) }, // RGBA32I
{ 128, 1, 1, 16, 1, 1, 0, 0, uint8_t(EncodingType::Uint ) }, // RGBA32U
{ 128, 1, 1, 16, 1, 1, 0, 0, uint8_t(EncodingType::Float) }, // RGBA32F
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // R5G6B5
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RGBA4
{ 16, 1, 1, 2, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RGB5A1
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // RGB10A2
{ 32, 1, 1, 4, 1, 1, 0, 0, uint8_t(EncodingType::Unorm) }, // R11G11B10F
{ 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Count) }, // UnknownDepth
{ 16, 1, 1, 2, 1, 1, 16, 0, uint8_t(EncodingType::Unorm) }, // D16
{ 24, 1, 1, 3, 1, 1, 24, 0, uint8_t(EncodingType::Unorm) }, // D24
{ 32, 1, 1, 4, 1, 1, 24, 8, uint8_t(EncodingType::Unorm) }, // D24S8
{ 32, 1, 1, 4, 1, 1, 32, 0, uint8_t(EncodingType::Unorm) }, // D32
{ 16, 1, 1, 2, 1, 1, 16, 0, uint8_t(EncodingType::Unorm) }, // D16F
{ 24, 1, 1, 3, 1, 1, 24, 0, uint8_t(EncodingType::Unorm) }, // D24F
{ 32, 1, 1, 4, 1, 1, 32, 0, uint8_t(EncodingType::Unorm) }, // D32F
{ 8, 1, 1, 1, 1, 1, 0, 8, uint8_t(EncodingType::Unorm) }, // D0S8
// +-------------------------------------------- bits per pixel
// | +----------------------------------------- block width
// | | +-------------------------------------- block height
// | | | +---------------------------------- block size
// | | | | +------------------------------- min blocks x
// | | | | | +---------------------------- min blocks y
// | | | | | | +------------------------ depth bits
// | | | | | | | +--------------------- stencil bits
// | | | | | | | | +---+---+---+----- r, g, b, a bits
// | | | | | | | | r g b a +-- encoding type
// | | | | | | | | | | | | |
{ 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC1
{ 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC2
{ 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC3
{ 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC4
{ 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC5
{ 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC6H
{ 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // BC7
{ 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC1
{ 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2
{ 8, 4, 4, 16, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2A
{ 4, 4, 4, 8, 1, 1, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // ETC2A1
{ 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC12
{ 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC14
{ 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC12A
{ 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC14A
{ 2, 8, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC22
{ 4, 4, 4, 8, 2, 2, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // PTC24
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Count) }, // Unknown
{ 1, 8, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // R1
{ 8, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 8, uint8_t(EncodingType::Unorm) }, // A8
{ 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // R8
{ 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Int ) }, // R8I
{ 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Uint ) }, // R8U
{ 8, 1, 1, 1, 1, 1, 0, 0, 8, 0, 0, 0, uint8_t(EncodingType::Snorm) }, // R8S
{ 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // R16
{ 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Int ) }, // R16I
{ 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Uint ) }, // R16U
{ 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Float) }, // R16F
{ 16, 1, 1, 2, 1, 1, 0, 0, 16, 0, 0, 0, uint8_t(EncodingType::Snorm) }, // R16S
{ 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(EncodingType::Int ) }, // R32I
{ 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(EncodingType::Uint ) }, // R32U
{ 32, 1, 1, 4, 1, 1, 0, 0, 32, 0, 0, 0, uint8_t(EncodingType::Float) }, // R32F
{ 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Unorm) }, // RG8
{ 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Int ) }, // RG8I
{ 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Uint ) }, // RG8U
{ 16, 1, 1, 2, 1, 1, 0, 0, 8, 8, 0, 0, uint8_t(EncodingType::Snorm) }, // RG8S
{ 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Unorm) }, // RG16
{ 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Int ) }, // RG16I
{ 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Uint ) }, // RG16U
{ 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Float) }, // RG16F
{ 32, 1, 1, 4, 1, 1, 0, 0, 16, 16, 0, 0, uint8_t(EncodingType::Snorm) }, // RG16S
{ 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(EncodingType::Int ) }, // RG32I
{ 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(EncodingType::Uint ) }, // RG32U
{ 64, 1, 1, 8, 1, 1, 0, 0, 32, 32, 0, 0, uint8_t(EncodingType::Float) }, // RG32F
{ 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Unorm) }, // RGB8
{ 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Int ) }, // RGB8I
{ 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Uint ) }, // RGB8U
{ 24, 1, 1, 3, 1, 1, 0, 0, 8, 8, 8, 0, uint8_t(EncodingType::Snorm) }, // RGB8S
{ 32, 1, 1, 4, 1, 1, 0, 0, 9, 9, 9, 5, uint8_t(EncodingType::Float) }, // RGB9E5F
{ 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Unorm) }, // BGRA8
{ 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Unorm) }, // RGBA8
{ 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Int ) }, // RGBA8I
{ 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Uint ) }, // RGBA8U
{ 32, 1, 1, 4, 1, 1, 0, 0, 8, 8, 8, 8, uint8_t(EncodingType::Snorm) }, // RGBA8S
{ 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Unorm) }, // RGBA16
{ 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Int ) }, // RGBA16I
{ 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Uint ) }, // RGBA16U
{ 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Float) }, // RGBA16F
{ 64, 1, 1, 8, 1, 1, 0, 0, 16, 16, 16, 16, uint8_t(EncodingType::Snorm) }, // RGBA16S
{ 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(EncodingType::Int ) }, // RGBA32I
{ 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(EncodingType::Uint ) }, // RGBA32U
{ 128, 1, 1, 16, 1, 1, 0, 0, 32, 32, 32, 32, uint8_t(EncodingType::Float) }, // RGBA32F
{ 16, 1, 1, 2, 1, 1, 0, 0, 5, 6, 5, 0, uint8_t(EncodingType::Unorm) }, // R5G6B5
{ 16, 1, 1, 2, 1, 1, 0, 0, 4, 4, 4, 4, uint8_t(EncodingType::Unorm) }, // RGBA4
{ 16, 1, 1, 2, 1, 1, 0, 0, 5, 5, 5, 1, uint8_t(EncodingType::Unorm) }, // RGB5A1
{ 32, 1, 1, 4, 1, 1, 0, 0, 10, 10, 10, 2, uint8_t(EncodingType::Unorm) }, // RGB10A2
{ 32, 1, 1, 4, 1, 1, 0, 0, 11, 11, 10, 0, uint8_t(EncodingType::Unorm) }, // R11G11B10F
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, uint8_t(EncodingType::Count) }, // UnknownDepth
{ 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D16
{ 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24
{ 32, 1, 1, 4, 1, 1, 24, 8, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24S8
{ 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D32
{ 16, 1, 1, 2, 1, 1, 16, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D16F
{ 24, 1, 1, 3, 1, 1, 24, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D24F
{ 32, 1, 1, 4, 1, 1, 32, 0, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D32F
{ 8, 1, 1, 1, 1, 1, 0, 8, 0, 0, 0, 0, uint8_t(EncodingType::Unorm) }, // D0S8
};
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_imageBlockInfo) );
@ -452,6 +453,100 @@ namespace bgfx
}
}
void imageRgba32fToLinear(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
uint8_t* dst = ( uint8_t*)_dst;
const uint8_t* src = (const uint8_t*)_src;
for (uint32_t yy = 0; yy < _height; ++yy, src += _pitch)
{
for (uint32_t xx = 0; xx < _width; ++xx, dst += 16)
{
float* fd = ( float*)dst;
const float* fs = (const float*)src;
fd[0] = bx::fpow(fs[0], 1.0f/2.2f);
fd[1] = bx::fpow(fs[1], 1.0f/2.2f);
fd[2] = bx::fpow(fs[2], 1.0f/2.2f);
fd[3] = fs[3];
}
}
}
void imageRgba32fToGamma(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src)
{
uint8_t* dst = ( uint8_t*)_dst;
const uint8_t* src = (const uint8_t*)_src;
for (uint32_t yy = 0; yy < _height; ++yy, src += _pitch)
{
for (uint32_t xx = 0; xx < _width; ++xx, dst += 16)
{
float* fd = ( float*)dst;
const float* fs = (const float*)src;
fd[0] = bx::fpow(fs[0], 2.2f);
fd[1] = bx::fpow(fs[1], 2.2f);
fd[2] = bx::fpow(fs[2], 2.2f);
fd[3] = fs[3];
}
}
}
void imageRgba32fLinearDownsample2x2Ref(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
{
const uint32_t dstwidth = _width/2;
const uint32_t dstheight = _height/2;
if (0 == dstwidth
|| 0 == dstheight)
{
return;
}
const uint8_t* src = (const uint8_t*)_src;
uint8_t* dst = (uint8_t*)_dst;
for (uint32_t yy = 0, ystep = _pitch*2; yy < dstheight; ++yy, src += ystep)
{
const float* rgba0 = (const float*)&src[0];
const float* rgba1 = (const float*)&src[_pitch];
for (uint32_t xx = 0; xx < dstwidth; ++xx, rgba0 += 8, rgba1 += 8, dst += 16)
{
float xyz[4];
xyz[0] = rgba0[0];
xyz[1] = rgba0[1];
xyz[2] = rgba0[2];
xyz[3] = rgba0[3];
xyz[0] += rgba0[4];
xyz[1] += rgba0[5];
xyz[2] += rgba0[6];
xyz[3] += rgba0[7];
xyz[0] += rgba1[0];
xyz[1] += rgba1[1];
xyz[2] += rgba1[2];
xyz[3] += rgba1[3];
xyz[0] += rgba1[4];
xyz[1] += rgba1[5];
xyz[2] += rgba1[6];
xyz[3] += rgba1[7];
xyz[0] *= 0.25f;
xyz[1] *= 0.25f;
xyz[2] *= 0.25f;
xyz[3] *= 0.25f;
}
}
}
void imageRgba32fLinearDownsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
{
imageRgba32fLinearDownsample2x2Ref(_width, _height, _pitch, _src, _dst);
}
void imageRgba32fDownsample2x2NormalMapRef(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
{
const uint32_t dstwidth = _width/2;
@ -1563,7 +1658,7 @@ namespace bgfx
bool imageConvert(void* _dst, TextureFormat::Enum _dstFormat, const void* _src, TextureFormat::Enum _srcFormat, uint32_t _width, uint32_t _height)
{
const uint32_t srcBpp = s_imageBlockInfo[_srcFormat].bitsPerPixel;
return imageConvert(_dst, _dstFormat, _src, _srcFormat, _width, _height, _width*srcBpp);
return imageConvert(_dst, _dstFormat, _src, _srcFormat, _width, _height, _width*srcBpp/8);
}
uint8_t bitRangeConvert(uint32_t _in, uint32_t _from, uint32_t _to)
@ -3605,12 +3700,17 @@ namespace bgfx
break;
default:
if (isCompressed(_format) )
{
void* temp = BX_ALLOC(_allocator, imageGetSize(_format, uint16_t(_pitch/4), uint16_t(_height) ) );
imageDecodeToRgba8(temp, _src, _width, _height, _pitch, _format);
imageRgba8ToRgba32f(_dst, _width, _height, _pitch, temp);
BX_FREE(_allocator, temp);
}
else
{
imageConvert(_dst, TextureFormat::RGBA32F, _src, _format, _width, _height, _pitch);
}
break;
}
}

View File

@ -63,6 +63,10 @@ namespace bgfx
uint8_t minBlockY;
uint8_t depthBits;
uint8_t stencilBits;
uint8_t rBits;
uint8_t gBits;
uint8_t bBits;
uint8_t aBits;
uint8_t encoding;
};
@ -304,6 +308,15 @@ namespace bgfx
///
void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
///
void imageRgba32fToLinear(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
///
void imageRgba32fToGamma(void* _dst, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src);
///
void imageRgba32fLinearDownsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
///
void imageRgba32fDownsample2x2NormalMap(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);

View File

@ -2343,18 +2343,18 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_rasterizerStateCache.invalidate();
}
uint32_t flags = _resolution.m_flags & ~(0
const uint32_t maskFlags = ~(0
| BGFX_RESET_HMD_RECENTER
| BGFX_RESET_MAXANISOTROPY
| BGFX_RESET_DEPTH_CLAMP
| BGFX_RESET_SUSPEND
);
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| m_resolution.m_flags != flags)
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
{
flags &= ~BGFX_RESET_INTERNAL_FORCE;
uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
bool resize = true
&& !BX_ENABLED(BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT) // can't use ResizeBuffers on Windows Phone
@ -5020,6 +5020,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
return;
}
if (_render->m_capture)
{
renderDocTriggerCapture();
}
PIX_BEGINEVENT(D3DCOLOR_RGBA(0xff, 0x00, 0x00, 0xff), L"rendererSubmit");
BGFX_GPU_PROFILER_BEGIN_DYNAMIC("rendererSubmit");

View File

@ -367,6 +367,9 @@ namespace bgfx { namespace d3d12
static const GUID IID_ID3D12RootSignature = { 0xc54a6b66, 0x72df, 0x4ee8, { 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14 } };
static const GUID IID_ID3D12QueryHeap = { 0x0d9658ae, 0xed45, 0x469e, { 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4 } };
static const GUID IID_IDXGIFactory4 = { 0x1bc6ea02, 0xef36, 0x464f, { 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a } };
#else
static const GUID IID_ID3D12CommandSignature = { 0xc36a797c, 0xec80, 0x4f0a, { 0x89, 0x85, 0xa7, 0xb2, 0x47, 0x50, 0x82, 0xd1 } };
static const GUID IID_ID3D12QueryHeap = { 0x0d9658ae, 0xed45, 0x469e, { 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4 } };
#endif // USE_D3D12_DYNAMIC_LIB
struct HeapProperty
@ -1868,18 +1871,18 @@ data.NumQualityLevels = 0;
m_pipelineStateCache.invalidate();
}
uint32_t flags = _resolution.m_flags & ~(0
const uint32_t maskFlags = ~(0
| BGFX_RESET_HMD_RECENTER
| BGFX_RESET_MAXANISOTROPY
| BGFX_RESET_DEPTH_CLAMP
| BGFX_RESET_SUSPEND
);
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| m_resolution.m_flags != flags)
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
{
flags &= ~BGFX_RESET_INTERNAL_FORCE;
uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
bool resize = (m_resolution.m_flags&BGFX_RESET_MSAA_MASK) == (_resolution.m_flags&BGFX_RESET_MSAA_MASK);

View File

@ -1291,18 +1291,18 @@ namespace bgfx { namespace d3d9
? m_caps.MaxAnisotropy
: 1
;
uint32_t flags = _resolution.m_flags & ~(0
const uint32_t maskFlags = ~(0
| BGFX_RESET_HMD_RECENTER
| BGFX_RESET_MAXANISOTROPY
| BGFX_RESET_DEPTH_CLAMP
| BGFX_RESET_SUSPEND
);
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| m_resolution.m_flags != flags)
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
{
flags &= ~BGFX_RESET_INTERNAL_FORCE;
uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
m_resolution = _resolution;
m_resolution.m_flags = flags;

View File

@ -2507,18 +2507,18 @@ namespace bgfx { namespace gl
}
}
uint32_t flags = _resolution.m_flags & ~(0
const uint32_t maskFlags = ~(0
| BGFX_RESET_HMD_RECENTER
| BGFX_RESET_MAXANISOTROPY
| BGFX_RESET_DEPTH_CLAMP
| BGFX_RESET_SUSPEND
);
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| m_resolution.m_flags != flags)
if (m_resolution.m_width != _resolution.m_width
|| m_resolution.m_height != _resolution.m_height
|| (m_resolution.m_flags&maskFlags) != (_resolution.m_flags&maskFlags) )
{
flags &= ~BGFX_RESET_INTERNAL_FORCE;
uint32_t flags = _resolution.m_flags & (~BGFX_RESET_INTERNAL_FORCE);
m_resolution = _resolution;
m_resolution.m_flags = flags;
@ -5640,6 +5640,11 @@ namespace bgfx { namespace gl
{
BGFX_GPU_PROFILER_BEGIN_DYNAMIC("rendererSubmit");
if (_render->m_capture)
{
renderDocTriggerCapture();
}
if (1 < m_numWindows
&& m_vaoSupport)
{

View File

@ -23,8 +23,39 @@ extern "C" {
#include <iqa.h>
}
#define LODEPNG_NO_COMPILE_ENCODER
#define LODEPNG_NO_COMPILE_DISK
#define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS
#define LODEPNG_NO_COMPILE_ERROR_TEXT
#define LODEPNG_NO_COMPILE_ALLOCATORS
#define LODEPNG_NO_COMPILE_CPP
#include <lodepng/lodepng.cpp>
void* lodepng_malloc(size_t _size)
{
return ::malloc(_size);
}
void* lodepng_realloc(void* _ptr, size_t _size)
{
return ::realloc(_ptr, _size);
}
void lodepng_free(void* _ptr)
{
::free(_ptr);
}
BX_PRAGMA_DIAGNOSTIC_PUSH();
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wmissing-field-initializers");
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wshadow");
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wint-to-pointer-cast")
#define STBI_MALLOC(_size) lodepng_malloc(_size)
#define STBI_REALLOC(_ptr, _size) lodepng_realloc(_ptr, _size)
#define STBI_FREE(_ptr) lodepng_free(_ptr)
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.c>
BX_PRAGMA_DIAGNOSTIC_POP();
#if 0
# define BX_TRACE(_format, ...) fprintf(stderr, "" _format "\n", ##__VA_ARGS__)
@ -60,6 +91,141 @@ namespace bgfx
::free(mem);
}
bool imageParse(ImageContainer& _imageContainer, const void* _data, uint32_t _size, void** _out)
{
*_out = NULL;
bool loaded = imageParse(_imageContainer, _data, _size);
if (!loaded)
{
bgfx::TextureFormat::Enum format = bgfx::TextureFormat::RGBA8;
uint32_t bpp = 32;
uint32_t width = 0;
uint32_t height = 0;
uint8_t* out = NULL;
static uint8_t pngMagic[] = { 0x89, 0x50, 0x4E, 0x47, 0x0d, 0x0a };
if (0 == memcmp(_data, pngMagic, sizeof(pngMagic) ) )
{
unsigned error;
LodePNGState state;
lodepng_state_init(&state);
state.decoder.color_convert = 0;
error = lodepng_decode(&out, &width, &height, &state, (uint8_t*)_data, _size);
if (0 == error)
{
*_out = out;
switch (state.info_raw.bitdepth)
{
case 8:
switch (state.info_raw.colortype)
{
case LCT_GREY:
format = bgfx::TextureFormat::R8;
bpp = 8;
break;
case LCT_GREY_ALPHA:
format = bgfx::TextureFormat::RG8;
bpp = 16;
break;
case LCT_RGB:
format = bgfx::TextureFormat::RGB8;
bpp = 24;
break;
case LCT_RGBA:
format = bgfx::TextureFormat::RGBA8;
bpp = 32;
break;
case LCT_PALETTE:
break;
}
break;
case 16:
switch (state.info_raw.colortype)
{
case LCT_GREY:
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
{
uint16_t* rgba = (uint16_t*)out + ii*4;
rgba[0] = bx::toHostEndian(rgba[0], false);
}
format = bgfx::TextureFormat::R16;
bpp = 16;
break;
case LCT_GREY_ALPHA:
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
{
uint16_t* rgba = (uint16_t*)out + ii*4;
rgba[0] = bx::toHostEndian(rgba[0], false);
rgba[1] = bx::toHostEndian(rgba[1], false);
}
format = bgfx::TextureFormat::R16;
bpp = 16;
break;
case LCT_RGBA:
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
{
uint16_t* rgba = (uint16_t*)out + ii*4;
rgba[0] = bx::toHostEndian(rgba[0], false);
rgba[1] = bx::toHostEndian(rgba[1], false);
rgba[2] = bx::toHostEndian(rgba[2], false);
rgba[3] = bx::toHostEndian(rgba[3], false);
}
format = bgfx::TextureFormat::RGBA16;
bpp = 64;
break;
case LCT_RGB:
case LCT_PALETTE:
break;
}
break;
default:
break;
}
}
lodepng_state_cleanup(&state);
}
else
{
int comp = 0;
*_out = stbi_load_from_memory( (uint8_t*)_data, _size, (int*)&width, (int*)&height, &comp, 4);
}
loaded = NULL != *_out;
if (loaded)
{
_imageContainer.m_data = *_out;
_imageContainer.m_size = width*height*bpp/8;
_imageContainer.m_offset = 0;
_imageContainer.m_width = width;
_imageContainer.m_height = height;
_imageContainer.m_depth = 1;
_imageContainer.m_format = format;
_imageContainer.m_numMips = 1;
_imageContainer.m_hasAlpha = true;
_imageContainer.m_cubeMap = false;
_imageContainer.m_ktx = false;
_imageContainer.m_ktxLE = false;
_imageContainer.m_srgb = false;
}
}
return loaded;
}
bool imageEncodeFromRgba8(void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint8_t _format)
{
TextureFormat::Enum format = TextureFormat::Enum(_format);
@ -334,7 +500,7 @@ void help(const char* _error = NULL)
);
fprintf(stderr
, "Usage: texturec -f <in> -o <out> -t <format>\n"
, "Usage: texturec -f <in> -o <out> [-t <format>]\n"
"\n"
"Supported input file types:\n"
@ -400,20 +566,6 @@ int main(int _argc, const char* _argv[])
return EXIT_FAILURE;
}
const char* type = cmdLine.findOption('t');
bgfx::TextureFormat::Enum format = bgfx::TextureFormat::BGRA8;
if (NULL != type)
{
format = bgfx::getFormat(type);
if (!isValid(format) )
{
help("Invalid format specified.");
return EXIT_FAILURE;
}
}
const bool mips = cmdLine.hasArg('m', "mips");
const bool normalMap = cmdLine.hasArg('n', "normalmap");
const bool iqa = cmdLine.hasArg('\0', "iqa");
@ -429,40 +581,29 @@ int main(int _argc, const char* _argv[])
uint8_t* decodedImage = NULL;
ImageContainer imageContainer;
bool loaded = imageParse(imageContainer, mem->data, mem->size);
if (!loaded)
bool loaded = imageParse(imageContainer, mem->data, mem->size, (void**)&decodedImage);
if (NULL != decodedImage)
{
int width = 0;
int height = 0;
int comp = 0;
decodedImage = stbi_load_from_memory( (uint8_t*)mem->data, mem->size, &width, &height, &comp, 4);
loaded = NULL != decodedImage;
if (loaded)
{
release(mem);
mem = makeRef(decodedImage, width*height*4);
imageContainer.m_data = mem->data;
imageContainer.m_size = mem->size;
imageContainer.m_offset = 0;
imageContainer.m_width = width;
imageContainer.m_height = height;
imageContainer.m_depth = 1;
imageContainer.m_format = bgfx::TextureFormat::RGBA8;
imageContainer.m_numMips = 1;
imageContainer.m_hasAlpha = true;
imageContainer.m_cubeMap = false;
imageContainer.m_ktx = false;
imageContainer.m_ktxLE = false;
imageContainer.m_srgb = false;
}
release(mem);
mem = makeRef(imageContainer.m_data, imageContainer.m_size);
}
if (loaded)
{
const char* type = cmdLine.findOption('t');
bgfx::TextureFormat::Enum format = imageContainer.m_format;
if (NULL != type)
{
format = bgfx::getFormat(type);
if (!isValid(format) )
{
help("Invalid format specified.");
return EXIT_FAILURE;
}
}
bx::CrtAllocator allocator;
const Memory* output = NULL;
@ -540,6 +681,66 @@ int main(int _argc, const char* _argv[])
BX_FREE(&allocator, rgbaDst);
}
else if (8 != getBlockInfo(imageContainer.m_format).rBits)
{
output = imageAlloc(imageContainer, format, mip.m_width, mip.m_height, 0, false, mips);
ImageMip dstMip;
imageGetRawData(imageContainer, 0, 0, NULL, 0, dstMip);
if (mip.m_width != dstMip.m_width
&& mip.m_height != dstMip.m_height)
{
printf("Invalid input image size %dx%d, it must be at least %dx%d to be converted to %s format.\n"
, mip.m_width
, mip.m_height
, dstMip.m_width
, dstMip.m_height
, getName(format)
);
return EXIT_FAILURE;
}
uint32_t size = imageGetSize(TextureFormat::RGBA32F, dstMip.m_width, dstMip.m_height);
temp = BX_ALLOC(&allocator, size);
float* rgba = (float*)temp;
float* rgbaDst = (float*)BX_ALLOC(&allocator, size);
imageDecodeToRgba32f(&allocator
, rgba
, mip.m_data
, mip.m_width
, mip.m_height
, mip.m_width*mip.m_bpp/8
, mip.m_format
);
imageEncodeFromRgba32f(&allocator, output->data, rgba, dstMip.m_width, dstMip.m_height, format);
imageRgba32fToLinear(rgba
, mip.m_width
, mip.m_height
, mip.m_width*mip.m_bpp/8
, rgba
);
for (uint8_t lod = 1; lod < numMips; ++lod)
{
imageRgba32fLinearDownsample2x2(dstMip.m_width, dstMip.m_height, dstMip.m_width*16, rgba, rgba);
imageGetRawData(imageContainer, 0, lod, output->data, output->size, dstMip);
uint8_t* data = const_cast<uint8_t*>(dstMip.m_data);
imageRgba32fToGamma(rgbaDst
, mip.m_width
, mip.m_height
, mip.m_width*mip.m_bpp/8
, rgba
);
imageEncodeFromRgba32f(&allocator, data, rgbaDst, dstMip.m_width, dstMip.m_height, format);
}
BX_FREE(&allocator, rgbaDst);
}
else
{
output = imageAlloc(imageContainer, format, mip.m_width, mip.m_height, 0, false, mips);
@ -649,6 +850,11 @@ int main(int _argc, const char* _argv[])
imageFree(output);
}
}
else
{
help("Failed to load input file.");
return EXIT_FAILURE;
}
release(mem);
}

View File

@ -721,10 +721,10 @@ int _main_(int _argc, char** _argv)
if (ImGui::BeginPopupModal("Help", NULL, ImGuiWindowFlags_AlwaysAutoResize) )
{
ImGui::SetWindowFontScale(1.2f);
ImGui::SetWindowFontScale(1.0f);
ImGui::Text(
"texturev, bgfx texture viewer tool\n"
"texturev, bgfx texture viewer tool " ICON_KI_WRENCH "\n"
"Copyright 2011-2016 Branimir Karadzic. All rights reserved.\n"
"License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n"
);
@ -733,6 +733,7 @@ int _main_(int _argc, char** _argv)
ImGui::Text("Key bindings:\n\n");
ImGui::PushFont(ImGui::Font::Mono);
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "ESC"); ImGui::SameLine(64); ImGui::Text("Exit.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "h"); ImGui::SameLine(64); ImGui::Text("Toggle help screen.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "f"); ImGui::SameLine(64); ImGui::Text("Toggle full-screen.");
@ -753,6 +754,8 @@ int _main_(int _argc, char** _argv)
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "r/g/b"); ImGui::SameLine(64); ImGui::Text("Toggle R, G, or B color channel.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "a"); ImGui::SameLine(64); ImGui::Text("Toggle alpha blending.");
ImGui::PopFont();
ImGui::NextLine();
ImGui::Dummy(ImVec2(0.0f, 0.0f) );

View File

@ -341,6 +341,30 @@ namespace bx
_result[2] = 1.0f / _a[2];
}
inline void vec3TangentFrame(const float* _n, float* _t, float* _b)
{
const float nx = _n[0];
const float ny = _n[1];
const float nz = _n[2];
if (bx::fabsolute(nx) > bx::fabsolute(nz) )
{
float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz);
_t[0] = -nz * invLen;
_t[1] = 0.0f;
_t[2] = nx * invLen;
}
else
{
float invLen = 1.0f / bx::fsqrt(ny*ny + nz*nz);
_t[0] = 0.0f;
_t[1] = nz * invLen;
_t[2] = -ny * invLen;
}
bx::vec3Cross(_b, _n, _t);
}
inline void quatIdentity(float* _result)
{
_result[0] = 0.0f;

View File

@ -13,30 +13,32 @@ function toolchain(_buildDir, _libDir)
value = "GCC",
description = "Choose GCC flavor",
allowed = {
{ "android-arm", "Android - ARM" },
{ "android-mips", "Android - MIPS" },
{ "android-x86", "Android - x86" },
{ "asmjs", "Emscripten/asm.js" },
{ "freebsd", "FreeBSD" },
{ "linux-gcc", "Linux (GCC compiler)" },
{ "linux-gcc-5", "Linux (GCC-5 compiler)" },
{ "linux-clang", "Linux (Clang compiler)" },
{ "linux-mips-gcc", "Linux (MIPS, GCC compiler)" },
{ "linux-arm-gcc", "Linux (ARM, GCC compiler)" },
{ "ios-arm", "iOS - ARM" },
{ "ios-simulator", "iOS - Simulator" },
{ "tvos-arm64", "tvOS - ARM64" },
{ "tvos-simulator", "tvOS - Simulator" },
{ "mingw-gcc", "MinGW" },
{ "mingw-clang", "MinGW (clang compiler)" },
{ "nacl", "Native Client" },
{ "nacl-arm", "Native Client - ARM" },
{ "netbsd", "NetBSD" },
{ "osx", "OSX" },
{ "pnacl", "Native Client - PNaCl" },
{ "ps4", "PS4" },
{ "qnx-arm", "QNX/Blackberry - ARM" },
{ "rpi", "RaspberryPi" },
{ "android-arm", "Android - ARM" },
{ "android-mips", "Android - MIPS" },
{ "android-x86", "Android - x86" },
{ "asmjs", "Emscripten/asm.js" },
{ "freebsd", "FreeBSD" },
{ "linux-gcc", "Linux (GCC compiler)" },
{ "linux-gcc-afl", "Linux (GCC + AFL fuzzer)" },
{ "linux-gcc-5", "Linux (GCC-5 compiler)" },
{ "linux-clang", "Linux (Clang compiler)" },
{ "linux-clang-afl", "Linux (Clang + AFL fuzzer)" },
{ "linux-mips-gcc", "Linux (MIPS, GCC compiler)" },
{ "linux-arm-gcc", "Linux (ARM, GCC compiler)" },
{ "ios-arm", "iOS - ARM" },
{ "ios-simulator", "iOS - Simulator" },
{ "tvos-arm64", "tvOS - ARM64" },
{ "tvos-simulator", "tvOS - Simulator" },
{ "mingw-gcc", "MinGW" },
{ "mingw-clang", "MinGW (clang compiler)" },
{ "nacl", "Native Client" },
{ "nacl-arm", "Native Client - ARM" },
{ "netbsd", "NetBSD" },
{ "osx", "OSX" },
{ "pnacl", "Native Client - PNaCl" },
{ "ps4", "PS4" },
{ "qnx-arm", "QNX/Blackberry - ARM" },
{ "rpi", "RaspberryPi" },
},
}
@ -120,7 +122,7 @@ function toolchain(_buildDir, _libDir)
tvosPlatform = _OPTIONS["with-tvos"]
end
if _ACTION == "gmake" then
if _ACTION == "gmake" or _ACTION == "ninja" then
if nil == _OPTIONS["gcc"] then
print("GCC flavor must be specified!")
@ -206,6 +208,12 @@ function toolchain(_buildDir, _libDir)
elseif "linux-gcc" == _OPTIONS["gcc"] then
location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
elseif "linux-gcc-afl" == _OPTIONS["gcc"] then
premake.gcc.cc = "afl-gcc"
premake.gcc.cxx = "afl-g++"
premake.gcc.ar = "ar"
location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
elseif "linux-gcc-5" == _OPTIONS["gcc"] then
premake.gcc.cc = "gcc-5"
premake.gcc.cxx = "g++-5"
@ -218,6 +226,12 @@ function toolchain(_buildDir, _libDir)
premake.gcc.ar = "ar"
location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
elseif "linux-clang-afl" == _OPTIONS["gcc"] then
premake.gcc.cc = "afl-clang"
premake.gcc.cxx = "afl-clang++"
premake.gcc.ar = "ar"
location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
elseif "linux-mips-gcc" == _OPTIONS["gcc"] then
location (path.join(_buildDir, "projects", _ACTION .. "-linux-mips-gcc"))
@ -610,7 +624,7 @@ function toolchain(_buildDir, _libDir)
"-mfpmath=sse",
}
configuration { "linux-gcc or linux-clang" }
configuration { "linux-gcc* or linux-clang*" }
buildoptions {
"-msse2",
"-Wunused-value",
@ -643,7 +657,7 @@ function toolchain(_buildDir, _libDir)
"-m64",
}
configuration { "linux-clang", "x32" }
configuration { "linux-clang*", "x32" }
targetdir (path.join(_buildDir, "linux32_clang/bin"))
objdir (path.join(_buildDir, "linux32_clang/obj"))
libdirs { path.join(_libDir, "lib/linux32_clang") }
@ -651,7 +665,7 @@ function toolchain(_buildDir, _libDir)
"-m32",
}
configuration { "linux-clang", "x64" }
configuration { "linux-clang*", "x64" }
targetdir (path.join(_buildDir, "linux64_clang/bin"))
objdir (path.join(_buildDir, "linux64_clang/obj"))
libdirs { path.join(_libDir, "lib/linux64_clang") }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.