mirror of
https://github.com/holub/mame
synced 2025-07-01 16:19:38 +03:00
update bgfx to latest (nw)
This commit is contained in:
parent
a74a7a37ef
commit
8981faa61f
1
3rdparty/bgfx/.gitignore
vendored
1
3rdparty/bgfx/.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
.git
|
||||
.svn
|
||||
tags
|
||||
.gdb_history
|
||||
|
8
3rdparty/bgfx/3rdparty/dxsdk/include/d3d10.h
vendored
8
3rdparty/bgfx/3rdparty/dxsdk/include/d3d10.h
vendored
@ -1667,7 +1667,7 @@ struct CD3D10_BUFFER_DESC : public D3D10_BUFFER_DESC
|
||||
MiscFlags = miscFlags;
|
||||
}
|
||||
~CD3D10_BUFFER_DESC() {}
|
||||
operator const D3D10_BUFFER_DESC&() const { return *this; }
|
||||
// operator const D3D10_BUFFER_DESC&() const { return *this; }
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1894,7 +1894,7 @@ struct CD3D10_TEXTURE1D_DESC : public D3D10_TEXTURE1D_DESC
|
||||
MiscFlags = miscFlags;
|
||||
}
|
||||
~CD3D10_TEXTURE1D_DESC() {}
|
||||
operator const D3D10_TEXTURE1D_DESC&() const { return *this; }
|
||||
// operator const D3D10_TEXTURE1D_DESC&() const { return *this; }
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -2137,7 +2137,7 @@ struct CD3D10_TEXTURE2D_DESC : public D3D10_TEXTURE2D_DESC
|
||||
MiscFlags = miscFlags;
|
||||
}
|
||||
~CD3D10_TEXTURE2D_DESC() {}
|
||||
operator const D3D10_TEXTURE2D_DESC&() const { return *this; }
|
||||
// operator const D3D10_TEXTURE2D_DESC&() const { return *this; }
|
||||
};
|
||||
#endif
|
||||
typedef struct D3D10_MAPPED_TEXTURE2D
|
||||
@ -2381,7 +2381,7 @@ struct CD3D10_TEXTURE3D_DESC : public D3D10_TEXTURE3D_DESC
|
||||
MiscFlags = miscFlags;
|
||||
}
|
||||
~CD3D10_TEXTURE3D_DESC() {}
|
||||
operator const D3D10_TEXTURE3D_DESC&() const { return *this; }
|
||||
// operator const D3D10_TEXTURE3D_DESC&() const { return *this; }
|
||||
};
|
||||
#endif
|
||||
typedef struct D3D10_MAPPED_TEXTURE3D
|
||||
|
40
3rdparty/bgfx/3rdparty/dxsdk/include/d3dx12.h
vendored
40
3rdparty/bgfx/3rdparty/dxsdk/include/d3dx12.h
vendored
@ -48,7 +48,7 @@ struct CD3DX12_RECT : public D3D12_RECT
|
||||
bottom = Bottom;
|
||||
}
|
||||
~CD3DX12_RECT() {}
|
||||
operator const D3D12_RECT&() const { return *this; }
|
||||
// operator const D3D12_RECT&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -99,7 +99,7 @@ struct CD3DX12_BOX : public D3D12_BOX
|
||||
back = Back;
|
||||
}
|
||||
~CD3DX12_BOX() {}
|
||||
operator const D3D12_BOX&() const { return *this; }
|
||||
// operator const D3D12_BOX&() const { return *this; }
|
||||
};
|
||||
inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r )
|
||||
{
|
||||
@ -162,7 +162,7 @@ struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
|
||||
BackFace.StencilFunc = backStencilFunc;
|
||||
}
|
||||
~CD3DX12_DEPTH_STENCIL_DESC() {}
|
||||
operator const D3D12_DEPTH_STENCIL_DESC&() const { return *this; }
|
||||
// operator const D3D12_DEPTH_STENCIL_DESC&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -189,7 +189,7 @@ struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC
|
||||
RenderTarget[ i ] = defaultRenderTargetBlendDesc;
|
||||
}
|
||||
~CD3DX12_BLEND_DESC() {}
|
||||
operator const D3D12_BLEND_DESC&() const { return *this; }
|
||||
// operator const D3D12_BLEND_DESC&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -240,7 +240,7 @@ struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC
|
||||
ConservativeRaster = conservativeRaster;
|
||||
}
|
||||
~CD3DX12_RASTERIZER_DESC() {}
|
||||
operator const D3D12_RASTERIZER_DESC&() const { return *this; }
|
||||
// operator const D3D12_RASTERIZER_DESC&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -258,7 +258,7 @@ struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO
|
||||
SizeInBytes = size;
|
||||
Alignment = alignment;
|
||||
}
|
||||
operator const D3D12_RESOURCE_ALLOCATION_INFO&() const { return *this; }
|
||||
// operator const D3D12_RESOURCE_ALLOCATION_INFO&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -292,7 +292,7 @@ struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES
|
||||
CreationNodeMask = creationNodeMask;
|
||||
VisibleNodeMask = nodeMask;
|
||||
}
|
||||
operator const D3D12_HEAP_PROPERTIES&() const { return *this; }
|
||||
// operator const D3D12_HEAP_PROPERTIES&() const { return *this; }
|
||||
bool IsCPUAccessible() const
|
||||
{
|
||||
return Type == D3D12_HEAP_TYPE_UPLOAD || Type == D3D12_HEAP_TYPE_READBACK || (Type == D3D12_HEAP_TYPE_CUSTOM &&
|
||||
@ -382,7 +382,7 @@ struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC
|
||||
Alignment = resAllocInfo.Alignment;
|
||||
Flags = flags;
|
||||
}
|
||||
operator const D3D12_HEAP_DESC&() const { return *this; }
|
||||
// operator const D3D12_HEAP_DESC&() const { return *this; }
|
||||
bool IsCPUAccessible() const
|
||||
{ return static_cast< const CD3DX12_HEAP_PROPERTIES* >( &Properties )->IsCPUAccessible(); }
|
||||
};
|
||||
@ -421,7 +421,7 @@ struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE
|
||||
memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) );
|
||||
DepthStencil.Stencil = stencil;
|
||||
}
|
||||
operator const D3D12_CLEAR_VALUE&() const { return *this; }
|
||||
// operator const D3D12_CLEAR_VALUE&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -439,7 +439,7 @@ struct CD3DX12_RANGE : public D3D12_RANGE
|
||||
Begin = begin;
|
||||
End = end;
|
||||
}
|
||||
operator const D3D12_RANGE&() const { return *this; }
|
||||
// operator const D3D12_RANGE&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -461,7 +461,7 @@ struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINAT
|
||||
Z = z;
|
||||
Subresource = subresource;
|
||||
}
|
||||
operator const D3D12_TILED_RESOURCE_COORDINATE&() const { return *this; }
|
||||
// operator const D3D12_TILED_RESOURCE_COORDINATE&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -485,7 +485,7 @@ struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE
|
||||
Height = height;
|
||||
Depth = depth;
|
||||
}
|
||||
operator const D3D12_TILE_REGION_SIZE&() const { return *this; }
|
||||
// operator const D3D12_TILE_REGION_SIZE&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -507,7 +507,7 @@ struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING
|
||||
DepthInTiles = depthInTiles;
|
||||
StartTileIndexInOverallResource = startTileIndexInOverallResource;
|
||||
}
|
||||
operator const D3D12_SUBRESOURCE_TILING&() const { return *this; }
|
||||
// operator const D3D12_SUBRESOURCE_TILING&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -527,7 +527,7 @@ struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE
|
||||
HeightInTexels = heightInTexels;
|
||||
DepthInTexels = depthInTexels;
|
||||
}
|
||||
operator const D3D12_TILE_SHAPE&() const { return *this; }
|
||||
// operator const D3D12_TILE_SHAPE&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -578,7 +578,7 @@ struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER
|
||||
barrier.UAV.pResource = pResource;
|
||||
return result;
|
||||
}
|
||||
operator const D3D12_RESOURCE_BARRIER&() const { return *this; }
|
||||
// operator const D3D12_RESOURCE_BARRIER&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -600,7 +600,7 @@ struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO
|
||||
NumTilesForPackedMips = numTilesForPackedMips;
|
||||
StartTileIndexInOverallResource = startTileIndexInOverallResource;
|
||||
}
|
||||
operator const D3D12_PACKED_MIP_INFO&() const { return *this; }
|
||||
// operator const D3D12_PACKED_MIP_INFO&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -634,7 +634,7 @@ struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT
|
||||
Depth = (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc.DepthOrArraySize : 1);
|
||||
RowPitch = rowPitch;
|
||||
}
|
||||
operator const D3D12_SUBRESOURCE_FOOTPRINT&() const { return *this; }
|
||||
// operator const D3D12_SUBRESOURCE_FOOTPRINT&() const { return *this; }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
@ -1304,7 +1304,7 @@ struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC
|
||||
{ return MipLevels * ArraySize() * PlaneCount(pDevice); }
|
||||
inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice)
|
||||
{ return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); }
|
||||
operator const D3D12_RESOURCE_DESC&() const { return *this; }
|
||||
// operator const D3D12_RESOURCE_DESC&() const { return *this; }
|
||||
};
|
||||
inline bool operator==( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r )
|
||||
{
|
||||
@ -1356,7 +1356,7 @@ inline UINT64 GetRequiredIntermediateSize(
|
||||
UINT64 RequiredSize = 0;
|
||||
|
||||
ID3D12Device* pDevice;
|
||||
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
|
||||
pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast<void**>(&pDevice));
|
||||
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize);
|
||||
pDevice->Release();
|
||||
|
||||
@ -1450,7 +1450,7 @@ inline UINT64 UpdateSubresources(
|
||||
|
||||
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
|
||||
ID3D12Device* pDevice;
|
||||
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
|
||||
pDestinationResource->GetDevice(__uuidof(ID3D12Device), reinterpret_cast<void**>(&pDevice));
|
||||
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize);
|
||||
pDevice->Release();
|
||||
|
||||
|
48
3rdparty/bgfx/3rdparty/dxsdk/include/dxgitype.h
vendored
48
3rdparty/bgfx/3rdparty/dxsdk/include/dxgitype.h
vendored
@ -10,74 +10,30 @@
|
||||
#define MAKE_DXGI_HRESULT(code) MAKE_HRESULT(1, _FACDXGI, code)
|
||||
#define MAKE_DXGI_STATUS(code) MAKE_HRESULT(0, _FACDXGI, code)
|
||||
|
||||
//#if defined(__MINGW32__) || !defined(DXGI_ERROR_INVALID_CALL)
|
||||
#ifndef DXGI_STATUS_OCCLUDED
|
||||
#if defined(__MINGW32__) || !defined(DXGI_ERROR_INVALID_CALL)
|
||||
# define DXGI_STATUS_OCCLUDED MAKE_DXGI_STATUS(1)
|
||||
#endif
|
||||
#ifndef DXGI_STATUS_CLIPPED
|
||||
# define DXGI_STATUS_CLIPPED MAKE_DXGI_STATUS(2)
|
||||
#endif
|
||||
#ifndef DXGI_STATUS_NO_DIRECTION
|
||||
# define DXGI_STATUS_NO_REDIRECTION MAKE_DXGI_STATUS(4)
|
||||
#endif
|
||||
#ifndef DXGI_STATUS_NO_DESKTOP_ACCESS
|
||||
# define DXGI_STATUS_NO_DESKTOP_ACCESS MAKE_DXGI_STATUS(5)
|
||||
#endif
|
||||
#ifndef DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE
|
||||
# define DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE MAKE_DXGI_STATUS(6)
|
||||
#endif
|
||||
#ifndef DXGI_STATUS_MODE_CHANGED
|
||||
# define DXGI_STATUS_MODE_CHANGED MAKE_DXGI_STATUS(7)
|
||||
#endif
|
||||
#ifndef DXGI_STATUS_MODE_CHANGE_IN_PROGRESS
|
||||
# define DXGI_STATUS_MODE_CHANGE_IN_PROGRESS MAKE_DXGI_STATUS(8)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_INVALID_CALL
|
||||
# define DXGI_ERROR_INVALID_CALL MAKE_DXGI_HRESULT(1)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_NOT_FOUND
|
||||
# define DXGI_ERROR_NOT_FOUND MAKE_DXGI_HRESULT(2)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_MORE_DATA
|
||||
# define DXGI_ERROR_MORE_DATA MAKE_DXGI_HRESULT(3)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_UNSUPPORTED
|
||||
# define DXGI_ERROR_UNSUPPORTED MAKE_DXGI_HRESULT(4)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_DEVICE_REMOVED
|
||||
# define DXGI_ERROR_DEVICE_REMOVED MAKE_DXGI_HRESULT(5)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_DEVICE_HUNG
|
||||
# define DXGI_ERROR_DEVICE_HUNG MAKE_DXGI_HRESULT(6)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_DEVICE_RESET
|
||||
# define DXGI_ERROR_DEVICE_RESET MAKE_DXGI_HRESULT(7)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_WAS_STILL_DRAWING
|
||||
# define DXGI_ERROR_WAS_STILL_DRAWING MAKE_DXGI_HRESULT(10)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_FRAME_STATISTICS_DISJOINT
|
||||
# define DXGI_ERROR_FRAME_STATISTICS_DISJOINT MAKE_DXGI_HRESULT(11)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE
|
||||
# define DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE MAKE_DXGI_HRESULT(12)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_DRIVER_INTERNAL_ERROR
|
||||
# define DXGI_ERROR_DRIVER_INTERNAL_ERROR MAKE_DXGI_HRESULT(32)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_NONEXCLUSIVE
|
||||
# define DXGI_ERROR_NONEXCLUSIVE MAKE_DXGI_HRESULT(33)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
|
||||
# define DXGI_ERROR_NOT_CURRENTLY_AVAILABLE MAKE_DXGI_HRESULT(34)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED
|
||||
# define DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED MAKE_DXGI_HRESULT(35)
|
||||
#endif
|
||||
#ifndef DXGI_ERROR_REMOTE_OUTOFMEMORY
|
||||
# define DXGI_ERROR_REMOTE_OUTOFMEMORY MAKE_DXGI_HRESULT(36)
|
||||
#endif
|
||||
//#endif // defined(__MINGW32__) || (_WIN32_WINNT < 0x0601)
|
||||
#endif // defined(__MINGW32__) || (_WIN32_WINNT < 0x0601)
|
||||
|
||||
#define DXGI_CPU_ACCESS_NONE ( 0 )
|
||||
#define DXGI_CPU_ACCESS_DYNAMIC ( 1 )
|
||||
|
@ -1,6 +1,18 @@
|
||||
GLSL optimizer Change Log
|
||||
=========================
|
||||
|
||||
2015 08
|
||||
-------
|
||||
|
||||
Changes:
|
||||
|
||||
* 2D shadow and 2D array uniforms got their own glslopt_basic_type entries.
|
||||
|
||||
Fixes:
|
||||
|
||||
* Fixed translation of 2D texture arrays (GLSL with EXT_texture_array, GLES3 and Metal).
|
||||
|
||||
|
||||
2015 06
|
||||
-------
|
||||
|
||||
|
@ -317,7 +317,6 @@
|
||||
<ClCompile Include="..\..\src\glsl\opt_swizzle_swizzle.cpp" />
|
||||
<ClCompile Include="..\..\src\glsl\opt_tree_grafting.cpp" />
|
||||
<ClCompile Include="..\..\src\glsl\opt_vectorize.cpp" />
|
||||
<ClCompile Include="..\..\src\glsl\opt_vector_splitting.cpp" />
|
||||
<ClCompile Include="..\..\src\glsl\s_expression.cpp" />
|
||||
<ClCompile Include="..\..\src\glsl\standalone_scaffolding.cpp" />
|
||||
<ClCompile Include="..\..\src\glsl\strtod.c" />
|
||||
|
@ -491,9 +491,6 @@
|
||||
<ClCompile Include="..\..\src\glsl\ir_stats.cpp">
|
||||
<Filter>src\glsl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\glsl\opt_vector_splitting.cpp">
|
||||
<Filter>src\glsl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\util\hash_table.c">
|
||||
<Filter>src\util</Filter>
|
||||
</ClCompile>
|
||||
|
@ -126,7 +126,6 @@
|
||||
2BA7E14617D0AEB200D5C475 /* lower_vector_insert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA7E13C17D0AEB200D5C475 /* lower_vector_insert.cpp */; };
|
||||
2BA7E14817D0AEB200D5C475 /* opt_dead_builtin_varyings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA7E13D17D0AEB200D5C475 /* opt_dead_builtin_varyings.cpp */; };
|
||||
2BA7E14A17D0AEB200D5C475 /* opt_flip_matrices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA7E13E17D0AEB200D5C475 /* opt_flip_matrices.cpp */; };
|
||||
2BA84CA619580C9D0021BE1D /* opt_vector_splitting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BA84CA519580C9D0021BE1D /* opt_vector_splitting.cpp */; };
|
||||
2BB2F5B012B8F1580052C6B0 /* lower_discard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AA12B8F1580052C6B0 /* lower_discard.cpp */; };
|
||||
2BB2F5B112B8F1580052C6B0 /* lower_instructions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AB12B8F1580052C6B0 /* lower_instructions.cpp */; };
|
||||
2BB2F5B212B8F1580052C6B0 /* lower_vector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BB2F5AC12B8F1580052C6B0 /* lower_vector.cpp */; };
|
||||
@ -292,7 +291,6 @@
|
||||
2BA7E13C17D0AEB200D5C475 /* lower_vector_insert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_vector_insert.cpp; path = ../../src/glsl/lower_vector_insert.cpp; sourceTree = "<group>"; };
|
||||
2BA7E13D17D0AEB200D5C475 /* opt_dead_builtin_varyings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_dead_builtin_varyings.cpp; path = ../../src/glsl/opt_dead_builtin_varyings.cpp; sourceTree = "<group>"; };
|
||||
2BA7E13E17D0AEB200D5C475 /* opt_flip_matrices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_flip_matrices.cpp; path = ../../src/glsl/opt_flip_matrices.cpp; sourceTree = "<group>"; };
|
||||
2BA84CA519580C9D0021BE1D /* opt_vector_splitting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = opt_vector_splitting.cpp; path = ../../src/glsl/opt_vector_splitting.cpp; sourceTree = "<group>"; };
|
||||
2BB2F5AA12B8F1580052C6B0 /* lower_discard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_discard.cpp; path = ../../src/glsl/lower_discard.cpp; sourceTree = SOURCE_ROOT; };
|
||||
2BB2F5AB12B8F1580052C6B0 /* lower_instructions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_instructions.cpp; path = ../../src/glsl/lower_instructions.cpp; sourceTree = SOURCE_ROOT; };
|
||||
2BB2F5AC12B8F1580052C6B0 /* lower_vector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lower_vector.cpp; path = ../../src/glsl/lower_vector.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@ -543,7 +541,6 @@
|
||||
2B38545B1293BE5000F3E692 /* opt_swizzle_swizzle.cpp */,
|
||||
2B38545C1293BE5000F3E692 /* opt_tree_grafting.cpp */,
|
||||
2B9F0A3C189664F3002FF617 /* opt_vectorize.cpp */,
|
||||
2BA84CA519580C9D0021BE1D /* opt_vector_splitting.cpp */,
|
||||
2BA55A991207FEA6002DC82D /* program.h */,
|
||||
2BA55A9A1207FEA6002DC82D /* s_expression.cpp */,
|
||||
2BA55A9B1207FEA6002DC82D /* s_expression.h */,
|
||||
@ -730,7 +727,6 @@
|
||||
2B78C91D1858B052007F5D2A /* ir_equals.cpp in Sources */,
|
||||
2B6A99F61223B1670059FBED /* glcpp-parse.c in Sources */,
|
||||
2B6A99FB1223B1670059FBED /* pp.c in Sources */,
|
||||
2BA84CA619580C9D0021BE1D /* opt_vector_splitting.cpp in Sources */,
|
||||
2BBA49281254706A00D42573 /* glsl_symbol_table.cpp in Sources */,
|
||||
2BBA492A1254706A00D42573 /* loop_analysis.cpp in Sources */,
|
||||
2BBA492C1254706A00D42573 /* loop_controls.cpp in Sources */,
|
||||
|
@ -103,7 +103,6 @@ SRC = ast_array_index.cpp \
|
||||
opt_swizzle_swizzle.cpp \
|
||||
opt_tree_grafting.cpp \
|
||||
opt_vectorize.cpp \
|
||||
opt_vector_splitting.cpp \
|
||||
s_expression.cpp \
|
||||
standalone_scaffolding.cpp \
|
||||
strtod.c \
|
||||
|
@ -454,10 +454,6 @@ static void do_optimization_passes(exec_list* ir, bool linked, _mesa_glsl_parse_
|
||||
progress2 = propagate_precision (ir, state->metal_target); progress |= progress2; if (progress2) debug_print_ir ("After prec propagation", ir, state, mem_ctx);
|
||||
progress2 = do_copy_propagation(ir); progress |= progress2; if (progress2) debug_print_ir ("After copy propagation", ir, state, mem_ctx);
|
||||
progress2 = do_copy_propagation_elements(ir); progress |= progress2; if (progress2) debug_print_ir ("After copy propagation elems", ir, state, mem_ctx);
|
||||
if (state->es_shader && linked)
|
||||
{
|
||||
progress2 = optimize_split_vectors(ir, linked, OPT_SPLIT_ONLY_LOOP_INDUCTORS); progress |= progress2; if (progress2) debug_print_ir("After split vectors", ir, state, mem_ctx);
|
||||
}
|
||||
|
||||
if (linked)
|
||||
{
|
||||
@ -488,7 +484,6 @@ static void do_optimization_passes(exec_list* ir, bool linked, _mesa_glsl_parse_
|
||||
progress2 = do_swizzle_swizzle(ir); progress |= progress2; if (progress2) debug_print_ir ("After swizzle swizzle", ir, state, mem_ctx);
|
||||
progress2 = do_noop_swizzle(ir); progress |= progress2; if (progress2) debug_print_ir ("After noop swizzle", ir, state, mem_ctx);
|
||||
progress2 = optimize_split_arrays(ir, linked, state->metal_target && state->stage == MESA_SHADER_FRAGMENT); progress |= progress2; if (progress2) debug_print_ir ("After split arrays", ir, state, mem_ctx);
|
||||
progress2 = optimize_split_vectors(ir, linked, OPT_SPLIT_ONLY_UNUSED); progress |= progress2; if (progress2) debug_print_ir("After split unused vectors", ir, state, mem_ctx);
|
||||
progress2 = optimize_redundant_jumps(ir); progress |= progress2; if (progress2) debug_print_ir ("After redundant jumps", ir, state, mem_ctx);
|
||||
|
||||
// do loop stuff only when linked; otherwise causes duplicate loop induction variable
|
||||
@ -528,7 +523,14 @@ static void glsl_type_to_optimizer_desc(const glsl_type* type, glsl_precision pr
|
||||
else if (type->is_sampler())
|
||||
{
|
||||
if (type->sampler_dimensionality == GLSL_SAMPLER_DIM_2D)
|
||||
out->type = kGlslTypeTex2D;
|
||||
{
|
||||
if (type->sampler_shadow)
|
||||
out->type = kGlslTypeTex2DShadow;
|
||||
else if (type->sampler_array)
|
||||
out->type = kGlslTypeTex2DArray;
|
||||
else
|
||||
out->type = kGlslTypeTex2D;
|
||||
}
|
||||
else if (type->sampler_dimensionality == GLSL_SAMPLER_DIM_3D)
|
||||
out->type = kGlslTypeTex3D;
|
||||
else if (type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE)
|
||||
|
@ -52,6 +52,8 @@ enum glslopt_basic_type {
|
||||
kGlslTypeTex2D,
|
||||
kGlslTypeTex3D,
|
||||
kGlslTypeTexCube,
|
||||
kGlslTypeTex2DShadow,
|
||||
kGlslTypeTex2DArray,
|
||||
kGlslTypeOther,
|
||||
kGlslTypeCount
|
||||
};
|
||||
|
@ -124,14 +124,6 @@ bool lower_vector_insert(exec_list *instructions, bool lower_nonconstant_index);
|
||||
void lower_named_interface_blocks(void *mem_ctx, gl_shader *shader);
|
||||
bool optimize_redundant_jumps(exec_list *instructions);
|
||||
|
||||
typedef enum {
|
||||
OPT_SPLIT_ONLY_LOOP_INDUCTORS = 0, //< only split vectors that are used as loop inductors (and are not used by any vector operation)
|
||||
OPT_SPLIT_ONLY_UNUSED = 1, //< only split vectors that have unused components (and are not used by any vector operation)
|
||||
OPT_SPLIT_ANY_POSSIBLE = 2, //< Split all vectors that are only accessed by their components
|
||||
} glsl_vector_splitting_mode;
|
||||
|
||||
bool optimize_split_vectors(exec_list *instructions, bool linked, glsl_vector_splitting_mode mode);
|
||||
|
||||
bool optimize_split_arrays(exec_list *instructions, bool linked, bool split_shader_outputs);
|
||||
bool lower_offset_arrays(exec_list *instructions);
|
||||
void optimize_dead_builtin_variables(exec_list *instructions,
|
||||
|
@ -254,6 +254,8 @@ _mesa_print_ir_glsl(exec_list *instructions,
|
||||
str.asprintf_append ("#extension GL_EXT_shader_framebuffer_fetch : enable\n");
|
||||
if (state->ARB_shader_bit_encoding_enable)
|
||||
str.asprintf_append("#extension GL_ARB_shader_bit_encoding : enable\n");
|
||||
if (state->EXT_texture_array_enable)
|
||||
str.asprintf_append ("#extension GL_EXT_texture_array : enable\n");
|
||||
}
|
||||
|
||||
// remove unused struct declarations
|
||||
@ -822,11 +824,14 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
|
||||
{
|
||||
glsl_sampler_dim sampler_dim = (glsl_sampler_dim)ir->sampler->type->sampler_dimensionality;
|
||||
const bool is_shadow = ir->sampler->type->sampler_shadow;
|
||||
const bool is_array = ir->sampler->type->sampler_array;
|
||||
const glsl_type* uv_type = ir->coordinate->type;
|
||||
const int uv_dim = uv_type->vector_elements;
|
||||
int sampler_uv_dim = tex_sampler_dim_size[sampler_dim];
|
||||
if (is_shadow)
|
||||
sampler_uv_dim += 1;
|
||||
if (is_array)
|
||||
sampler_uv_dim += 1;
|
||||
const bool is_proj = (uv_dim > sampler_uv_dim);
|
||||
const bool is_lod = (ir->op == ir_txl);
|
||||
|
||||
@ -876,6 +881,9 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
|
||||
else
|
||||
buffer.asprintf_append ("texture");
|
||||
}
|
||||
|
||||
if (is_array && state->EXT_texture_array_enable)
|
||||
buffer.asprintf_append ("Array");
|
||||
|
||||
if (is_proj)
|
||||
buffer.asprintf_append ("Proj");
|
||||
|
@ -209,6 +209,7 @@ _mesa_print_ir_metal(exec_list *instructions,
|
||||
|
||||
// includes, prefix etc.
|
||||
ctx.prefixStr.asprintf_append ("#include <metal_stdlib>\n");
|
||||
ctx.prefixStr.asprintf_append ("#pragma clang diagnostic ignored \"-Wparentheses-equality\"\n");
|
||||
ctx.prefixStr.asprintf_append ("using namespace metal;\n");
|
||||
|
||||
ctx.inputStr.asprintf_append("struct xlatMtlShaderInput {\n");
|
||||
@ -235,8 +236,10 @@ _mesa_print_ir_metal(exec_list *instructions,
|
||||
// skip gl_ variables if they aren't used/assigned
|
||||
if (strstr(var->name, "gl_") == var->name)
|
||||
{
|
||||
if (!var->data.used && !var->data.assigned)
|
||||
continue;
|
||||
if (NULL == strstr(var->name, "gl_FragData_") ) {
|
||||
if (!var->data.used && !var->data.assigned)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -464,6 +467,8 @@ static void print_type_precision(string_buffer& buffer, const glsl_type *t, glsl
|
||||
typeName = "depth2d<float>"; // depth type must always be float
|
||||
else if (!strcmp(typeName, "samplerCubeShadow"))
|
||||
typeName = "depthcube<float>"; // depth type must always be float
|
||||
else if (!strcmp(typeName, "sampler2DArray"))
|
||||
typeName = halfPrec ? "texture2d_array<half>" : "texture2d_array<float>";
|
||||
|
||||
if (t->base_type == GLSL_TYPE_ARRAY) {
|
||||
print_type_precision(buffer, t->fields.array, prec, true);
|
||||
@ -1160,17 +1165,26 @@ static int tex_sampler_dim_size[] = {
|
||||
};
|
||||
|
||||
|
||||
static void print_texture_uv (ir_print_metal_visitor* vis, ir_texture* ir, bool is_shadow, bool is_proj, int uv_dim, int sampler_uv_dim)
|
||||
static void print_texture_uv (ir_print_metal_visitor* vis, ir_texture* ir, bool is_shadow, bool is_proj, bool is_array, int uv_dim, int sampler_uv_dim)
|
||||
{
|
||||
if (!is_shadow)
|
||||
{
|
||||
if (!is_proj)
|
||||
if (!is_proj && !is_array)
|
||||
{
|
||||
// regular UV
|
||||
vis->buffer.asprintf_append (sampler_uv_dim == 3 ? "(float3)(" : "(float2)(");
|
||||
ir->coordinate->accept(vis);
|
||||
vis->buffer.asprintf_append (")");
|
||||
}
|
||||
else if (is_array)
|
||||
{
|
||||
// array sample
|
||||
vis->buffer.asprintf_append ("(float2)((");
|
||||
ir->coordinate->accept(vis);
|
||||
vis->buffer.asprintf_append (").xy), (uint)((");
|
||||
ir->coordinate->accept(vis);
|
||||
vis->buffer.asprintf_append (").z)");
|
||||
}
|
||||
else
|
||||
{
|
||||
// regular projected
|
||||
@ -1212,12 +1226,13 @@ void ir_print_metal_visitor::visit(ir_texture *ir)
|
||||
{
|
||||
glsl_sampler_dim sampler_dim = (glsl_sampler_dim)ir->sampler->type->sampler_dimensionality;
|
||||
const bool is_shadow = ir->sampler->type->sampler_shadow;
|
||||
const bool is_array = ir->sampler->type->sampler_array;
|
||||
const glsl_type* uv_type = ir->coordinate->type;
|
||||
const int uv_dim = uv_type->vector_elements;
|
||||
int sampler_uv_dim = tex_sampler_dim_size[sampler_dim];
|
||||
if (is_shadow)
|
||||
sampler_uv_dim += 1;
|
||||
const bool is_proj = (uv_dim > sampler_uv_dim);
|
||||
const bool is_proj = (uv_dim > sampler_uv_dim) && !is_array;
|
||||
|
||||
// texture name & call to sample
|
||||
ir->sampler->accept(this);
|
||||
@ -1239,7 +1254,7 @@ void ir_print_metal_visitor::visit(ir_texture *ir)
|
||||
buffer.asprintf_append (", ");
|
||||
|
||||
// texture coordinate
|
||||
print_texture_uv (this, ir, is_shadow, is_proj, uv_dim, sampler_uv_dim);
|
||||
print_texture_uv (this, ir, is_shadow, is_proj, is_array, uv_dim, sampler_uv_dim);
|
||||
|
||||
// lod bias
|
||||
if (ir->op == ir_txb)
|
||||
|
@ -1,485 +0,0 @@
|
||||
/*
|
||||
* Based on work Copyright © 2010 Intel Corporation, vector splitting
|
||||
* implemented by Copyright © 2014 Unity Technologies
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file opt_vector_splitting.cpp
|
||||
*
|
||||
* If a vector is always dereferenced only by its xyzw components separately,
|
||||
* and never accessed as a whole (or with swizzle mask with >1 bits set), then
|
||||
* split it apart into its elements, making it more amenable to other
|
||||
* optimization passes.
|
||||
*
|
||||
* This skips uniforms/varyings, which would need careful
|
||||
* handling due to their ir->location fields tying them to the GL API
|
||||
* and other shader stages.
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_visitor.h"
|
||||
#include "ir_rvalue_visitor.h"
|
||||
#include "glsl_types.h"
|
||||
#include "ir_optimization.h"
|
||||
#include "loop_analysis.h"
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
namespace {
|
||||
namespace opt_vector_splitting {
|
||||
|
||||
class variable_entry : public exec_node
|
||||
{
|
||||
public:
|
||||
variable_entry(ir_variable *var)
|
||||
{
|
||||
this->var = var;
|
||||
this->split = true;
|
||||
this->use_mask = 0;
|
||||
this->declaration = false;
|
||||
this->components = NULL;
|
||||
this->mem_ctx = NULL;
|
||||
}
|
||||
|
||||
ir_variable *var; /* The key: the variable's pointer. */
|
||||
|
||||
/** Whether this array should be split or not. */
|
||||
bool split;
|
||||
|
||||
/** bitmask for the components in the vector that actually get written to.
|
||||
* If multiple slots are written simultaneously, split gets set to false.*/
|
||||
int use_mask;
|
||||
|
||||
/* If the variable had a decl we can work with in the instruction
|
||||
* stream. We can't do splitting on function arguments, which
|
||||
* don't get this variable set.
|
||||
*/
|
||||
bool declaration;
|
||||
|
||||
ir_variable **components;
|
||||
|
||||
/** ralloc_parent(this->var) -- the shader's talloc context. */
|
||||
void *mem_ctx;
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
||||
|
||||
using namespace opt_vector_splitting;
|
||||
|
||||
/**
|
||||
* This class does a walk over the tree, coming up with the set of
|
||||
* variables that could be split by looking to see if they are arrays
|
||||
* that are only ever constant-index dereferenced.
|
||||
*/
|
||||
class ir_vector_reference_visitor : public ir_hierarchical_visitor {
|
||||
public:
|
||||
ir_vector_reference_visitor(void)
|
||||
{
|
||||
this->mem_ctx = ralloc_context(NULL);
|
||||
this->variable_list.make_empty();
|
||||
}
|
||||
|
||||
~ir_vector_reference_visitor(void)
|
||||
{
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
bool get_split_list(exec_list *instructions, bool linked, glsl_vector_splitting_mode mode);
|
||||
|
||||
virtual ir_visitor_status visit(ir_variable *);
|
||||
virtual ir_visitor_status visit(ir_dereference_variable *);
|
||||
virtual ir_visitor_status visit_enter(ir_swizzle *);
|
||||
virtual ir_visitor_status visit_enter(ir_assignment *);
|
||||
virtual ir_visitor_status visit_enter(ir_function_signature *);
|
||||
|
||||
variable_entry *get_variable_entry(ir_variable *var);
|
||||
|
||||
/* List of variable_entry */
|
||||
exec_list variable_list;
|
||||
|
||||
/* Current split mode */
|
||||
glsl_vector_splitting_mode mode;
|
||||
|
||||
loop_state *loopstate;
|
||||
|
||||
void *mem_ctx;
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
||||
variable_entry *
|
||||
ir_vector_reference_visitor::get_variable_entry(ir_variable *var)
|
||||
{
|
||||
assert(var);
|
||||
|
||||
if (var->data.mode != ir_var_auto &&
|
||||
var->data.mode != ir_var_temporary)
|
||||
return NULL;
|
||||
|
||||
if (!var->type->is_vector())
|
||||
return NULL;
|
||||
|
||||
// If mode is loop_inductors, allow only loop inductors to be stored.
|
||||
if (mode == OPT_SPLIT_ONLY_LOOP_INDUCTORS && loopstate)
|
||||
{
|
||||
loop_variable_state* inductor_state = loopstate->get_for_inductor(var);
|
||||
if (!inductor_state)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
foreach_in_list(variable_entry, entry, &this->variable_list) {
|
||||
if (entry->var == var)
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
variable_entry *entry = new(mem_ctx) variable_entry(var);
|
||||
this->variable_list.push_tail(entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
ir_visitor_status
|
||||
ir_vector_reference_visitor::visit(ir_variable *ir)
|
||||
{
|
||||
variable_entry *entry = this->get_variable_entry(ir);
|
||||
|
||||
if (entry)
|
||||
entry->declaration = true;
|
||||
|
||||
return visit_continue;
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_vector_reference_visitor::visit(ir_dereference_variable *ir)
|
||||
{
|
||||
variable_entry *entry = this->get_variable_entry(ir->var);
|
||||
|
||||
/* If we made it to here without seeing an ir_swizzle,
|
||||
* then the dereference of this vector didn't have a swizzle in it
|
||||
* (see the visit_continue_with_parent below), so we can't split
|
||||
* the variable.
|
||||
*/
|
||||
if (entry)
|
||||
entry->split = false;
|
||||
|
||||
return visit_continue;
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_vector_reference_visitor::visit_enter(ir_swizzle *ir)
|
||||
{
|
||||
ir_variable *var = ir->variable_referenced();
|
||||
if (!var)
|
||||
return visit_continue;
|
||||
|
||||
variable_entry *entry = this->get_variable_entry(var);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
if (ir->mask.num_components > 1)
|
||||
{
|
||||
entry->split = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update the usemask
|
||||
entry->use_mask |= (1 << ir->mask.x);
|
||||
}
|
||||
}
|
||||
|
||||
// Skip the rest of the swizzle IR tree, we're done here.
|
||||
return visit_continue_with_parent;
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_vector_reference_visitor::visit_enter(ir_assignment *ir)
|
||||
{
|
||||
ir_dereference_variable *dest = ir->lhs->as_dereference_variable();
|
||||
if (dest)
|
||||
{
|
||||
variable_entry *entry = this->get_variable_entry(dest->var);
|
||||
if (entry)
|
||||
{
|
||||
// Count how many bits the write mask has
|
||||
unsigned maskbitval = ir->write_mask; // count the number of bits set
|
||||
int maskbitcount; // accumulates the total bits set
|
||||
for ( maskbitcount = 0; maskbitval; maskbitcount++)
|
||||
{
|
||||
maskbitval &= maskbitval - 1; // clear the least significant bit set
|
||||
}
|
||||
if (maskbitcount > 1)
|
||||
{
|
||||
// Writing to more than one slot, cannot split.
|
||||
entry->split = false;
|
||||
}
|
||||
|
||||
// Update write mask
|
||||
entry->use_mask |= ir->write_mask;
|
||||
}
|
||||
}
|
||||
|
||||
// Visit only the rhs, there may be swizzles and variable dereferences there as well
|
||||
ir->rhs->accept(this);
|
||||
return visit_continue_with_parent;
|
||||
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_vector_reference_visitor::visit_enter(ir_function_signature *ir)
|
||||
{
|
||||
/* We don't have logic for array-splitting function arguments,
|
||||
* so just look at the body instructions and not the parameter
|
||||
* declarations.
|
||||
*/
|
||||
visit_list_elements(this, &ir->body);
|
||||
return visit_continue_with_parent;
|
||||
}
|
||||
|
||||
bool
|
||||
ir_vector_reference_visitor::get_split_list(exec_list *instructions,
|
||||
bool linked,
|
||||
glsl_vector_splitting_mode _mode)
|
||||
{
|
||||
mode = _mode;
|
||||
|
||||
if (linked)
|
||||
{
|
||||
loop_state* ls = analyze_loop_variables(instructions);
|
||||
if (ls->loop_found)
|
||||
set_loop_controls(instructions, ls);
|
||||
|
||||
loopstate = ls;
|
||||
}
|
||||
else
|
||||
{
|
||||
loopstate = NULL;
|
||||
}
|
||||
|
||||
visit_list_elements(this, instructions);
|
||||
|
||||
/* If the shaders aren't linked yet, we can't mess with global
|
||||
* declarations, which need to be matched by name across shaders.
|
||||
*/
|
||||
if (!linked) {
|
||||
foreach_in_list(ir_variable, var, instructions) {
|
||||
if (var) {
|
||||
variable_entry *entry = get_variable_entry(var);
|
||||
if (entry)
|
||||
entry->remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Trim out variables we found that we can't split. */
|
||||
foreach_in_list_safe(variable_entry, entry, &variable_list) {
|
||||
|
||||
if (debug) {
|
||||
printf("array %s@%p: decl %d, split %d\n",
|
||||
entry->var->name, (void *) entry->var, entry->declaration,
|
||||
entry->split);
|
||||
}
|
||||
|
||||
if (!(entry->declaration && entry->split)) {
|
||||
entry->remove();
|
||||
}
|
||||
else if (mode == OPT_SPLIT_ONLY_UNUSED)
|
||||
{
|
||||
/* Build mask of fully used vector (vec2 -> 0x3, vec3 -> 0x7, vec4 -> 0xe) */
|
||||
unsigned int fullmask = (1 << entry->var->type->vector_elements) - 1;
|
||||
if (entry->use_mask == fullmask)
|
||||
{
|
||||
entry->remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !variable_list.is_empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class rewrites the dereferences of arrays that have been split
|
||||
* to use the newly created ir_variables for each component.
|
||||
*/
|
||||
class ir_vector_splitting_visitor : public ir_rvalue_visitor {
|
||||
public:
|
||||
ir_vector_splitting_visitor(exec_list *vars)
|
||||
{
|
||||
this->variable_list = vars;
|
||||
}
|
||||
|
||||
virtual ~ir_vector_splitting_visitor()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ir_visitor_status visit_leave(ir_assignment *);
|
||||
|
||||
void split_rvalue(ir_rvalue **rval);
|
||||
void handle_rvalue(ir_rvalue **rvalue);
|
||||
variable_entry *get_splitting_entry(ir_variable *var);
|
||||
|
||||
exec_list *variable_list;
|
||||
};
|
||||
|
||||
variable_entry *
|
||||
ir_vector_splitting_visitor::get_splitting_entry(ir_variable *var)
|
||||
{
|
||||
assert(var);
|
||||
|
||||
foreach_in_list(variable_entry, entry, this->variable_list) {
|
||||
if (entry->var == var) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ir_vector_splitting_visitor::split_rvalue(ir_rvalue **rval)
|
||||
{
|
||||
ir_swizzle *swizzle = (*rval)->as_swizzle();
|
||||
|
||||
if (!swizzle)
|
||||
return;
|
||||
|
||||
ir_variable *var = swizzle->variable_referenced();
|
||||
if (!var)
|
||||
return;
|
||||
|
||||
variable_entry *entry = get_splitting_entry(var);
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
assert(swizzle->mask.num_components == 1);
|
||||
|
||||
*rval = new(entry->mem_ctx)
|
||||
ir_dereference_variable(entry->components[swizzle->mask.x]);
|
||||
}
|
||||
|
||||
void
|
||||
ir_vector_splitting_visitor::handle_rvalue(ir_rvalue **rvalue)
|
||||
{
|
||||
if (!*rvalue)
|
||||
return;
|
||||
|
||||
ir_rvalue *v = *rvalue;
|
||||
split_rvalue(&v);
|
||||
*rvalue = v;
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_vector_splitting_visitor::visit_leave(ir_assignment *ir)
|
||||
{
|
||||
/* The normal rvalue visitor skips the LHS of assignments, but we
|
||||
* need to process those just the same.
|
||||
*/
|
||||
ir_rvalue *lhs = ir->lhs;
|
||||
|
||||
ir_dereference_variable *dest = ir->lhs->as_dereference_variable();
|
||||
if (dest)
|
||||
{
|
||||
variable_entry *entry = get_splitting_entry(dest->var);
|
||||
if (entry)
|
||||
{
|
||||
// Find the only set bit in writemask
|
||||
int component = 0;
|
||||
while (((ir->write_mask & (1 << component)) == 0) && (component < 4))
|
||||
{
|
||||
component++;
|
||||
}
|
||||
assert(ir->write_mask == (1 << component));
|
||||
|
||||
ir_dereference_variable *newderef = new(entry->mem_ctx)
|
||||
ir_dereference_variable(entry->components[component]);
|
||||
|
||||
ir->set_lhs(newderef);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ir->lhs = lhs->as_dereference();
|
||||
ir->lhs->accept(this);
|
||||
}
|
||||
|
||||
handle_rvalue(&ir->rhs);
|
||||
ir->rhs->accept(this);
|
||||
|
||||
if (ir->condition) {
|
||||
handle_rvalue(&ir->condition);
|
||||
ir->condition->accept(this);
|
||||
}
|
||||
|
||||
return visit_continue;
|
||||
}
|
||||
|
||||
bool
|
||||
optimize_split_vectors(exec_list *instructions, bool linked, glsl_vector_splitting_mode mode)
|
||||
{
|
||||
ir_vector_reference_visitor refs;
|
||||
if (!refs.get_split_list(instructions, linked, mode))
|
||||
return false;
|
||||
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
/* Replace the decls of the vectors to be split with their split
|
||||
* components.
|
||||
*/
|
||||
foreach_in_list(variable_entry, entry, &refs.variable_list) {
|
||||
const struct glsl_type *type = entry->var->type;
|
||||
const struct glsl_type *subtype;
|
||||
glsl_precision subprec = (glsl_precision)entry->var->data.precision;
|
||||
|
||||
subtype = type->get_base_type();
|
||||
|
||||
entry->mem_ctx = ralloc_parent(entry->var);
|
||||
|
||||
entry->components = ralloc_array(mem_ctx,
|
||||
ir_variable *,
|
||||
type->vector_elements);
|
||||
|
||||
for (unsigned int i = 0; i < type->vector_elements; i++) {
|
||||
const char *name = ralloc_asprintf(mem_ctx, "%s_%c",
|
||||
entry->var->name, "xyzw"[i]);
|
||||
|
||||
entry->components[i] =
|
||||
new(entry->mem_ctx) ir_variable(subtype, name, ir_var_temporary, subprec);
|
||||
entry->var->insert_before(entry->components[i]);
|
||||
}
|
||||
|
||||
entry->var->remove();
|
||||
}
|
||||
|
||||
ir_vector_splitting_visitor split(&refs.variable_list);
|
||||
visit_list_elements(&split, instructions);
|
||||
|
||||
if (debug)
|
||||
_mesa_print_ir(stdout, instructions, NULL);
|
||||
|
||||
ralloc_free(mem_ctx);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
@ -135,7 +135,6 @@
|
||||
'glsl/opt_swizzle_swizzle.cpp',
|
||||
'glsl/opt_tree_grafting.cpp',
|
||||
'glsl/opt_vectorize.cpp',
|
||||
'glsl/opt_vector_splitting.cpp',
|
||||
'glsl/opt_flip_matrices.cpp',
|
||||
'glsl/opt_dead_builtin_varyings.cpp',
|
||||
'glsl/program.h',
|
||||
|
20
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-in.txt
vendored
Normal file
20
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-in.txt
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
#extension GL_EXT_texture_array : require
|
||||
|
||||
vec4 xll_tex2DArray(sampler2DArray s, vec3 coord) { return texture2DArray (s, coord); }
|
||||
vec4 xll_tex2DArrayBias(sampler2DArray s, vec4 coord) { return texture2DArray (s, coord.xyz, coord.w); }
|
||||
|
||||
uniform sampler2DArray myarr;
|
||||
|
||||
vec4 xlat_main( in vec4 uv ) {
|
||||
vec4 s = xll_tex2DArray( myarr, uv.xyz);
|
||||
vec4 sswiz = xll_tex2DArray( myarr, uv.xyw);
|
||||
vec4 sbias = xll_tex2DArrayBias( myarr, vec4( uv.xyz, 1.5));
|
||||
return s + sswiz + sbias;
|
||||
}
|
||||
|
||||
varying vec4 uv;
|
||||
void main() {
|
||||
vec4 xl_retval;
|
||||
xl_retval = xlat_main(uv);
|
||||
gl_FragData[0] = vec4(xl_retval);
|
||||
}
|
19
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-inES3.txt
vendored
Normal file
19
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-inES3.txt
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
#version 300 es
|
||||
out lowp vec4 _fragData;
|
||||
|
||||
vec4 xll_tex2DArray(sampler2DArray s, vec3 coord) { return texture (s, coord); }
|
||||
vec4 xll_tex2DArrayBias(sampler2DArray s, vec4 coord) { return texture (s, coord.xyz, coord.w); }
|
||||
|
||||
uniform lowp sampler2DArray myarr;
|
||||
|
||||
lowp vec4 xlat_main( in highp vec4 uv ) {
|
||||
highp vec4 s = xll_tex2DArray( myarr, uv.xyz);
|
||||
highp vec4 sswiz = xll_tex2DArray( myarr, uv.xyw);
|
||||
highp vec4 sbias = xll_tex2DArrayBias( myarr, vec4( uv.xyz, 1.5));
|
||||
highp vec4 slod = textureLod(myarr, uv.xyz, 2.5);
|
||||
return (((s + sswiz) + sbias) + slod);
|
||||
}
|
||||
in highp vec4 uv;
|
||||
void main() {
|
||||
_fragData = xlat_main(uv);
|
||||
}
|
14
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-out.txt
vendored
Normal file
14
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-out.txt
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
#extension GL_EXT_texture_array : enable
|
||||
uniform sampler2DArray myarr;
|
||||
varying vec4 uv;
|
||||
void main ()
|
||||
{
|
||||
gl_FragData[0] = ((texture2DArray (myarr, uv.xyz) + texture2DArray (myarr, uv.xyw)) + texture2DArray (myarr, uv.xyz, 1.5));
|
||||
}
|
||||
|
||||
|
||||
// stats: 2 alu 3 tex 0 flow
|
||||
// inputs: 1
|
||||
// #0: uv (high float) 4x1 [-1]
|
||||
// textures: 1
|
||||
// #0: myarr (high 2darray) 0x0 [-1]
|
33
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-outES3.txt
vendored
Normal file
33
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-outES3.txt
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
#version 300 es
|
||||
out lowp vec4 _fragData;
|
||||
uniform sampler2DArray myarr;
|
||||
in highp vec4 uv;
|
||||
void main ()
|
||||
{
|
||||
lowp vec4 tmpvar_1;
|
||||
highp vec4 slod_2;
|
||||
lowp vec4 tmpvar_3;
|
||||
tmpvar_3 = texture (myarr, uv.xyz);
|
||||
highp vec4 tmpvar_4;
|
||||
tmpvar_4 = tmpvar_3;
|
||||
lowp vec4 tmpvar_5;
|
||||
tmpvar_5 = texture (myarr, uv.xyw);
|
||||
highp vec4 tmpvar_6;
|
||||
tmpvar_6 = tmpvar_5;
|
||||
lowp vec4 tmpvar_7;
|
||||
tmpvar_7 = texture (myarr, uv.xyz, 1.5);
|
||||
highp vec4 tmpvar_8;
|
||||
tmpvar_8 = tmpvar_7;
|
||||
lowp vec4 tmpvar_9;
|
||||
tmpvar_9 = textureLod (myarr, uv.xyz, 2.5);
|
||||
slod_2 = tmpvar_9;
|
||||
tmpvar_1 = ((tmpvar_4 + tmpvar_6) + (tmpvar_8 + slod_2));
|
||||
_fragData = tmpvar_1;
|
||||
}
|
||||
|
||||
|
||||
// stats: 3 alu 4 tex 0 flow
|
||||
// inputs: 1
|
||||
// #0: uv (high float) 4x1 [-1]
|
||||
// textures: 1
|
||||
// #0: myarr (low 2darray) 0x0 [-1]
|
42
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-outES3Metal.txt
vendored
Normal file
42
3rdparty/bgfx/3rdparty/glsl-optimizer/tests/fragment/tex2DArray-outES3Metal.txt
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
struct xlatMtlShaderInput {
|
||||
float4 uv;
|
||||
};
|
||||
struct xlatMtlShaderOutput {
|
||||
half4 _fragData [[color(0)]];
|
||||
};
|
||||
struct xlatMtlShaderUniform {
|
||||
};
|
||||
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
|
||||
, texture2d_array<half> myarr [[texture(0)]], sampler _mtlsmp_myarr [[sampler(0)]])
|
||||
{
|
||||
xlatMtlShaderOutput _mtl_o;
|
||||
half4 tmpvar_1;
|
||||
float4 slod_2;
|
||||
half4 tmpvar_3;
|
||||
tmpvar_3 = myarr.sample(_mtlsmp_myarr, (float2)((_mtl_i.uv.xyz).xy), (uint)((_mtl_i.uv.xyz).z));
|
||||
float4 tmpvar_4;
|
||||
tmpvar_4 = float4(tmpvar_3);
|
||||
half4 tmpvar_5;
|
||||
tmpvar_5 = myarr.sample(_mtlsmp_myarr, (float2)((_mtl_i.uv.xyw).xy), (uint)((_mtl_i.uv.xyw).z));
|
||||
float4 tmpvar_6;
|
||||
tmpvar_6 = float4(tmpvar_5);
|
||||
half4 tmpvar_7;
|
||||
tmpvar_7 = myarr.sample(_mtlsmp_myarr, (float2)((_mtl_i.uv.xyz).xy), (uint)((_mtl_i.uv.xyz).z), bias(1.5));
|
||||
float4 tmpvar_8;
|
||||
tmpvar_8 = float4(tmpvar_7);
|
||||
half4 tmpvar_9;
|
||||
tmpvar_9 = myarr.sample(_mtlsmp_myarr, (float2)((_mtl_i.uv.xyz).xy), (uint)((_mtl_i.uv.xyz).z), level(2.5));
|
||||
slod_2 = float4(tmpvar_9);
|
||||
tmpvar_1 = half4(((tmpvar_4 + tmpvar_6) + (tmpvar_8 + slod_2)));
|
||||
_mtl_o._fragData = tmpvar_1;
|
||||
return _mtl_o;
|
||||
}
|
||||
|
||||
|
||||
// stats: 3 alu 4 tex 0 flow
|
||||
// inputs: 1
|
||||
// #0: uv (high float) 4x1 [-1]
|
||||
// textures: 1
|
||||
// #0: myarr (low 2darray) 0x0 [-1] loc 0
|
@ -10,4 +10,4 @@ void main ()
|
||||
// inputs: 1
|
||||
// #0: xlv_TEXCOORD0 (high float) 4x1 [-1]
|
||||
// textures: 1
|
||||
// #0: shadowmap (high 2d) 0x0 [-1]
|
||||
// #0: shadowmap (high 2dshadow) 0x0 [-1]
|
||||
|
@ -13,4 +13,4 @@ void main ()
|
||||
// inputs: 1
|
||||
// #0: xlv_TEXCOORD0 (high float) 4x1 [-1]
|
||||
// textures: 1
|
||||
// #0: shadowmap (low 2d) 0x0 [-1]
|
||||
// #0: shadowmap (low 2dshadow) 0x0 [-1]
|
||||
|
@ -20,4 +20,4 @@ void main ()
|
||||
// #0: uvHi (high float) 4x1 [-1]
|
||||
// #1: uvMed (medium float) 4x1 [-1]
|
||||
// textures: 1
|
||||
// #0: shadowmap (low 2d) 0x0 [-1]
|
||||
// #0: shadowmap (low 2dshadow) 0x0 [-1]
|
||||
|
@ -30,4 +30,4 @@ fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]]
|
||||
// #0: uvHi (high float) 4x1 [-1]
|
||||
// #1: uvMed (medium float) 4x1 [-1]
|
||||
// textures: 1
|
||||
// #0: shadowmap (low 2d) 0x0 [-1] loc 0
|
||||
// #0: shadowmap (low 2dshadow) 0x0 [-1] loc 0
|
||||
|
@ -38,4 +38,4 @@ void main ()
|
||||
// #0: uv (high float) 4x1 [-1]
|
||||
// textures: 2
|
||||
// #0: tex (low 2d) 0x0 [-1]
|
||||
// #1: shadowmap (low 2d) 0x0 [-1]
|
||||
// #1: shadowmap (low 2dshadow) 0x0 [-1]
|
||||
|
@ -20,4 +20,4 @@ void main ()
|
||||
// #0: uv (high float) 4x1 [-1]
|
||||
// textures: 2
|
||||
// #0: tex (low 2d) 0x0 [-1]
|
||||
// #1: shadowmap (low 2d) 0x0 [-1]
|
||||
// #1: shadowmap (low 2dshadow) 0x0 [-1]
|
||||
|
@ -30,4 +30,4 @@ fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]]
|
||||
// #0: uv (high float) 4x1 [-1]
|
||||
// textures: 2
|
||||
// #0: tex (low 2d) 0x0 [-1] loc 0
|
||||
// #1: shadowmap (low 2d) 0x0 [-1] loc 1
|
||||
// #1: shadowmap (low 2dshadow) 0x0 [-1] loc 1
|
||||
|
@ -460,6 +460,8 @@ static const char* kGlslTypeNames[kGlslTypeCount] = {
|
||||
"2d",
|
||||
"3d",
|
||||
"cube",
|
||||
"2dshadow",
|
||||
"2darray",
|
||||
"other",
|
||||
};
|
||||
static const char* kGlslPrecNames[kGlslPrecCount] = {
|
||||
|
@ -40,14 +40,14 @@ vec4 Temp_0;
|
||||
vec4 Temp_1;
|
||||
vec4 Temp_2;
|
||||
vec4 Temp_3;
|
||||
int tmpvar_1;
|
||||
ivec4 Temp_int_0;
|
||||
void main ()
|
||||
{
|
||||
Temp_0 = (dcl_Input0_POSITION0.yyyy * glstate_matrix_mvp[1]);
|
||||
Temp_0 = ((glstate_matrix_mvp[0] * dcl_Input0_POSITION0.xxxx) + Temp_0);
|
||||
Temp_0 = ((glstate_matrix_mvp[2] * dcl_Input0_POSITION0.zzzz) + Temp_0);
|
||||
vec4 tmpvar_2;
|
||||
tmpvar_2 = ((glstate_matrix_mvp[3] * dcl_Input0_POSITION0.wwww) + Temp_0);
|
||||
vec4 tmpvar_1;
|
||||
tmpvar_1 = ((glstate_matrix_mvp[3] * dcl_Input0_POSITION0.wwww) + Temp_0);
|
||||
VtxGeoOutput1_TEXCOORD0.xy = ((dcl_Input2_TEXCOORD0.xyxx * _MainTex_ST.xyxx) + _MainTex_ST.zwzz).xy;
|
||||
Temp_0.xyz = (dcl_Input0_POSITION0.yyyy * glstate_matrix_modelview0[1].xyzx).xyz;
|
||||
Temp_0.xyz = ((glstate_matrix_modelview0[0].xyzx * dcl_Input0_POSITION0.xxxx) + Temp_0.xyzx).xyz;
|
||||
@ -60,58 +60,30 @@ void main ()
|
||||
Temp_0.w = inversesqrt(Temp_0.w);
|
||||
Temp_1.xyz = (Temp_0.wwww * Temp_1.xyzx).xyz;
|
||||
Temp_2.xyz = glstate_lightmodel_ambient.xyz;
|
||||
tmpvar_1 = 0;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + glstate_lightmodel_ambient.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_int_0.w = 0;
|
||||
while (true) {
|
||||
if ((Temp_int_0.w >= 4)) {
|
||||
break;
|
||||
};
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[Temp_int_0.w].wwww) + unity_LightPosition[Temp_int_0.w].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[Temp_int_0.w].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[Temp_int_0.w].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
Temp_int_0.w = (Temp_int_0.w + 1);
|
||||
};
|
||||
VtxGeoOutput2_COLOR0.xyz = (Temp_2.xyzx + Temp_2.xyzx).xyz;
|
||||
VtxGeoOutput2_COLOR0.w = 1.0;
|
||||
gl_Position = tmpvar_2;
|
||||
gl_Position = tmpvar_1;
|
||||
}
|
||||
|
||||
|
||||
// stats: 87 alu 0 tex 0 flow
|
||||
// stats: 43 alu 0 tex 2 flow
|
||||
// inputs: 3
|
||||
// #0: dcl_Input0_POSITION0 (high float) 4x1 [-1]
|
||||
// #1: dcl_Input1_NORMAL0 (high float) 4x1 [-1]
|
||||
|
@ -40,14 +40,14 @@ vec4 Temp_0;
|
||||
vec4 Temp_1;
|
||||
vec4 Temp_2;
|
||||
vec4 Temp_3;
|
||||
highp int tmpvar_1;
|
||||
highp ivec4 Temp_int_0;
|
||||
void main ()
|
||||
{
|
||||
Temp_0 = (dcl_Input0_POSITION0.yyyy * glstate_matrix_mvp[1]);
|
||||
Temp_0 = ((glstate_matrix_mvp[0] * dcl_Input0_POSITION0.xxxx) + Temp_0);
|
||||
Temp_0 = ((glstate_matrix_mvp[2] * dcl_Input0_POSITION0.zzzz) + Temp_0);
|
||||
highp vec4 tmpvar_2;
|
||||
tmpvar_2 = ((glstate_matrix_mvp[3] * dcl_Input0_POSITION0.wwww) + Temp_0);
|
||||
highp vec4 tmpvar_1;
|
||||
tmpvar_1 = ((glstate_matrix_mvp[3] * dcl_Input0_POSITION0.wwww) + Temp_0);
|
||||
VtxGeoOutput1_TEXCOORD0.xy = ((dcl_Input2_TEXCOORD0.xyxx * _MainTex_ST.xyxx) + _MainTex_ST.zwzz).xy;
|
||||
Temp_0.xyz = (dcl_Input0_POSITION0.yyyy * glstate_matrix_modelview0[1].xyzx).xyz;
|
||||
Temp_0.xyz = ((glstate_matrix_modelview0[0].xyzx * dcl_Input0_POSITION0.xxxx) + Temp_0.xyzx).xyz;
|
||||
@ -60,58 +60,30 @@ void main ()
|
||||
Temp_0.w = inversesqrt(Temp_0.w);
|
||||
Temp_1.xyz = (Temp_0.wwww * Temp_1.xyzx).xyz;
|
||||
Temp_2.xyz = glstate_lightmodel_ambient.xyz;
|
||||
tmpvar_1 = 0;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + glstate_lightmodel_ambient.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[tmpvar_1].wwww) + unity_LightPosition[tmpvar_1].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[tmpvar_1].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[tmpvar_1].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
tmpvar_1++;
|
||||
Temp_int_0.w = 0;
|
||||
while (true) {
|
||||
if ((Temp_int_0.w >= 4)) {
|
||||
break;
|
||||
};
|
||||
Temp_3.xyz = ((-(Temp_0.xyzx) * unity_LightPosition[Temp_int_0.w].wwww) + unity_LightPosition[Temp_int_0.w].xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_3.xyz, Temp_3.xyz);
|
||||
Temp_2.w = ((Temp_1.w * unity_LightAtten[Temp_int_0.w].z) + 1.0);
|
||||
Temp_2.w = (1.0/(Temp_2.w));
|
||||
Temp_1.w = inversesqrt(Temp_1.w);
|
||||
Temp_3.xyz = (Temp_1.wwww * Temp_3.xyzx).xyz;
|
||||
Temp_1.w = dot (Temp_1.xyz, Temp_3.xyz);
|
||||
Temp_1.w = max (Temp_1.w, 0.0);
|
||||
Temp_1.w = (Temp_1.w * Temp_2.w);
|
||||
Temp_2.xyz = ((unity_LightColor[Temp_int_0.w].xyzx * Temp_1.wwww) + Temp_2.xyzx).xyz;
|
||||
Temp_int_0.w = (Temp_int_0.w + 1);
|
||||
};
|
||||
VtxGeoOutput2_COLOR0.xyz = (Temp_2.xyzx + Temp_2.xyzx).xyz;
|
||||
VtxGeoOutput2_COLOR0.w = 1.0;
|
||||
gl_Position = tmpvar_2;
|
||||
gl_Position = tmpvar_1;
|
||||
}
|
||||
|
||||
|
||||
// stats: 87 alu 0 tex 0 flow
|
||||
// stats: 43 alu 0 tex 2 flow
|
||||
// inputs: 3
|
||||
// #0: dcl_Input0_POSITION0 (high float) 4x1 [-1]
|
||||
// #1: dcl_Input1_NORMAL0 (high float) 4x1 [-1]
|
||||
|
@ -52,7 +52,7 @@ float4 Temp_0_2;
|
||||
float4 Temp_1_3;
|
||||
float4 Temp_2_4;
|
||||
float4 Temp_3_5;
|
||||
int tmpvar_6;
|
||||
int4 Temp_int_0_6;
|
||||
Temp_0_2 = (_mtl_i.dcl_Input0_POSITION0.yyyy * _mtl_u.glstate_matrix_mvp[1]);
|
||||
Temp_0_2 = ((_mtl_u.glstate_matrix_mvp[0] * _mtl_i.dcl_Input0_POSITION0.xxxx) + Temp_0_2);
|
||||
Temp_0_2 = ((_mtl_u.glstate_matrix_mvp[2] * _mtl_i.dcl_Input0_POSITION0.zzzz) + Temp_0_2);
|
||||
@ -69,51 +69,23 @@ int tmpvar_6;
|
||||
Temp_0_2.w = rsqrt(Temp_0_2.w);
|
||||
Temp_1_3.xyz = (Temp_0_2.wwww * Temp_1_3.xyzx).xyz;
|
||||
Temp_2_4.xyz = _mtl_u.glstate_lightmodel_ambient.xyz;
|
||||
tmpvar_6 = 0;
|
||||
Temp_3_5.xyz = ((-(Temp_0_2.xyzx) * _mtl_u.unity_LightPosition[tmpvar_6].wwww) + _mtl_u.unity_LightPosition[tmpvar_6].xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_3_5.xyz, Temp_3_5.xyz);
|
||||
Temp_2_4.w = ((Temp_1_3.w * _mtl_u.unity_LightAtten[tmpvar_6].z) + 1.0);
|
||||
Temp_2_4.w = (1.0/(Temp_2_4.w));
|
||||
Temp_1_3.w = rsqrt(Temp_1_3.w);
|
||||
Temp_3_5.xyz = (Temp_1_3.wwww * Temp_3_5.xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_1_3.xyz, Temp_3_5.xyz);
|
||||
Temp_1_3.w = max (Temp_1_3.w, 0.0);
|
||||
Temp_1_3.w = (Temp_1_3.w * Temp_2_4.w);
|
||||
Temp_2_4.xyz = ((_mtl_u.unity_LightColor[tmpvar_6].xyzx * Temp_1_3.wwww) + _mtl_u.glstate_lightmodel_ambient.xyzx).xyz;
|
||||
tmpvar_6++;
|
||||
Temp_3_5.xyz = ((-(Temp_0_2.xyzx) * _mtl_u.unity_LightPosition[tmpvar_6].wwww) + _mtl_u.unity_LightPosition[tmpvar_6].xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_3_5.xyz, Temp_3_5.xyz);
|
||||
Temp_2_4.w = ((Temp_1_3.w * _mtl_u.unity_LightAtten[tmpvar_6].z) + 1.0);
|
||||
Temp_2_4.w = (1.0/(Temp_2_4.w));
|
||||
Temp_1_3.w = rsqrt(Temp_1_3.w);
|
||||
Temp_3_5.xyz = (Temp_1_3.wwww * Temp_3_5.xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_1_3.xyz, Temp_3_5.xyz);
|
||||
Temp_1_3.w = max (Temp_1_3.w, 0.0);
|
||||
Temp_1_3.w = (Temp_1_3.w * Temp_2_4.w);
|
||||
Temp_2_4.xyz = ((_mtl_u.unity_LightColor[tmpvar_6].xyzx * Temp_1_3.wwww) + Temp_2_4.xyzx).xyz;
|
||||
tmpvar_6++;
|
||||
Temp_3_5.xyz = ((-(Temp_0_2.xyzx) * _mtl_u.unity_LightPosition[tmpvar_6].wwww) + _mtl_u.unity_LightPosition[tmpvar_6].xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_3_5.xyz, Temp_3_5.xyz);
|
||||
Temp_2_4.w = ((Temp_1_3.w * _mtl_u.unity_LightAtten[tmpvar_6].z) + 1.0);
|
||||
Temp_2_4.w = (1.0/(Temp_2_4.w));
|
||||
Temp_1_3.w = rsqrt(Temp_1_3.w);
|
||||
Temp_3_5.xyz = (Temp_1_3.wwww * Temp_3_5.xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_1_3.xyz, Temp_3_5.xyz);
|
||||
Temp_1_3.w = max (Temp_1_3.w, 0.0);
|
||||
Temp_1_3.w = (Temp_1_3.w * Temp_2_4.w);
|
||||
Temp_2_4.xyz = ((_mtl_u.unity_LightColor[tmpvar_6].xyzx * Temp_1_3.wwww) + Temp_2_4.xyzx).xyz;
|
||||
tmpvar_6++;
|
||||
Temp_3_5.xyz = ((-(Temp_0_2.xyzx) * _mtl_u.unity_LightPosition[tmpvar_6].wwww) + _mtl_u.unity_LightPosition[tmpvar_6].xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_3_5.xyz, Temp_3_5.xyz);
|
||||
Temp_2_4.w = ((Temp_1_3.w * _mtl_u.unity_LightAtten[tmpvar_6].z) + 1.0);
|
||||
Temp_2_4.w = (1.0/(Temp_2_4.w));
|
||||
Temp_1_3.w = rsqrt(Temp_1_3.w);
|
||||
Temp_3_5.xyz = (Temp_1_3.wwww * Temp_3_5.xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_1_3.xyz, Temp_3_5.xyz);
|
||||
Temp_1_3.w = max (Temp_1_3.w, 0.0);
|
||||
Temp_1_3.w = (Temp_1_3.w * Temp_2_4.w);
|
||||
Temp_2_4.xyz = ((_mtl_u.unity_LightColor[tmpvar_6].xyzx * Temp_1_3.wwww) + Temp_2_4.xyzx).xyz;
|
||||
tmpvar_6++;
|
||||
Temp_int_0_6.w = 0;
|
||||
while (true) {
|
||||
if ((Temp_int_0_6.w >= 4)) {
|
||||
break;
|
||||
};
|
||||
Temp_3_5.xyz = ((-(Temp_0_2.xyzx) * _mtl_u.unity_LightPosition[Temp_int_0_6.w].wwww) + _mtl_u.unity_LightPosition[Temp_int_0_6.w].xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_3_5.xyz, Temp_3_5.xyz);
|
||||
Temp_2_4.w = ((Temp_1_3.w * _mtl_u.unity_LightAtten[Temp_int_0_6.w].z) + 1.0);
|
||||
Temp_2_4.w = (1.0/(Temp_2_4.w));
|
||||
Temp_1_3.w = rsqrt(Temp_1_3.w);
|
||||
Temp_3_5.xyz = (Temp_1_3.wwww * Temp_3_5.xyzx).xyz;
|
||||
Temp_1_3.w = dot (Temp_1_3.xyz, Temp_3_5.xyz);
|
||||
Temp_1_3.w = max (Temp_1_3.w, 0.0);
|
||||
Temp_1_3.w = (Temp_1_3.w * Temp_2_4.w);
|
||||
Temp_2_4.xyz = ((_mtl_u.unity_LightColor[Temp_int_0_6.w].xyzx * Temp_1_3.wwww) + Temp_2_4.xyzx).xyz;
|
||||
Temp_int_0_6.w = (Temp_int_0_6.w + 1);
|
||||
};
|
||||
_mtl_o.VtxGeoOutput2_COLOR0.xyz = (Temp_2_4.xyzx + Temp_2_4.xyzx).xyz;
|
||||
_mtl_o.VtxGeoOutput2_COLOR0.w = 1.0;
|
||||
_mtl_o.gl_Position = phase0_Output0_1;
|
||||
@ -121,7 +93,7 @@ int tmpvar_6;
|
||||
}
|
||||
|
||||
|
||||
// stats: 87 alu 0 tex 0 flow
|
||||
// stats: 43 alu 0 tex 2 flow
|
||||
// inputs: 3
|
||||
// #0: dcl_Input0_POSITION0 (high float) 4x1 [-1] loc 0
|
||||
// #1: dcl_Input1_NORMAL0 (high float) 4x1 [-1] loc 1
|
||||
|
@ -12,7 +12,8 @@
|
||||
//#define ImVector MyVector
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
#include <assert.h>
|
||||
#define IM_ASSERT(_EXPR, ...) assert(_EXPR)
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
|
353
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
353
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -19,7 +19,8 @@
|
||||
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
||||
- How do I update to a newer version of ImGui?
|
||||
- Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
|
||||
- Why is my text output blurry?
|
||||
- I integrated ImGui in my engine and the text or lines are blurry..
|
||||
- I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
||||
- How can I load a different font than the default?
|
||||
- How can I load multiple fonts?
|
||||
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||
@ -187,7 +188,7 @@
|
||||
- 2015/03/17 (1.36) - renamed GetItemBoxMin()/GetItemBoxMax()/IsMouseHoveringBox() to GetItemRectMin()/GetItemRectMax()/IsMouseHoveringRect(). Kept inline redirection function (will obsolete).
|
||||
- 2015/03/15 (1.36) - renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing
|
||||
- 2015/03/13 (1.36) - renamed GetWindowIsFocused() to IsWindowFocused(). Kept inline redirection function (will obsolete).
|
||||
- 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth
|
||||
- 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth (casing)
|
||||
- 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond). Kept inline redirection function (will obsolete).
|
||||
- 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once.
|
||||
- 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now.
|
||||
@ -281,9 +282,9 @@
|
||||
|
||||
Button("Hello###ID"; // Label = "Hello", ID = hash of "ID"
|
||||
Button("World###ID"; // Label = "World", ID = hash of "ID" (same as above)
|
||||
|
||||
sprintf(buf, "My game (%f FPS)###MyGame");
|
||||
Begin(buf); // Variable label, ID = hash of "MyGame"
|
||||
|
||||
sprintf(buf, "My game (%f FPS)###MyGame");
|
||||
Begin(buf); // Variable label, ID = hash of "MyGame"
|
||||
|
||||
- Use PushID() / PopID() to create scopes and avoid ID conflicts within the same Window.
|
||||
This is the most convenient way of distinguishing ID if you are iterating and creating many UI elements.
|
||||
@ -336,8 +337,12 @@
|
||||
e.g. when displaying a single object that may change over time (1-1 relationship), using a static string as ID will preserve your node open/closed state when the targeted object change.
|
||||
e.g. when displaying a list of objects, using indices or pointers as ID will preserve the node open/closed state differently. experiment and see what makes more sense!
|
||||
|
||||
Q: Why is my text output blurry?
|
||||
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||
Q: I integrated ImGui in my engine and the text or lines are blurry..
|
||||
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
||||
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
||||
|
||||
Q. I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
||||
Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
|
||||
|
||||
Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
|
||||
A: Use the font atlas to load the TTF file you want:
|
||||
@ -394,14 +399,19 @@
|
||||
Issue numbers (#) refer to github issues.
|
||||
The list below consist mostly of notes of things to do before they are requested/discussed by users (at that point it usually happens on the github)
|
||||
|
||||
- window: autofit feedback loop when user relies on any dynamic layout (window width multiplier, column). maybe just clearly drop manual autofit?
|
||||
- window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list.
|
||||
- window: maximum window size settings (per-axis). for large popups in particular user may not want the popup to fill all space.
|
||||
- window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. perhaps a lightweight explicit cleanup pass.
|
||||
- window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column). clarify.
|
||||
- window: allow resizing of child windows (possibly given min/max for each axis?)
|
||||
- window: background options for child windows, border option (disable rounding)
|
||||
- window: add a way to clear an existing window instead of appending (e.g. for tooltip override using a consistent api rather than the deferred tooltip)
|
||||
- window: resizing from any sides? + mouse cursor directives for app.
|
||||
!- window: begin with *p_opened == false should return false.
|
||||
- window: get size/pos helpers given names (see discussion in #249)
|
||||
- window: a collapsed window can be stuck behind the main menu bar?
|
||||
- window: detect extra End() call that pop the "Debug" window out and assert at call site instead of later.
|
||||
!- scrolling: allow immediately effective change of scroll if we haven't appended items yet
|
||||
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split)
|
||||
- widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc.
|
||||
- widgets: clean up widgets internal toward exposing everything.
|
||||
- widgets: add disabled and read-only modes (#211)
|
||||
@ -416,6 +426,8 @@
|
||||
- input number: use mouse wheel to step up/down
|
||||
- input number: applying arithmetics ops (+,-,*,/) messes up with text edit undo stack.
|
||||
- text: proper alignment options
|
||||
- image/image button: misalignment on padded/bordered button?
|
||||
- image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
|
||||
- layout: horizontal layout helper (#97)
|
||||
- layout: more generic alignment state (left/right/centered) for single items?
|
||||
- layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
|
||||
@ -426,23 +438,25 @@
|
||||
- popup: border options. richer api like BeginChild() perhaps? (#197)
|
||||
- combo: sparse combo boxes (via function call?)
|
||||
- combo: contents should extends to fit label if combo widget is small
|
||||
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keybord for custom listbox (pr #203)
|
||||
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
|
||||
- listbox: multiple selection
|
||||
- listbox: user may want to initial scroll to focus on the one selected value?
|
||||
- listbox: keyboard navigation.
|
||||
- listbox: scrolling should track modified selection.
|
||||
-! menus/popups: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331)
|
||||
- menus: local shortcuts, global shortcuts (#126)
|
||||
- menus: icons
|
||||
- menus: menubars: some sort of priority / effect of main menu-bar on desktop size?
|
||||
- statusbar: add a per-window status bar helper similar to what menubar does.
|
||||
- tabs
|
||||
- separator: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y)
|
||||
- gauge: various forms of gauge/loading bars widgets
|
||||
- color: add a better color picker (perhaps a popup).
|
||||
- plot: plotlines should use the polygon-stroke facilities (currently issues with averaging normals)
|
||||
- color: add a better color picker
|
||||
- plot: PlotLines() should use the polygon-stroke facilities (currently issues with averaging normals)
|
||||
- plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots)
|
||||
- plot: "smooth" automatic scale over time, user give an input 0.0(full user scale) 1.0(full derived from value)
|
||||
- plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
|
||||
- file selection widget -> build the tool in our codebase to improve model-dialog idioms
|
||||
- applet: file selection widget (as an example)
|
||||
- slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
|
||||
- slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar).
|
||||
- slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate.
|
||||
@ -453,13 +467,15 @@
|
||||
- text edit: centered text for slider as input text so it matches typical positioning.
|
||||
- text edit: flag to disable live update of the user buffer.
|
||||
- text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
|
||||
- tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
|
||||
- tree node / optimization: avoid formatting when clipped.
|
||||
- tree node: tree-node/header right-most side doesn't take account of horizontal scrolling.
|
||||
- tree node: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
|
||||
- textwrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (git issue #249)
|
||||
- settings: write more decent code to allow saving/loading new fields
|
||||
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file
|
||||
- style: store rounded corners in texture to use 1 quad per corner (filled and wireframe). so rounding have minor cost.
|
||||
- style: color-box not always square?
|
||||
- style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps that other settings?
|
||||
- style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc.
|
||||
- text: simple markup language for color change?
|
||||
- log: LogButtons() options for specifying depth and/or hiding depth slider
|
||||
- log: have more control over the log scope (e.g. stop logging when leaving current tree node scope)
|
||||
@ -473,11 +489,12 @@
|
||||
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
|
||||
- input: rework IO to be able to pass actual events to fix temporal aliasing issues.
|
||||
- input: support track pad style scrolling & slider edit.
|
||||
- memory: add a way to discard allocs of unused/transient windows. with the current architecture new windows (including popup, opened combos, listbox) perform at least 3 allocs.
|
||||
- misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
|
||||
- misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
|
||||
- style editor: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space?
|
||||
- style editor: color child window height expressed in multiple of line height.
|
||||
!- examples: directx9/directx11: resizing window duplicate the font data :(
|
||||
- optimization: use another hash function than crc32, e.g. FNV1a
|
||||
- optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
|
||||
- optimization: turn some the various stack vectors into statically-sized arrays
|
||||
- optimization: better clipping for multi-component widgets
|
||||
@ -698,6 +715,10 @@ ImGuiIO::ImGuiIO()
|
||||
MouseDoubleClickTime = 0.30f;
|
||||
MouseDoubleClickMaxDist = 6.0f;
|
||||
MouseDragThreshold = 6.0f;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++)
|
||||
MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++)
|
||||
KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f;
|
||||
for (int i = 0; i < ImGuiKey_COUNT; i++)
|
||||
KeyMap[i] = -1;
|
||||
KeyRepeatDelay = 0.250f;
|
||||
@ -898,7 +919,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
|
||||
if ((*str & 0xe0) == 0xc0)
|
||||
{
|
||||
*out_char = 0xFFFD; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 2) return 0;
|
||||
if (in_text_end && in_text_end - (const char*)str < 2) return 1;
|
||||
if (*str < 0xc2) return 2;
|
||||
c = (unsigned int)((*str++ & 0x1f) << 6);
|
||||
if ((*str & 0xc0) != 0x80) return 2;
|
||||
@ -909,7 +930,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
|
||||
if ((*str & 0xf0) == 0xe0)
|
||||
{
|
||||
*out_char = 0xFFFD; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 3) return 0;
|
||||
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
|
||||
if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
|
||||
if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
|
||||
c = (unsigned int)((*str++ & 0x0f) << 12);
|
||||
@ -923,7 +944,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
|
||||
if ((*str & 0xf8) == 0xf0)
|
||||
{
|
||||
*out_char = 0xFFFD; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 4) return 0;
|
||||
if (in_text_end && in_text_end - (const char*)str < 4) return 1;
|
||||
if (*str > 0xf4) return 4;
|
||||
if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4;
|
||||
if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below
|
||||
@ -1303,14 +1324,16 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiTextFilter::Draw(const char* label, float width)
|
||||
bool ImGuiTextFilter::Draw(const char* label, float width)
|
||||
{
|
||||
if (width != 0.0f)
|
||||
ImGui::PushItemWidth(width);
|
||||
ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
|
||||
bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
|
||||
if (width != 0.0f)
|
||||
ImGui::PopItemWidth();
|
||||
Build();
|
||||
if (value_changed)
|
||||
Build();
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
void ImGuiTextFilter::TextRange::split(char separator, ImVector<TextRange>& out)
|
||||
@ -1564,11 +1587,18 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window = NULL)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
g.ActiveId = id;
|
||||
g.ActiveIdIsFocusedOnly = false;
|
||||
g.ActiveIdAllowHoveringOthers = false;
|
||||
g.ActiveIdIsJustActivated = true;
|
||||
g.ActiveIdWindow = window;
|
||||
}
|
||||
|
||||
void ImGui::SetHoveredID(ImGuiID id)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
g.HoveredId = id;
|
||||
g.HoveredIdAllowHoveringOthers = false;
|
||||
}
|
||||
|
||||
void ImGui::KeepAliveID(ImGuiID id)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
@ -1627,7 +1657,7 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id)
|
||||
window->DC.LastItemHoveredRect = true;
|
||||
window->DC.LastItemHoveredAndUsable = false;
|
||||
if (g.HoveredRootWindow == window->RootWindow)
|
||||
if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdIsFocusedOnly || (g.ActiveId == window->MoveID))
|
||||
if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdAllowHoveringOthers || (g.ActiveId == window->MoveID))
|
||||
if (IsWindowContentHoverable(window))
|
||||
window->DC.LastItemHoveredAndUsable = true;
|
||||
}
|
||||
@ -1656,11 +1686,11 @@ bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when
|
||||
bool ImGui::IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
if (g.HoveredId == 0 || g.HoveredId == id)
|
||||
if (g.HoveredId == 0 || g.HoveredId == id || g.HoveredIdAllowHoveringOthers)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
if (g.HoveredWindow == window || (flatten_childs && g.HoveredRootWindow == window->RootWindow))
|
||||
if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdIsFocusedOnly) && ImGui::IsMouseHoveringRect(bb.Min, bb.Max))
|
||||
if ((g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdAllowHoveringOthers) && ImGui::IsMouseHoveringRect(bb.Min, bb.Max))
|
||||
if (IsWindowContentHoverable(g.HoveredRootWindow))
|
||||
return true;
|
||||
}
|
||||
@ -1742,6 +1772,17 @@ void ImGui::MemFree(void* ptr)
|
||||
return GImGui->IO.MemFreeFn(ptr);
|
||||
}
|
||||
|
||||
const char* ImGui::GetClipboardText()
|
||||
{
|
||||
return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn() : "";
|
||||
}
|
||||
|
||||
void ImGui::SetClipboardText(const char* text)
|
||||
{
|
||||
if (GImGui->IO.SetClipboardTextFn)
|
||||
GImGui->IO.SetClipboardTextFn(text);
|
||||
}
|
||||
|
||||
const char* ImGui::GetVersion()
|
||||
{
|
||||
return IMGUI_VERSION;
|
||||
@ -1839,10 +1880,10 @@ void ImGui::NewFrame()
|
||||
g.IO.MousePosPrev = g.IO.MousePos;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++)
|
||||
{
|
||||
g.IO.MouseClicked[i] = g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] < 0.0f;
|
||||
g.IO.MouseReleased[i] = !g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] >= 0.0f;
|
||||
g.IO.MouseDownDurationPrev[i] = g.IO.MouseDownDuration[i];
|
||||
g.IO.MouseDownDuration[i] = g.IO.MouseDown[i] ? (g.IO.MouseDownDuration[i] < 0.0f ? 0.0f : g.IO.MouseDownDuration[i] + g.IO.DeltaTime) : -1.0f;
|
||||
g.IO.MouseClicked[i] = g.IO.MouseDownDuration[i] == 0.0f;
|
||||
g.IO.MouseReleased[i] = g.IO.MouseDownDurationPrev[i] >= 0.0f && !g.IO.MouseDown[i];
|
||||
g.IO.MouseDoubleClicked[i] = false;
|
||||
if (g.IO.MouseClicked[i])
|
||||
{
|
||||
@ -1877,6 +1918,7 @@ void ImGui::NewFrame()
|
||||
// Clear reference to active widget if the widget isn't alive anymore
|
||||
g.HoveredIdPreviousFrame = g.HoveredId;
|
||||
g.HoveredId = 0;
|
||||
g.HoveredIdAllowHoveringOthers = false;
|
||||
if (!g.ActiveIdIsAlive && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
|
||||
SetActiveID(0);
|
||||
g.ActiveIdPreviousFrame = g.ActiveId;
|
||||
@ -2259,78 +2301,86 @@ static void PopClipRect()
|
||||
window->ClipRect = window->DrawList->_ClipRectStack.back();
|
||||
}
|
||||
|
||||
// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal.
|
||||
void ImGui::EndFrame()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
|
||||
IM_ASSERT(g.FrameCountEnded != g.FrameCount); // ImGui::EndFrame() called multiple times, or forgot to call ImGui::NewFrame() again
|
||||
|
||||
// Render tooltip
|
||||
if (g.Tooltip[0])
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextUnformatted(g.Tooltip);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
// Hide implicit "Debug" window if it hasn't been used
|
||||
IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin/End
|
||||
if (g.CurrentWindow && !g.CurrentWindow->Accessed)
|
||||
g.CurrentWindow->Active = false;
|
||||
ImGui::End();
|
||||
|
||||
// Click to focus window and start moving (after we're done with all our widgets)
|
||||
if (!g.ActiveId)
|
||||
g.MovedWindow = NULL;
|
||||
if (g.ActiveId == 0 && g.HoveredId == 0 && g.IO.MouseClicked[0])
|
||||
{
|
||||
if (!(g.FocusedWindow && !g.FocusedWindow->WasActive && g.FocusedWindow->Active)) // Unless we just made a popup appear
|
||||
{
|
||||
if (g.HoveredRootWindow != NULL)
|
||||
{
|
||||
FocusWindow(g.HoveredWindow);
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovedWindow = g.HoveredWindow;
|
||||
SetActiveID(g.HoveredRootWindow->MoveID, g.HoveredRootWindow);
|
||||
}
|
||||
}
|
||||
else if (g.FocusedWindow != NULL && GetFrontMostModalRootWindow() == NULL)
|
||||
{
|
||||
// Clicking on void disable focus
|
||||
FocusWindow(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the window list so that all child windows are after their parent
|
||||
// We cannot do that on FocusWindow() because childs may not exist yet
|
||||
g.WindowsSortBuffer.resize(0);
|
||||
g.WindowsSortBuffer.reserve(g.Windows.Size);
|
||||
for (int i = 0; i != g.Windows.Size; i++)
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[i];
|
||||
if (window->Flags & ImGuiWindowFlags_ChildWindow) // if a child is active its parent will add it
|
||||
if (window->Active)
|
||||
continue;
|
||||
AddWindowToSortedBuffer(g.WindowsSortBuffer, window);
|
||||
}
|
||||
IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size); // we done something wrong
|
||||
g.Windows.swap(g.WindowsSortBuffer);
|
||||
|
||||
// Clear Input data for next frame
|
||||
g.IO.MouseWheel = 0.0f;
|
||||
memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters));
|
||||
|
||||
g.FrameCountEnded = g.FrameCount;
|
||||
}
|
||||
|
||||
void ImGui::Render()
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
|
||||
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
|
||||
|
||||
const bool first_render_of_the_frame = (g.FrameCountRendered != g.FrameCount);
|
||||
if (g.FrameCountEnded != g.FrameCount)
|
||||
ImGui::EndFrame();
|
||||
g.FrameCountRendered = g.FrameCount;
|
||||
|
||||
if (first_render_of_the_frame)
|
||||
{
|
||||
// Hide implicit "Debug" window if it hasn't been used
|
||||
IM_ASSERT(g.CurrentWindowStack.Size == 1); // Mismatched Begin/End
|
||||
if (g.CurrentWindow && !g.CurrentWindow->Accessed)
|
||||
g.CurrentWindow->Active = false;
|
||||
ImGui::End();
|
||||
|
||||
// Click to focus window and start moving (after we're done with all our widgets)
|
||||
if (!g.ActiveId)
|
||||
g.MovedWindow = NULL;
|
||||
if (g.ActiveId == 0 && g.HoveredId == 0 && g.IO.MouseClicked[0])
|
||||
{
|
||||
if (!(g.FocusedWindow && !g.FocusedWindow->WasActive && g.FocusedWindow->Active)) // Unless we just made a popup appear
|
||||
{
|
||||
if (g.HoveredRootWindow != NULL)
|
||||
{
|
||||
FocusWindow(g.HoveredWindow);
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovedWindow = g.HoveredWindow;
|
||||
SetActiveID(g.HoveredRootWindow->MoveID, g.HoveredRootWindow);
|
||||
}
|
||||
}
|
||||
else if (g.FocusedWindow != NULL && GetFrontMostModalRootWindow() == NULL)
|
||||
{
|
||||
// Clicking on void disable focus
|
||||
FocusWindow(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the window list so that all child windows are after their parent
|
||||
// We cannot do that on FocusWindow() because childs may not exist yet
|
||||
g.WindowsSortBuffer.resize(0);
|
||||
g.WindowsSortBuffer.reserve(g.Windows.Size);
|
||||
for (int i = 0; i != g.Windows.Size; i++)
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[i];
|
||||
if (window->Flags & ImGuiWindowFlags_ChildWindow) // if a child is active its parent will add it
|
||||
if (window->Active)
|
||||
continue;
|
||||
AddWindowToSortedBuffer(g.WindowsSortBuffer, window);
|
||||
}
|
||||
IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size); // we done something wrong
|
||||
g.Windows.swap(g.WindowsSortBuffer);
|
||||
|
||||
// Clear Input data for next frame
|
||||
g.IO.MouseWheel = 0.0f;
|
||||
memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters));
|
||||
}
|
||||
|
||||
// Skip render altogether if alpha is 0.0
|
||||
// Note that vertex buffers have been created and are wasted, so it is best practice that you don't create windows in the first place, or respond to Begin() returning false.
|
||||
// Note that vertex buffers have been created and are wasted, so it is best practice that you don't create windows in the first place, or consistently respond to Begin() returning false.
|
||||
if (g.Style.Alpha > 0.0f)
|
||||
{
|
||||
// Render tooltip
|
||||
if (g.Tooltip[0])
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextUnformatted(g.Tooltip);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
// Gather windows to render
|
||||
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsActiveWindows = 0;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(g.RenderDrawLists); i++)
|
||||
@ -2360,13 +2410,13 @@ void ImGui::Render()
|
||||
for (int i = 1; i < IM_ARRAYSIZE(g.RenderDrawLists); i++)
|
||||
{
|
||||
ImVector<ImDrawList*>& layer = g.RenderDrawLists[i];
|
||||
if (!layer.empty())
|
||||
{
|
||||
memcpy(&g.RenderDrawLists[0][n], &layer[0], layer.Size * sizeof(ImDrawList*));
|
||||
n += layer.Size;
|
||||
}
|
||||
if (layer.empty())
|
||||
continue;
|
||||
memcpy(&g.RenderDrawLists[0][n], &layer[0], layer.Size * sizeof(ImDrawList*));
|
||||
n += layer.Size;
|
||||
}
|
||||
|
||||
// Draw software mouse cursor if requested
|
||||
if (g.IO.MouseDrawCursor)
|
||||
{
|
||||
const ImGuiMouseCursorData& cursor_data = g.MouseCursorData[g.MouseCursor];
|
||||
@ -2392,9 +2442,7 @@ void ImGui::Render()
|
||||
|
||||
// Render. If user hasn't set a callback then they may retrieve the draw data via GetDrawData()
|
||||
if (g.RenderDrawData.CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL)
|
||||
{
|
||||
g.IO.RenderDrawListsFn(&g.RenderDrawData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3276,13 +3324,13 @@ void ImGui::EndChild()
|
||||
}
|
||||
|
||||
// Helper to create a child window / scrolling region that looks like a normal widget frame.
|
||||
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size)
|
||||
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding);
|
||||
return ImGui::BeginChild(id, size, false, ImGuiWindowFlags_NoMove);
|
||||
return ImGui::BeginChild(id, size, false, ImGuiWindowFlags_NoMove | extra_flags);
|
||||
}
|
||||
|
||||
void ImGui::EndChildFrame()
|
||||
@ -3430,8 +3478,9 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
IM_ASSERT(name != NULL); // Window name required
|
||||
IM_ASSERT(g.Initialized); // Forgot to call ImGui::NewFrame()
|
||||
IM_ASSERT(name != NULL); // Must pass a name
|
||||
IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet
|
||||
|
||||
if (flags & ImGuiWindowFlags_NoInputs)
|
||||
flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
@ -3839,7 +3888,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
else if ((flags & ImGuiWindowFlags_Popup) != 0)
|
||||
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding);
|
||||
else if ((flags & ImGuiWindowFlags_ChildWindow) != 0)
|
||||
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size - window->ScrollbarSizes, window->Color(ImGuiCol_ChildWindowBg, bg_alpha), window_rounding, window->ScrollbarY ? (1|8) : (0xF));
|
||||
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_ChildWindowBg, bg_alpha), window_rounding);
|
||||
else
|
||||
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding);
|
||||
}
|
||||
@ -3958,7 +4007,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
|
||||
// Note that if our window is collapsed we will end up with a null clipping rectangle which is the correct behavior.
|
||||
const ImRect title_bar_rect = window->TitleBarRect();
|
||||
ImRect clip_rect(title_bar_rect.Min.x+0.5f+window->WindowPadding.x*0.5f, title_bar_rect.Max.y+window->MenuBarHeight()+0.5f, window->Pos.x+window->Size.x+0.5f-window->WindowPadding.x*0.5f, window->Pos.y+window->Size.y+0.5f);
|
||||
ImRect clip_rect(title_bar_rect.Min.x+0.5f+window->WindowPadding.x*0.5f, title_bar_rect.Max.y+window->MenuBarHeight()+0.5f, window->Pos.x+window->Size.x-window->WindowPadding.x*0.5f, window->Pos.y+window->Size.y);
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_ShowBorders))
|
||||
clip_rect.Min += ImVec2(1.0f,1.0f);
|
||||
clip_rect.Max.x -= window->ScrollbarY ? style.ScrollbarSize : 0.0f;
|
||||
@ -4029,11 +4078,19 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
|
||||
bool other_scrollbar = (horizontal ? window->ScrollbarY : window->ScrollbarX);
|
||||
float other_scrollbar_size_w = other_scrollbar ? style.ScrollbarSize : 0.0f;
|
||||
const ImRect window_rect = window->Rect();
|
||||
const float border_offset = (window->Flags & ImGuiWindowFlags_ShowBorders) ? 1.0f : 0.0f;
|
||||
ImRect bb = horizontal
|
||||
? ImRect(window->Pos.x + 1, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - 1 - other_scrollbar_size_w, window_rect.Max.y)
|
||||
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + window->TitleBarHeight()+1, window_rect.Max.x, window_rect.Max.y - 1 - other_scrollbar_size_w);
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, window->Color(ImGuiCol_ScrollbarBg));
|
||||
bb.Expand(-3.0f);
|
||||
? ImRect(window->Pos.x + border_offset, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w, window_rect.Max.y)
|
||||
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + window->TitleBarHeight() + border_offset, window_rect.Max.x, window_rect.Max.y - other_scrollbar_size_w);
|
||||
|
||||
float window_rounding = (window->Flags & ImGuiWindowFlags_ChildWindow) ? style.ChildWindowRounding : style.WindowRounding;
|
||||
int window_rounding_corners;
|
||||
if (horizontal)
|
||||
window_rounding_corners = 8 | (other_scrollbar ? 0 : 4);
|
||||
else
|
||||
window_rounding_corners = ((window->Flags & ImGuiWindowFlags_NoTitleBar) ? 2 : 0) | (other_scrollbar ? 0 : 4);
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, window->Color(ImGuiCol_ScrollbarBg), window_rounding, window_rounding_corners);
|
||||
bb.Reduce(ImVec2(ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
|
||||
|
||||
// V denote the main axis of the scrollbar
|
||||
float scrollbar_size_v = horizontal ? bb.GetWidth() : bb.GetHeight();
|
||||
@ -4063,7 +4120,7 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
|
||||
|
||||
// Click position in scrollbar normalized space (0.0f->1.0f)
|
||||
const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v);
|
||||
g.HoveredId = id;
|
||||
ImGui::SetHoveredID(id);
|
||||
|
||||
bool seek_absolute = false;
|
||||
if (!previously_held)
|
||||
@ -4127,9 +4184,9 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != window)
|
||||
ImGui::SetActiveID(0);
|
||||
|
||||
if (g.Windows.back() == window)
|
||||
// Bring to front
|
||||
if ((window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus) || g.Windows.back() == window)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < g.Windows.Size; i++)
|
||||
if (g.Windows[i] == window)
|
||||
{
|
||||
@ -5085,7 +5142,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
const bool hovered = IsHovered(bb, id, (flags & ImGuiButtonFlags_FlattenChilds) != 0);
|
||||
if (hovered)
|
||||
{
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
if (allow_key_modifiers || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
|
||||
{
|
||||
if (g.IO.MouseClicked[0])
|
||||
@ -5799,8 +5856,8 @@ static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
{
|
||||
if (!scalar_format)
|
||||
scalar_format = "%f";
|
||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||
scalar_format = "%f";
|
||||
float* v = (float*)data_ptr;
|
||||
float ref_v = *v;
|
||||
if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
|
||||
@ -5824,7 +5881,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
||||
|
||||
// Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen)
|
||||
SetActiveID(g.ScalarAsInputTextId, window);
|
||||
g.HoveredId = 0;
|
||||
SetHoveredID(0);
|
||||
FocusableItemUnregister(window);
|
||||
|
||||
char buf[32];
|
||||
@ -5835,7 +5892,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
||||
// First frame
|
||||
IM_ASSERT(g.ActiveId == id); // InputText ID expected to match the Slider ID (else we'd need to store them both, which is also possible)
|
||||
g.ScalarAsInputTextId = g.ActiveId;
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
}
|
||||
else if (g.ActiveId != g.ScalarAsInputTextId)
|
||||
{
|
||||
@ -6041,7 +6098,7 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
|
||||
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
@ -6100,7 +6157,7 @@ bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float
|
||||
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
@ -6341,7 +6398,7 @@ bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, f
|
||||
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
@ -6565,16 +6622,15 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
||||
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, window->Color(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
|
||||
int res_w = ImMin((int)graph_size.x, values_count);
|
||||
if (plot_type == ImGuiPlotType_Lines)
|
||||
res_w -= 1;
|
||||
int res_w = ImMin((int)graph_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
|
||||
int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);
|
||||
|
||||
// Tooltip on hover
|
||||
int v_hovered = -1;
|
||||
if (IsHovered(inner_bb, 0))
|
||||
{
|
||||
const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f);
|
||||
const int v_idx = (int)(t * (values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0)));
|
||||
const int v_idx = (int)(t * item_count);
|
||||
IM_ASSERT(v_idx >= 0 && v_idx < values_count);
|
||||
|
||||
const float v0 = values_getter(data, (v_idx + values_offset) % values_count);
|
||||
@ -6590,7 +6646,7 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
||||
|
||||
float v0 = values_getter(data, (0 + values_offset) % values_count);
|
||||
float t0 = 0.0f;
|
||||
ImVec2 p0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) / (scale_max - scale_min)) );
|
||||
ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) / (scale_max - scale_min)) ); // Point in the normalized space of our target rectangle
|
||||
|
||||
const ImU32 col_base = window->Color((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram);
|
||||
const ImU32 col_hovered = window->Color((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLinesHovered : ImGuiCol_PlotHistogramHovered);
|
||||
@ -6598,19 +6654,27 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge
|
||||
for (int n = 0; n < res_w; n++)
|
||||
{
|
||||
const float t1 = t0 + t_step;
|
||||
const int v_idx = (int)(t0 * values_count);
|
||||
IM_ASSERT(v_idx >= 0 && v_idx < values_count);
|
||||
const float v1 = values_getter(data, (v_idx + values_offset + 1) % values_count);
|
||||
const ImVec2 p1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) / (scale_max - scale_min)) );
|
||||
const int v1_idx = (int)(t0 * item_count + 0.5f);
|
||||
IM_ASSERT(v1_idx >= 0 && v1_idx < values_count);
|
||||
const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count);
|
||||
const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) / (scale_max - scale_min)) );
|
||||
|
||||
// NB- Draw calls are merged together by the DrawList system.
|
||||
// NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU.
|
||||
ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0);
|
||||
ImVec2 pos1 = ImLerp(inner_bb.Min, inner_bb.Max, (plot_type == ImGuiPlotType_Lines) ? tp1 : ImVec2(tp1.x, 1.0f));
|
||||
if (plot_type == ImGuiPlotType_Lines)
|
||||
window->DrawList->AddLine(ImLerp(inner_bb.Min, inner_bb.Max, p0), ImLerp(inner_bb.Min, inner_bb.Max, p1), v_hovered == v_idx ? col_hovered : col_base);
|
||||
{
|
||||
window->DrawList->AddLine(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base);
|
||||
}
|
||||
else if (plot_type == ImGuiPlotType_Histogram)
|
||||
window->DrawList->AddRectFilled(ImLerp(inner_bb.Min, inner_bb.Max, p0), ImLerp(inner_bb.Min, inner_bb.Max, ImVec2(p1.x, 1.0f))+ImVec2(-1,0), v_hovered == v_idx ? col_hovered : col_base);
|
||||
{
|
||||
if (pos1.x >= pos0.x + 2.0f)
|
||||
pos1.x -= 1.0f;
|
||||
window->DrawList->AddRectFilled(pos0, pos1, v_hovered == v1_idx ? col_hovered : col_base);
|
||||
}
|
||||
|
||||
t0 = t1;
|
||||
p0 = p1;
|
||||
tp0 = tp1;
|
||||
}
|
||||
|
||||
// Text overlay
|
||||
@ -7079,7 +7143,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
const bool hovered = IsHovered(frame_bb, id);
|
||||
if (hovered)
|
||||
{
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
g.MouseCursor = ImGuiMouseCursor_TextInput;
|
||||
}
|
||||
const bool user_clicked = hovered && io.MouseClicked[0];
|
||||
@ -7094,8 +7158,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
// Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar)
|
||||
// From the moment we focused we are ignoring the content of 'buf'
|
||||
const int prev_len_w = edit_state.CurLenW;
|
||||
edit_state.Text.resize(buf_size); // wchar count <= utf-8 count
|
||||
edit_state.InitialText.resize(buf_size); // utf-8
|
||||
edit_state.Text.resize(buf_size+1); // wchar count <= utf-8 count. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
|
||||
edit_state.InitialText.resize(buf_size+1); // utf-8. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
|
||||
ImFormatString(edit_state.InitialText.Data, edit_state.InitialText.Size, "%s", buf);
|
||||
const char* buf_end = NULL;
|
||||
edit_state.CurLenW = ImTextStrFromUtf8(edit_state.Text.Data, edit_state.Text.Size, buf, NULL, &buf_end);
|
||||
@ -7117,7 +7181,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
else
|
||||
{
|
||||
edit_state.Id = id;
|
||||
edit_state.ScrollX = 0.f;
|
||||
edit_state.ScrollX = 0.0f;
|
||||
stb_textedit_initialize_state(&edit_state.StbState, !is_multiline);
|
||||
if (!is_multiline && focus_requested_by_code)
|
||||
select_all = true;
|
||||
@ -7147,7 +7211,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
|
||||
// Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget.
|
||||
// Down the line we should have a cleaner concept of focused vs active in the library.
|
||||
g.ActiveIdIsFocusedOnly = !io.MouseDown[0];
|
||||
g.ActiveIdAllowHoveringOthers = !io.MouseDown[0];
|
||||
|
||||
// Edit in progress
|
||||
const float mouse_x = (g.IO.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
|
||||
@ -7167,6 +7231,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
{
|
||||
stb_textedit_drag(&edit_state, &edit_state.StbState, mouse_x, mouse_y);
|
||||
edit_state.CursorAnimReset();
|
||||
edit_state.CursorFollow = true;
|
||||
}
|
||||
if (edit_state.SelectedAllMouseLock && !io.MouseDown[0])
|
||||
edit_state.SelectedAllMouseLock = false;
|
||||
@ -7174,7 +7239,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
if (g.IO.InputCharacters[0])
|
||||
{
|
||||
// Process text input (before we check for Return because using some IME will effectively send a Return?)
|
||||
if (!is_ctrl_down && !is_alt_down && is_editable)
|
||||
// We ignore CTRL inputs, but need to allow CTRL+ALT as some keyboards (e.g. German) use AltGR - which is Alt+Ctrl - to input certain characters.
|
||||
if (!(is_ctrl_down && !is_alt_down) && is_editable)
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(g.IO.InputCharacters) && g.IO.InputCharacters[n]; n++)
|
||||
if (unsigned int c = (unsigned int)g.IO.InputCharacters[n])
|
||||
@ -7436,9 +7502,9 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
{
|
||||
const float scroll_increment_x = size.x * 0.25f;
|
||||
if (cursor_offset.x < edit_state.ScrollX)
|
||||
edit_state.ScrollX = ImMax(0.0f, cursor_offset.x - scroll_increment_x);
|
||||
edit_state.ScrollX = (float)(int)ImMax(0.0f, cursor_offset.x - scroll_increment_x);
|
||||
else if (cursor_offset.x - size.x >= edit_state.ScrollX)
|
||||
edit_state.ScrollX = cursor_offset.x - size.x + scroll_increment_x;
|
||||
edit_state.ScrollX = (float)(int)(cursor_offset.x - size.x + scroll_increment_x);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7619,7 +7685,7 @@ bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast,
|
||||
if (decimal_precision < 0)
|
||||
strcpy(display_format, "%f"); // Ideally we'd have a minimum decimal precision of 1 to visually denote that this is a float, while hiding non-significant digits? %f doesn't have a minimum of 1
|
||||
else
|
||||
ImFormatString(display_format, 16, "%%%df", decimal_precision);
|
||||
ImFormatString(display_format, 16, "%%.%df", decimal_precision);
|
||||
return InputScalarEx(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), display_format, extra_flags);
|
||||
}
|
||||
|
||||
@ -7805,7 +7871,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
bool menu_toggled = false;
|
||||
if (hovered)
|
||||
{
|
||||
g.HoveredId = id;
|
||||
SetHoveredID(id);
|
||||
if (g.IO.MouseClicked[0])
|
||||
{
|
||||
SetActiveID(0);
|
||||
@ -8490,7 +8556,10 @@ void ImGui::Dummy(const ImVec2& size)
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
ItemSize(size);
|
||||
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
ItemSize(bb);
|
||||
ItemAdd(bb, NULL);
|
||||
}
|
||||
|
||||
bool ImGui::IsRectVisible(const ImVec2& size)
|
||||
|
49
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
49
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui.h
vendored
@ -22,7 +22,7 @@
|
||||
// Define assertion handler.
|
||||
#ifndef IM_ASSERT
|
||||
#include <assert.h>
|
||||
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
||||
#define IM_ASSERT(_EXPR, ...) assert(_EXPR)
|
||||
#endif
|
||||
|
||||
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||
@ -115,11 +115,11 @@ namespace ImGui
|
||||
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging imgui
|
||||
|
||||
// Window
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // this is the older/longer API. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! maybe obsolete this API eventually.
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||
IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // this is the older/longer API. the extra parameters aren't very relevant. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! maybe obsolete this API eventually.
|
||||
IMGUI_API void End();
|
||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
|
||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
|
||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
|
||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
|
||||
IMGUI_API void EndChild();
|
||||
IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
|
||||
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
||||
@ -386,7 +386,7 @@ namespace ImGui
|
||||
IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
|
||||
IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
|
||||
|
||||
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size); // helper to create a child window / scrolling region that looks like a normal widget frame
|
||||
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame
|
||||
IMGUI_API void EndChildFrame();
|
||||
|
||||
IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in);
|
||||
@ -416,9 +416,11 @@ namespace ImGui
|
||||
IMGUI_API void CaptureKeyboardFromApp(); // manually enforce imgui setting the io.WantCaptureKeyboard flag next frame (your application needs to handle it). e.g. capture keyboard when your widget is being hovered.
|
||||
IMGUI_API void CaptureMouseFromApp(); // manually enforce imgui setting the io.WantCaptureMouse flag next frame (your application needs to handle it).
|
||||
|
||||
// Helpers functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO()
|
||||
// Helpers functions to access functions pointers in ImGui::GetIO()
|
||||
IMGUI_API void* MemAlloc(size_t sz);
|
||||
IMGUI_API void MemFree(void* ptr);
|
||||
IMGUI_API const char* GetClipboardText();
|
||||
IMGUI_API void SetClipboardText(const char* text);
|
||||
|
||||
// Internal state/context access - if you want to use multiple ImGui context, or share context between modules (e.g. DLL), or allocate the memory yourself
|
||||
IMGUI_API const char* GetVersion();
|
||||
@ -458,6 +460,7 @@ enum ImGuiWindowFlags_
|
||||
ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
|
||||
ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Enable horizontal scrollbar (off by default). You need to use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
|
||||
ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
|
||||
// [Internal]
|
||||
ImGuiWindowFlags_ChildWindow = 1 << 20, // Don't use! For internal use by BeginChild()
|
||||
ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 21, // Don't use! For internal use by BeginChild()
|
||||
@ -867,11 +870,11 @@ struct ImGuiTextFilter
|
||||
int CountGrep;
|
||||
|
||||
ImGuiTextFilter(const char* default_filter = "");
|
||||
void Clear() { InputBuf[0] = 0; Build(); }
|
||||
void Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
|
||||
bool PassFilter(const char* text, const char* text_end = NULL) const;
|
||||
bool IsActive() const { return !Filters.empty(); }
|
||||
IMGUI_API void Build();
|
||||
void Clear() { InputBuf[0] = 0; Build(); }
|
||||
bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
|
||||
bool PassFilter(const char* text, const char* text_end = NULL) const;
|
||||
bool IsActive() const { return !Filters.empty(); }
|
||||
IMGUI_API void Build();
|
||||
};
|
||||
|
||||
// Helper: Text buffer for logging/accumulating text
|
||||
@ -886,6 +889,7 @@ struct ImGuiTextBuffer
|
||||
int size() const { return Buf.Size - 1; }
|
||||
bool empty() { return Buf.Size >= 2; }
|
||||
void clear() { Buf.clear(); Buf.push_back(0); }
|
||||
const char* c_str() const { return Buf.Data; }
|
||||
IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2);
|
||||
IMGUI_API void appendv(const char* fmt, va_list args);
|
||||
};
|
||||
@ -955,9 +959,9 @@ struct ImGuiTextEditCallbackData
|
||||
int SelectionEnd; // // Read-write
|
||||
|
||||
// NB: calling those function loses selection.
|
||||
void DeleteChars(int pos, int bytes_count);
|
||||
void InsertChars(int pos, const char* text, const char* text_end = NULL);
|
||||
bool HasSelection() const { return SelectionStart != SelectionEnd; }
|
||||
void DeleteChars(int pos, int bytes_count);
|
||||
void InsertChars(int pos, const char* text, const char* text_end = NULL);
|
||||
bool HasSelection() const { return SelectionStart != SelectionEnd; }
|
||||
};
|
||||
|
||||
// ImColor() is just a helper that implicity converts to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float)
|
||||
@ -1111,7 +1115,7 @@ struct ImDrawList
|
||||
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
||||
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
|
||||
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 col = 0xFFFFFFFF);
|
||||
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness, bool anti_aliased);
|
||||
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col, bool anti_aliased);
|
||||
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
|
||||
@ -1160,7 +1164,7 @@ struct ImDrawData
|
||||
int TotalIdxCount; // For convenience, sum of all cmd_lists idx_buffer.Size
|
||||
|
||||
// Functions
|
||||
IMGUI_API ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
|
||||
ImDrawData() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; }
|
||||
IMGUI_API void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||
IMGUI_API void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||
};
|
||||
@ -1216,11 +1220,12 @@ struct ImFontAtlas
|
||||
// Pitch = Width * BytesPerPixels
|
||||
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
||||
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
||||
IMGUI_API void SetTexID(void* id) { TexID = id; }
|
||||
void SetTexID(void* id) { TexID = id; }
|
||||
|
||||
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
|
||||
// (Those functions could be static but aren't so most users don't have to refer to the ImFontAtlas:: name ever if in their code; just using io.Fonts->)
|
||||
IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
|
||||
IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
|
||||
IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
|
||||
IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs
|
||||
IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
|
||||
@ -1267,18 +1272,18 @@ struct ImFont
|
||||
ImVector<Glyph> Glyphs;
|
||||
const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
||||
float FallbackXAdvance; //
|
||||
ImVector<float> IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (for CalcTextSize functions which are often bottleneck in large UI)
|
||||
ImVector<int> IndexLookup; // Sparse. Index glyphs by Unicode code-point
|
||||
ImVector<float> IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
|
||||
ImVector<int> IndexLookup; // Sparse. Index glyphs by Unicode code-point.
|
||||
|
||||
// Methods
|
||||
IMGUI_API ImFont();
|
||||
IMGUI_API ~ImFont();
|
||||
IMGUI_API void Clear();
|
||||
IMGUI_API void BuildLookupTable();
|
||||
IMGUI_API float GetCharAdvance(unsigned short c) const { return ((int)c < IndexXAdvance.Size) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
|
||||
IMGUI_API const Glyph* FindGlyph(unsigned short c) const;
|
||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
||||
IMGUI_API bool IsLoaded() const { return ContainerAtlas != NULL; }
|
||||
float GetCharAdvance(unsigned short c) const { return ((int)c < IndexXAdvance.Size) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
|
||||
bool IsLoaded() const { return ContainerAtlas != NULL; }
|
||||
|
||||
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
||||
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <ctype.h> // toupper, isprint
|
||||
#include <math.h> // sqrtf, fabsf, fmodf, powf, cosf, sinf, floorf, ceilf
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#include <stdint.h> // intptr_t
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
||||
@ -216,7 +217,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
{
|
||||
ImFont* font = atlas->Fonts[i];
|
||||
ImGui::BulletText("Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size);
|
||||
ImGui::TreePush((void*)i);
|
||||
ImGui::TreePush((void*)intptr_t(i));
|
||||
if (i > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { atlas->Fonts[i] = atlas->Fonts[0]; atlas->Fonts[0] = font; } }
|
||||
ImGui::PushFont(font);
|
||||
ImGui::Text("The quick brown fox jumps over the lazy dog");
|
||||
@ -254,7 +255,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (ImGui::TreeNode((void*)i, "Child %d", i))
|
||||
if (ImGui::TreeNode((void*)intptr_t(i), "Child %d", i))
|
||||
{
|
||||
ImGui::Text("blah blah");
|
||||
ImGui::SameLine();
|
||||
@ -684,13 +685,29 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
phase += 0.10f*values_offset;
|
||||
}
|
||||
}
|
||||
ImGui::PlotLines("##Graph", values.Data, values.Size, values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
|
||||
ImGui::PlotLines("##Lines", values.Data, values.Size, values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
|
||||
ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Text("Graph");
|
||||
ImGui::Text("Lines");
|
||||
ImGui::Checkbox("pause", &pause);
|
||||
ImGui::EndGroup();
|
||||
ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0,80));
|
||||
|
||||
// Use functions to generate output
|
||||
// FIXME: This is rather awkward because current plot API only pass in indices. We probably want an API passing floats and user provide sample rate/count.
|
||||
struct Funcs
|
||||
{
|
||||
static float Sin(void*, int i) { return sinf(i * 0.1f); }
|
||||
static float Saw(void*, int i) { return (i & 1) ? 1.0f : 0.0f; }
|
||||
};
|
||||
static int func_type = 0, display_count = 70;
|
||||
ImGui::Separator();
|
||||
ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth();
|
||||
ImGui::SameLine();
|
||||
ImGui::SliderInt("Sample count", &display_count, 1, 500);
|
||||
float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
|
||||
ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
|
||||
ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0,80));
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Layout"))
|
||||
@ -925,7 +942,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
if (i > 0) ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Text("%s", i == 0 ? "Top" : i == 1 ? "25%" : i == 2 ? "Center" : i == 3 ? "75%" : "Bottom");
|
||||
ImGui::BeginChild(ImGui::GetID((void*)i), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
|
||||
ImGui::BeginChild(ImGui::GetID((void*)intptr_t(i)), ImVec2(ImGui::GetWindowWidth() * 0.17f, 200.0f), true);
|
||||
if (scroll_to)
|
||||
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_px, i * 0.25f);
|
||||
for (int line = 0; line < 100; line++)
|
||||
@ -950,10 +967,12 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
{
|
||||
ImGui::Bullet(); ImGui::TextWrapped("Horizontal scrolling for a window has to be enabled explicitly via the ImGuiWindowFlags_HorizontalScrollbar flag.");
|
||||
ImGui::Bullet(); ImGui::TextWrapped("You may want to explicitly specify content width by calling SetNextWindowContentWidth() before Begin().");
|
||||
static int lines = 7;
|
||||
ImGui::SliderInt("Lines", &lines, 1, 15);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f));
|
||||
ImGui::BeginChild("scrolling", ImVec2(0, ImGui::GetItemsLineHeightWithSpacing()*7 + 30), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
for (int line = 0; line < 7; line++)
|
||||
for (int line = 0; line < lines; line++)
|
||||
{
|
||||
// Display random stuff
|
||||
int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3);
|
||||
@ -1382,9 +1401,10 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
ImGui::Text("MousePos: (%g, %g)", io.MousePos.x, io.MousePos.y);
|
||||
ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (%.02f secs)", i, io.MouseDownDuration[i]); }
|
||||
ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
|
||||
ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
|
||||
ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (io.MouseDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); }
|
||||
ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
|
||||
ImGui::Text("Mouse dbl-clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
|
||||
ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
|
||||
ImGui::Text("MouseWheel: %.1f", io.MouseWheel);
|
||||
|
||||
ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (%.02f secs)", i, io.KeysDownDuration[i]); }
|
||||
@ -1462,7 +1482,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
|
||||
ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
|
||||
ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
|
||||
ImGui::SliderFloat("ScrollbarWidth", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
|
||||
ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
|
||||
ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 16.0f, "%.0f");
|
||||
ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
|
||||
ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 16.0f, "%.0f");
|
||||
|
@ -291,6 +291,7 @@ void ImDrawList::ChannelsMerge()
|
||||
|
||||
void ImDrawList::ChannelsSetCurrent(int idx)
|
||||
{
|
||||
IM_ASSERT(idx < _ChannelsCount);
|
||||
if (_ChannelsCurrent == idx) return;
|
||||
memcpy(&_Channels.Data[_ChannelsCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer)); // copy 12 bytes, four times
|
||||
memcpy(&_Channels.Data[_ChannelsCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer));
|
||||
@ -713,7 +714,7 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int
|
||||
r = ImMin(r, fabsf(b.x-a.x) * ( ((rounding_corners&(1|2))==(1|2)) || ((rounding_corners&(4|8))==(4|8)) ? 0.5f : 1.0f ) - 1.0f);
|
||||
r = ImMin(r, fabsf(b.y-a.y) * ( ((rounding_corners&(1|8))==(1|8)) || ((rounding_corners&(2|4))==(2|4)) ? 0.5f : 1.0f ) - 1.0f);
|
||||
|
||||
if (r == 0.0f || rounding_corners == 0)
|
||||
if (r <= 0.0f || rounding_corners == 0)
|
||||
{
|
||||
PathLineTo(a);
|
||||
PathLineTo(ImVec2(b.x,a.y));
|
||||
@ -1079,7 +1080,16 @@ static unsigned int stb_decompress_length(unsigned char *input);
|
||||
static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsigned int length);
|
||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||
static void Decode85(const unsigned char* src, unsigned int* dst) { for (; *src; src += 5) *dst++ = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4])))); }
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
{
|
||||
while (*src)
|
||||
{
|
||||
unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4]))));
|
||||
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianess.
|
||||
src += 5;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Load embedded ProggyClean.ttf at size 13, disable oversampling
|
||||
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
||||
@ -1146,7 +1156,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
|
||||
{
|
||||
int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4;
|
||||
void* compressed_ttf = ImGui::MemAlloc(compressed_ttf_size);
|
||||
Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned int*)compressed_ttf);
|
||||
Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
|
||||
ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges);
|
||||
ImGui::MemFree(compressed_ttf);
|
||||
return font;
|
||||
@ -1458,6 +1468,18 @@ const ImWchar* ImFontAtlas::GetGlyphRangesDefault()
|
||||
return &ranges[0];
|
||||
}
|
||||
|
||||
const ImWchar* ImFontAtlas::GetGlyphRangesKorean()
|
||||
{
|
||||
static const ImWchar ranges[] =
|
||||
{
|
||||
0x0020, 0x00FF, // Basic Latin + Latin Supplement
|
||||
0x3131, 0x3163, // Korean alphabets
|
||||
0xAC00, 0xD79D, // Korean characters
|
||||
0,
|
||||
};
|
||||
return &ranges[0];
|
||||
}
|
||||
|
||||
const ImWchar* ImFontAtlas::GetGlyphRangesChinese()
|
||||
{
|
||||
static const ImWchar ranges[] =
|
||||
|
@ -14,6 +14,11 @@
|
||||
#include <stdio.h> // FILE*
|
||||
#include <math.h> // sqrtf()
|
||||
|
||||
#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
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Forward Declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -331,6 +336,7 @@ struct ImGuiState
|
||||
|
||||
float Time;
|
||||
int FrameCount;
|
||||
int FrameCountEnded;
|
||||
int FrameCountRendered;
|
||||
ImVector<ImGuiWindow*> Windows;
|
||||
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
||||
@ -340,12 +346,13 @@ struct ImGuiState
|
||||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
||||
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
|
||||
ImGuiID HoveredId; // Hovered widget
|
||||
bool HoveredIdAllowHoveringOthers;
|
||||
ImGuiID HoveredIdPreviousFrame;
|
||||
ImGuiID ActiveId; // Active widget
|
||||
ImGuiID ActiveIdPreviousFrame;
|
||||
bool ActiveIdIsAlive;
|
||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||
bool ActiveIdIsFocusedOnly; // Set only by active widget. Denote focus but no active interaction
|
||||
bool ActiveIdAllowHoveringOthers; // Set only by active widget
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window. Pointer is only valid if ActiveID is the "#MOVE" identifier of a window.
|
||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
||||
@ -416,18 +423,19 @@ struct ImGuiState
|
||||
|
||||
Time = 0.0f;
|
||||
FrameCount = 0;
|
||||
FrameCountRendered = -1;
|
||||
FrameCountEnded = FrameCountRendered = -1;
|
||||
CurrentWindow = NULL;
|
||||
FocusedWindow = NULL;
|
||||
HoveredWindow = NULL;
|
||||
HoveredRootWindow = NULL;
|
||||
HoveredId = 0;
|
||||
HoveredIdAllowHoveringOthers = false;
|
||||
HoveredIdPreviousFrame = 0;
|
||||
ActiveId = 0;
|
||||
ActiveIdPreviousFrame = 0;
|
||||
ActiveIdIsAlive = false;
|
||||
ActiveIdIsJustActivated = false;
|
||||
ActiveIdIsFocusedOnly = false;
|
||||
ActiveIdAllowHoveringOthers = false;
|
||||
ActiveIdWindow = NULL;
|
||||
MovedWindow = NULL;
|
||||
SettingsDirtyTimer = 0.0f;
|
||||
@ -473,7 +481,7 @@ struct ImGuiState
|
||||
|
||||
// Transient per-window data, reset at the beginning of the frame
|
||||
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
|
||||
struct ImGuiDrawContext
|
||||
struct IMGUI_API ImGuiDrawContext
|
||||
{
|
||||
ImVec2 CursorPos;
|
||||
ImVec2 CursorPosPrevLine;
|
||||
@ -631,14 +639,21 @@ public:
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; } // If this ever crash it means that ImGui::NewFrame() has never been called (which is illegal). We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
|
||||
// We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
|
||||
// If this ever crash because g.CurrentWindow is NULL it means that either
|
||||
// - ImGui::NewFrame() has never been called, which is illegal.
|
||||
// - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; }
|
||||
inline ImGuiWindow* GetCurrentWindow() { ImGuiState& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
|
||||
IMGUI_API ImGuiWindow* GetParentWindow();
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
|
||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||
IMGUI_API void SetHoveredID(ImGuiID id);
|
||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||
|
||||
IMGUI_API void EndFrame(); // This automatically called by Render()
|
||||
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
||||
@ -683,3 +698,6 @@ namespace ImGui
|
||||
|
||||
} // namespace ImGuiP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
1686
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.cpp
vendored
Normal file
1686
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
310
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.h
vendored
Normal file
310
3rdparty/bgfx/3rdparty/ocornut-imgui/imgui_wm.h
vendored
Normal file
@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on ImWindow code from:
|
||||
* https://github.com/thennequin/ImWindow
|
||||
*
|
||||
* MIT license:
|
||||
* https://github.com/thennequin/ImWindow/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
#ifndef IMGUI_WM_H_HEADER_GUARD
|
||||
#define IMGUI_WM_H_HEADER_GUARD
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
typedef unsigned int ImU32;
|
||||
|
||||
#ifndef ImwList
|
||||
# include <list>
|
||||
# define ImwList std::list
|
||||
#endif // ImList
|
||||
|
||||
#ifndef ImwMap
|
||||
# include <unordered_map>
|
||||
# define ImwMap std::unordered_map
|
||||
#endif // ImMap
|
||||
|
||||
namespace ImGuiWM
|
||||
{
|
||||
enum EDockOrientation
|
||||
{
|
||||
E_DOCK_ORIENTATION_CENTER,
|
||||
E_DOCK_ORIENTATION_TOP,
|
||||
E_DOCK_ORIENTATION_LEFT,
|
||||
E_DOCK_ORIENTATION_RIGHT,
|
||||
E_DOCK_ORIENTATION_BOTTOM,
|
||||
};
|
||||
|
||||
class Id
|
||||
{
|
||||
public:
|
||||
Id();
|
||||
ImU32 GetId() const;
|
||||
const char* GetStr() const;
|
||||
|
||||
private:
|
||||
ImU32 m_iId;
|
||||
char m_pId[11];
|
||||
static int s_iNextId;
|
||||
};
|
||||
|
||||
class Window
|
||||
{
|
||||
friend class WindowManager;
|
||||
friend class Container;
|
||||
|
||||
public:
|
||||
virtual void OnGui() = 0;
|
||||
virtual void OnMenu() {};
|
||||
|
||||
const char* GetId() const { return m_oId.GetStr(); }
|
||||
|
||||
void Destroy();
|
||||
|
||||
void SetTitle(const char* pTitle);
|
||||
const char* GetTitle() const;
|
||||
|
||||
const ImVec2& GetLastPosition() const;
|
||||
const ImVec2& GetLastSize() const;
|
||||
|
||||
protected:
|
||||
Window();
|
||||
virtual ~Window();
|
||||
|
||||
char* m_pTitle;
|
||||
Id m_oId;
|
||||
|
||||
ImVec2 m_oLastPosition;
|
||||
ImVec2 m_oLastSize;
|
||||
};
|
||||
|
||||
typedef ImwList<Window*> WindowList;
|
||||
|
||||
class PlatformWindow;
|
||||
|
||||
class Container
|
||||
{
|
||||
friend class PlatformWindow;
|
||||
|
||||
public:
|
||||
void Dock(Window* pWindow,EDockOrientation eOrientation = E_DOCK_ORIENTATION_CENTER);
|
||||
bool UnDock(Window* pWindow);
|
||||
|
||||
bool IsEmpty();
|
||||
bool IsSplit();
|
||||
bool HasWindowTabbed();
|
||||
Container* HasWindow(const Window* pWindow);
|
||||
PlatformWindow* GetPlatformWindowParent() const;
|
||||
Container* GetBestDocking(const ImVec2 oCursorPosInContainer,EDockOrientation& oOutOrientation,ImVec2& oOutAreaPos,ImVec2& oOutAreaSize);
|
||||
|
||||
protected:
|
||||
Container(Container* pParent);
|
||||
Container(PlatformWindow* pParent);
|
||||
~Container();
|
||||
|
||||
void CreateSplits();
|
||||
void Paint();
|
||||
|
||||
Container* m_pParent;
|
||||
PlatformWindow* m_pParentWindow;
|
||||
WindowList m_lWindows;
|
||||
Container* m_pSplits[2];
|
||||
|
||||
float m_fSplitRatio;
|
||||
bool m_bVerticalSplit;
|
||||
int m_iActiveWindow;
|
||||
|
||||
bool m_bIsDrag;
|
||||
|
||||
ImVec2 m_oLastPosition;
|
||||
ImVec2 m_oLastSize;
|
||||
};
|
||||
|
||||
class PlatformWindow
|
||||
{
|
||||
friend class WindowManager;
|
||||
|
||||
public:
|
||||
PlatformWindow(bool bMainWindow,bool bIsDragWindow);
|
||||
virtual ~PlatformWindow();
|
||||
|
||||
virtual bool Init(PlatformWindow* pParent) = 0;
|
||||
|
||||
virtual const ImVec2& GetPosition() const = 0;
|
||||
virtual const ImVec2& GetSize() const = 0;
|
||||
|
||||
virtual void Show() = 0;
|
||||
virtual void Hide() = 0;
|
||||
virtual void SetSize(const ImVec2& size) = 0;
|
||||
virtual void SetPosition(const ImVec2& pos) = 0;
|
||||
virtual void SetTitle(const char* pTitle) = 0;
|
||||
|
||||
bool IsMain();
|
||||
|
||||
void Dock(Window* pWindow);
|
||||
bool UnDock(Window* pWindow);
|
||||
|
||||
Container* GetContainer();
|
||||
Container* HasWindow(Window* pWindow);
|
||||
bool IsStateSet();
|
||||
|
||||
protected:
|
||||
void SetState();
|
||||
void RestoreState();
|
||||
void OnLoseFocus();
|
||||
virtual void PreUpdate() = 0;
|
||||
virtual void PaintBegin() = 0;
|
||||
virtual void Paint();
|
||||
virtual void PaintEnd() = 0;
|
||||
virtual void Destroy() = 0;
|
||||
virtual void StartDrag() = 0;
|
||||
virtual void StopDrag() = 0;
|
||||
virtual bool IsDraging() = 0;
|
||||
|
||||
void PaintContainer();
|
||||
void OnClose();
|
||||
|
||||
Id m_oId;
|
||||
bool m_bMain;
|
||||
bool m_bIsDragWindow;
|
||||
Container* m_pContainer;
|
||||
void* m_pState;
|
||||
void* m_pPreviousState;
|
||||
};
|
||||
|
||||
typedef ImwList<PlatformWindow*> PlatformWindowList;
|
||||
|
||||
class WindowManager
|
||||
{
|
||||
friend class Window;
|
||||
friend class PlatformWindow;
|
||||
friend class Container;
|
||||
|
||||
struct PlatformWindowAction
|
||||
{
|
||||
PlatformWindow* m_pPlatformWindow;
|
||||
unsigned int m_iFlags;
|
||||
ImVec2 m_oPosition;
|
||||
ImVec2 m_oSize;
|
||||
};
|
||||
|
||||
struct DockAction
|
||||
{
|
||||
Window* m_pWindow;
|
||||
|
||||
// Is Dock or Float
|
||||
bool m_bFloat;
|
||||
|
||||
//For Docking
|
||||
Window* m_pWith;
|
||||
EDockOrientation m_eOrientation;
|
||||
PlatformWindow* m_pToPlatformWindow;
|
||||
Container* m_pToContainer;
|
||||
|
||||
//For Floating
|
||||
ImVec2 m_oPosition;
|
||||
ImVec2 m_oSize;
|
||||
};
|
||||
|
||||
struct DrawWindowAreaAction
|
||||
{
|
||||
DrawWindowAreaAction(PlatformWindow* pWindow,const ImVec2& oRectPos,const ImVec2& oRectSize,const ImColor& oColor);
|
||||
PlatformWindow* m_pWindow;
|
||||
ImVec2 m_oRectPos;
|
||||
ImVec2 m_oRectSize;
|
||||
ImColor m_oColor;
|
||||
};
|
||||
|
||||
public:
|
||||
struct Config
|
||||
{
|
||||
Config();
|
||||
float m_fDragMarginRatio;
|
||||
float m_fDragMarginSizeRatio;
|
||||
ImColor m_oHightlightAreaColor;
|
||||
};
|
||||
|
||||
WindowManager();
|
||||
virtual ~WindowManager();
|
||||
|
||||
bool Init();
|
||||
bool Run();
|
||||
void Exit();
|
||||
|
||||
PlatformWindow* GetMainPlatformWindow();
|
||||
Config& GetConfig();
|
||||
|
||||
void SetMainTitle(const char* pTitle);
|
||||
|
||||
void Dock(Window* pWindow, EDockOrientation eOrientation = E_DOCK_ORIENTATION_CENTER, PlatformWindow* pToPlatformWindow = NULL);
|
||||
void DockTo(Window* pWindow, EDockOrientation eOrientation = E_DOCK_ORIENTATION_CENTER, Container* pContainer = NULL);
|
||||
void DockWith(Window* pWindow, Window* pWithWindow,EDockOrientation eOrientation = E_DOCK_ORIENTATION_CENTER);
|
||||
void Float(Window* pWindow, const ImVec2& oPosition = ImVec2(-1,-1), const ImVec2& oSize = ImVec2(-1,-1));
|
||||
|
||||
const WindowList& GetWindowList() const;
|
||||
PlatformWindow* GetCurrentPlatformWindow();
|
||||
PlatformWindow* GetWindowParent(Window* pWindow);
|
||||
|
||||
void Log(const char* pFormat, ...);
|
||||
virtual void LogFormatted(const char* pStr) = 0;;
|
||||
|
||||
static WindowManager* GetInstance();
|
||||
|
||||
protected:
|
||||
virtual PlatformWindow* CreatePlatformWindow(bool bMain,PlatformWindow* pParent,bool bDragWindow) = 0;
|
||||
virtual void InternalRun() = 0;
|
||||
|
||||
void AddWindow(Window* pWindow);
|
||||
void RemoveWindow(Window* pWindow);
|
||||
void DestroyWindow(Window* pWindow);
|
||||
|
||||
void InternalDock(Window* pWindow,EDockOrientation eOrientation,PlatformWindow* pToPlatformWindow);
|
||||
void InternalDockTo(Window* pWindow,EDockOrientation eOrientation,Container* pToContainer);
|
||||
void InternalDockWith(Window* pWindow,Window* pWithWindow,EDockOrientation eOrientation);
|
||||
bool InternalFloat(Window* pWindow,ImVec2 oPosition,ImVec2 oSize);
|
||||
void InternalUnDock(Window* pWindow);
|
||||
void InternalDrag(Window* pWindow);
|
||||
|
||||
void OnClosePlatformWindow(PlatformWindow* pWindow);
|
||||
|
||||
void DrawWindowArea(PlatformWindow* pWindow,const ImVec2& oPos,const ImVec2& oSize,const ImColor& oColor);
|
||||
|
||||
void PreUpdate();
|
||||
void Update();
|
||||
void UpdatePlatformwWindowActions();
|
||||
void UpdateDockActions();
|
||||
void UpdateOrphans();
|
||||
|
||||
void Paint(PlatformWindow* pWindow);
|
||||
|
||||
void StartDragWindow(Window* pWindow);
|
||||
void StopDragWindow();
|
||||
void UpdateDragWindow();
|
||||
Container* GetBestDocking(PlatformWindow* pPlatformWindow,const ImVec2 oCursorPos,EDockOrientation& oOutOrientation,ImVec2& oOutAreaPos,ImVec2& oOutAreaSize);
|
||||
|
||||
Config m_oConfig;
|
||||
PlatformWindow* m_pMainPlatformWindow;
|
||||
PlatformWindowList m_lPlatformWindows;
|
||||
PlatformWindow* m_pDragPlatformWindow;
|
||||
WindowList m_lWindows;
|
||||
WindowList m_lOrphanWindows;
|
||||
WindowList m_lToDestroyWindows;
|
||||
PlatformWindowList m_lToDestroyPlatformWindows;
|
||||
ImwList<PlatformWindowAction*> m_lPlatformWindowActions;
|
||||
ImwList<DockAction*> m_lDockActions;
|
||||
ImwList<DrawWindowAreaAction> m_lDrawWindowAreas;
|
||||
|
||||
PlatformWindow* m_pCurrentPlatformWindow;
|
||||
Window* m_pDraggedWindow;
|
||||
|
||||
ImVec2 m_oDragPreviewOffset;
|
||||
|
||||
static WindowManager* s_pInstance;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // IMGUI_WM_H_HEADER_GUARD
|
623
3rdparty/bgfx/3rdparty/renderdoc/renderdoc_app.h
vendored
623
3rdparty/bgfx/3rdparty/renderdoc/renderdoc_app.h
vendored
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 Crytek
|
||||
* Copyright (c) 2015 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -22,275 +22,494 @@
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(RENDERDOC_NO_STDINT)
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#ifdef RENDERDOC_EXPORTS
|
||||
#define RENDERDOC_API __declspec(dllexport)
|
||||
#else
|
||||
#define RENDERDOC_API __declspec(dllimport)
|
||||
#endif
|
||||
#define RENDERDOC_CC __cdecl
|
||||
|
||||
#if defined(WIN32)
|
||||
#define RENDERDOC_CC __cdecl
|
||||
#elif defined(__linux__)
|
||||
|
||||
#ifdef RENDERDOC_EXPORTS
|
||||
#define RENDERDOC_API __attribute__ ((visibility ("default")))
|
||||
#define RENDERDOC_CC
|
||||
#else
|
||||
#define RENDERDOC_API
|
||||
#error "Unknown platform"
|
||||
#endif
|
||||
|
||||
#define RENDERDOC_CC
|
||||
|
||||
#else
|
||||
|
||||
#error "Unknown platform"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct CaptureOptions
|
||||
{
|
||||
CaptureOptions()
|
||||
: AllowVSync(true),
|
||||
AllowFullscreen(true),
|
||||
DebugDeviceMode(false),
|
||||
CaptureCallstacks(false),
|
||||
CaptureCallstacksOnlyDraws(false),
|
||||
DelayForDebugger(0),
|
||||
VerifyMapWrites(false),
|
||||
HookIntoChildren(false),
|
||||
RefAllResources(false),
|
||||
SaveAllInitials(false),
|
||||
CaptureAllCmdLists(false)
|
||||
{}
|
||||
|
||||
// Whether or not to allow the application to enable vsync
|
||||
//
|
||||
// 1 - allows the application to enable or disable vsync at will
|
||||
// 0 - vsync is force disabled
|
||||
uint32_t AllowVSync;
|
||||
|
||||
// Whether or not to allow the application to enable fullscreen
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// RenderDoc capture options
|
||||
//
|
||||
|
||||
typedef enum
|
||||
{
|
||||
// Allow the application to enable vsync
|
||||
//
|
||||
// 1 - allows the application to enable or disable fullscreen at will
|
||||
// Default - enabled
|
||||
//
|
||||
// 1 - The application can enable or disable vsync at will
|
||||
// 0 - vsync is force disabled
|
||||
eRENDERDOC_Option_AllowVSync = 0,
|
||||
|
||||
// Allow the application to enable fullscreen
|
||||
//
|
||||
// Default - enabled
|
||||
//
|
||||
// 1 - The application can enable or disable fullscreen at will
|
||||
// 0 - fullscreen is force disabled
|
||||
uint32_t AllowFullscreen;
|
||||
eRENDERDOC_Option_AllowFullscreen = 1,
|
||||
|
||||
// 1 - in-built API debugging features and records the results into the
|
||||
// capture logfile, which is matched up with events on replay
|
||||
// 0 - no API debugging is enabled
|
||||
uint32_t DebugDeviceMode;
|
||||
|
||||
// 1 - Captures callstacks for every API event during capture
|
||||
// Record API debugging events and messages
|
||||
//
|
||||
// Default - disabled
|
||||
//
|
||||
// 1 - Enable built-in API debugging features and records the results into
|
||||
// the capture logfile, which is matched up with events on replay
|
||||
// 0 - no API debugging is forcibly enabled
|
||||
eRENDERDOC_Option_DebugDeviceMode = 2,
|
||||
|
||||
// Capture CPU callstacks for API events
|
||||
//
|
||||
// Default - disabled
|
||||
//
|
||||
// 1 - Enables capturing of callstacks
|
||||
// 0 - no callstacks are captured
|
||||
uint32_t CaptureCallstacks;
|
||||
|
||||
eRENDERDOC_Option_CaptureCallstacks = 3,
|
||||
|
||||
// When capturing CPU callstacks, only capture them from drawcalls.
|
||||
// This option does nothing without the above option being enabled
|
||||
//
|
||||
// Default - disabled
|
||||
//
|
||||
// 1 - Only captures callstacks for drawcall type API events.
|
||||
// Ignored if CaptureCallstacks is disabled
|
||||
// 0 - Callstacks, if enabled, are captured for every event.
|
||||
uint32_t CaptureCallstacksOnlyDraws;
|
||||
eRENDERDOC_Option_CaptureCallstacksOnlyDraws = 4,
|
||||
|
||||
// Specify a delay in seconds to wait for a debugger to attach after
|
||||
// Specify a delay in seconds to wait for a debugger to attach, after
|
||||
// creating or injecting into a process, before continuing to allow it to run.
|
||||
//
|
||||
// 0 indicates no delay, and the process will run immediately after injection
|
||||
uint32_t DelayForDebugger;
|
||||
|
||||
// 1 - Verify any writes to mapped buffers, to check that they don't overwrite the
|
||||
// bounds of the pointer returned.
|
||||
// 0 - No verification is performed, and overwriting bounds may cause crashes or
|
||||
// corruption in RenderDoc
|
||||
uint32_t VerifyMapWrites;
|
||||
|
||||
// 1 - Hooks any system API events that create child processes, and injects
|
||||
// renderdoc into them recursively with the same options.
|
||||
//
|
||||
// Default - 0 seconds
|
||||
//
|
||||
eRENDERDOC_Option_DelayForDebugger = 5,
|
||||
|
||||
// Verify any writes to mapped buffers, by checking the memory after the
|
||||
// bounds of the returned pointer to detect any modification.
|
||||
//
|
||||
// Default - disabled
|
||||
//
|
||||
// 1 - Verify any writes to mapped buffers
|
||||
// 0 - No verification is performed, and overwriting bounds may cause
|
||||
// crashes or corruption in RenderDoc
|
||||
eRENDERDOC_Option_VerifyMapWrites = 6,
|
||||
|
||||
// Hooks any system API calls that create child processes, and injects
|
||||
// RenderDoc into them recursively with the same options.
|
||||
//
|
||||
// Default - disabled
|
||||
//
|
||||
// 1 - Hooks into spawned child processes
|
||||
// 0 - Child processes are not hooked by RenderDoc
|
||||
uint32_t HookIntoChildren;
|
||||
eRENDERDOC_Option_HookIntoChildren = 7,
|
||||
|
||||
// By default renderdoc only includes resources in the final logfile necessary
|
||||
// for that frame, this allows you to override that behaviour
|
||||
// By default RenderDoc only includes resources in the final logfile necessary
|
||||
// for that frame, this allows you to override that behaviour.
|
||||
//
|
||||
// Default - disabled
|
||||
//
|
||||
// 1 - all live resources at the time of capture are included in the log
|
||||
// and available for inspection
|
||||
// 0 - only the resources referenced by the captured frame are included
|
||||
uint32_t RefAllResources;
|
||||
eRENDERDOC_Option_RefAllResources = 8,
|
||||
|
||||
// By default renderdoc skips saving initial states for resources where the
|
||||
// By default RenderDoc skips saving initial states for resources where the
|
||||
// previous contents don't appear to be used, assuming that writes before
|
||||
// reads indicate previous contents aren't used.
|
||||
//
|
||||
// Default - disabled
|
||||
//
|
||||
// 1 - initial contents at the start of each captured frame are saved, even if
|
||||
// they are later overwritten or cleared before being used.
|
||||
// 0 - unless a read is detected, initial contents will not be saved and will
|
||||
// appear as black or empty data.
|
||||
uint32_t SaveAllInitials;
|
||||
eRENDERDOC_Option_SaveAllInitials = 9,
|
||||
|
||||
// In APIs that allow for the recording of command lists to be replayed later,
|
||||
// renderdoc may choose to not capture command lists before a frame capture is
|
||||
// RenderDoc may choose to not capture command lists before a frame capture is
|
||||
// triggered, to reduce overheads. This means any command lists recorded once
|
||||
// and replayed many times will not be available and may cause a failure to
|
||||
// capture.
|
||||
//
|
||||
// Note this is typically only true for APIs where multithreading is difficult
|
||||
// or discouraged. Newer APIs like Vulkan and D3D12 will ignore this option and
|
||||
// always capture all command lists since the API is heavily oriented around it,
|
||||
// and the overheads have been reduced by API design.
|
||||
// Note this is only true for APIs where multithreading is difficult or
|
||||
// discouraged. Newer APIs like Vulkan and D3D12 will ignore this option
|
||||
// and always capture all command lists since the API is heavily oriented
|
||||
// around it and the overheads have been reduced by API design.
|
||||
//
|
||||
// 1 - All command lists are captured from the start of the application
|
||||
// 0 - Command lists are only captured if their recording begins during
|
||||
// the period when a frame capture is in progress.
|
||||
uint32_t CaptureAllCmdLists;
|
||||
};
|
||||
eRENDERDOC_Option_CaptureAllCmdLists = 10,
|
||||
|
||||
enum KeyButton
|
||||
// Mute API debugging output when the debug device mode option is enabled
|
||||
//
|
||||
// Default - enabled
|
||||
//
|
||||
// 1 - Mute any API debug messages from being displayed or passed through
|
||||
// 0 - API debugging is displayed as normal
|
||||
eRENDERDOC_Option_DebugOutputMute = 11,
|
||||
|
||||
} RENDERDOC_CaptureOption;
|
||||
|
||||
// Sets an option that controls how RenderDoc behaves on capture.
|
||||
//
|
||||
// Returns 1 if the option and value are valid
|
||||
// Returns 0 if either is invalid and the option is unchanged
|
||||
typedef int (RENDERDOC_CC *pRENDERDOC_SetCaptureOptionU32)(RENDERDOC_CaptureOption opt, uint32_t val);
|
||||
typedef int (RENDERDOC_CC *pRENDERDOC_SetCaptureOptionF32)(RENDERDOC_CaptureOption opt, float val);
|
||||
|
||||
// Gets the current value of an option as a uint32_t
|
||||
//
|
||||
// If the option is invalid, 0xffffffff is returned
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetCaptureOptionU32)(RENDERDOC_CaptureOption opt);
|
||||
|
||||
// Gets the current value of an option as a float
|
||||
//
|
||||
// If the option is invalid, -FLT_MAX is returned
|
||||
typedef float (RENDERDOC_CC *pRENDERDOC_GetCaptureOptionF32)(RENDERDOC_CaptureOption opt);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
eKey_0 = 0x30, // '0'
|
||||
// ...
|
||||
eKey_9 = 0x39, // '9'
|
||||
eKey_A = 0x41, // 'A'
|
||||
// ...
|
||||
eKey_Z = 0x5A, // 'Z'
|
||||
// '0' - '9' matches ASCII values
|
||||
eRENDERDOC_Key_0 = 0x30,
|
||||
eRENDERDOC_Key_1 = 0x31,
|
||||
eRENDERDOC_Key_2 = 0x32,
|
||||
eRENDERDOC_Key_3 = 0x33,
|
||||
eRENDERDOC_Key_4 = 0x34,
|
||||
eRENDERDOC_Key_5 = 0x35,
|
||||
eRENDERDOC_Key_6 = 0x36,
|
||||
eRENDERDOC_Key_7 = 0x37,
|
||||
eRENDERDOC_Key_8 = 0x38,
|
||||
eRENDERDOC_Key_9 = 0x39,
|
||||
|
||||
eKey_Divide,
|
||||
eKey_Multiply,
|
||||
eKey_Subtract,
|
||||
eKey_Plus,
|
||||
// 'A' - 'Z' matches ASCII values
|
||||
eRENDERDOC_Key_A = 0x41,
|
||||
eRENDERDOC_Key_B = 0x42,
|
||||
eRENDERDOC_Key_C = 0x43,
|
||||
eRENDERDOC_Key_D = 0x44,
|
||||
eRENDERDOC_Key_E = 0x45,
|
||||
eRENDERDOC_Key_F = 0x46,
|
||||
eRENDERDOC_Key_G = 0x47,
|
||||
eRENDERDOC_Key_H = 0x48,
|
||||
eRENDERDOC_Key_I = 0x49,
|
||||
eRENDERDOC_Key_J = 0x4A,
|
||||
eRENDERDOC_Key_K = 0x4B,
|
||||
eRENDERDOC_Key_L = 0x4C,
|
||||
eRENDERDOC_Key_M = 0x4D,
|
||||
eRENDERDOC_Key_N = 0x4E,
|
||||
eRENDERDOC_Key_O = 0x4F,
|
||||
eRENDERDOC_Key_P = 0x50,
|
||||
eRENDERDOC_Key_Q = 0x51,
|
||||
eRENDERDOC_Key_R = 0x52,
|
||||
eRENDERDOC_Key_S = 0x53,
|
||||
eRENDERDOC_Key_T = 0x54,
|
||||
eRENDERDOC_Key_U = 0x55,
|
||||
eRENDERDOC_Key_V = 0x56,
|
||||
eRENDERDOC_Key_W = 0x57,
|
||||
eRENDERDOC_Key_X = 0x58,
|
||||
eRENDERDOC_Key_Y = 0x59,
|
||||
eRENDERDOC_Key_Z = 0x5A,
|
||||
|
||||
eKey_F1,
|
||||
eKey_F2,
|
||||
eKey_F3,
|
||||
eKey_F4,
|
||||
eKey_F5,
|
||||
eKey_F6,
|
||||
eKey_F7,
|
||||
eKey_F8,
|
||||
eKey_F9,
|
||||
eKey_F10,
|
||||
eKey_F11,
|
||||
eKey_F12,
|
||||
// leave the rest of the ASCII range free
|
||||
// in case we want to use it later
|
||||
eRENDERDOC_Key_NonPrintable = 0x100,
|
||||
|
||||
eKey_Home,
|
||||
eKey_End,
|
||||
eKey_Insert,
|
||||
eKey_Delete,
|
||||
eKey_PageUp,
|
||||
eKey_PageDn,
|
||||
eRENDERDOC_Key_Divide,
|
||||
eRENDERDOC_Key_Multiply,
|
||||
eRENDERDOC_Key_Subtract,
|
||||
eRENDERDOC_Key_Plus,
|
||||
|
||||
eKey_Backspace,
|
||||
eKey_Tab,
|
||||
eKey_PrtScrn,
|
||||
eKey_Pause,
|
||||
eRENDERDOC_Key_F1,
|
||||
eRENDERDOC_Key_F2,
|
||||
eRENDERDOC_Key_F3,
|
||||
eRENDERDOC_Key_F4,
|
||||
eRENDERDOC_Key_F5,
|
||||
eRENDERDOC_Key_F6,
|
||||
eRENDERDOC_Key_F7,
|
||||
eRENDERDOC_Key_F8,
|
||||
eRENDERDOC_Key_F9,
|
||||
eRENDERDOC_Key_F10,
|
||||
eRENDERDOC_Key_F11,
|
||||
eRENDERDOC_Key_F12,
|
||||
|
||||
eKey_Max,
|
||||
};
|
||||
eRENDERDOC_Key_Home,
|
||||
eRENDERDOC_Key_End,
|
||||
eRENDERDOC_Key_Insert,
|
||||
eRENDERDOC_Key_Delete,
|
||||
eRENDERDOC_Key_PageUp,
|
||||
eRENDERDOC_Key_PageDn,
|
||||
|
||||
enum InAppOverlay
|
||||
eRENDERDOC_Key_Backspace,
|
||||
eRENDERDOC_Key_Tab,
|
||||
eRENDERDOC_Key_PrtScrn,
|
||||
eRENDERDOC_Key_Pause,
|
||||
|
||||
eRENDERDOC_Key_Max,
|
||||
} RENDERDOC_InputButton;
|
||||
|
||||
// Sets which key or keys can be used to toggle focus between multiple windows
|
||||
//
|
||||
// If keys is NULL or num is 0, toggle keys will be disabled
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(RENDERDOC_InputButton *keys, int num);
|
||||
|
||||
// Sets which key or keys can be used to capture the next frame
|
||||
//
|
||||
// If keys is NULL or num is 0, captures keys will be disabled
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(RENDERDOC_InputButton *keys, int num);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
eOverlay_Enabled = 0x1,
|
||||
eOverlay_FrameRate = 0x2,
|
||||
eOverlay_FrameNumber = 0x4,
|
||||
eOverlay_CaptureList = 0x8,
|
||||
// This single bit controls whether the overlay is enabled or disabled globally
|
||||
eRENDERDOC_Overlay_Enabled = 0x1,
|
||||
|
||||
eOverlay_Default = (eOverlay_Enabled|eOverlay_FrameRate|eOverlay_FrameNumber|eOverlay_CaptureList),
|
||||
eOverlay_All = ~0U,
|
||||
eOverlay_None = 0,
|
||||
};
|
||||
// Show the average framerate over several seconds as well as min/max
|
||||
eRENDERDOC_Overlay_FrameRate = 0x2,
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// !!!! IMPORTANT NOTE !!!! //
|
||||
// //
|
||||
// This API is pretty much experimental and //
|
||||
// still in flux. The only thing guaranteed //
|
||||
// to remain compatible is a call to //
|
||||
// RENDERDOC_GetAPIVersion which must exactly //
|
||||
// match the version you expect. //
|
||||
// It will be bumped on breaking changes. //
|
||||
////////////////////////////////////////////////
|
||||
// Show the current frame number
|
||||
eRENDERDOC_Overlay_FrameNumber = 0x4,
|
||||
|
||||
// API breaking change history:
|
||||
// Version 1 -> 2 - strings changed from wchar_t* to char* (UTF-8)
|
||||
// Version 2 -> 3 - StartFrameCapture, EndFrameCapture and SetActiveWindow take
|
||||
// 'device' pointer as well as window handles.
|
||||
// This is either ID3D11Device* or the GL context (HGLRC/GLXContext)
|
||||
// You can still pass NULL to both to capture the default, as long as
|
||||
// there's only one device/window pair alive.
|
||||
#define RENDERDOC_API_VERSION 3
|
||||
// Show a list of recent captures, and how many captures have been made
|
||||
eRENDERDOC_Overlay_CaptureList = 0x8,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// In-program functions
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Default values for the overlay mask
|
||||
eRENDERDOC_Overlay_Default =
|
||||
(eRENDERDOC_Overlay_Enabled|
|
||||
eRENDERDOC_Overlay_FrameRate|
|
||||
eRENDERDOC_Overlay_FrameNumber|
|
||||
eRENDERDOC_Overlay_CaptureList),
|
||||
|
||||
extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPIVersion();
|
||||
typedef int (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)();
|
||||
// Enable all bits
|
||||
eRENDERDOC_Overlay_All = ~0U,
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_Shutdown();
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_Shutdown)();
|
||||
// Disable all bits
|
||||
eRENDERDOC_Overlay_None = 0,
|
||||
} RENDERDOC_OverlayBits;
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetLogFile(const char *logfile);
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetLogFile)(const char *logfile);
|
||||
|
||||
extern "C" RENDERDOC_API const char* RENDERDOC_CC RENDERDOC_GetLogFile();
|
||||
typedef const char* (RENDERDOC_CC *pRENDERDOC_GetLogFile)();
|
||||
|
||||
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetNumCaptures();
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
|
||||
|
||||
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetCapture(uint32_t idx, char *logfile, uint32_t *pathlength, uint64_t *timestamp);
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *logfile, uint32_t *pathlength, uint64_t *timestamp);
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureOptions(const CaptureOptions *opts);
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureOptions)(const CaptureOptions *opts);
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerCapture();
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
|
||||
|
||||
// In the below functions 'device pointer' corresponds to the API specific handle, e.g.
|
||||
// ID3D11Device, or the GL context pointer.
|
||||
// The 'window handle' is the OS's native window handle (HWND or GLXDrawable).
|
||||
|
||||
// This must match precisely to a pair, and it sets the RenderDoc in-app overlay to select that
|
||||
// window as 'active' and respond to keypresses.
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetActiveWindow(void *device, void *wndHandle);
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(void *device, void *wndHandle);
|
||||
|
||||
// Either parameter can be NULL to wild-card match, such that you can capture from any
|
||||
// device to a particular window, or a particular device to any window.
|
||||
// In either case, if there are two or more possible matching (device,window) pairs it
|
||||
// is undefined which one will be captured.
|
||||
// You can pass (NULL, NULL) if you know you only have one device and one window, and
|
||||
// it will match. Likewise if you have not created a window at all (only off-screen
|
||||
// rendering), then NULL window pointer will capture, whether you pass a NULL device
|
||||
// or specify a device among multiple.
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_StartFrameCapture(void *device, void *wndHandle);
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(void *device, void *wndHandle);
|
||||
|
||||
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_EndFrameCapture(void *device, void *wndHandle);
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(void *device, void *wndHandle);
|
||||
|
||||
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetOverlayBits();
|
||||
// returns the overlay bits that have been set
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetOverlayBits)();
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_MaskOverlayBits(uint32_t And, uint32_t Or);
|
||||
// sets the overlay bits with an and & or mask
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or);
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetFocusToggleKeys(KeyButton *keys, int num);
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetFocusToggleKeys)(KeyButton *keys, int num);
|
||||
// this function will attempt to shut down RenderDoc.
|
||||
//
|
||||
// Note: that this will only work correctly if done immediately after
|
||||
// the dll is loaded, before any API work happens. RenderDoc will remove its
|
||||
// injected hooks and shut down. Behaviour is undefined if this is called
|
||||
// after any API functions have been called.
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_Shutdown)();
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureKeys(KeyButton *keys, int num);
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureKeys)(KeyButton *keys, int num);
|
||||
// This function will unload RenderDoc's crash handler.
|
||||
//
|
||||
// If you use your own crash handler and don't want RenderDoc's handler to
|
||||
// intercede, you can call this function to unload it and any unhandled
|
||||
// exceptions will pass to the next handler.
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_InitRemoteAccess(uint32_t *ident);
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_InitRemoteAccess)(uint32_t *ident);
|
||||
// Sets the logfile path template
|
||||
//
|
||||
// logfile is a UTF-8 string that gives a template for how captures will be named
|
||||
// and where they will be saved.
|
||||
//
|
||||
// Any extension is stripped off the path, and captures are saved in the directory
|
||||
// specified, and named with the filename and the frame number appended. If the
|
||||
// directory does not exist it will be created, including any parent directories.
|
||||
//
|
||||
// If pathtemplate is NULL, the template will remain unchanged
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// SetLogFilePathTemplate("my_captures/example");
|
||||
//
|
||||
// Capture #1 -> my_captures/example_frame123.rdc
|
||||
// Capture #2 -> my_captures/example_frame456.rdc
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetLogFilePathTemplate)(const char *pathtemplate);
|
||||
|
||||
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_IsRemoteAccessConnected();
|
||||
// returns the current logfile template, see SetLogFileTemplate above, as a UTF-8 string
|
||||
typedef const char* (RENDERDOC_CC *pRENDERDOC_GetLogFilePathTemplate)();
|
||||
|
||||
// returns the number of captures that have been made
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetNumCaptures)();
|
||||
|
||||
// This function returns the details of a capture, by index. New captures are added
|
||||
// to the end of the list.
|
||||
//
|
||||
// logfile will be filled with the absolute path to the capture file, as a UTF-8 string
|
||||
// pathlength will be written with the length in bytes of the logfile string
|
||||
// timestamp will be written with the time of the capture, in seconds since the Unix epoch
|
||||
//
|
||||
// Any of the parameters can be NULL and they'll be skipped.
|
||||
//
|
||||
// The function will return 1 if the capture index is valid, or 0 if the index is invalid
|
||||
// If the index is invalid, the values will be unchanged
|
||||
//
|
||||
// Note: when captures are deleted in the UI they will remain in this list, so the
|
||||
// logfile path may not exist anymore.
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetCapture)(uint32_t idx, char *logfile, uint32_t *pathlength, uint64_t *timestamp);
|
||||
|
||||
// capture the next frame on whichever window and API is currently considered active
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_TriggerCapture)();
|
||||
|
||||
// returns 1 if the RenderDoc UI is connected to this application, 0 otherwise
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_IsRemoteAccessConnected)();
|
||||
|
||||
extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_LaunchReplayUI(uint32_t connectRemoteAccess, const char *cmdline);
|
||||
// This function will launch the Replay UI associated with the RenderDoc library injected
|
||||
// into the running application.
|
||||
//
|
||||
// if connectRemoteAccess is 1, the Replay UI will be launched with a command line parameter
|
||||
// to connect to this application
|
||||
// cmdline is the rest of the command line, as a UTF-8 string. E.g. a captures to open
|
||||
// if cmdline is NULL, the command line will be empty.
|
||||
//
|
||||
// returns the PID of the replay UI if successful, 0 if not successful.
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_LaunchReplayUI)(uint32_t connectRemoteAccess, const char *cmdline);
|
||||
|
||||
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_UnloadCrashHandler();
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_UnloadCrashHandler)();
|
||||
// RenderDoc can return a higher version than requested if it's backwards compatible,
|
||||
// this function returns the actual version returned. If a parameter is NULL, it will be
|
||||
// ignored and the others will be filled out.
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(int *major, int *minor, int *patch);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Capturing functions
|
||||
//
|
||||
|
||||
// A device pointer is a pointer to the API's root handle.
|
||||
//
|
||||
// This would be an ID3D11Device, HGLRC/GLXContext, ID3D12Device, etc
|
||||
typedef void* RENDERDOC_DevicePointer;
|
||||
|
||||
// A window handle is the OS's native window handle
|
||||
//
|
||||
// This would be an HWND, GLXDrawable, etc
|
||||
typedef void* RENDERDOC_WindowHandle;
|
||||
|
||||
// This sets the RenderDoc in-app overlay in the API/window pair as 'active' and it will
|
||||
// respond to keypresses. Neither parameter can be NULL
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
|
||||
|
||||
// When choosing either a device pointer or a window handle to capture, you can pass NULL.
|
||||
// Passing NULL specifies a 'wildcard' match against anything. This allows you to specify
|
||||
// any API rendering to a specific window, or a specific API instance rendering to any window,
|
||||
// or in the simplest case of one window and one API, you can just pass NULL for both.
|
||||
//
|
||||
// In either case, if there are two or more possible matching (device,window) pairs it
|
||||
// is undefined which one will be captured.
|
||||
//
|
||||
// Note: for headless rendering you can pass NULL for the window handle and either specify
|
||||
// a device pointer or leave it NULL as above.
|
||||
|
||||
// Immediately starts capturing API calls on the specified device pointer and window handle.
|
||||
//
|
||||
// If there is no matching thing to capture (e.g. no supported API has been initialised),
|
||||
// this will do nothing.
|
||||
//
|
||||
// The results are undefined (including crashes) if two captures are started overlapping,
|
||||
// even on separate devices and/oror windows.
|
||||
typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
|
||||
|
||||
// Returns whether or not a frame capture is currently ongoing anywhere.
|
||||
//
|
||||
// This will return 1 if a capture is ongoing, and 0 if there is no capture running
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_IsFrameCapturing)();
|
||||
|
||||
// Ends capturing immediately.
|
||||
//
|
||||
// This will return 1 if the capture succeeded, and 0 if there was an error capturing.
|
||||
typedef uint32_t (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(RENDERDOC_DevicePointer device, RENDERDOC_WindowHandle wndHandle);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// RenderDoc API versions
|
||||
//
|
||||
|
||||
// RenderDoc uses semantic versioning (http://semver.org/).
|
||||
//
|
||||
// MAJOR version is incremented when incompatible API changes happen.
|
||||
// MINOR version is incremented when functionality is added in a backwards-compatible manner.
|
||||
// PATCH version is incremented when backwards-compatible bug fixes happen.
|
||||
//
|
||||
// Note that this means the API returned can be higher than the one you might have requested.
|
||||
// e.g. if you are running against a newer RenderDoc that supports 1.0.1, it will be returned
|
||||
// instead of 1.0.0. You can check this with the GetAPIVersion entry point
|
||||
typedef enum
|
||||
{
|
||||
eRENDERDOC_API_Version_1_0_0 = 10000, // RENDERDOC_API_1_0_0 = 1 000 000
|
||||
} RENDERDOC_Version;
|
||||
|
||||
// eRENDERDOC_API_Version_1_0_0
|
||||
typedef struct
|
||||
{
|
||||
pRENDERDOC_GetAPIVersion GetAPIVersion;
|
||||
|
||||
pRENDERDOC_SetCaptureOptionU32 SetCaptureOptionU32;
|
||||
pRENDERDOC_SetCaptureOptionF32 SetCaptureOptionF32;
|
||||
|
||||
pRENDERDOC_GetCaptureOptionU32 GetCaptureOptionU32;
|
||||
pRENDERDOC_GetCaptureOptionF32 GetCaptureOptionF32;
|
||||
|
||||
pRENDERDOC_SetFocusToggleKeys SetFocusToggleKeys;
|
||||
pRENDERDOC_SetCaptureKeys SetCaptureKeys;
|
||||
|
||||
pRENDERDOC_GetOverlayBits GetOverlayBits;
|
||||
pRENDERDOC_MaskOverlayBits MaskOverlayBits;
|
||||
|
||||
pRENDERDOC_Shutdown Shutdown;
|
||||
pRENDERDOC_UnloadCrashHandler UnloadCrashHandler;
|
||||
|
||||
pRENDERDOC_SetLogFilePathTemplate SetLogFilePathTemplate;
|
||||
pRENDERDOC_GetLogFilePathTemplate GetLogFilePathTemplate;
|
||||
|
||||
pRENDERDOC_GetNumCaptures GetNumCaptures;
|
||||
pRENDERDOC_GetCapture GetCapture;
|
||||
|
||||
pRENDERDOC_TriggerCapture TriggerCapture;
|
||||
|
||||
pRENDERDOC_IsRemoteAccessConnected IsRemoteAccessConnected;
|
||||
pRENDERDOC_LaunchReplayUI LaunchReplayUI;
|
||||
|
||||
pRENDERDOC_SetActiveWindow SetActiveWindow;
|
||||
|
||||
pRENDERDOC_StartFrameCapture StartFrameCapture;
|
||||
pRENDERDOC_IsFrameCapturing IsFrameCapturing;
|
||||
pRENDERDOC_EndFrameCapture EndFrameCapture;
|
||||
} RENDERDOC_API_1_0_0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// RenderDoc API entry point
|
||||
//
|
||||
// This entry point can be obtained via GetProcAddress/dlsym if RenderDoc is available.
|
||||
//
|
||||
// The name is the same as the typedef - "RENDERDOC_GetAPI"
|
||||
//
|
||||
// This function is not thread safe, and should not be called on multiple threads at once.
|
||||
// Ideally, call this once as early as possible in your application's startup, before doing
|
||||
// any API work, since some configuration functionality etc has to be done also before
|
||||
// initialising any APIs.
|
||||
//
|
||||
// Parameters:
|
||||
// version is a single value from the RENDERDOC_Version above.
|
||||
//
|
||||
// outAPIPointers will be filled out with a pointer to the corresponding struct of function
|
||||
// pointers.
|
||||
//
|
||||
// Returns:
|
||||
// 1 - if the outAPIPointers has been filled with a pointer to the API struct requested
|
||||
// 0 - if the requested version is not supported or the arguments are invalid.
|
||||
//
|
||||
typedef int (RENDERDOC_CC *pRENDERDOC_GetAPI)(RENDERDOC_Version version, void **outAPIPointers);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
105
3rdparty/bgfx/3rdparty/scintilla/gtk/makefile.orig
vendored
Normal file
105
3rdparty/bgfx/3rdparty/scintilla/gtk/makefile.orig
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
# Make file for Scintilla on Linux or compatible OS
|
||||
# Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||
# The License.txt file describes the conditions under which this software may be distributed.
|
||||
# This makefile assumes GCC 4.3 is used and changes will be needed to use other compilers.
|
||||
# GNU make does not like \r\n line endings so should be saved to CVS in binary form.
|
||||
# Builds for GTK+ 2 and no longer supports GTK+ 1.
|
||||
# Also works with ming32-make on Windows.
|
||||
|
||||
.SUFFIXES: .cxx .c .o .h .a
|
||||
ifdef CLANG
|
||||
CC = clang++
|
||||
CCOMP = clang
|
||||
# Can choose aspect to sanitize: address and undefined can simply change SANITIZE but for
|
||||
# thread also need to create Position Independent Executable -> search online documentation
|
||||
SANITIZE = address
|
||||
#SANITIZE = undefined
|
||||
else
|
||||
CC = g++ -mrecip
|
||||
CCOMP = gcc -mrecip
|
||||
endif
|
||||
AR = ar
|
||||
RANLIB = touch
|
||||
|
||||
ifdef GTK3
|
||||
GTKVERSION=gtk+-3.0
|
||||
else
|
||||
GTKVERSION=gtk+-2.0
|
||||
endif
|
||||
|
||||
# Environment variable windir always defined on Win32
|
||||
|
||||
ifndef windir
|
||||
ifeq ($(shell uname),Darwin)
|
||||
RANLIB = ranlib
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef windir
|
||||
DEL = del /q
|
||||
COMPLIB=..\bin\scintilla.a
|
||||
else
|
||||
DEL = rm -f
|
||||
COMPLIB=../bin/scintilla.a
|
||||
endif
|
||||
|
||||
vpath %.h ../src ../include ../lexlib
|
||||
vpath %.cxx ../src ../lexlib ../lexers
|
||||
|
||||
INCLUDEDIRS=-I ../include -I ../src -I ../lexlib
|
||||
ifdef CHECK_DEPRECATED
|
||||
DEPRECATED=-DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DDISABLE_GDK_FONT
|
||||
endif
|
||||
CXXBASEFLAGS=-Wall -pedantic -DGTK -DSCI_LEXER $(INCLUDEDIRS) $(DEPRECATED)
|
||||
|
||||
ifdef NOTHREADS
|
||||
THREADFLAGS=-DG_THREADS_IMPL_NONE
|
||||
else
|
||||
THREADFLAGS=
|
||||
endif
|
||||
|
||||
ifdef DEBUG
|
||||
ifdef CLANG
|
||||
CTFLAGS=-DDEBUG -g -fsanitize=$(SANITIZE) $(CXXBASEFLAGS) $(THREADFLAGS)
|
||||
else
|
||||
CTFLAGS=-DDEBUG -g $(CXXBASEFLAGS) $(THREADFLAGS)
|
||||
endif
|
||||
else
|
||||
CTFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS)
|
||||
endif
|
||||
|
||||
CFLAGS:=$(CTFLAGS)
|
||||
CXXTFLAGS:=--std=c++0x $(CTFLAGS)
|
||||
|
||||
CONFIGFLAGS:=$(shell pkg-config --cflags $(GTKVERSION))
|
||||
MARSHALLER=scintilla-marshal.o
|
||||
|
||||
.cxx.o:
|
||||
$(CC) $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) -c $<
|
||||
.c.o:
|
||||
$(CCOMP) $(CONFIGFLAGS) $(CFLAGS) -w -c $<
|
||||
|
||||
LEXOBJS:=$(addsuffix .o,$(basename $(notdir $(wildcard ../lexers/Lex*.cxx))))
|
||||
|
||||
all: $(COMPLIB)
|
||||
|
||||
clean:
|
||||
$(DEL) *.o $(COMPLIB) *.plist
|
||||
|
||||
analyze:
|
||||
clang --analyze $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx
|
||||
|
||||
deps:
|
||||
$(CC) -MM $(CONFIGFLAGS) $(CXXTFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx | sed -e 's/\/usr.* //' | grep [a-zA-Z] >deps.mak
|
||||
|
||||
$(COMPLIB): Accessor.o CharacterSet.o LexerBase.o LexerModule.o LexerSimple.o StyleContext.o WordList.o \
|
||||
CharClassify.o Decoration.o Document.o PerLine.o Catalogue.o CallTip.o CaseConvert.o CaseFolder.o \
|
||||
ScintillaBase.o ContractionState.o Editor.o ExternalLexer.o PropSetSimple.o PlatGTK.o \
|
||||
KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o CharacterCategory.o ViewStyle.o \
|
||||
RESearch.o RunStyles.o Selection.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \
|
||||
$(MARSHALLER) $(LEXOBJS)
|
||||
$(AR) rc $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
# Automatically generate header dependencies with "make deps"
|
||||
include deps.mak
|
9647
3rdparty/bgfx/3rdparty/scintilla/src/Editor.cxx.orig
vendored
Normal file
9647
3rdparty/bgfx/3rdparty/scintilla/src/Editor.cxx.orig
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
3rdparty/bgfx/3rdparty/stb/stb_image.c
vendored
8
3rdparty/bgfx/3rdparty/stb/stb_image.c
vendored
@ -1,3 +1,11 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(disable:4312) // warning C4312: 'type cast': conversion from '' to '' of greater size
|
||||
# pragma warning(disable:4456) // warning C4456: declaration of 'k' hides previous local declaration
|
||||
# pragma warning(disable:4457) // warning C4457: declaration of 'y' hides function parameter
|
||||
#endif
|
||||
|
||||
/* stb_image - v2.06 - public domain image loader - http://nothings.org/stb_image.h
|
||||
no warranty implied; use at your own risk
|
||||
|
||||
|
2
3rdparty/bgfx/3rdparty/stb/stb_truetype.h
vendored
2
3rdparty/bgfx/3rdparty/stb/stb_truetype.h
vendored
@ -1,5 +1,7 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wshadow"
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(disable:4456) // warning C4456: declaration of 'k' hides previous local declaration
|
||||
#endif
|
||||
|
||||
// stb_truetype.h - v1.07 - public domain
|
||||
|
5
3rdparty/bgfx/README.md
vendored
5
3rdparty/bgfx/README.md
vendored
@ -28,10 +28,11 @@ Supported platforms:
|
||||
* Android (14+, ARM, x86, MIPS)
|
||||
* asm.js/Emscripten (1.25.0)
|
||||
* FreeBSD
|
||||
* iOS
|
||||
* iOS (iPhone, iPad, AppleTV)
|
||||
* Linux /statusIcon)
|
||||
* MIPS Creator CI20
|
||||
* Native Client (PPAPI 37+, ARM, x86, x64, PNaCl)
|
||||
* OSX (10.9)
|
||||
* OSX (10.9+)
|
||||
* RaspberryPi
|
||||
* Windows (XP, Vista, 7, 8, 10) /statusIcon)
|
||||
* WinRT (WinPhone 8.0+)
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/uint32_t.h>
|
||||
#include "logo.h"
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
// embedded shaders
|
||||
#include "vs_metaballs.bin.h"
|
||||
@ -504,6 +504,11 @@ class Metaballs : public entry::AppI
|
||||
fs_metaballs = bgfx::makeRef(fs_metaballs_dx11, sizeof(fs_metaballs_dx11) );
|
||||
break;
|
||||
|
||||
case bgfx::RendererType::Metal:
|
||||
vs_metaballs = bgfx::makeRef(vs_metaballs_mtl, sizeof(vs_metaballs_mtl) );
|
||||
fs_metaballs = bgfx::makeRef(fs_metaballs_mtl, sizeof(fs_metaballs_mtl) );
|
||||
break;
|
||||
|
||||
default:
|
||||
vs_metaballs = bgfx::makeRef(vs_metaballs_glsl, sizeof(vs_metaballs_glsl) );
|
||||
fs_metaballs = bgfx::makeRef(fs_metaballs_glsl, sizeof(fs_metaballs_glsl) );
|
||||
|
25
3rdparty/bgfx/examples/08-update/update.cpp
vendored
25
3rdparty/bgfx/examples/08-update/update.cpp
vendored
@ -141,7 +141,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
loadTexture("texture_compression_bc1.dds", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP),
|
||||
loadTexture("texture_compression_bc2.dds", BGFX_TEXTURE_U_CLAMP),
|
||||
loadTexture("texture_compression_bc3.dds", BGFX_TEXTURE_V_CLAMP),
|
||||
loadTexture("texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER|BGFX_TEXTURE_V_BORDER),
|
||||
loadTexture("texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER|BGFX_TEXTURE_V_BORDER|BGFX_TEXTURE_BORDER_COLOR(1) ),
|
||||
loadTexture("texture_compression_etc2.ktx"),
|
||||
loadTexture("texture_compression_ptc12.pvr"),
|
||||
loadTexture("texture_compression_ptc14.pvr"),
|
||||
@ -197,20 +197,22 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
// Create static index buffer.
|
||||
bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );
|
||||
|
||||
// Create texture sampler uniforms.
|
||||
bgfx::UniformHandle s_texCube = bgfx::createUniform("s_texCube", bgfx::UniformType::Int1);
|
||||
bgfx::UniformHandle s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
|
||||
|
||||
bgfx::UniformHandle u_time = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
|
||||
|
||||
bgfx::ProgramHandle program = loadProgram("vs_update", "fs_update");
|
||||
bgfx::ProgramHandle programCmp = loadProgram("vs_update", "fs_update_cmp");
|
||||
bgfx::ProgramHandle program3d = BGFX_INVALID_HANDLE;
|
||||
// Create programs.
|
||||
bgfx::ProgramHandle program = loadProgram("vs_update", "fs_update");
|
||||
bgfx::ProgramHandle programCmp = loadProgram("vs_update", "fs_update_cmp");
|
||||
bgfx::ProgramHandle program3d = BGFX_INVALID_HANDLE;
|
||||
if (texture3DSupported)
|
||||
{
|
||||
program3d = loadProgram("vs_update", "fs_update_3d");
|
||||
}
|
||||
|
||||
// Create texture sampler uniforms.
|
||||
bgfx::UniformHandle s_texCube = bgfx::createUniform("s_texCube", bgfx::UniformType::Int1);
|
||||
bgfx::UniformHandle s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
|
||||
|
||||
// Create time uniform.
|
||||
bgfx::UniformHandle u_time = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
|
||||
|
||||
const uint32_t textureSide = 2048;
|
||||
|
||||
bgfx::TextureHandle textureCube = bgfx::createTextureCube(textureSide, 1
|
||||
@ -243,6 +245,9 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
|
||||
while (!entry::processEvents(width, height, debug, reset) )
|
||||
{
|
||||
float borderColor[4] = { float(rand()%255)/255.0f, float(rand()%255)/255.0f, float(rand()%255)/255.0f, float(rand()%255)/255.0f };
|
||||
bgfx::setPaletteColor(1, borderColor);
|
||||
|
||||
// Set view 0 and 1 viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
bgfx::setViewRect(1, 0, 0, width, height);
|
||||
|
2
3rdparty/bgfx/examples/10-font/font.cpp
vendored
2
3rdparty/bgfx/examples/10-font/font.cpp
vendored
@ -5,7 +5,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/string.h>
|
||||
#include <bx/fpumath.h>
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/fpumath.h>
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/fpumath.h>
|
||||
|
@ -19,7 +19,7 @@ using namespace std::tr1;
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/allocator.h>
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/fpumath.h>
|
||||
@ -311,7 +311,6 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
|
||||
// Floor.
|
||||
bx::mtxMul(lightMtx, mtxFloor, mtxShadow);
|
||||
bgfx::setUniform(u_lightMtx, lightMtx);
|
||||
uint32_t cached = bgfx::setTransform(mtxFloor);
|
||||
for (uint32_t pass = 0; pass < 2; ++pass)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/fpumath.h>
|
||||
|
@ -3,7 +3,7 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/uint32_t.h>
|
||||
|
||||
#include "common.h"
|
||||
@ -127,6 +127,11 @@ class DrawStress : public entry::AppI
|
||||
fs_drawstress = bgfx::makeRef(fs_drawstress_dx11, sizeof(fs_drawstress_dx11) );
|
||||
break;
|
||||
|
||||
case bgfx::RendererType::Metal:
|
||||
vs_drawstress = bgfx::makeRef(vs_drawstress_mtl, sizeof(vs_drawstress_mtl) );
|
||||
fs_drawstress = bgfx::makeRef(fs_drawstress_mtl, sizeof(fs_drawstress_mtl) );
|
||||
break;
|
||||
|
||||
default:
|
||||
vs_drawstress = bgfx::makeRef(vs_drawstress_glsl, sizeof(vs_drawstress_glsl) );
|
||||
fs_drawstress = bgfx::makeRef(fs_drawstress_glsl, sizeof(fs_drawstress_glsl) );
|
||||
|
8
3rdparty/bgfx/examples/19-oit/oit.cpp
vendored
8
3rdparty/bgfx/examples/19-oit/oit.cpp
vendored
@ -311,11 +311,11 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
|
||||
bgfx::setViewTransform(0, view, proj);
|
||||
|
||||
// Set clear color palette for index 0
|
||||
bgfx::setClearColor(0, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
// Set palette color for index 0
|
||||
bgfx::setPaletteColor(0, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// Set clear color palette for index 1
|
||||
bgfx::setClearColor(1, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
// Set palette color for index 1
|
||||
bgfx::setPaletteColor(1, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
|
2
3rdparty/bgfx/examples/20-nanovg/nanovg.cpp
vendored
2
3rdparty/bgfx/examples/20-nanovg/nanovg.cpp
vendored
@ -26,7 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/string.h>
|
||||
#include <bx/timer.h>
|
||||
#include "entry/entry.h"
|
||||
|
15
3rdparty/bgfx/examples/21-deferred/deferred.cpp
vendored
15
3rdparty/bgfx/examples/21-deferred/deferred.cpp
vendored
@ -18,11 +18,6 @@
|
||||
static float s_texelHalf = 0.0f;
|
||||
static bool s_originBottomLeft = false;
|
||||
|
||||
inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far)
|
||||
{
|
||||
bx::mtxProj(_result, _fovy, _aspect, _near, _far, s_originBottomLeft);
|
||||
}
|
||||
|
||||
struct PosNormalTangentTexcoordVertex
|
||||
{
|
||||
float m_x;
|
||||
@ -233,11 +228,11 @@ class Deferred : public entry::AppI
|
||||
// Enable m_debug text.
|
||||
bgfx::setDebug(m_debug);
|
||||
|
||||
// Set clear color palette for index 0
|
||||
bgfx::setClearColor(0, UINT32_C(0x00000000) );
|
||||
// Set palette color for index 0
|
||||
bgfx::setPaletteColor(0, UINT32_C(0x00000000) );
|
||||
|
||||
// Set clear color palette for index 1
|
||||
bgfx::setClearColor(1, UINT32_C(0x303030ff) );
|
||||
// Set palette color for index 1
|
||||
bgfx::setPaletteColor(1, UINT32_C(0x303030ff) );
|
||||
|
||||
// Set geometry pass view clear state.
|
||||
bgfx::setViewClear(RENDER_PASS_GEOMETRY_ID
|
||||
@ -504,7 +499,7 @@ class Deferred : public entry::AppI
|
||||
bgfx::setViewFrameBuffer(RENDER_PASS_LIGHT_ID, m_lightBuffer);
|
||||
|
||||
float proj[16];
|
||||
mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
|
||||
bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, s_originBottomLeft);
|
||||
|
||||
bgfx::setViewFrameBuffer(RENDER_PASS_GEOMETRY_ID, m_gbuffer);
|
||||
bgfx::setViewTransform(RENDER_PASS_GEOMETRY_ID, view, proj);
|
||||
|
@ -210,8 +210,6 @@ void VectorDisplay::endFrame()
|
||||
|
||||
if (m_brightness > 0)
|
||||
{
|
||||
bgfx::setUniform(u_params, params);
|
||||
|
||||
bgfx::setTexture(0, s_texColor, m_sceneFrameBuffer);
|
||||
|
||||
int npasses = (int)(m_brightness * 4);
|
||||
@ -264,6 +262,8 @@ void VectorDisplay::endFrame()
|
||||
}
|
||||
}
|
||||
|
||||
bgfx::discard();
|
||||
|
||||
//now do last pass, combination of blur and normal buffer to screen
|
||||
bgfx::setViewTransform(viewCounter, NULL, proj);
|
||||
bgfx::setViewRect(viewCounter, 0, 0, m_screenWidth, m_screenHeight);
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef __VECTORDISPLAY_H__
|
||||
#define __VECTORDISPLAY_H__
|
||||
|
||||
#include "bgfx.h"
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
#include <tinystl/allocator.h>
|
||||
#include <tinystl/vector.h>
|
||||
|
2
3rdparty/bgfx/examples/24-nbody/nbody.cpp
vendored
2
3rdparty/bgfx/examples/24-nbody/nbody.cpp
vendored
@ -7,7 +7,7 @@
|
||||
#include "bgfx_utils.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "camera.h"
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
struct u_paramsDataStruct
|
||||
{
|
||||
|
2
3rdparty/bgfx/examples/25-c99/helloworld.c
vendored
2
3rdparty/bgfx/examples/25-c99/helloworld.c
vendored
@ -3,7 +3,7 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bgfx.c99.h>
|
||||
#include <bgfx/c99/bgfx.h>
|
||||
#include "../00-helloworld/logo.h"
|
||||
|
||||
extern bool entry_process_events(uint32_t* _width, uint32_t* _height, uint32_t* _debug, uint32_t* _reset);
|
||||
|
2
3rdparty/bgfx/examples/common/bgfx_utils.cpp
vendored
2
3rdparty/bgfx/examples/common/bgfx_utils.cpp
vendored
@ -12,7 +12,7 @@
|
||||
#include <tinystl/string.h>
|
||||
namespace stl = tinystl;
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/fpumath.h>
|
||||
#include <bx/string.h>
|
||||
|
2
3rdparty/bgfx/examples/common/bgfx_utils.h
vendored
2
3rdparty/bgfx/examples/common/bgfx_utils.h
vendored
@ -6,7 +6,7 @@
|
||||
#ifndef BGFX_UTILS_H_HEADER_GUARD
|
||||
#define BGFX_UTILS_H_HEADER_GUARD
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
void* load(const char* _filePath, uint32_t* _size = NULL);
|
||||
void unload(void* _ptr);
|
||||
|
2
3rdparty/bgfx/examples/common/cube_atlas.cpp
vendored
2
3rdparty/bgfx/examples/common/cube_atlas.cpp
vendored
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
#include <limits.h> // INT_MAX
|
||||
#include <memory.h> // memset
|
||||
|
2
3rdparty/bgfx/examples/common/cube_atlas.h
vendored
2
3rdparty/bgfx/examples/common/cube_atlas.h
vendored
@ -15,7 +15,7 @@
|
||||
/// algorithm based on C++ sources provided by Jukka Jylänki at:
|
||||
/// http://clb.demon.fi/files/RectangleBinPack/
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
struct AtlasRegion
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/string.h>
|
||||
#include <bx/readerwriter.h>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_ANDROID
|
||||
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <bx/thread.h>
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#define GLFW_DLL
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
#include "dbg.h"
|
||||
|
||||
// This is just trivial implementation of GLFW3 integration.
|
||||
|
@ -17,7 +17,7 @@
|
||||
//# define HAS_METAL_SDK
|
||||
#endif
|
||||
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
|
||||
#include <bx/uint32_t.h>
|
||||
#include <bx/thread.h>
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_NACL
|
||||
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -29,7 +29,7 @@
|
||||
#include <ppapi/c/ppp_instance.h>
|
||||
#include <ppapi/gles2/gl2ext_ppapi.h>
|
||||
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
#include <bx/thread.h>
|
||||
|
||||
#include "entry.h"
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
|
||||
#include <bx/uint32_t.h>
|
||||
#include <bx/thread.h>
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <bx/thread.h>
|
||||
|
@ -7,12 +7,13 @@
|
||||
|
||||
#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_WINDOWS
|
||||
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
|
||||
#include <bx/uint32_t.h>
|
||||
#include <bx/thread.h>
|
||||
#include <bx/mutex.h>
|
||||
#include <bx/handlealloc.h>
|
||||
#include <bx/timer.h>
|
||||
#include <tinystl/allocator.h>
|
||||
#include <tinystl/string.h>
|
||||
|
||||
@ -116,6 +117,17 @@ namespace entry
|
||||
|
||||
void update(EventQueue& _eventQueue)
|
||||
{
|
||||
int64_t now = bx::getHPCounter();
|
||||
static int64_t next = now;
|
||||
|
||||
if (now < next)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int64_t timerFreq = bx::getHPFrequency();
|
||||
next = now + timerFreq/60;
|
||||
|
||||
if (NULL == m_xinputdll)
|
||||
{
|
||||
return;
|
||||
@ -518,7 +530,7 @@ namespace entry
|
||||
, msg->m_y
|
||||
, msg->m_width
|
||||
, msg->m_height
|
||||
, m_hwnd[0]
|
||||
, NULL
|
||||
, NULL
|
||||
, (HINSTANCE)GetModuleHandle(NULL)
|
||||
, 0
|
||||
@ -902,33 +914,6 @@ namespace entry
|
||||
top = newrect.top +(newrect.bottom-newrect.top-height)/2;
|
||||
}
|
||||
|
||||
HWND parent = GetWindow(_hwnd, GW_OWNER);
|
||||
if (NULL != parent)
|
||||
{
|
||||
if (_windowFrame)
|
||||
{
|
||||
SetWindowPos(parent
|
||||
, HWND_TOP
|
||||
, -32000
|
||||
, -32000
|
||||
, 0
|
||||
, 0
|
||||
, SWP_SHOWWINDOW
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowPos(parent
|
||||
, HWND_TOP
|
||||
, newrect.left
|
||||
, newrect.top
|
||||
, newrect.right-newrect.left
|
||||
, newrect.bottom-newrect.top
|
||||
, SWP_SHOWWINDOW
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SetWindowPos(_hwnd
|
||||
, HWND_TOP
|
||||
, left
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#if BX_PLATFORM_WINRT
|
||||
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
#include <bx/thread.h>
|
||||
|
||||
using namespace Windows::ApplicationModel;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define XK_LATIN1
|
||||
#include <X11/keysymdef.h>
|
||||
#include <X11/Xlib.h> // will include X11 which #defines None... Don't mess with order of includes.
|
||||
#include <bgfxplatform.h>
|
||||
#include <bgfx/bgfxplatform.h>
|
||||
|
||||
#undef None
|
||||
#include <bx/thread.h>
|
||||
@ -299,11 +299,10 @@ namespace entry
|
||||
m_visual = DefaultVisual(m_display, screen);
|
||||
m_root = RootWindow(m_display, screen);
|
||||
|
||||
XSetWindowAttributes windowAttrs;
|
||||
memset(&windowAttrs, 0, sizeof(windowAttrs) );
|
||||
windowAttrs.background_pixmap = 0;
|
||||
windowAttrs.border_pixel = 0;
|
||||
windowAttrs.event_mask = 0
|
||||
memset(&m_windowAttrs, 0, sizeof(m_windowAttrs) );
|
||||
m_windowAttrs.background_pixmap = 0;
|
||||
m_windowAttrs.border_pixel = 0;
|
||||
m_windowAttrs.event_mask = 0
|
||||
| ButtonPressMask
|
||||
| ButtonReleaseMask
|
||||
| ExposureMask
|
||||
@ -322,7 +321,7 @@ namespace entry
|
||||
, InputOutput
|
||||
, m_visual
|
||||
, CWBorderPixel|CWEventMask
|
||||
, &windowAttrs
|
||||
, &m_windowAttrs
|
||||
);
|
||||
|
||||
// Clear window to black.
|
||||
@ -338,6 +337,20 @@ namespace entry
|
||||
XMapWindow(m_display, m_window[0]);
|
||||
XStoreName(m_display, m_window[0], "BGFX");
|
||||
|
||||
XIM im;
|
||||
im = XOpenIM(m_display, NULL, NULL, NULL);
|
||||
|
||||
XIC ic;
|
||||
ic = XCreateIC(im
|
||||
, XNInputStyle
|
||||
, 0
|
||||
| XIMPreeditNothing
|
||||
| XIMStatusNothing
|
||||
, XNClientWindow
|
||||
, m_window[0]
|
||||
, NULL
|
||||
);
|
||||
|
||||
//
|
||||
bgfx::x11SetDisplayWindow(m_display, m_window[0]);
|
||||
|
||||
@ -449,10 +462,30 @@ namespace entry
|
||||
|
||||
default:
|
||||
{
|
||||
WindowHandle handle = findHandle(xkey.window);
|
||||
if (KeyPress == event.type)
|
||||
{
|
||||
Status status = 0;
|
||||
uint8_t utf8[4];
|
||||
int len = Xutf8LookupString(ic, &xkey, (char*)utf8, sizeof(utf8), &keysym, &status);
|
||||
switch (status)
|
||||
{
|
||||
case XLookupChars:
|
||||
case XLookupBoth:
|
||||
if (0 != len)
|
||||
{
|
||||
m_eventQueue.postCharEvent(handle, len, utf8);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Key::Enum key = fromXk(keysym);
|
||||
if (Key::None != key)
|
||||
{
|
||||
WindowHandle handle = findHandle(xkey.window);
|
||||
m_eventQueue.postKeyEvent(handle, key, m_modifiers, KeyPress == event.type);
|
||||
}
|
||||
}
|
||||
@ -479,6 +512,9 @@ namespace entry
|
||||
|
||||
s_joystick.shutdown();
|
||||
|
||||
XDestroyIC(ic);
|
||||
XCloseIM(im);
|
||||
|
||||
XUnmapWindow(m_display, m_window[0]);
|
||||
XDestroyWindow(m_display, m_window[0]);
|
||||
|
||||
@ -493,21 +529,6 @@ namespace entry
|
||||
|
||||
void createWindow(WindowHandle _handle, Msg* msg)
|
||||
{
|
||||
XSetWindowAttributes windowAttrs;
|
||||
memset(&windowAttrs, 0, sizeof(windowAttrs) );
|
||||
windowAttrs.background_pixmap = 0;
|
||||
windowAttrs.border_pixel = 0;
|
||||
windowAttrs.event_mask = 0
|
||||
| ButtonPressMask
|
||||
| ButtonReleaseMask
|
||||
| ExposureMask
|
||||
| KeyPressMask
|
||||
| KeyReleaseMask
|
||||
| PointerMotionMask
|
||||
| ResizeRedirectMask
|
||||
| StructureNotifyMask
|
||||
;
|
||||
|
||||
Window window = XCreateWindow(m_display
|
||||
, m_root
|
||||
, msg->m_x
|
||||
@ -519,7 +540,7 @@ namespace entry
|
||||
, InputOutput
|
||||
, m_visual
|
||||
, CWBorderPixel|CWEventMask
|
||||
, &windowAttrs
|
||||
, &m_windowAttrs
|
||||
);
|
||||
m_window[_handle.idx] = window;
|
||||
|
||||
@ -583,6 +604,8 @@ namespace entry
|
||||
Visual* m_visual;
|
||||
Window m_root;
|
||||
|
||||
XSetWindowAttributes m_windowAttrs;
|
||||
|
||||
Display* m_display;
|
||||
Window m_window[ENTRY_CONFIG_MAX_WINDOWS];
|
||||
uint32_t m_flags[ENTRY_CONFIG_MAX_WINDOWS];
|
||||
@ -648,26 +671,23 @@ namespace entry
|
||||
|
||||
void setWindowPos(WindowHandle _handle, int32_t _x, int32_t _y)
|
||||
{
|
||||
BX_UNUSED(_handle, _x, _y);
|
||||
Display* display = s_ctx.m_display;
|
||||
Window window = s_ctx.m_window[_handle.idx];
|
||||
XMoveWindow(display, window, _x, _y);
|
||||
}
|
||||
|
||||
void setWindowSize(WindowHandle _handle, uint32_t _width, uint32_t _height)
|
||||
{
|
||||
BX_UNUSED(_handle);
|
||||
XResizeRequestEvent ev;
|
||||
ev.type = ResizeRequest;
|
||||
ev.serial = 0;
|
||||
ev.send_event = true;
|
||||
ev.display = s_ctx.m_display;
|
||||
ev.window = s_ctx.m_window[0];
|
||||
ev.width = (int)_width;
|
||||
ev.height = (int)_height;
|
||||
XSendEvent(s_ctx.m_display, s_ctx.m_window[0], false, ResizeRedirectMask, (XEvent*)&ev);
|
||||
Display* display = s_ctx.m_display;
|
||||
Window window = s_ctx.m_window[_handle.idx];
|
||||
XResizeWindow(display, window, int32_t(_width), int32_t(_height) );
|
||||
}
|
||||
|
||||
void setWindowTitle(WindowHandle _handle, const char* _title)
|
||||
{
|
||||
XStoreName(s_ctx.m_display, s_ctx.m_window[_handle.idx], _title);
|
||||
Display* display = s_ctx.m_display;
|
||||
Window window = s_ctx.m_window[_handle.idx];
|
||||
XStoreName(display, window, _title);
|
||||
}
|
||||
|
||||
void toggleWindowFrame(WindowHandle _handle)
|
||||
|
@ -25,7 +25,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <math.h>
|
||||
|
||||
#if USE_EDTAA3
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define FONT_MANAGER_H_HEADER_GUARD
|
||||
|
||||
#include <bx/handlealloc.h>
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
class Atlas;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <stddef.h> // offsetof
|
||||
#include <memory.h> // memcpy
|
||||
#include <wchar.h> // wcslen
|
||||
@ -329,6 +329,15 @@ void TextBuffer::clearTextBuffer()
|
||||
|
||||
void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
|
||||
{
|
||||
if (_codePoint == L'\t')
|
||||
{
|
||||
for (uint32_t ii = 0; ii < 4; ++ii)
|
||||
{
|
||||
appendGlyph(_handle, L' ');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const GlyphInfo* glyph = m_fontManager->getGlyphInfo(_handle, _codePoint);
|
||||
BX_WARN(NULL != glyph, "Glyph not found (font handle %d, code point %d)", _handle.idx, _codePoint);
|
||||
if (NULL == glyph)
|
||||
@ -336,27 +345,27 @@ void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
|
||||
return;
|
||||
}
|
||||
|
||||
const FontInfo& font = m_fontManager->getFontInfo(_handle);
|
||||
|
||||
if( m_vertexCount/4 >= MAX_BUFFERED_CHARACTERS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const FontInfo& font = m_fontManager->getFontInfo(_handle);
|
||||
|
||||
if (_codePoint == L'\n')
|
||||
{
|
||||
m_penX = m_originX;
|
||||
m_penY += m_lineGap + m_lineAscender -m_lineDescender;
|
||||
m_lineGap = font.lineGap;
|
||||
m_lineDescender = font.descender;
|
||||
m_lineAscender = font.ascender;
|
||||
m_lineDescender = font.descender;
|
||||
m_lineAscender = font.ascender;
|
||||
m_lineStartIndex = m_vertexCount;
|
||||
return;
|
||||
}
|
||||
|
||||
//is there a change of font size that require the text on the left to be centered again ?
|
||||
if (font.ascender > m_lineAscender
|
||||
|| (font.descender < m_lineDescender) )
|
||||
|| (font.descender < m_lineDescender) )
|
||||
{
|
||||
if (font.descender < m_lineDescender)
|
||||
{
|
||||
@ -377,7 +386,7 @@ void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
|
||||
const Atlas* atlas = m_fontManager->getAtlas();
|
||||
|
||||
if (m_styleFlags & STYLE_BACKGROUND
|
||||
&& m_backgroundColor & 0xFF000000)
|
||||
&& m_backgroundColor & 0xff000000)
|
||||
{
|
||||
float x0 = (m_penX - kerning);
|
||||
float y0 = (m_penY);
|
||||
@ -592,7 +601,7 @@ TextBufferManager::TextBufferManager(FontManager* _fontManager)
|
||||
vs_font_distance_field_subpixel = bgfx::makeRef(vs_font_distance_field_subpixel_mtl, sizeof(vs_font_distance_field_subpixel_mtl) );
|
||||
fs_font_distance_field_subpixel = bgfx::makeRef(fs_font_distance_field_subpixel_mtl, sizeof(fs_font_distance_field_subpixel_mtl) );
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
vs_font_basic = bgfx::makeRef(vs_font_basic_glsl, sizeof(vs_font_basic_glsl) );
|
||||
fs_font_basic = bgfx::makeRef(fs_font_basic_glsl, sizeof(fs_font_basic_glsl) );
|
||||
|
@ -466,7 +466,7 @@ struct Imgui
|
||||
_size = sizeof(s_droidSansTtf);
|
||||
}
|
||||
|
||||
IMGUI_create(_data, _size, _fontSize, _allocator);
|
||||
IMGUI_create(_data, _size, _fontSize, m_allocator);
|
||||
|
||||
m_nvg = nvgCreate(1, m_view);
|
||||
nvgCreateFontMem(m_nvg, "default", (unsigned char*)_data, INT32_MAX, 0);
|
||||
@ -3080,8 +3080,8 @@ struct Imgui
|
||||
|
||||
bool visible(int32_t _elemY, int32_t _elemHeight, int32_t _scissorY, int32_t _scissorHeight)
|
||||
{
|
||||
return _elemY > _scissorY
|
||||
&& (_elemY+_elemHeight) < (_scissorY+_scissorHeight);
|
||||
return (_elemY+_elemHeight) > _scissorY
|
||||
&& (_elemY) < (_scissorY+_scissorHeight);
|
||||
}
|
||||
|
||||
inline Area& getCurrentArea()
|
||||
|
64
3rdparty/bgfx/examples/common/imgui/imgui.h
vendored
64
3rdparty/bgfx/examples/common/imgui/imgui.h
vendored
@ -26,8 +26,9 @@
|
||||
#ifndef IMGUI_H_HEADER_GUARD
|
||||
#define IMGUI_H_HEADER_GUARD
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <ocornut-imgui/imgui.h>
|
||||
#include <ocornut-imgui/imgui_wm.h>
|
||||
|
||||
#define IMGUI_MBUT_LEFT 0x01
|
||||
#define IMGUI_MBUT_RIGHT 0x02
|
||||
@ -207,20 +208,65 @@ bool imguiMouseOverArea();
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
#define IMGUI_FLAGS_NONE UINT16_C(0x0000)
|
||||
#define IMGUI_FLAGS_ALPHA_BLEND UINT16_C(0x0001)
|
||||
|
||||
// Helper function for passing bgfx::TextureHandle to ImGui::Image.
|
||||
inline void Image(bgfx::TextureHandle _handle, 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) )
|
||||
inline void Image(bgfx::TextureHandle _handle
|
||||
, uint16_t _flags
|
||||
, const ImVec2& _size
|
||||
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
||||
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
||||
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
)
|
||||
{
|
||||
union { bgfx::TextureHandle handle; ImTextureID ptr; } texture;
|
||||
texture.handle = _handle;
|
||||
Image(texture.ptr, _size, _uv0, _uv1, _tint_col, _border_col);
|
||||
union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
|
||||
texture.s.flags = _flags;
|
||||
texture.s.handle = _handle;
|
||||
Image(texture.ptr, _size, _uv0, _uv1, _tintCol, _borderCol);
|
||||
}
|
||||
|
||||
// Helper function for passing bgfx::TextureHandle to ImGui::Image.
|
||||
inline void Image(bgfx::TextureHandle _handle
|
||||
, const ImVec2& _size
|
||||
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
||||
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
||||
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
)
|
||||
{
|
||||
Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _tintCol, _borderCol);
|
||||
}
|
||||
|
||||
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
|
||||
inline bool ImageButton(bgfx::TextureHandle _handle, const ImVec2& _size, const ImVec2& _uv0 = ImVec2(0,0), const ImVec2& _uv1 = ImVec2(1,1), int _frame_padding = -1, const ImVec4& _bg_col = ImVec4(0,0,0,0), const ImVec4& _tint_col = ImVec4(1,1,1,1))
|
||||
inline bool ImageButton(bgfx::TextureHandle _handle
|
||||
, uint16_t _flags
|
||||
, const ImVec2& _size
|
||||
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
||||
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
||||
, int _framePadding = -1
|
||||
, const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
)
|
||||
{
|
||||
union { bgfx::TextureHandle handle; ImTextureID ptr; } texture;
|
||||
texture.handle = _handle;
|
||||
return ImageButton(texture.ptr, _size, _uv0, _uv1, _frame_padding, _bg_col, _tint_col);
|
||||
union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
|
||||
texture.s.flags = _flags;
|
||||
texture.s.handle = _handle;
|
||||
return ImageButton(texture.ptr, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
||||
}
|
||||
|
||||
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
|
||||
inline bool ImageButton(bgfx::TextureHandle _handle
|
||||
, const ImVec2& _size
|
||||
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
||||
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
||||
, int _framePadding = -1
|
||||
, const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
)
|
||||
{
|
||||
return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
||||
}
|
||||
|
||||
} // namespace ImGui
|
||||
|
@ -3,15 +3,24 @@
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/allocator.h>
|
||||
#include <bx/fpumath.h>
|
||||
#include <bx/timer.h>
|
||||
#include <ocornut-imgui/imgui.h>
|
||||
#include <ocornut-imgui/imgui_wm.h>
|
||||
#include "imgui.h"
|
||||
#include "ocornut_imgui.h"
|
||||
#include <stb/stb_image.c>
|
||||
|
||||
#ifndef USE_ENTRY
|
||||
# define USE_ENTRY defined(SCI_NAMESPACE)
|
||||
#endif // USE_ENTRY
|
||||
|
||||
#if USE_ENTRY
|
||||
# include "../entry/entry.h"
|
||||
#endif // USE_ENTRY
|
||||
|
||||
#if defined(SCI_NAMESPACE)
|
||||
# include "../entry/input.h"
|
||||
# include "scintilla.h"
|
||||
@ -20,86 +29,334 @@
|
||||
#include "vs_ocornut_imgui.bin.h"
|
||||
#include "fs_ocornut_imgui.bin.h"
|
||||
|
||||
void viewCallback(const ImDrawList* _parentList, const ImDrawCmd* _cmd);
|
||||
|
||||
class PlatformWindow : public ImGuiWM::PlatformWindow
|
||||
{
|
||||
typedef ImGuiWM::PlatformWindow Super;
|
||||
|
||||
public:
|
||||
PlatformWindow(bool _mainWindow, bool _isDragWindow)
|
||||
: ImGuiWM::PlatformWindow(_mainWindow, _isDragWindow)
|
||||
, m_pos(0.0f, 0.0f)
|
||||
, m_size(0.0f, 0.0f)
|
||||
, m_drag(false)
|
||||
{
|
||||
#if USE_ENTRY
|
||||
if (!_mainWindow
|
||||
&& !_isDragWindow)
|
||||
{
|
||||
m_window = entry::createWindow(0, 0, 640, 380);
|
||||
extern void pwToWindow(entry::WindowHandle _handle, PlatformWindow* _pw);
|
||||
pwToWindow(m_window, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_window.idx = 0;
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
}
|
||||
|
||||
virtual ~PlatformWindow() BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Init(ImGuiWM::PlatformWindow* /*_parent*/) BX_OVERRIDE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual const ImVec2& GetPosition() const BX_OVERRIDE
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
virtual const ImVec2& GetSize() const BX_OVERRIDE
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
virtual void Show() BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Hide() BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetSize(const ImVec2& _size) BX_OVERRIDE
|
||||
{
|
||||
#if USE_ENTRY
|
||||
if (0 != m_window.idx
|
||||
&& m_size.x != _size.x
|
||||
&& m_size.y != _size.y)
|
||||
{
|
||||
entry::setWindowSize(m_window, int32_t(_size.x), int32_t(_size.y) );
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
|
||||
m_size = _size;
|
||||
}
|
||||
|
||||
virtual void SetPosition(const ImVec2& _pos) BX_OVERRIDE
|
||||
{
|
||||
|
||||
#if USE_ENTRY
|
||||
if (0 != m_window.idx
|
||||
&& m_pos.x != _pos.x
|
||||
&& m_pos.y != _pos.y)
|
||||
{
|
||||
entry::setWindowPos(m_window, int32_t(_pos.x), int32_t(_pos.y) );
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
|
||||
m_pos = _pos;
|
||||
}
|
||||
|
||||
virtual void SetTitle(const char* _title) BX_OVERRIDE
|
||||
{
|
||||
#if USE_ENTRY
|
||||
entry::setWindowTitle(m_window, _title);
|
||||
#else
|
||||
BX_UNUSED(_title);
|
||||
#endif // USE_ENTRY
|
||||
}
|
||||
|
||||
virtual void PreUpdate() BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
virtual void PaintBegin()
|
||||
{
|
||||
#if USE_ENTRY
|
||||
if (!m_bIsDragWindow)
|
||||
{
|
||||
ImDrawList* drawList = ImGui::GetWindowDrawList();
|
||||
union { entry::WindowHandle handle; void* ptr; } cast = { m_window };
|
||||
drawList->AddCallback(viewCallback, cast.ptr);
|
||||
drawList->PushClipRect(ImVec4(0.0f, 0.0f, m_size.x, m_size.y) );
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
}
|
||||
|
||||
virtual void Paint() BX_OVERRIDE
|
||||
{
|
||||
if (!m_bIsDragWindow)
|
||||
{
|
||||
Super::Paint();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void PaintEnd()
|
||||
{
|
||||
#if USE_ENTRY
|
||||
if (!m_bIsDragWindow)
|
||||
{
|
||||
ImDrawList* drawList = ImGui::GetWindowDrawList();
|
||||
drawList->PopClipRect();
|
||||
drawList->AddCallback(viewCallback, NULL);
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
}
|
||||
|
||||
virtual void Destroy() BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
virtual void StartDrag() BX_OVERRIDE
|
||||
{
|
||||
m_drag = true;
|
||||
}
|
||||
|
||||
virtual void StopDrag() BX_OVERRIDE
|
||||
{
|
||||
m_drag = false;
|
||||
}
|
||||
|
||||
virtual bool IsDraging() BX_OVERRIDE
|
||||
{
|
||||
return m_drag;
|
||||
}
|
||||
|
||||
private:
|
||||
ImVec2 m_pos;
|
||||
ImVec2 m_size;
|
||||
bool m_drag;
|
||||
|
||||
#if USE_ENTRY
|
||||
entry::WindowHandle m_window;
|
||||
#endif // USE_ENTRY
|
||||
};
|
||||
|
||||
class WindowManager : public ImGuiWM::WindowManager
|
||||
{
|
||||
typedef ImGuiWM::WindowManager Super;
|
||||
|
||||
public:
|
||||
WindowManager()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~WindowManager() BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ImGuiWM::PlatformWindow* CreatePlatformWindow(bool _main, ImGuiWM::PlatformWindow* _parent, bool _isDragWindow) BX_OVERRIDE
|
||||
{
|
||||
#if USE_ENTRY
|
||||
#else
|
||||
if (!_main
|
||||
&& !_isDragWindow)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
|
||||
PlatformWindow* window = new (ImGui::MemAlloc(sizeof(PlatformWindow) ) ) PlatformWindow(_main, _isDragWindow);
|
||||
window->Init(_parent);
|
||||
return static_cast<ImGuiWM::PlatformWindow*>(window);
|
||||
}
|
||||
|
||||
virtual void LogFormatted(const char* _str) BX_OVERRIDE
|
||||
{
|
||||
BX_TRACE("%s", _str); BX_UNUSED(_str);
|
||||
}
|
||||
|
||||
virtual void InternalRun() BX_OVERRIDE
|
||||
{
|
||||
PreUpdate();
|
||||
Update();
|
||||
}
|
||||
};
|
||||
|
||||
struct OcornutImguiContext
|
||||
{
|
||||
static void* memAlloc(size_t _size);
|
||||
static void memFree(void* _ptr);
|
||||
static void renderDrawLists(ImDrawData* draw_data);
|
||||
static void renderDrawLists(ImDrawData* _drawData);
|
||||
|
||||
void render(ImDrawData* draw_data)
|
||||
void render(ImDrawData* _drawData)
|
||||
{
|
||||
const float width = ImGui::GetIO().DisplaySize.x;
|
||||
const float height = ImGui::GetIO().DisplaySize.y;
|
||||
const ImGuiIO& io = ImGui::GetIO();
|
||||
const float width = io.DisplaySize.x;
|
||||
const float height = io.DisplaySize.y;
|
||||
|
||||
float ortho[16];
|
||||
bx::mtxOrtho(ortho, 0.0f, width, height, 0.0f, -1.0f, 1.0f);
|
||||
{
|
||||
float ortho[16];
|
||||
bx::mtxOrtho(ortho, 0.0f, width, height, 0.0f, -1.0f, 1.0f);
|
||||
bgfx::setViewTransform(m_viewId, NULL, ortho);
|
||||
}
|
||||
|
||||
bgfx::setViewTransform(m_viewId, NULL, ortho);
|
||||
#if USE_ENTRY
|
||||
for (uint32_t ii = 1; ii < BX_COUNTOF(m_window); ++ii)
|
||||
{
|
||||
Window& window = m_window[ii];
|
||||
if (bgfx::isValid(window.m_fbh) )
|
||||
{
|
||||
const uint8_t viewId = window.m_viewId;
|
||||
bgfx::setViewClear(viewId
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
, 0x303030ff + rand()
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
bgfx::setViewFrameBuffer(viewId, window.m_fbh);
|
||||
bgfx::setViewRect(viewId
|
||||
, 0
|
||||
, 0
|
||||
, window.m_state.m_width
|
||||
, window.m_state.m_height
|
||||
);
|
||||
float ortho[16];
|
||||
bx::mtxOrtho(ortho
|
||||
, 0.0f
|
||||
, float(window.m_state.m_width)
|
||||
, float(window.m_state.m_height)
|
||||
, 0.0f
|
||||
, -1.0f
|
||||
, 1.0f
|
||||
);
|
||||
bgfx::setViewTransform(viewId
|
||||
, NULL
|
||||
, ortho
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
|
||||
// Render command lists
|
||||
for (int32_t ii = 0; ii < draw_data->CmdListsCount; ++ii)
|
||||
for (int32_t ii = 0, num = _drawData->CmdListsCount; ii < num; ++ii)
|
||||
{
|
||||
bgfx::TransientVertexBuffer tvb;
|
||||
bgfx::TransientIndexBuffer tib;
|
||||
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[ii];
|
||||
uint32_t vtx_size = (uint32_t)cmd_list->VtxBuffer.size();
|
||||
uint32_t idx_size = (uint32_t)cmd_list->IdxBuffer.size();
|
||||
const ImDrawList* drawList = _drawData->CmdLists[ii];
|
||||
uint32_t numVertices = (uint32_t)drawList->VtxBuffer.size();
|
||||
uint32_t numIndices = (uint32_t)drawList->IdxBuffer.size();
|
||||
|
||||
if (!bgfx::checkAvailTransientVertexBuffer(vtx_size, m_decl) || !bgfx::checkAvailTransientIndexBuffer(idx_size) )
|
||||
if (!bgfx::checkAvailTransientVertexBuffer(numVertices, m_decl)
|
||||
|| !bgfx::checkAvailTransientIndexBuffer(numIndices) )
|
||||
{
|
||||
// not enough space in transient buffer just quit drawing the rest...
|
||||
break;
|
||||
}
|
||||
|
||||
bgfx::allocTransientVertexBuffer(&tvb, vtx_size, m_decl);
|
||||
bgfx::allocTransientIndexBuffer(&tib, idx_size);
|
||||
bgfx::allocTransientVertexBuffer(&tvb, numVertices, m_decl);
|
||||
bgfx::allocTransientIndexBuffer(&tib, numIndices);
|
||||
|
||||
ImDrawVert* verts = (ImDrawVert*)tvb.data;
|
||||
memcpy(verts, cmd_list->VtxBuffer.begin(), vtx_size * sizeof(ImDrawVert) );
|
||||
memcpy(verts, drawList->VtxBuffer.begin(), numVertices * sizeof(ImDrawVert) );
|
||||
|
||||
ImDrawIdx* indices = (ImDrawIdx*)tib.data;
|
||||
memcpy(indices, cmd_list->IdxBuffer.begin(), idx_size * sizeof(ImDrawIdx) );
|
||||
memcpy(indices, drawList->IdxBuffer.begin(), numIndices * sizeof(ImDrawIdx) );
|
||||
|
||||
uint32_t elem_offset = 0;
|
||||
const ImDrawCmd* pcmd_begin = cmd_list->CmdBuffer.begin();
|
||||
const ImDrawCmd* pcmd_end = cmd_list->CmdBuffer.end();
|
||||
for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++)
|
||||
uint32_t offset = 0;
|
||||
for (const ImDrawCmd* cmd = drawList->CmdBuffer.begin(), *cmdEnd = drawList->CmdBuffer.end(); cmd != cmdEnd; ++cmd)
|
||||
{
|
||||
if (pcmd->UserCallback)
|
||||
if (cmd->UserCallback)
|
||||
{
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
elem_offset += pcmd->ElemCount;
|
||||
continue;
|
||||
cmd->UserCallback(drawList, cmd);
|
||||
}
|
||||
if (0 == pcmd->ElemCount)
|
||||
else if (0 != cmd->ElemCount)
|
||||
{
|
||||
continue;
|
||||
uint64_t state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_MSAA
|
||||
;
|
||||
|
||||
bgfx::TextureHandle th = m_texture;
|
||||
|
||||
if (NULL != cmd->TextureId)
|
||||
{
|
||||
union { ImTextureID ptr; struct { uint16_t flags; bgfx::TextureHandle handle; } s; } texture = { cmd->TextureId };
|
||||
state |= 0 != (IMGUI_FLAGS_ALPHA_BLEND & texture.s.flags)
|
||||
? BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
||||
: BGFX_STATE_NONE
|
||||
;
|
||||
th = texture.s.handle;
|
||||
}
|
||||
else
|
||||
{
|
||||
state |= BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA);
|
||||
}
|
||||
|
||||
const uint16_t xx = uint16_t(bx::fmax(cmd->ClipRect.x, 0.0f) );
|
||||
const uint16_t yy = uint16_t(bx::fmax(cmd->ClipRect.y, 0.0f) );
|
||||
bgfx::setScissor(xx, yy
|
||||
, uint16_t(bx::fmin(cmd->ClipRect.z, 65535.0f)-xx)
|
||||
, uint16_t(bx::fmin(cmd->ClipRect.w, 65535.0f)-yy)
|
||||
);
|
||||
|
||||
bgfx::setState(state);
|
||||
bgfx::setTexture(0, s_tex, th);
|
||||
bgfx::setVertexBuffer(&tvb, 0, numVertices);
|
||||
bgfx::setIndexBuffer(&tib, offset, cmd->ElemCount);
|
||||
bgfx::submit(m_viewId, m_program);
|
||||
}
|
||||
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
||||
| BGFX_STATE_MSAA
|
||||
);
|
||||
bgfx::setScissor(uint16_t(bx::fmax(pcmd->ClipRect.x, 0.0f) )
|
||||
, uint16_t(bx::fmax(pcmd->ClipRect.y, 0.0f) )
|
||||
, uint16_t(bx::fmin(pcmd->ClipRect.z, 65535.0f)-bx::fmax(pcmd->ClipRect.x, 0.0f) )
|
||||
, uint16_t(bx::fmin(pcmd->ClipRect.w, 65535.0f)-bx::fmax(pcmd->ClipRect.y, 0.0f) )
|
||||
);
|
||||
union { void* ptr; bgfx::TextureHandle handle; } texture = { pcmd->TextureId };
|
||||
|
||||
bgfx::setTexture(0, s_tex, 0 != texture.handle.idx
|
||||
? texture.handle
|
||||
: m_texture
|
||||
);
|
||||
|
||||
bgfx::setVertexBuffer(&tvb, 0, vtx_size);
|
||||
bgfx::setIndexBuffer(&tib, elem_offset, pcmd->ElemCount);
|
||||
bgfx::submit(m_viewId, m_program);
|
||||
|
||||
elem_offset += pcmd->ElemCount;
|
||||
offset += cmd->ElemCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -176,9 +433,9 @@ struct OcornutImguiContext
|
||||
|
||||
m_decl
|
||||
.begin()
|
||||
.add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
|
||||
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
|
||||
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
|
||||
.end();
|
||||
|
||||
s_tex = bgfx::createUniform("s_tex", bgfx::UniformType::Int1);
|
||||
@ -202,10 +459,61 @@ struct OcornutImguiContext
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.FrameRounding = 4.0f;
|
||||
|
||||
m_wm = BX_NEW(m_allocator, WindowManager);
|
||||
m_wm->Init();
|
||||
|
||||
#if 0
|
||||
{
|
||||
class Window : public ImGuiWM::Window
|
||||
{
|
||||
public:
|
||||
Window(const char* _title)
|
||||
: ImGuiWM::Window()
|
||||
{
|
||||
SetTitle(_title);
|
||||
}
|
||||
|
||||
virtual void OnGui() BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class WindowX : public ImGuiWM::Window
|
||||
{
|
||||
public:
|
||||
WindowX(const char* _title)
|
||||
: ImGuiWM::Window()
|
||||
{
|
||||
SetTitle(_title);
|
||||
}
|
||||
|
||||
virtual void OnGui() BX_OVERRIDE
|
||||
{
|
||||
#if defined(SCI_NAMESPACE) && 0
|
||||
bool opened = true;
|
||||
ImGuiScintilla("Scintilla Editor", &opened, ImVec2(640.0f, 480.0f) );
|
||||
#endif // 0
|
||||
}
|
||||
};
|
||||
|
||||
Window* w0 = new Window("test");
|
||||
WindowX* w1 = new WindowX("abcd");
|
||||
Window* w2 = new Window("xyzw");
|
||||
Window* w3 = new Window("0123");
|
||||
|
||||
m_wm->Dock(w0);
|
||||
m_wm->DockWith(w1, w0, ImGuiWM::E_DOCK_ORIENTATION_RIGHT);
|
||||
m_wm->DockWith(w2, w1, ImGuiWM::E_DOCK_ORIENTATION_BOTTOM);
|
||||
m_wm->DockWith(w3, w0, ImGuiWM::E_DOCK_ORIENTATION_BOTTOM);
|
||||
}
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
void destroy()
|
||||
{
|
||||
m_wm->Exit();
|
||||
BX_DELETE(m_allocator, m_wm);
|
||||
ImGui::Shutdown();
|
||||
|
||||
bgfx::destroyUniform(s_tex);
|
||||
@ -217,7 +525,9 @@ struct OcornutImguiContext
|
||||
|
||||
void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId)
|
||||
{
|
||||
m_viewId = _viewId;
|
||||
m_viewId = _viewId;
|
||||
m_defaultViewId = _viewId;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (_inputChar < 0x7f)
|
||||
{
|
||||
@ -261,15 +571,11 @@ struct OcornutImguiContext
|
||||
bool opened = true;
|
||||
ShowExampleAppCustomNodeGraph(&opened);
|
||||
#endif // 0
|
||||
|
||||
#if defined(SCI_NAMESPACE) && 0
|
||||
bool opened = true;
|
||||
ImGuiScintilla("Scintilla Editor", &opened, ImVec2(640.0f, 480.0f) );
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
void endFrame()
|
||||
{
|
||||
m_wm->Run();
|
||||
ImGui::Render();
|
||||
}
|
||||
|
||||
@ -278,13 +584,84 @@ struct OcornutImguiContext
|
||||
bgfx::ProgramHandle m_program;
|
||||
bgfx::TextureHandle m_texture;
|
||||
bgfx::UniformHandle s_tex;
|
||||
WindowManager* m_wm;
|
||||
int64_t m_last;
|
||||
int32_t m_lastScroll;
|
||||
uint8_t m_viewId;
|
||||
uint8_t m_defaultViewId;
|
||||
|
||||
#if USE_ENTRY
|
||||
struct Window
|
||||
{
|
||||
Window()
|
||||
{
|
||||
m_fbh.idx = bgfx::invalidHandle;
|
||||
}
|
||||
|
||||
entry::WindowState m_state;
|
||||
PlatformWindow* m_pw;
|
||||
bgfx::FrameBufferHandle m_fbh;
|
||||
uint8_t m_viewId;
|
||||
};
|
||||
|
||||
Window m_window[16];
|
||||
#endif // USE_ENTRY
|
||||
};
|
||||
|
||||
static OcornutImguiContext s_ctx;
|
||||
|
||||
#if USE_ENTRY
|
||||
|
||||
void viewCallback(const ImDrawList* /*_parentList*/, const ImDrawCmd* _cmd)
|
||||
{
|
||||
union { void* ptr; entry::WindowHandle handle; } cast = { _cmd->UserCallbackData };
|
||||
|
||||
if (0 != cast.handle.idx)
|
||||
{
|
||||
s_ctx.m_viewId = s_ctx.m_window[cast.handle.idx].m_viewId;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_ctx.m_viewId = s_ctx.m_defaultViewId;
|
||||
}
|
||||
}
|
||||
|
||||
void pwToWindow(entry::WindowHandle _handle, PlatformWindow* _pw)
|
||||
{
|
||||
s_ctx.m_window[_handle.idx].m_pw = _pw;
|
||||
}
|
||||
|
||||
void imguiUpdateWindow(const entry::WindowState& _state)
|
||||
{
|
||||
OcornutImguiContext::Window& window = s_ctx.m_window[_state.m_handle.idx];
|
||||
|
||||
if (window.m_state.m_nwh != _state.m_nwh
|
||||
|| (window.m_state.m_width != _state.m_width
|
||||
|| window.m_state.m_height != _state.m_height) )
|
||||
{
|
||||
// When window changes size or native window handle changed
|
||||
// frame buffer must be recreated.
|
||||
if (bgfx::isValid(window.m_fbh) )
|
||||
{
|
||||
bgfx::destroyFrameBuffer(window.m_fbh);
|
||||
window.m_fbh.idx = bgfx::invalidHandle;
|
||||
}
|
||||
|
||||
if (NULL != _state.m_nwh)
|
||||
{
|
||||
window.m_fbh = bgfx::createFrameBuffer(_state.m_nwh, _state.m_width, _state.m_height);
|
||||
window.m_viewId = 200 + _state.m_handle.idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.m_viewId = s_ctx.m_defaultViewId;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&window.m_state, &_state, sizeof(entry::WindowState) );
|
||||
}
|
||||
#endif // USE_ENTRY
|
||||
|
||||
void* OcornutImguiContext::memAlloc(size_t _size)
|
||||
{
|
||||
return BX_ALLOC(s_ctx.m_allocator, _size);
|
||||
|
@ -1105,7 +1105,7 @@ ScintillaEditor* ImGuiScintilla(const char* _name, bool* _opened, const ImVec2&
|
||||
{
|
||||
ScintillaEditor* sci = NULL;
|
||||
|
||||
if (ImGui::Begin(_name, _opened, _size) )
|
||||
// if (ImGui::Begin(_name, _opened, _size) )
|
||||
{
|
||||
ImGuiStorage* storage = ImGui::GetStateStorage();
|
||||
|
||||
@ -1121,7 +1121,7 @@ ScintillaEditor* ImGuiScintilla(const char* _name, bool* _opened, const ImVec2&
|
||||
sci->draw();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
// ImGui::End();
|
||||
return sci;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <math.h>
|
||||
#include "nanovg.h"
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
#include <bx/bx.h>
|
||||
|
||||
@ -667,7 +667,6 @@ namespace
|
||||
);
|
||||
bgfx::setVertexBuffer(&gl->tvb, paths[i].strokeOffset, paths[i].strokeCount);
|
||||
bgfx::setTexture(0, gl->s_tex, gl->th);
|
||||
bgfx::setTexture(0, gl->s_tex, gl->th);
|
||||
bgfx::submit(gl->viewid, gl->prog);
|
||||
}
|
||||
}
|
||||
|
20
3rdparty/bgfx/examples/makefile
vendored
20
3rdparty/bgfx/examples/makefile
vendored
@ -30,3 +30,23 @@ rebuild:
|
||||
@make -s --no-print-directory rebuild -C common/font
|
||||
@make -s --no-print-directory rebuild -C common/imgui
|
||||
@make -s --no-print-directory rebuild -C common/nanovg
|
||||
|
||||
metal:
|
||||
@make -s --no-print-directory TARGET=5 -C 01-cubes
|
||||
@make -s --no-print-directory TARGET=5 -C 03-raymarch
|
||||
@make -s --no-print-directory TARGET=5 -C 04-mesh
|
||||
@make -s --no-print-directory TARGET=5 -C 05-instancing
|
||||
@make -s --no-print-directory TARGET=5 -C 06-bump
|
||||
@make -s --no-print-directory TARGET=5 -C 07-callback
|
||||
@make -s --no-print-directory TARGET=5 -C 08-update
|
||||
@make -s --no-print-directory TARGET=5 -C 09-hdr
|
||||
@make -s --no-print-directory TARGET=5 -C 12-lod
|
||||
@make -s --no-print-directory TARGET=5 -C 13-stencil
|
||||
@make -s --no-print-directory TARGET=5 -C 14-shadowvolumes
|
||||
@make -s --no-print-directory TARGET=5 -C 15-shadowmaps-simple
|
||||
@make -s --no-print-directory TARGET=5 -C 16-shadowmaps
|
||||
@make -s --no-print-directory TARGET=5 -C 18-ibl
|
||||
@make -s --no-print-directory TARGET=5 -C 19-oit
|
||||
@make -s --no-print-directory TARGET=5 -C 21-deferred
|
||||
@make -s --no-print-directory TARGET=5 -C 23-vectordisplay
|
||||
@make -s --no-print-directory TARGET=5 -C 24-nbody
|
||||
|
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_bump.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_bump.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_callback.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_callback.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_cubes.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_cubes.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_combine.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_combine.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_debug.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_debug.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_debug_line.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_debug_line.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_geom.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_geom.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_light.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_deferred_light.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_blur.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_blur.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_bright.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_bright.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_lum.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_lum.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_lumavg.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_lumavg.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_mesh.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_mesh.bin
vendored
Normal file
Binary file not shown.
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_skybox.bin
vendored
Normal file
BIN
3rdparty/bgfx/examples/runtime/shaders/metal/fs_hdr_skybox.bin
vendored
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user