void CComponentGraphic_GL::GetDependencyPosition(size_t uDependencyIndex, int* pOutX, int* pOutY) { BEATS_ASSERT(m_pOwner->GetDependency(uDependencyIndex) != NULL); *pOutX = m_gridPosX + MIN_WIDTH; *pOutY = m_gridPosY + HEADER_HEIGHT + (int)(uDependencyIndex + 1) * DEPENDENCY_HEIGHT; }
bool CBlendEquationRenderStateParam::operator!=( const CRenderStateParamBase& other ) const { BEATS_ASSERT( other.GetRenderStateType() == eRS_BlendEquationMode ); CBlendEquationRenderStateParam* pOther = (CBlendEquationRenderStateParam*)&other; return m_nValue != pOther->m_nValue; }
void CComponentGraphic_GL::DrawDependencies( float cellSize ) { CreateMaterials(); CQuadBatchRenderGroup *renderGroup = dynamic_cast<CQuadBatchRenderGroup *>( CRenderGroupManager::GetInstance()->GetRenderGroup(CRenderGroupManager::LAYER_GUI)); BEATS_ASSERT(renderGroup); size_t uDependencyCount = m_pOwner->GetDependencies().size(); for (int i = 0; i < (int)uDependencyCount; ++i) { // 1. Draw background. CQuadPTC dependencyPoint; dependencyPoint.tl.position.x = m_gridPosX * cellSize; // Left top dependencyPoint.tl.position.y = (m_gridPosY + HEADER_HEIGHT + i * DEPENDENCY_HEIGHT) * cellSize; dependencyPoint.tl.position.z = (float)m_gridPosZ; dependencyPoint.tl.tex.u = 0; dependencyPoint.tl.tex.v = 0; dependencyPoint.bl.position.x = m_gridPosX * cellSize; // Left down dependencyPoint.bl.position.y = (m_gridPosY + HEADER_HEIGHT + (i + 1) * DEPENDENCY_HEIGHT) * cellSize; dependencyPoint.bl.position.z = (float)m_gridPosZ; dependencyPoint.bl.tex.u = 0; dependencyPoint.bl.tex.v = 1; dependencyPoint.tr.position.x = (m_gridPosX + MIN_WIDTH) * cellSize; // Right top dependencyPoint.tr.position.y = (m_gridPosY + HEADER_HEIGHT + i * DEPENDENCY_HEIGHT) * cellSize ; dependencyPoint.tr.position.z = (float)m_gridPosZ; dependencyPoint.tr.tex.u = 1; dependencyPoint.tr.tex.v = 0; dependencyPoint.br.position.x = (m_gridPosX + MIN_WIDTH) * cellSize; // Right down dependencyPoint.br.position.y = (m_gridPosY + HEADER_HEIGHT + (i + 1) * DEPENDENCY_HEIGHT) * cellSize; dependencyPoint.br.position.z = (float)m_gridPosZ; dependencyPoint.br.tex.u = 1; dependencyPoint.br.tex.v = 1; renderGroup->AddQuad(dependencyPoint, m_pMaterials[eCT_RectBG]); // 2. Draw dependency name. m_pFont->RenderText(m_pOwner->GetDependency(i)->GetDisplayName(), dependencyPoint.tl.position.x + Font_Render_X_Offset, dependencyPoint.tl.position.y, 0xFFFFFFFF); // 3. Draw Connect rect. CDependencyDescription* pDescription = m_pOwner->GetDependency(i); BEATS_ASSERT(pDescription != NULL); bool bConnected = pDescription->GetDependencyLineCount() > 0; EComponentTexture textureType = eCT_Count; EDependencyType descriptionType = pDescription->GetType(); bool bIsList = pDescription->IsListType(); if (bConnected) { textureType = bIsList ? eCT_ConnectedDependencyList : eCT_ConnectedDependency; } else { if (bIsList) { textureType = descriptionType == eDT_Strong ? eCT_StrongDependencyList : eCT_WeakDependencyList; } else { textureType = descriptionType == eDT_Strong ? eCT_StrongDependency : eCT_WeakDependency; } } BEATS_ASSERT(textureType != eCT_Count); dependencyPoint.tl.position.x = (m_gridPosX + MIN_WIDTH) * cellSize; // Left top dependencyPoint.tl.position.y = (m_gridPosY + HEADER_HEIGHT + i * DEPENDENCY_HEIGHT) * cellSize; dependencyPoint.tl.position.z = (float)m_gridPosZ; dependencyPoint.tl.tex.u = 0; dependencyPoint.tl.tex.v = 0; dependencyPoint.bl.position.x = (m_gridPosX + MIN_WIDTH) * cellSize; // Left down dependencyPoint.bl.position.y = (m_gridPosY + HEADER_HEIGHT + (i + 1) * DEPENDENCY_HEIGHT) * cellSize; dependencyPoint.bl.position.z = (float)m_gridPosZ; dependencyPoint.bl.tex.u = 0; dependencyPoint.bl.tex.v = 1; dependencyPoint.tr.position.x = (m_gridPosX + MIN_WIDTH + CONNECTION_WIDTH) * cellSize; // Right top dependencyPoint.tr.position.y = (m_gridPosY + HEADER_HEIGHT + i * DEPENDENCY_HEIGHT) * cellSize; dependencyPoint.tr.position.z = (float)m_gridPosZ; dependencyPoint.tr.tex.u = 1; dependencyPoint.tr.tex.v = 0; dependencyPoint.br.position.x = (m_gridPosX + MIN_WIDTH + CONNECTION_WIDTH) * cellSize; // Right down dependencyPoint.br.position.y = (m_gridPosY + HEADER_HEIGHT + (i + 1) * DEPENDENCY_HEIGHT) * cellSize; dependencyPoint.br.position.z = (float)m_gridPosZ; dependencyPoint.br.tex.u = 1; dependencyPoint.br.tex.v = 1; renderGroup->AddQuad(dependencyPoint, m_pMaterials[textureType]); // 4. Draw the line. DrawDependencyLine(cellSize, m_pOwner->GetDependency(i)); } }
void CComponentGraphic_GL::DrawDependencyLine( float /*cellSize*/, const CDependencyDescription* pDependency ) { CreateMaterials(); CQuadBatchRenderGroup *renderGroup = dynamic_cast<CQuadBatchRenderGroup *>( CRenderGroupManager::GetInstance()->GetRenderGroup(CRenderGroupManager::LAYER_GUI)); BEATS_ASSERT(renderGroup); BEATS_ASSERT(pDependency != NULL); if (pDependency->IsVisible()) { size_t uDependencyLineCount = pDependency->GetDependencyLineCount(); for (size_t i = 0; i < uDependencyLineCount; ++i) { CDependencyDescriptionLine* pDependencyLine = pDependency->GetDependencyLine(i); const SVertex* pData = pDependencyLine->GetRectArray(); static const size_t SVERTEX_SIZE = 24; CSerializer serializer(SVERTEX_SIZE * 4, (void*)pData); DWORD tmpColor = 0; CQuadPTC dependencyLine; serializer >> dependencyLine.br.position.x; serializer >> dependencyLine.br.position.y; serializer >> dependencyLine.br.position.z; serializer >> tmpColor; serializer >> dependencyLine.br.tex.u; serializer >> dependencyLine.br.tex.v; serializer >> dependencyLine.bl.position.x; serializer >> dependencyLine.bl.position.y; serializer >> dependencyLine.bl.position.z; serializer >> tmpColor; serializer >> dependencyLine.bl.tex.u; serializer >> dependencyLine.bl.tex.v; serializer >> dependencyLine.tr.position.x; serializer >> dependencyLine.tr.position.y; serializer >> dependencyLine.tr.position.z; serializer >> tmpColor; serializer >> dependencyLine.tr.tex.u; serializer >> dependencyLine.tr.tex.v; serializer >> dependencyLine.tl.position.x; serializer >> dependencyLine.tl.position.y; serializer >> dependencyLine.tl.position.z; serializer >> tmpColor; serializer >> dependencyLine.tl.tex.u; serializer >> dependencyLine.tl.tex.v; renderGroup->AddQuad(dependencyLine, m_pMaterials[pDependencyLine->IsSelected() ? eCT_SelectedLine : eCT_NormalLine]); const SVertex* pArrowData = pDependencyLine->GetArrowRectArray(); CSerializer serializerArrow(SVERTEX_SIZE * 4, (void*)pArrowData); CQuadPTC arrow; serializerArrow >> arrow.br.position.x; serializerArrow >> arrow.br.position.y; serializerArrow >> arrow.br.position.z; serializerArrow >> tmpColor; serializerArrow >> arrow.br.tex.u; serializerArrow >> arrow.br.tex.v; serializerArrow >> arrow.bl.position.x; serializerArrow >> arrow.bl.position.y; serializerArrow >> arrow.bl.position.z; serializerArrow >> tmpColor; serializerArrow >> arrow.bl.tex.u; serializerArrow >> arrow.bl.tex.v; serializerArrow >> arrow.tr.position.x; serializerArrow >> arrow.tr.position.y; serializerArrow >> arrow.tr.position.z; serializerArrow >> tmpColor; serializerArrow >> arrow.tr.tex.u; serializerArrow >> arrow.tr.tex.v; serializerArrow >> arrow.tl.position.x; serializerArrow >> arrow.tl.position.y; serializerArrow >> arrow.tl.position.z; serializerArrow >> tmpColor; serializerArrow >> arrow.tl.tex.u; serializerArrow >> arrow.tl.tex.v; renderGroup->AddQuad(arrow, m_pMaterials[pDependencyLine->IsSelected() ? eCT_SelectedArrow : eCT_NormalArrow]); //Render index number for dependency list. if (pDependency->IsListType()) { kmVec3 deltaDirection; kmVec3Subtract(&deltaDirection, &dependencyLine.tr.position, &dependencyLine.tl.position); float fXPos = (dependencyLine.tl.position.x + deltaDirection.x * 0.15f); static const float fHardCodeOffset = 8; float fYPos = (dependencyLine.tl.position.y + deltaDirection.y * 0.15f - fHardCodeOffset); TCHAR szIndex[8]; _stprintf(szIndex, _T("%d"), pDependencyLine->GetIndex()); m_pFont->RenderText(szIndex, fXPos, fYPos, 0xffff00ff); } } }
bool CSkin::Load() { bool bRet = false; BEATS_ASSERT(!IsLoaded(), _T("Can't Load a skin which is already loaded!")); if (m_pSkinMaterial == NULL) { m_pSkinMaterial = new CMaterial(); m_pSkinMaterial->SetSharders( _T("SkinShader.vs"), _T("SkinShader.ps")); m_pSkinMaterial->GetRenderState()->SetBoolState(CBoolRenderStateParam::eBSP_DepthTest, true); m_pSkinMaterial->GetRenderState()->SetBoolState(CBoolRenderStateParam::eBSP_Blend, false); m_pSkinMaterial->GetRenderState()->SetBoolState(CBoolRenderStateParam::eBSP_ScissorTest, false); m_pSkinMaterial->Initialize(); } // Load From File const TString& strFilePath = GetFilePath(); if (!strFilePath.empty()) { CSerializer serializer(strFilePath.c_str()); size_t uMeshcount = 0; serializer >> uMeshcount; // HACK: TODO: temp fix uMeshcount = 1; for (size_t i = 0; i < uMeshcount; ++i) { std::vector<CVertexPTB> vertices; std::vector<unsigned short> indices; size_t uMaterialCount = 0; serializer >> uMaterialCount; BEATS_ASSERT(uMaterialCount == 1, _T("Only support one material!")); for (size_t j = 0; j < uMaterialCount; ++j) { TString strTextureName; serializer >> strTextureName; BEATS_ASSERT(!strTextureName.empty(), _T("Texutre can't be empty in skin!")); SharePtr<CTexture> pTexture = CResourceManager::GetInstance()->GetResource<CTexture>(strTextureName); BEATS_ASSERT(pTexture != NULL); m_pSkinMaterial->SetTexture(0, pTexture); } CSerializer tmpVerticesBufferPos, tmpVerticesBufferUV; size_t uVertexCount = 0; serializer >> uVertexCount; for (size_t k = 0; k < uVertexCount; ++k) { CVertexPTB vertexPTB; serializer >> vertexPTB.position.x >> vertexPTB.position.y >> vertexPTB.position.z >> vertexPTB.tex.u >> vertexPTB.tex.v; serializer >> vertexPTB.bones.x; serializer >> vertexPTB.weights.x; serializer >> vertexPTB.bones.y; serializer >> vertexPTB.weights.y; serializer >> vertexPTB.bones.z; serializer >> vertexPTB.weights.z; serializer >> vertexPTB.bones.w; serializer >> vertexPTB.weights.w; vertices.push_back(vertexPTB); #ifdef _DEBUG float sum = vertexPTB.weights.x + vertexPTB.weights.y + vertexPTB.weights.z + vertexPTB.weights.w; BEATS_ASSERT(sum < 1.01F, _T("Weight can't be greater than 1.01F, cur Value : %f!"), sum); BEATS_WARNING(sum > 0.99F, _T("Weight can't be smaller than 0.99F, cur Value : %f!"), sum); #endif } size_t uIndexCount = 0; serializer >> uIndexCount; for (size_t l = 0; l < uIndexCount; ++l) { int nIndex = 0; serializer >> nIndex; BEATS_ASSERT(nIndex < (int)vertices.size() && nIndex < 0xFFFF, _T("Invalid index %d"), nIndex); indices.push_back((unsigned short)nIndex); } CRenderGroup *p3DRenderGroup = CRenderGroupManager::GetInstance()->GetRenderGroup(CRenderGroupManager::LAYER_3D); CRenderBatch* pRenderBatch = p3DRenderGroup->GetRenderBatch(VERTEX_FORMAT(CVertexPTB), m_pSkinMaterial, GL_TRIANGLES, true); pRenderBatch->SetStatic(true); pRenderBatch->AddIndexedVertices(vertices.data(), vertices.size(), indices.data(), indices.size()); pRenderBatch->SetGroup(p3DRenderGroup); bool bAlreadyExists = false; for (size_t w = 0; w < m_renderBatches.size(); ++w) { if (m_renderBatches[w] == pRenderBatch) { bAlreadyExists = true; break; } } if (!bAlreadyExists) { m_renderBatches.push_back(pRenderBatch); } } bRet = true; }
void CComponentGraphic_GL::DrawHead(float cellSize) { CreateMaterials(); CQuadBatchRenderGroup *renderGroup = dynamic_cast<CQuadBatchRenderGroup *>( CRenderGroupManager::GetInstance()->GetRenderGroup(CRenderGroupManager::LAYER_GUI)); BEATS_ASSERT(renderGroup); CQuadPTC head; head.tl.position.x = (m_gridPosX + CONNECTION_WIDTH) * cellSize;// Left top head.tl.position.y = m_gridPosY * cellSize; head.tl.position.z = (float)m_gridPosZ; head.tl.tex.u = 0; head.tl.tex.v = 0; head.bl.position.x = (m_gridPosX + CONNECTION_WIDTH) * cellSize;// Left down head.bl.position.y = (m_gridPosY + HEADER_HEIGHT) * cellSize; head.bl.position.z = (float)m_gridPosZ; head.bl.tex.u = 0; head.bl.tex.v = 1; head.tr.position.x = (m_gridPosX + CONNECTION_WIDTH + MIN_WIDTH) * cellSize; // Right top head.tr.position.y = m_gridPosY * cellSize; head.tr.position.z = (float)m_gridPosZ; head.tr.tex.u = 1; head.tr.tex.v = 0; head.br.position.x = (m_gridPosX + CONNECTION_WIDTH + MIN_WIDTH) * cellSize; // Right down head.br.position.y = (m_gridPosY + HEADER_HEIGHT) * cellSize; head.br.position.z = (float)m_gridPosZ; head.br.tex.u = 1; head.br.tex.v = 1; renderGroup->AddQuad(head, m_pMaterials[eCT_RectBG]); // 2. Draw title text. m_pFont->RenderText(m_pOwner->GetDisplayName(), head.tl.position.x + Font_Render_X_Offset, head.tl.position.y, 0xFFFFFFFF); // 3. Draw Connect rect. CQuadPTC connectRect; connectRect.tl.position.x = m_gridPosX * cellSize; // Left top connectRect.tl.position.y = m_gridPosY * cellSize; connectRect.tl.position.z = (float)m_gridPosZ; connectRect.tl.tex.u = 0; connectRect.tl.tex.v = 0; connectRect.bl.position.x = m_gridPosX * cellSize; // Left down connectRect.bl.position.y = (m_gridPosY + HEADER_HEIGHT) * cellSize; connectRect.bl.position.z = (float)m_gridPosZ; connectRect.bl.tex.u = 0; connectRect.bl.tex.v = 1; connectRect.tr.position.x = (m_gridPosX + CONNECTION_WIDTH) * cellSize; // Right top connectRect.tr.position.y = m_gridPosY * cellSize; connectRect.tr.position.z = (float)m_gridPosZ; connectRect.tr.tex.u = 1; connectRect.tr.tex.v = 0; connectRect.br.position.x = (m_gridPosX + CONNECTION_WIDTH) * cellSize; // Right down connectRect.br.position.y = (m_gridPosY + HEADER_HEIGHT) * cellSize; connectRect.br.position.z = (float)m_gridPosZ; connectRect.br.tex.u = 1; connectRect.br.tex.v = 1; renderGroup->AddQuad(connectRect, m_pMaterials[eCT_ConnectRect]); }
void CLanguageManager::LoadFromFile(ELanguageType language) { #ifdef EDITOR_MODE BEYONDENGINE_UNUSED_PARAM(language); m_languageMap.clear(); TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Resource); filePath.append(_T("/LanguageConfig.xml")); if (CFilePathTool::GetInstance()->Exists(filePath.c_str())) { rapidxml::file<> fdoc(filePath.c_str()); rapidxml::xml_document<> doc; try { doc.parse<rapidxml::parse_default>(fdoc.data()); doc.m_pszFilePath = filePath.c_str(); } catch (rapidxml::parse_error &e) { TCHAR info[MAX_PATH]; _stprintf(info, _T("Load file :%s Failed! error :%s"), filePath.c_str(), e.what()); MessageBox(BEYONDENGINE_HWND, info, _T("Load File Failed"), MB_OK | MB_ICONERROR); } uint32_t uCounter = 0; rapidxml::xml_node<>* pRootNode = doc.first_node("Language"); rapidxml::xml_node<>* pLanguageNode = pRootNode->first_node("LanguageNode"); while (pLanguageNode != nullptr) { uCounter++; TString strEnum = pLanguageNode->first_attribute("Enum")->value(); BEATS_ASSERT(!strEnum.empty()); if (pLanguageNode->first_attribute("Tag")) { TString strTag = pLanguageNode->first_attribute("Tag")->value(); m_languageTagMap[strEnum] = strTag; } BEATS_ASSERT(m_languageMap.find(strEnum) == m_languageMap.end()); std::map<ELanguageType, TString>& curMap = m_languageMap[strEnum]; rapidxml::xml_node<>* pLanguageValueNode = pLanguageNode->first_node(); while (pLanguageValueNode != nullptr) { TString languageTypeStr = pLanguageValueNode->name(); ELanguageType languageType = eLT_Count; for (int j = 0; j < eLT_Count; ++j) { if (pszLanguageTypeString[j] == languageTypeStr) { languageType = (ELanguageType)j; break; } } BEATS_ASSERT(curMap.find(languageType) == curMap.end()); const TCHAR* pszValue = pLanguageValueNode->first_attribute("Value")->value(); BEATS_ASSERT(_tcslen(pszValue) > 0); curMap[languageType] = pszValue; pLanguageValueNode = pLanguageValueNode->next_sibling(); } pLanguageNode = pLanguageNode->next_sibling(); } BEATS_ASSERT((uint32_t)_ttoi(pRootNode->first_attribute("Count")->value()) == uCounter); } #else TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Language); filePath.append(_T("/")).append(pszLanguageTypeString[language]).append(_T(".bin")); bool bFindLanguageFile = CFilePathTool::GetInstance()->Exists(filePath.c_str()); BEATS_ASSERT(bFindLanguageFile, "Can't Find language file %s", filePath.c_str()); if (bFindLanguageFile) { int count = 0; CSerializer tmp(filePath.c_str()); tmp >> count; m_texts.clear(); for (int i = 0; i < count; ++i) { ELanguageTextType textId = (ELanguageTextType)i; std::string strValue; tmp >> strValue; m_texts.emplace(textId, strValue); } tmp >> count; for (int i = 0; i < count; ++i) { uint32_t key; tmp >> key; BEATS_ASSERT(m_texts.find((ELanguageTextType)key) == m_texts.end()); tmp >> m_texts[(ELanguageTextType)key]; } } #endif }
void CRenderer::LineWidth(GLfloat fLineWidth) { BEATS_ASSERT(fLineWidth > 0); glLineWidth(fLineWidth); FC_CHECK_GL_ERROR_DEBUG(); }
void CRenderState::SetShaderProgram(GLuint program) { BEATS_ASSERT(program != m_uCurrShaderProgram); m_uCurrShaderProgram = program; }
bool wxPtrButtonEditor::OnEvent( wxPropertyGrid* propGrid, wxPGProperty* property, wxWindow* ctrl, wxEvent& event ) const { if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) { wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary(); CWxwidgetsPropertyBase* pPropertyDescription = static_cast<CWxwidgetsPropertyBase*>(property->GetClientData()); CEnginePropertyGirdManager* pManager = static_cast<CEnginePropertyGirdManager*>(static_cast<CEnginePropertyGrid*>(propGrid)->GetManager()); const wxWindow* pButton = NULL; for (size_t i = 0; i < buttons->GetCount(); ++i) { if (event.GetId() == buttons->GetButtonId(i)) { pButton = buttons->GetButton(i); break; } } if (pButton != NULL) { if (pPropertyDescription->GetType() == eRPT_Ptr) { CPtrPropertyDescription* pPtrPropertyDescription = static_cast<CPtrPropertyDescription*>(pPropertyDescription); wxString valueStr = property->GetValueAsString(); bool bValueChanged = false; if (pButton->GetLabel().CmpNoCase(_T("+")) == 0) { size_t ptrGuid = pPtrPropertyDescription->GetPtrGuid(); std::vector<size_t> derivedClassGuid; CComponentProxyManager::GetInstance()->QueryDerivedClass(ptrGuid, derivedClassGuid, true); CComponentBase* pBase = CComponentProxyManager::GetInstance()->GetComponentTemplate(ptrGuid); bValueChanged = derivedClassGuid.size() == 0; if (!bValueChanged) { wxPGChoices choice; if (pBase != NULL) { choice.Add(pBase->GetClassStr(), pBase->GetGuid()); } for (auto i : derivedClassGuid) { pBase = CComponentManager::GetInstance()->GetComponentTemplate(i); choice.Add(pBase->GetClassStr(), pBase->GetGuid()); } wxString strSelectItem = ::wxGetSingleChoice(wxT("TypeChoice"), wxT("Caption"), choice.GetLabels(), NULL, wxDefaultCoord, wxDefaultCoord, false, wxCHOICE_WIDTH, wxCHOICE_HEIGHT); if ( !strSelectItem.empty() ) { int nSelectIndex = choice.Index(strSelectItem); size_t uDerivedGuid = choice.GetValue(nSelectIndex); pPtrPropertyDescription->SetDerivedGuid(uDerivedGuid); bValueChanged = true; } } if (bValueChanged) { bool bCreateInstance = pPtrPropertyDescription->CreateInstance(); bCreateInstance; BEATS_ASSERT(bCreateInstance); CComponentEditorProxy* pCompBase = static_cast<CComponentEditorProxy*>(pPtrPropertyDescription->GetInstanceComponent()); BEATS_ASSERT(pCompBase != NULL); BEATS_ASSERT(pManager != NULL); TString* pStrValue = (TString*)pPtrPropertyDescription->GetValue(eVT_CurrentValue); property->SetValueFromString(pStrValue->c_str()); pManager->RefreshProperty(property); pManager->InsertComponentsInPropertyGrid(pCompBase, property); buttons->GetButton(0)->SetLabel(_T("-")); valueStr.insert(0, _T("+")); } } else if (pButton->GetLabel().CmpNoCase(_T("-")) == 0) { property->DeleteChildren(); bool bDeleteInstance = pPtrPropertyDescription->DestroyInstance(); bDeleteInstance; BEATS_ASSERT(bDeleteInstance); // Destroy instance may cause the value changed, so we fetch it again. char szTmp[MAX_PATH]; pPtrPropertyDescription->GetValueAsChar(eVT_CurrentValue, szTmp); valueStr = szTmp; pPtrPropertyDescription->GetChildren().clear(); buttons->GetButton(0)->SetLabel(_T("+")); valueStr.Remove(0, 1); // Remove the "+" prefix bValueChanged = true; } if (bValueChanged) { wxVariant newValue(valueStr); pPtrPropertyDescription->SetValue(newValue, false); property->SetValue(newValue); propGrid->Refresh(); } } if (pPropertyDescription->IsContainerProperty()) { if (pButton->GetLabel().CmpNoCase(_T("+")) == 0) { CPropertyDescriptionBase* pNewChild = pPropertyDescription->AddChild(NULL); if (pNewChild != NULL) { std::vector<CPropertyDescriptionBase*> value; value.push_back(pNewChild); pManager->InsertInPropertyGrid(value, property); } } else if (pButton->GetLabel().CmpNoCase(_T("-")) == 0) { pPropertyDescription->DeleteAllChild(); property->DeleteChildren(); } char valueStr[256]; pPropertyDescription->GetValueAsChar(eVT_CurrentValue, valueStr); property->SetValue(valueStr); property->SetModifiedStatus(pPropertyDescription->GetChildrenCount() > 0); property->RecreateEditor(); } if (pButton->GetLabel().CmpNoCase(_T("x")) == 0) { BEATS_ASSERT(pPropertyDescription->GetParent() != NULL); CPropertyDescriptionBase* pParent = pPropertyDescription->GetParent(); pParent->DeleteChild(pPropertyDescription); // NOTICE: We have deleted this already! pPropertyDescription = NULL; property->SetClientData(NULL); char valueStr[256]; pParent->GetValueAsChar(eVT_CurrentValue, valueStr); property->GetParent()->SetValue(valueStr); //TODO: I can't refresh property here, because we are trying to delete property of which callback we are in. pManager->SetUpdateFlag(true); } return true; } } return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); }
void CMouse::UnLockMouseBtnState( EMouseButton btn ) { BEATS_ASSERT(m_lockMouseInfo.find(btn) != m_lockMouseInfo.end(), _T("The button has not been locked! btn:%d"), btn); m_lockMouseInfo.erase(m_lockMouseInfo.find(btn)); }
void CRenderer::ClearDepth(GLclampf depth) { BEATS_ASSERT(depth >= 0 && depth <= 1); glClearDepth(depth); FC_CHECK_GL_ERROR_DEBUG(); }
void CRenderer::VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { BEATS_ASSERT( type == GL_BYTE || type == GL_UNSIGNED_BYTE || type == GL_SHORT || type == GL_UNSIGNED_SHORT || type == GL_INT || type == GL_UNSIGNED_INT ); glVertexAttribIPointer(index, size, type, stride, pointer); FC_CHECK_GL_ERROR_DEBUG(); }
CTouch* CTouchDelegate::GetTouch(size_t uIndex) const { BEATS_ASSERT(uIndex < TOUCH_MAX_NUM); return m_pTouches[uIndex]; }
const CFontGlyph *CFreetypeFontFace::PrepareChar(wchar_t character, bool& bGlyphRestFlag) { bGlyphRestFlag = false; m_glyphMapLocker.lock(); auto itr = m_glyphMap.find(character); CFreetypeFontGlyph *pGlyph = itr != m_glyphMap.end() ? down_cast<CFreetypeFontGlyph *>(itr->second) : nullptr; m_glyphMapLocker.unlock(); if (!pGlyph) { float outlineWidth = GetBorderWeight() * GetScaleFactor(); ApplyFTSize(); FT_Face pFontFace = m_pFont->GetFontFace(); BEATS_ASSERT(pFontFace != NULL); bool bFindCharacterGlyph = FT_Get_Char_Index(pFontFace, character) != 0; BEYONDENGINE_UNUSED_PARAM(bFindCharacterGlyph); BEATS_ASSERT(bFindCharacterGlyph, _T("Character %d can't be found in all font face!"), character); FT_Error err = FT_Load_Char(pFontFace, character, FT_LOAD_NO_BITMAP); BEYONDENGINE_UNUSED_PARAM(err); BEATS_ASSERT(!err); FT_GlyphSlot pGlyphSlot = pFontFace->glyph; BEATS_ASSERT(pGlyphSlot != NULL); int32_t nBorderAdvanceX = pGlyphSlot->metrics.horiAdvance >> FT_SHIFT_NUM; int32_t nBorderAdvanceY = m_nLineHeight + (uint32_t)ceil(outlineWidth * 2.0f); int32_t nFontAdvanceX = nBorderAdvanceX; int32_t nFontHeight = 0; int32_t nBorderOriginWidth = 0; int32_t nFontOriginWidth = 0; int32_t nBorderHeight = 0; FT_BBox borderBox; FT_BBox fontBox; int32_t x = 0, y = 0; if (pGlyphSlot->format == FT_GLYPH_FORMAT_OUTLINE) { FT_Library ftLib = CFont::GetLibrary(); // Set up a stroker. FT_Stroker stroker; FT_Stroker_New(ftLib, &stroker); FT_Stroker_Set(stroker, (int32_t)(outlineWidth * 64), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0); FT_Glyph pOutlineGlyph, pInnerGlyph; if (FT_Get_Glyph(pGlyphSlot, &pOutlineGlyph) == 0 && FT_Get_Glyph(pGlyphSlot, &pInnerGlyph) == 0) { FT_Glyph_StrokeBorder(&pOutlineGlyph, stroker, 0, 1); BEATS_ASSERT(pOutlineGlyph->format == FT_GLYPH_FORMAT_OUTLINE && pInnerGlyph->format == FT_GLYPH_FORMAT_OUTLINE); FT_Outline *pOutLine = &reinterpret_cast<FT_OutlineGlyph>(pOutlineGlyph)->outline; FT_Glyph_Get_CBox(pOutlineGlyph, FT_GLYPH_BBOX_GRIDFIT, &borderBox); FT_Glyph_Get_CBox(pInnerGlyph, FT_GLYPH_BBOX_GRIDFIT, &fontBox); nBorderOriginWidth = (borderBox.xMax - borderBox.xMin) >> FT_SHIFT_NUM; nFontOriginWidth = (fontBox.xMax - fontBox.xMin) >> FT_SHIFT_NUM; int32_t nBorderWidth = nextMOE(nBorderOriginWidth); // Because our GL_UNPACK_ALIGNMENT should be 8 here. nBorderHeight = (borderBox.yMax - borderBox.yMin) >> FT_SHIFT_NUM; nFontHeight = (fontBox.yMax - fontBox.yMin) >> FT_SHIFT_NUM; x = pGlyphSlot->metrics.horiBearingX >> FT_SHIFT_NUM; y = pGlyphSlot->metrics.horiBearingY >> FT_SHIFT_NUM; if(nBorderAdvanceX < x + nBorderOriginWidth) // It is true for most of the time, because border size always greater than nAdvanceX { nBorderAdvanceX = x + nBorderOriginWidth; } if (nFontAdvanceX < x + nFontOriginWidth) { nFontAdvanceX = nFontOriginWidth; } if(m_uCurrX + x + nBorderWidth > PAGE_WIDTH) { m_uCurrX = 0; m_uCurrY += (nBorderAdvanceY + m_nBorderSpace); if (m_uCurrY + nBorderAdvanceY > PAGE_HEIGHT) { BEATS_WARNING(false, "Freetype texture buffer overflow for %d glyphs, we will rebuild this texture buffer.", (uint32_t)m_glyphMap.size()); ResetGlyphs(); bGlyphRestFlag = true; return nullptr; } } int32_t nDataSize = nBorderWidth * nBorderHeight; float fBorderOffsetY = 1.0f; // Makes it look like a shadow. unsigned char* pBorderData = RenderFontDataToBmp(nBorderWidth, nBorderHeight, -borderBox.xMin, (int32_t)(-borderBox.yMin * fBorderOffsetY), pOutLine); FT_Outline *pInnerOutLine = &reinterpret_cast<FT_OutlineGlyph>(pInnerGlyph)->outline; unsigned char* pFontData = RenderFontDataToBmp(nBorderWidth, nBorderHeight, -borderBox.xMin, -borderBox.yMin, pInnerOutLine); unsigned char* pAllData = new unsigned char[nDataSize * 2]; for (int32_t i = 0; i < nDataSize; ++i) { pAllData[i * 2] = pBorderData[i]; pAllData[i * 2 + 1] = pFontData[i]; } BEATS_ASSERT(m_pTexture.Get() != nullptr); GLint nX = MAX((int32_t)m_uCurrX + x, 0); GLint nY = MAX((int32_t)m_uCurrY + (m_nAscender - y), 0); SFontUpdateImageInfo* pImageInfo = new SFontUpdateImageInfo; pImageInfo->m_pTexture = m_pTexture; pImageInfo->m_nWidth = nBorderWidth; pImageInfo->m_nHeight = nBorderHeight; pImageInfo->m_x = nX; pImageInfo->m_y = nY; pImageInfo->m_pData = pAllData; m_fontUpdateImageCacheMutex.lock(); m_fontUpdateImageCache.push_back(pImageInfo); m_fontUpdateImageCacheMutex.unlock(); // Clean up afterwards. FT_Stroker_Done(stroker); FT_Done_Glyph(pOutlineGlyph); FT_Done_Glyph(pInnerGlyph); BEATS_SAFE_DELETE_ARRAY(pBorderData); BEATS_SAFE_DELETE_ARRAY(pFontData); }
void CParticleControlWnd::OnStopBtnClicked(wxCommandEvent& /*event*/) { BEATS_ASSERT(m_pAttachedEmitter != nullptr); m_pAttachedEmitter->Stop(); }
void CApplication::Destroy() { BEATS_ASSERT(m_sMainApplication, _T("You should implement and initialize an application")); BEATS_SAFE_DELETE(m_sMainApplication); }