当前位置: 首页>>代码示例>>C++>>正文


C++ TAssert函数代码示例

本文整理汇总了C++中TAssert函数的典型用法代码示例。如果您正苦于以下问题:C++ TAssert函数的具体用法?C++ TAssert怎么用?C++ TAssert使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TAssert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TAssert

void CRenderingContext::RenderText(const tstring& sText, unsigned iLength, FTFont* pFont)
{
	TAssert(m_pShader);
	if (!m_pShader)
		return;

	CRenderContext& oContext = GetContext();

	if (iLength == -1)
		iLength = sText.length();

	TAssert(m_pShader->m_iPositionAttribute >= 0);
	TAssert(m_pShader->m_aiTexCoordAttributes[0] >= 0);

	if (!oContext.m_bProjectionUpdated)
		SetUniform("mProjection", oContext.m_mProjection);

	if (!oContext.m_bViewUpdated)
		SetUniform("mView", oContext.m_mView);

	// Take the position out and let FTGL do it. It looks sharper that way.
	Matrix4x4 mTransformations = oContext.m_mTransformations;
	Vector vecPosition = mTransformations.GetTranslation();
	mTransformations.SetTranslation(Vector());
	SetUniform("mGlobal", mTransformations);

	oContext.m_bProjectionUpdated = oContext.m_bViewUpdated = oContext.m_bTransformUpdated = true;

	ftglSetAttributeLocations(m_pShader->m_iPositionAttribute, m_pShader->m_aiTexCoordAttributes[0]);

	pFont->Render(sText.c_str(), iLength, FTPoint(vecPosition.x, vecPosition.y, vecPosition.z));
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:32,代码来源:renderingcontext.cpp

示例2: ResizeMap

void ResizeMap(FileMappingInfo* mapping_info, size_t minimum_size)
{
	munmap(mapping_info->m_memory, mapping_info->m_memory_size);

	struct stat file_statbuf;

	fstat(mapping_info->m_file_handle, &file_statbuf);
	int file_size = file_statbuf.st_size;

	// I'm not sure this will ever happen. If years go by and this assert is
	// never hit then the fstat and the next tmax below can be removed.
	TAssert(file_size <= minimum_size);

	minimum_size = tmax(minimum_size, file_size);

	int page_size = sysconf(_SC_PAGESIZE);
	int remainder = stb_mod_eucl(minimum_size, page_size);
	int aligned_size;
	if (remainder)
		aligned_size = minimum_size - stb_mod_eucl(minimum_size, page_size) + page_size;
	else
		aligned_size = tmax(minimum_size, page_size);

	int truncated = ftruncate(mapping_info->m_file_handle, aligned_size);
	TAssert(truncated == 0);

	mapping_info->m_memory_size = aligned_size;
	mapping_info->m_memory = mmap(nullptr, aligned_size, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, mapping_info->m_file_handle, 0);
}
开发者ID:ezhangle,项目名称:DrawSomething,代码行数:29,代码来源:platform_osx.cpp

示例3: addSingleResult

	virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace)
	{
		if (!m_pController->IsColliding())
			return 1;

		if (convexResult.m_hitCollisionObject == m_me)
			return btScalar(1.0);

		if (convexResult.m_hitCollisionObject->getBroadphaseHandle()->m_collisionFilterGroup & CG_TRIGGER)
			return 1;

		if (!convexResult.m_hitCollisionObject->hasContactResponse())
			return btScalar(1.0);

		if ((size_t)convexResult.m_hitCollisionObject->getUserPointer() >= GameServer()->GetMaxEntities())
		{
			size_t iIndex = (size_t)convexResult.m_hitCollisionObject->getUserPointer() - GameServer()->GetMaxEntities();
			CBaseEntity* pControllerEntity = m_pController->GetEntity();
			TAssert(pControllerEntity);
			if (pControllerEntity)
			{
				TAssert(normalInWorldSpace);
				if (!pControllerEntity->ShouldCollideWithExtra(iIndex, Vector(convexResult.m_hitPointLocal)))
					return 1;
			}
		}
		else
		{
			CEntityHandle<CBaseEntity> hCollidedEntity((size_t)convexResult.m_hitCollisionObject->getUserPointer());
			TAssert(hCollidedEntity != NULL);
			if (hCollidedEntity.GetPointer())
			{
				CBaseEntity* pControllerEntity = m_pController->GetEntity();
				TAssert(pControllerEntity);
				if (pControllerEntity)
				{
					TAssert(normalInWorldSpace);
					if (!pControllerEntity->ShouldCollideWith(hCollidedEntity, Vector(convexResult.m_hitPointLocal)))
						return 1;
				}
			}
		}

		btVector3 hitNormalWorld;
		if (normalInWorldSpace)
		{
			hitNormalWorld = convexResult.m_hitNormalLocal;
		} else
		{
			///need to transform normal into worldspace
			hitNormalWorld = convexResult.m_hitCollisionObject->getWorldTransform().getBasis()*convexResult.m_hitNormalLocal;
		}

		btScalar dotUp = m_up.dot(hitNormalWorld);
		if (dotUp < 0)
			return btScalar(1.0);

		return ClosestConvexResultCallback::addSingleResult (convexResult, normalInWorldSpace);
	}
开发者ID:BSVino,项目名称:Digitanks,代码行数:59,代码来源:character_controller.cpp

示例4: TAssert

size_t CShaderLibrary::GetProgram(const tstring& sName)
{
	TAssert(Get());
	if (!Get())
		return 0;

	TAssert(Get()->GetShader(sName));
	if (!Get()->GetShader(sName))
		return 0;

	return Get()->GetShader(sName)->m_iProgram;
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:12,代码来源:shaders.cpp

示例5: glGetAttribLocation

void CRenderingContext::SetCustomIntBuffer(const char* pszName, size_t iSize, size_t iOffset, size_t iStride)
{
	int iAttribute = glGetAttribLocation(m_iProgram, pszName);

	TAssert(iAttribute != ~0);
	if (iAttribute == ~0)
		return;

	TAssert(iOffset%4 == 0);	// Should be multiples of four because it's offsets in bytes and we're always working with floats or doubles
	glEnableVertexAttribArray(iAttribute);
	glVertexAttribIPointer(iAttribute, iSize, GL_INT, iStride, BUFFER_OFFSET(iOffset));
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:12,代码来源:renderingcontext.cpp

示例6: TAssert

DoubleVector CTreeManager::GetTreeOrigin(const CTreeAddress& oAddress) const
{
	TAssert(oAddress.IsValid());
	if (!oAddress.IsValid())
		return DoubleVector();

	const CChunkTrees* pChunkTrees = GetChunkTrees(oAddress.iTerrain, oAddress.vecMin);

	TAssert(pChunkTrees);
	if (!pChunkTrees)
		return DoubleVector();

	return pChunkTrees->GetTreeOrigin(oAddress.iTree);
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:14,代码来源:trees.cpp

示例7: GLDebugCallback

void CALLBACK GLDebugCallback(GLenum iSource, GLenum iType, GLuint id, GLenum iSeverity, GLsizei iLength, const GLchar* pszMessage, GLvoid* pUserParam)
{
	if (iType != GL_DEBUG_TYPE_PERFORMANCE_ARB)
	{
		TAssert(iSeverity != GL_DEBUG_SEVERITY_HIGH_ARB);
		TAssert(iSeverity != GL_DEBUG_SEVERITY_MEDIUM_ARB);
	}

	if (gl_debug.GetBool())
	{
		tstring sMessage = "OpenGL Debug Message (";

		if (iSource == GL_DEBUG_SOURCE_API_ARB)
			sMessage += "Source: API ";
		else if (iSource == GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB)
			sMessage += "Source: Window System ";
		else if (iSource == GL_DEBUG_SOURCE_SHADER_COMPILER_ARB)
			sMessage += "Source: Shader Compiler ";
		else if (iSource == GL_DEBUG_SOURCE_THIRD_PARTY_ARB)
			sMessage += "Source: Third Party ";
		else if (iSource == GL_DEBUG_SOURCE_APPLICATION_ARB)
			sMessage += "Source: Application ";
		else if (iSource == GL_DEBUG_SOURCE_OTHER_ARB)
			sMessage += "Source: Other ";

		if (iType == GL_DEBUG_TYPE_ERROR_ARB)
			sMessage += "Type: Error ";
		else if (iType == GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB)
			sMessage += "Type: Deprecated Behavior ";
		else if (iType == GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB)
			sMessage += "Type: Undefined Behavior ";
		else if (iType == GL_DEBUG_TYPE_PORTABILITY_ARB)
			sMessage += "Type: Portability ";
		else if (iType == GL_DEBUG_TYPE_PERFORMANCE_ARB)
			sMessage += "Type: Performance ";
		else if (iType == GL_DEBUG_TYPE_OTHER_ARB)
			sMessage += "Type: Other ";

		if (iSeverity == GL_DEBUG_SEVERITY_HIGH_ARB)
			sMessage += "Severity: High) ";
		else if (iSeverity == GL_DEBUG_SEVERITY_MEDIUM_ARB)
			sMessage += "Severity: Medium) ";
		else if (iSeverity == GL_DEBUG_SEVERITY_LOW_ARB)
			sMessage += "Severity: Low) ";

		sMessage += convertstring<GLchar, tchar>(pszMessage) + "\n";

		TMsg(convertstring<GLchar, tchar>(sMessage).c_str());
	}
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:50,代码来源:application.cpp

示例8: TAssert

bool CAOGenerator::Texel(size_t w, size_t h, size_t& iTexel, bool bUseMask)
{
    if (w < 0 || h < 0 || w >= m_iWidth || h >= m_iHeight)
        return false;

    TAssert(m_iHeight == m_iWidth); // This formula is actually wrong unless the thing is a perfect square
    iTexel = m_iHeight*(m_iHeight-h-1) + w;

    TAssert(iTexel >= 0 && iTexel < m_iWidth * m_iHeight);

    if (bUseMask && !m_bPixelMask[iTexel])
        return false;

    return true;
}
开发者ID:ezhangle,项目名称:SMAK,代码行数:15,代码来源:ao.cpp

示例9: TAssert

void CToyUtil::AddSceneAreaVisible(size_t iSceneArea, size_t iVisible)
{
	TAssert(iSceneArea < m_asSceneAreas.size());
	if (iSceneArea >= m_asSceneAreas.size())
		return;

	TAssert(iVisible < m_asSceneAreas.size());
	if (iVisible >= m_asSceneAreas.size())
		return;

	if (IsVisibleFrom(iSceneArea, iVisible))
		return;

	m_asSceneAreas[iSceneArea].m_aiVisibleAreas.push_back(iVisible);
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:15,代码来源:toy_util.cpp

示例10: TAssert

bool CTexelGenerator::Texel(size_t w, size_t h, size_t& iTexel, size_t tw, size_t th, bool* abMask)
{
	if (w < 0 || h < 0 || w >= tw || h >= th)
		return false;

	TAssert(tw == th); // This formula is actually wrong unless the thing is a perfect square
	iTexel = th*(th-h-1) + w;

	TAssert(iTexel >= 0 && iTexel < tw * th);

	if (abMask && !abMask[iTexel])
		return false;

	return true;
}
开发者ID:BSVino,项目名称:SMAK,代码行数:15,代码来源:crunch.cpp

示例11: GameData

void CStructure::SetPhysicsTransform(const Matrix4x4& m)
{
	CPlanet* pPlanet = GameData().GetPlanet();
	if (!pPlanet)
	{
		SetLocalTransform(TMatrix(m));
		return;
	}

	if (!pPlanet->GetChunkManager()->HasGroupCenter())
	{
		SetLocalTransform(TMatrix(m));
		return;
	}

	GameData().SetGroupTransform(m);

	TMatrix mLocalTransform(pPlanet->GetChunkManager()->GetGroupCenterToPlanetTransform() * m);

	CBaseEntity* pMoveParent = GetMoveParent();
	TAssert(pMoveParent);
	if (pMoveParent)
	{
		while (pMoveParent != pPlanet)
		{
			mLocalTransform = pMoveParent->GetLocalTransform().InvertedRT() * mLocalTransform;
			pMoveParent = pMoveParent->GetMoveParent();
		}
	}

	SetLocalTransform(mLocalTransform);
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:32,代码来源:structure.cpp

示例12: LevelEditor

void CEditorPanel::TargetEntityChangedCallback(const tstring& sArgs)
{
    CLevel* pLevel = LevelEditor()->GetLevel();
    if (!pLevel)
        return;

    auto pOutput = GetCurrentOutput();
    if (!pOutput)
        return;

    pOutput->m_sTargetName = m_hOutputEntityNameText->GetText();

    tvector<tstring> asTargets;

    for (size_t i = 0; i < pLevel->GetEntityData().size(); i++)
    {
        auto* pEntity = &pLevel->GetEntityData()[i];
        if (!pEntity)
            continue;

        if (!pEntity->GetName().length())
            continue;

        CEntityRegistration* pRegistration = CBaseEntity::GetRegisteredEntity("C"+pEntity->GetClass());
        TAssert(pRegistration);
        if (!pRegistration)
            continue;

        asTargets.push_back(pEntity->GetName());
    }

    m_hOutputEntityNameText->SetAutoCompleteCommands(asTargets);

    LayoutInput();
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:35,代码来源:editorpanel.cpp

示例13: CToy

size_t CToyUtil::AddSceneArea(const tstring& sFileName)
{
	CToy* pArea = new CToy();
	bool bRead = CToyUtil::Read(GetGameDirectory() + T_DIR_SEP + sFileName, pArea);

	if (!bRead)
	{
		delete pArea;

		TAssert(bRead);
		TError("Couldn't find scene area " + sFileName + "\n");

		return ~0;
	}

	CSceneArea& oSceneArea = m_asSceneAreas.push_back();

	oSceneArea.m_sFileName = sFileName;
	oSceneArea.m_aabbArea = pArea->GetVisBounds();

	// I'm visible to myself.
	oSceneArea.m_aiNeighboringAreas.push_back(m_asSceneAreas.size()-1);

	delete pArea;

	return m_asSceneAreas.size()-1;
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:27,代码来源:toy_util.cpp

示例14: GameNetwork

CGameServer::~CGameServer()
{
	GameNetwork()->SetCallbacks(NULL, NULL, NULL, NULL);

	if (m_pWorkListener)
		m_pWorkListener->BeginProgress();

	if (m_pWorkListener)
		m_pWorkListener->SetAction("Scrubbing database", CBaseEntity::GetEntityRegistration().size());

	DestroyAllEntities(tvector<tstring>());

	GamePhysics()->RemoveAllEntities();

	for (size_t i = 0; i < m_apLevels.size(); i++)
		m_apLevels[i].reset();

	if (m_pCameraManager)
		delete m_pCameraManager;

	if (m_pWorkListener)
		m_pWorkListener->EndProgress();

	TAssert(s_pGameServer == this);
	s_pGameServer = NULL;
}
开发者ID:BSVino,项目名称:LunarWorkshop,代码行数:26,代码来源:gameserver.cpp

示例15: ReadReport

NTSTATUS INTERNAL
ReadReport(
    __in  PDEVICE_EXTENSION DevExt,
    __in  PIRP              Irp,
    __out BOOLEAN           *fSentDown
    )
{
    NTSTATUS status;
    PIO_STACK_LOCATION irpsp = IoGetCurrentIrpStackLocation(Irp);
    ULONG DataLen = irpsp->Parameters.DeviceIoControl.OutputBufferLength;

    TEnter(Func, ("(DevExt=%p,Irp=%p,IrpSp=%p)", DevExt, Irp, irpsp));
    TAssert(Irp->UserBuffer != NULL);
    if (DataLen != sizeof(HID_INPUT_REPORT))
    {
        status = STATUS_INVALID_BUFFER_SIZE;
        LogError(ERRLOG_INVALID_BUFFER_SIZE,
                 status,
                 UNIQUE_ERRID(0x60),
                 NULL,
                 NULL);
        TWarn(("Invalid input report size (len=%d,Expected=%d).",
               DataLen, sizeof(HID_INPUT_REPORT)));
    }
    else
    {
        status = OemReadReport(DevExt, Irp, fSentDown);
    }

    TExit(Func, ("=%x", status));
    return status;
}       //ReadReport
开发者ID:kcrazy,项目名称:winekit,代码行数:32,代码来源:ioctl.c


注:本文中的TAssert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。