本文整理汇总了C++中CS_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ CS_ASSERT函数的具体用法?C++ CS_ASSERT怎么用?C++ CS_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CS_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CS_ASSERT
//-------------------------------------------------------------
//-------------------------------------------------------------
void Entity::AddComponent(const ComponentSPtr& in_component)
{
CS_ASSERT(in_component != nullptr, "Cannot add null component");
CS_ASSERT(in_component->GetEntity() == nullptr, "Component cannot be attached to more than 1 entity at a time.");
m_components.push_back(in_component);
in_component->SetEntity(this);
in_component->OnAddedToEntity();
if(GetScene() != nullptr)
{
in_component->OnAddedToScene();
if (m_appActive == true)
{
in_component->OnResume();
if (m_appForegrounded == true)
{
in_component->OnForeground();
}
}
}
}
示例2: CS_ASSERT
//------------------------------------------------------------------------------
void GLMesh::BuildMesh(const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize) noexcept
{
CS_ASSERT(vertexDataSize > 0 && vertexData, "Cannot build mesh with empty data");
glGenBuffers(1, &m_vertexBufferHandle);
CS_ASSERT(m_vertexBufferHandle != 0, "Invalid vertex buffer.");
if(indexData)
{
glGenBuffers(1, &m_indexBufferHandle);
CS_ASSERT(m_indexBufferHandle != 0, "Invalid index buffer.");
}
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferHandle);
glBufferData(GL_ARRAY_BUFFER, vertexDataSize, vertexData, GL_STATIC_DRAW);
if(indexData)
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferHandle);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexDataSize, indexData, GL_STATIC_DRAW);
}
CS_ASSERT_NOGLERROR("An OpenGL error occurred while creating GLMesh.");
}
示例3: CS_ASSERT
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
void StandardDrawable::Draw(Rendering::CanvasRenderer* in_renderer, const Core::Matrix3& in_transform, const Core::Vector2& in_absSize, const Core::Colour& in_absColour)
{
CS_ASSERT(m_texture != nullptr, "StandardDrawable cannot draw without texture");
//When textures are packed into an atlas their alpha space is cropped. This functionality restores the alpha space by resizing and offsetting the box.
Core::Vector2 offsetTL
(
(-m_atlasFrame.m_originalSize.x * 0.5f) + (m_atlasFrame.m_croppedSize.x * 0.5f) + m_atlasFrame.m_offset.x,
(m_atlasFrame.m_originalSize.y * 0.5f) - (m_atlasFrame.m_croppedSize.y * 0.5f) - m_atlasFrame.m_offset.y
);
offsetTL = in_absSize/m_atlasFrame.m_originalSize * offsetTL;
Core::Vector2 size = in_absSize/m_atlasFrame.m_originalSize * m_atlasFrame.m_croppedSize;
in_renderer->DrawBox(in_transform, size, offsetTL, m_texture, m_atlasFrame.m_uvs, in_absColour * m_colour, Rendering::AlignmentAnchor::k_middleCentre);
}
示例4: SndSysBasicStream
SndSysSpeexSoundStream::SndSysSpeexSoundStream (csRef<SndSysSpeexSoundData> pData,
csSndSysSoundFormat *pRenderFormat,
int Mode3D) :
SndSysBasicStream(pRenderFormat, Mode3D), m_pSoundData(pData), header(0)
{
// Allocate an advance buffer
m_pCyclicBuffer = new SoundCyclicBuffer (
(m_RenderFormat.Bits/8 * m_RenderFormat.Channels) *
(m_RenderFormat.Freq * SPEEX_BUFFER_LENGTH_MULTIPLIER /
SPEEX_BUFFER_LENGTH_DIVISOR));
CS_ASSERT(m_pCyclicBuffer!=0);
// Initialize speex stream.
ResetPosition(false);
}
示例5: CS_ASSERT
csStringBase &csStringBase::Overwrite (size_t iPos, const csStringBase &iStr)
{
CS_ASSERT (iPos <= Size);
if (GetData() == 0 || iPos == Size)
return Append (iStr);
size_t const sl = iStr.Length ();
size_t const NewSize = iPos + sl;
ExpandIfNeeded (NewSize);
char* p = GetDataMutable(); // GLOBAL NOTE *2*
memcpy (p + iPos, iStr.GetData (), sl + 1); // GLOBAL NOTE *1*
Size = NewSize;
return *this;
}
示例6: m_desc
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
Test::Test(const TestDesc& in_desc, const PassDelegate& in_passDelegate, const FailDelegate& in_failDelegate) noexcept
: m_desc(in_desc), m_passDelegate(in_passDelegate), m_failDelegate(in_failDelegate)
{
CS_ASSERT(m_passDelegate, "A valid pass delegate must be supplied.");
CS_ASSERT(m_failDelegate, "A valid fail delegate must be supplied.");
m_taskScheduler = CS::Application::Get()->GetTaskScheduler();
m_timerEventConnection = m_timer.OpenConnection(in_desc.GetTimeoutSeconds(), [=]()
{
std::unique_lock<std::mutex> lock(m_mutex);
if (m_active)
{
m_active = false;
m_timer.Stop();
m_timerEventConnection.reset();
m_failDelegate("Timed out.");
}
});
m_timer.Start();
}
示例7: CS_ASSERT
//------------------------------------------------------------------------------
bool BinaryInputStream::Read(u8* buffer, u64 length) noexcept
{
CS_ASSERT(IsValid(), "Trying to use an invalid FileStream.");
if(m_fileStream.eof())
{
return false;
}
//Ensure that we never overrun the file stream
const auto currentPosition = GetReadPosition();
const auto maxValidLength = std::min(m_length - currentPosition, length);
if(maxValidLength == 0)
{
return true;
}
m_fileStream.read(reinterpret_cast<s8*>(buffer), maxValidLength);
CS_ASSERT(!m_fileStream.fail(), "Unexpected error occured in filestream");
return true;
}
示例8: ExpandIfNeeded
csStringBase &csStringBase::PadLeft (size_t iNewSize, char iChar)
{
if (iNewSize > Size)
{
ExpandIfNeeded (iNewSize);
char* p = GetDataMutable(); // GLOBAL NOTE *2*
CS_ASSERT(p != 0);
const size_t toInsert = iNewSize - Size;
memmove (p + toInsert, p, Size + 1); // GLOBAL NOTE *1*
for (size_t x = 0; x < toInsert; x++)
p [x] = iChar;
Size = iNewSize;
}
return *this;
}
示例9: CS_ASSERT
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
EntityUPtr PrimitiveEntityFactory::CreateBox(const Colour& in_colour, const Vector3& in_size)
{
CS_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), "Entities must be created on the main thread.");
ModelCSPtr mesh = m_primitiveModelFactory->CreateBox(in_size);
MaterialCSPtr material = CreateStaticBlinnColourMaterial(in_colour);
StaticModelComponentSPtr meshComponent = m_renderComponentFactory->CreateStaticModelComponent(mesh, material);
meshComponent->SetShadowCastingEnabled(true);
auto entity = Entity::Create();
entity->SetName(ToString(m_entityCount++) + "-Box");
entity->AddComponent(meshComponent);
return entity;
}
示例10: CS_ASSERT
//-------------------------------------------------------------
//-------------------------------------------------------------
void Entity::RemoveEntity(Entity* in_child)
{
CS_ASSERT(in_child != nullptr, "Cannot remove null child");
CS_ASSERT(in_child->GetParent() == this, "Cannot remove entity that is not a child of this");
SharedEntityList::iterator it = std::find_if(m_children.begin(), m_children.end(), [in_child](const EntitySPtr& in_entity)
{
return in_entity.get() == in_child;
});
if(it != m_children.end())
{
m_transform.RemoveChildTransform(&in_child->GetTransform());
if(m_scene != nullptr)
{
m_scene->Remove(in_child);
}
in_child->m_parent = nullptr;
std::swap(m_children.back(), *it);
m_children.pop_back();
}
}
示例11: CS_ASSERT
//------------------------------------------------
//------------------------------------------------
void PointerSystem::OnInit()
{
m_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();
CS_ASSERT(m_screen != nullptr, "Cannot find system required by PointerSystem: Screen.");
m_mouseButtonConnection = SFMLWindow::Get()->GetMouseButtonEvent().OpenConnection(ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseButtonEvent));
m_mouseMovedConnection = SFMLWindow::Get()->GetMouseMovedEvent().OpenConnection(ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseMoved));
m_mouseWheelConnection = SFMLWindow::Get()->GetMouseWheelEvent().OpenConnection(ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseWheeled));
//create the mouse pointer
ChilliSource::Integer2 mousePosi = SFMLWindow::Get()->GetMousePosition();
ChilliSource::Vector2 mousePos((f32)mousePosi.x, m_screen->GetResolution().y - (f32)mousePosi.y);
m_pointerId = AddPointerCreateEvent(mousePos);
}
示例12: StreamingReporterBase
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
CSReporter::CSReporter(const Catch::ReporterConfig& in_config) noexcept
: StreamingReporterBase(in_config)
{
CS_ASSERT(!m_config->includeSuccessfulResults(), "CSReporter doesn't support reporting successful results.");
CS_ASSERT(!m_config->warnAboutMissingAssertions(), "CSReporter doesn't support warning about missing assertions.");
CS_ASSERT(!m_config->showInvisibles(), "CSReporter doesn't support showing invisibles.");
CS_ASSERT(!m_config->showDurations(), "CSReporter doesn't support showing durations.");
CS_ASSERT(!m_config->useColour(), "CSReporter doesn't support coloured output.");
CS_ASSERT(!m_config->shouldDebugBreak(), "CSReporter doesn't support debug break.");
}
示例13: CS_ASSERT
psMovementManager::psMovementManager(iEventNameRegistry* eventname_reg, psControlManager* controls)
{
CS_ASSERT(eventname_reg);
event_frame = csevFrame(eventname_reg);
event_mousemove = csevMouseMove(eventname_reg,0);
actor = NULL;
this->controls = controls;
ready = false;
psengine->GetMsgHandler()->Subscribe(this,MSGTYPE_MOVEINFO);
psengine->GetMsgHandler()->Subscribe(this,MSGTYPE_MOVELOCK);
psengine->GetMsgHandler()->Subscribe(this,MSGTYPE_MOVEMOD);
defaultmode = NULL;
actormode = NULL;
onGround = true;
locked = false;
activeMoves = 0;
autoMove = false;
toggleRun = false;
mouseAutoMove = false;
mouseLook = false;
mouseLookCanAct = false;
mouseZoom = false;
mouseMove = false;
sneaking = false;
runToMarkerID = 0;
lastDist = 0.0f;
runToDiff = csVector3(0.0f);
lastDeltaX = 0.0f;
lastDeltaY = 0.0f;
sensY = 1.0f;
sensX = 1.0f;
invertedMouse = true;
activeModType = psMoveModMsg::NONE;
forward = NULL;
backward = NULL;
run = NULL;
walk = NULL;
kbdRotate = 0;
}
示例14: GetData
// Note: isalpha(int c), toupper(int c), tolower(int c), isspace(int c)
// If c is not an unsigned char value, or EOF, the behaviour of these functions
// is undefined.
csStringBase &csStringBase::RTrim()
{
if (Size > 0)
{
char const* const p = GetData();
CS_ASSERT(p != 0);
const char* c;
for (c = p + Size - 1; c != p; c--)
if (!isspace ((unsigned char)*c))
break;
size_t i = c - p;
if (i < Size - 1)
Truncate(i + 1);
}
return *this;
}
示例15: CS_ASSERT
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
void ResourcePool::AddProvider(ResourceProvider* in_provider)
{
CS_ASSERT(in_provider != nullptr, "Cannot add null resource provider to pool");
auto itDescriptor = m_descriptors.find(in_provider->GetResourceType());
if(itDescriptor == m_descriptors.end())
{
PoolDesc desc;
desc.m_providers.push_back(in_provider);
m_descriptors.insert(std::make_pair(in_provider->GetResourceType(), desc));
}
else
{
itDescriptor->second.m_providers.push_back(in_provider);
}
}