More std::string removal
This commit is contained in:
parent
173bc86ea9
commit
46664170cd
2 changed files with 43 additions and 51 deletions
65
odbg.cc
65
odbg.cc
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const std::string NormalOutput_ = "(DISABLED)";
|
char const NormalOutput_[] = "(DISABLED)";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ void T_OutputDebugger::makeUI( )
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_OutputDebugger::registerTexture(
|
void T_OutputDebugger::registerTexture(
|
||||||
__rw__ T_Texture& texture ,
|
T_Texture& texture ,
|
||||||
__rd__ const E_ODbgMode mode ,
|
const E_ODbgMode mode ,
|
||||||
__rd__ std::string const& name )
|
T_String const& name )
|
||||||
{
|
{
|
||||||
texture.debugIndex_ = registerTexture(
|
texture.debugIndex_ = registerTexture(
|
||||||
texture.id_ , texture.levels_ , mode , name );
|
texture.id_ , texture.levels_ , mode , name );
|
||||||
|
@ -128,16 +128,18 @@ void T_OutputDebugger::debugOutput( )
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void T_OutputDebugger::registerSubmode(
|
void T_OutputDebugger::registerSubmode(
|
||||||
__rd__ const E_ODbgMode mode ,
|
const E_ODbgMode mode ,
|
||||||
__rd__ std::string const& name ,
|
T_String const& name ,
|
||||||
__rd__ std::string const& shader ,
|
T_String const& shader ,
|
||||||
__rd__ F_SubmodeSetup setup )
|
F_SubmodeSetup setup )
|
||||||
{
|
{
|
||||||
assert( mode != E_ODbgMode::__COUNT__ );
|
assert( mode != E_ODbgMode::__COUNT__ );
|
||||||
|
ebcl::T_StringBuilder sb( "debug/" );
|
||||||
|
sb << shader << ".glsl" << '\0';
|
||||||
submodes_[ int( mode ) ].add( T_Submode_{
|
submodes_[ int( mode ) ].add( T_Submode_{
|
||||||
name ,
|
name ,
|
||||||
Globals::Shaders( ).pipeline({
|
Globals::Shaders( ).pipeline({
|
||||||
"fullscreen.v.glsl" , "debug/" + shader + ".glsl" }) ,
|
"fullscreen.v.glsl" , sb.data( ) }) ,
|
||||||
setup
|
setup
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -145,29 +147,24 @@ void T_OutputDebugger::registerSubmode(
|
||||||
void T_OutputDebugger::initSubmodeCombo( )
|
void T_OutputDebugger::initSubmodeCombo( )
|
||||||
{
|
{
|
||||||
for ( auto sm = 0u ; sm < int( E_ODbgMode::__COUNT__ ) ; sm ++ ) {
|
for ( auto sm = 0u ; sm < int( E_ODbgMode::__COUNT__ ) ; sm ++ ) {
|
||||||
size_t reqSize = 1;
|
imguiStrings.clear( );
|
||||||
for ( auto const& m : submodes_[ sm ] ) {
|
for ( auto const& m : submodes_[ sm ] ) {
|
||||||
reqSize += 1 + m.name.length( );
|
imguiStrings << m.name << '\0';
|
||||||
}
|
}
|
||||||
assert( reqSize > 1 );
|
imguiStrings << '\0';
|
||||||
|
|
||||||
smCombo_[ sm ] = new char[ reqSize ];
|
smCombo_[ sm ] = new char[ imguiStrings.size( ) ];
|
||||||
char* ptr = smCombo_[ sm ];
|
memcpy( smCombo_[ sm ] , imguiStrings.data( ) , imguiStrings.size( ) );
|
||||||
for ( auto const& m : submodes_[ sm ] ) {
|
|
||||||
strcpy( ptr , m.name.c_str( ) );
|
|
||||||
ptr += 1 + m.name.length( );
|
|
||||||
}
|
|
||||||
*ptr = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int32_t T_OutputDebugger::registerTexture(
|
int32_t T_OutputDebugger::registerTexture(
|
||||||
__rd__ const GLuint id ,
|
const GLuint id ,
|
||||||
__rd__ const uint32_t levels ,
|
const uint32_t levels ,
|
||||||
__rd__ const E_ODbgMode mode ,
|
const E_ODbgMode mode ,
|
||||||
__rd__ std::string const& name )
|
T_String const& name )
|
||||||
{
|
{
|
||||||
assert( mode != E_ODbgMode::__COUNT__ );
|
assert( mode != E_ODbgMode::__COUNT__ );
|
||||||
assert( id != 0 );
|
assert( id != 0 );
|
||||||
|
@ -186,7 +183,7 @@ int32_t T_OutputDebugger::registerTexture(
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_OutputDebugger::unregisterTexture(
|
void T_OutputDebugger::unregisterTexture(
|
||||||
__rd__ const uint32_t index )
|
const uint32_t index )
|
||||||
{
|
{
|
||||||
assert( index < outputs_.size( ) );
|
assert( index < outputs_.size( ) );
|
||||||
assert( outputs_[ index ].id != 0 );
|
assert( outputs_[ index ].id != 0 );
|
||||||
|
@ -210,30 +207,24 @@ void T_OutputDebugger::clearSelectorItems( )
|
||||||
|
|
||||||
void T_OutputDebugger::makeSelectorItems( )
|
void T_OutputDebugger::makeSelectorItems( )
|
||||||
{
|
{
|
||||||
size_t requiredSize = 2 + NormalOutput_.length( );
|
imguiStrings.clear( );
|
||||||
|
imguiStrings << NormalOutput_ << '\0';
|
||||||
|
|
||||||
uint32_t nrLeft = nRegistered_, i = 0;
|
uint32_t nrLeft = nRegistered_, i = 0;
|
||||||
selectorMapping_.add( -1 );
|
selectorMapping_.add( -1 );
|
||||||
while ( nrLeft ) {
|
while ( nrLeft ) {
|
||||||
assert( i < outputs_.size( ) );
|
assert( i < outputs_.size( ) );
|
||||||
if ( outputs_[ i ].id != 0 ) {
|
if ( outputs_[ i ].id != 0 ) {
|
||||||
requiredSize += 1 + outputs_[ i ].name.length( );
|
imguiStrings << outputs_[ i ].name << '\0';
|
||||||
selectorMapping_.add( i );
|
selectorMapping_.add( i );
|
||||||
nrLeft --;
|
nrLeft --;
|
||||||
}
|
}
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
|
imguiStrings << '\0';
|
||||||
|
|
||||||
assert( selectorMapping_.size( ) == 1 + nRegistered_ );
|
assert( selectorMapping_.size( ) == 1 + nRegistered_ );
|
||||||
assert( requiredSize >= 2 + NormalOutput_.length( ) + 2 * nRegistered_ );
|
|
||||||
|
|
||||||
selectorItems_ = new char[ requiredSize ];
|
selectorItems_ = new char[ imguiStrings.size( ) ];
|
||||||
char* ptr = selectorItems_;
|
memcpy( selectorItems_ , imguiStrings.data( ) , imguiStrings.size( ) );
|
||||||
strcpy( ptr , NormalOutput_.c_str( ) );
|
|
||||||
ptr += NormalOutput_.length( ) + 1;
|
|
||||||
for ( i = 1 ; i < selectorMapping_.size( ) ; i ++ ) {
|
|
||||||
auto const& name( outputs_[ selectorMapping_[ i ] ].name );
|
|
||||||
strcpy( ptr , name.c_str( ) );
|
|
||||||
ptr += name.length( ) + 1;
|
|
||||||
}
|
|
||||||
*ptr = 0;
|
|
||||||
}
|
}
|
||||||
|
|
29
odbg.hh
29
odbg.hh
|
@ -22,9 +22,9 @@ struct T_OutputDebugger
|
||||||
~T_OutputDebugger( );
|
~T_OutputDebugger( );
|
||||||
|
|
||||||
void registerTexture(
|
void registerTexture(
|
||||||
__rw__ T_Texture& texture ,
|
T_Texture& texture ,
|
||||||
__rd__ const E_ODbgMode mode ,
|
const E_ODbgMode mode ,
|
||||||
__rd__ std::string const& name );
|
T_String const& name );
|
||||||
|
|
||||||
bool& uiEnabled( )
|
bool& uiEnabled( )
|
||||||
{ return enabled_; }
|
{ return enabled_; }
|
||||||
|
@ -40,7 +40,7 @@ struct T_OutputDebugger
|
||||||
GLuint id;
|
GLuint id;
|
||||||
uint32_t levels;
|
uint32_t levels;
|
||||||
E_ODbgMode mode;
|
E_ODbgMode mode;
|
||||||
std::string name;
|
T_String name;
|
||||||
//
|
//
|
||||||
int submode;
|
int submode;
|
||||||
int lod;
|
int lod;
|
||||||
|
@ -49,7 +49,7 @@ struct T_OutputDebugger
|
||||||
using F_SubmodeSetup = std::function< void( GLuint ) >;
|
using F_SubmodeSetup = std::function< void( GLuint ) >;
|
||||||
struct T_Submode_
|
struct T_Submode_
|
||||||
{
|
{
|
||||||
std::string name;
|
T_String name;
|
||||||
T_ShaderPipeline pipeline;
|
T_ShaderPipeline pipeline;
|
||||||
F_SubmodeSetup setup;
|
F_SubmodeSetup setup;
|
||||||
};
|
};
|
||||||
|
@ -59,25 +59,26 @@ struct T_OutputDebugger
|
||||||
T_Array< T_Texture_ > outputs_;
|
T_Array< T_Texture_ > outputs_;
|
||||||
T_Array< T_Submode_ > submodes_[ int( E_ODbgMode::__COUNT__ ) ];
|
T_Array< T_Submode_ > submodes_[ int( E_ODbgMode::__COUNT__ ) ];
|
||||||
char* smCombo_[ int( E_ODbgMode::__COUNT__ ) ];
|
char* smCombo_[ int( E_ODbgMode::__COUNT__ ) ];
|
||||||
|
ebcl::T_StringBuilder imguiStrings;
|
||||||
|
|
||||||
int32_t selected_ = -1;
|
int32_t selected_ = -1;
|
||||||
char* selectorItems_;
|
char* selectorItems_;
|
||||||
T_Array< int32_t > selectorMapping_;
|
T_Array< int32_t > selectorMapping_;
|
||||||
|
|
||||||
void registerSubmode(
|
void registerSubmode(
|
||||||
__rd__ const E_ODbgMode mode ,
|
const E_ODbgMode mode ,
|
||||||
__rd__ std::string const& name ,
|
T_String const& name ,
|
||||||
__rd__ std::string const& shader ,
|
T_String const& shader ,
|
||||||
__rd__ F_SubmodeSetup setup = F_SubmodeSetup( ) );
|
F_SubmodeSetup setup = F_SubmodeSetup( ) );
|
||||||
void initSubmodeCombo( );
|
void initSubmodeCombo( );
|
||||||
|
|
||||||
int32_t registerTexture(
|
int32_t registerTexture(
|
||||||
__rd__ const GLuint id ,
|
const GLuint id ,
|
||||||
__rd__ const uint32_t levels ,
|
const uint32_t levels ,
|
||||||
__rd__ const E_ODbgMode mode ,
|
const E_ODbgMode mode ,
|
||||||
__rd__ std::string const& name );
|
T_String const& name );
|
||||||
void unregisterTexture(
|
void unregisterTexture(
|
||||||
__rd__ const uint32_t index );
|
const uint32_t index );
|
||||||
|
|
||||||
void makeSelectorItems( );
|
void makeSelectorItems( );
|
||||||
void clearSelectorItems( );
|
void clearSelectorItems( );
|
||||||
|
|
Loading…
Reference in a new issue