CEGUI资源加载流程

Posted 林多

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CEGUI资源加载流程相关的知识,希望对你有一定的参考价值。

CEGUI资源加载流程

  • CEGUI版本 0.8.7

主要资源类型

Scheme

  • scheme资源(包括图像集、字体资源、窗口外观信息、类型映射)等。可以通过“.scheme“”将CEGUI系统所需要的全部资源一次加载。
  • 例:TaharezLook.scheme
<?xml version="1.0" ?>								
<GUIScheme version="5" name="TaharezLook">								
	<Imageset filename="TaharezLook.imageset" />							
	<Font filename="DejaVuSans-12.font" />							
	<LookNFeel filename="TaharezLook.looknfeel" />							
	<WindowRendererSet filename="CEGUICoreWindowRendererSet" />							
								
	<FalagardMapping windowType="TaharezLook/Label"       targetType="DefaultWindow"     renderer="Core/Default"      lookNFeel="TaharezLook/Label" />							
	<FalagardMapping windowType="TaharezLook/Button"      targetType="CEGUI/PushButton"  renderer="Core/Button"       lookNFeel="TaharezLook/Button" />							
	<FalagardMapping windowType="TaharezLook/Checkbox"    targetType="CEGUI/ToggleButton"    renderer="Core/ToggleButton" lookNFeel="TaharezLook/Checkbox" />							
	<FalagardMapping windowType="TaharezLook/ImageButton" targetType="CEGUI/PushButton"  renderer="Core/Button"       lookNFeel="TaharezLook/ImageButton" />							
	<FalagardMapping windowType="TaharezLook/RadioButton" targetType="CEGUI/RadioButton" renderer="Core/ToggleButton" lookNFeel="TaharezLook/RadioButton" />							
	<FalagardMapping windowType="TaharezLook/FrameWindow"  targetType="CEGUI/FrameWindow" renderer="Core/FrameWindow"  lookNFeel="TaharezLook/FrameWindow" />							
	<FalagardMapping windowType="TaharezLook/Titlebar"     targetType="CEGUI/Titlebar"    renderer="Core/Titlebar"     lookNFeel="TaharezLook/Titlebar" />							
	<FalagardMapping windowType="TaharezLook/Editbox"          targetType="CEGUI/Editbox"          renderer="Core/Editbox"          lookNFeel="TaharezLook/Editbox" />							
	<FalagardMapping windowType="TaharezLook/MultiLineEditbox" targetType="CEGUI/MultiLineEditbox" renderer="Core/MultiLineEditbox" lookNFeel="TaharezLook/MultiLineEditbox" />							
	<FalagardMapping windowType="TaharezLook/Menubar"   targetType="CEGUI/Menubar"   renderer="Core/Menubar"   lookNFeel="TaharezLook/Menubar" />							
	<FalagardMapping windowType="TaharezLook/PopupMenu" targetType="CEGUI/PopupMenu" renderer="Core/PopupMenu" lookNFeel="TaharezLook/PopupMenu" />							
	<FalagardMapping windowType="TaharezLook/MenuItem"  targetType="CEGUI/MenuItem"  renderer="Core/MenuItem"  lookNFeel="TaharezLook/MenuItem" />							
	<FalagardMapping windowType="TaharezLook/AlternateProgressBar" targetType="CEGUI/ProgressBar" renderer="Core/ProgressBar" lookNFeel="TaharezLook/AltProgressBar" />							
	<FalagardMapping windowType="TaharezLook/ProgressBar"          targetType="CEGUI/ProgressBar" renderer="Core/ProgressBar" lookNFeel="TaharezLook/ProgressBar" />							
	<FalagardMapping windowType="TaharezLook/VUMeter"              targetType="CEGUI/ProgressBar" renderer="Core/ProgressBar" lookNFeel="TaharezLook/VUMeter" />							
	<FalagardMapping windowType="TaharezLook/VerticalScrollbar"   targetType="CEGUI/Scrollbar" renderer="Core/Scrollbar" lookNFeel="TaharezLook/VerticalScrollbar" />							
	<FalagardMapping windowType="TaharezLook/HorizontalScrollbar" targetType="CEGUI/Scrollbar" renderer="Core/Scrollbar" lookNFeel="TaharezLook/HorizontalScrollbar" />							
	<FalagardMapping windowType="TaharezLook/VerticalScrollbarThumb"   targetType="CEGUI/Thumb" renderer="Core/Button" lookNFeel="TaharezLook/VerticalScrollbarThumb" />							
	<FalagardMapping windowType="TaharezLook/HorizontalScrollbarThumb" targetType="CEGUI/Thumb" renderer="Core/Button" lookNFeel="TaharezLook/HorizontalScrollbarThumb" />							
	<FalagardMapping windowType="TaharezLook/LargeVerticalScrollbar"      targetType="CEGUI/Scrollbar" renderer="Core/Scrollbar" lookNFeel="TaharezLook/LargeVerticalScrollbar" />							
	<FalagardMapping windowType="TaharezLook/LargeVerticalScrollbarThumb" targetType="CEGUI/Thumb"     renderer="Core/Button"    lookNFeel="TaharezLook/LargeVerticalScrollbarThumb" />							
	<FalagardMapping windowType="TaharezLook/TabButton"  targetType="CEGUI/TabButton"  renderer="Core/TabButton"  lookNFeel="TaharezLook/TabButton" />							
	<FalagardMapping windowType="TaharezLook/TabControl" targetType="CEGUI/TabControl" renderer="Core/TabControl" lookNFeel="TaharezLook/TabControl" />							
	<FalagardMapping windowType="TaharezLook/TabContentPane"    targetType="DefaultWindow"    renderer="Core/Default"    lookNFeel="TaharezLook/TabContentPane" />							
	<FalagardMapping windowType="TaharezLook/TabButtonPane"    targetType="DefaultWindow"    renderer="Core/Default"    lookNFeel="TaharezLook/TabButtonPane" />							
	<FalagardMapping windowType="TaharezLook/ComboDropList" targetType="CEGUI/ComboDropList" renderer="Core/Listbox" lookNFeel="TaharezLook/ComboDropList" />							
	<FalagardMapping windowType="TaharezLook/ComboEditbox"  targetType="CEGUI/Editbox"	 renderer="Core/Editbox" lookNFeel="TaharezLook/ComboEditbox" />						
	<FalagardMapping windowType="TaharezLook/Combobox" targetType="CEGUI/Combobox"	 renderer="Core/Default" lookNFeel="TaharezLook/Combobox" />						
	<FalagardMapping windowType="TaharezLook/Listbox"           targetType="CEGUI/Listbox"           renderer="Core/Listbox"           lookNFeel="TaharezLook/Listbox" />							
	<FalagardMapping windowType="TaharezLook/ListHeader"        targetType="CEGUI/ListHeader"        renderer="Core/ListHeader"        lookNFeel="TaharezLook/ListHeader" />							
	<FalagardMapping windowType="TaharezLook/ListHeaderSegment" targetType="CEGUI/ListHeaderSegment" renderer="Core/ListHeaderSegment" lookNFeel="TaharezLook/ListHeaderSegment" />							
	<FalagardMapping windowType="TaharezLook/MultiColumnList"   targetType="CEGUI/MultiColumnList"   renderer="Core/MultiColumnList"   lookNFeel="TaharezLook/MultiColumnList" />							
	<FalagardMapping windowType="TaharezLook/Slider"      targetType="CEGUI/Slider"      renderer="Core/Slider"  lookNFeel="TaharezLook/Slider" />							
	<FalagardMapping windowType="TaharezLook/SliderThumb" targetType="CEGUI/Thumb" renderer="Core/Button"  lookNFeel="TaharezLook/SliderThumb" />							
	<FalagardMapping windowType="TaharezLook/ScrollablePane" targetType="CEGUI/ScrollablePane" renderer="Core/ScrollablePane" lookNFeel="TaharezLook/ScrollablePane" />							
	<FalagardMapping windowType="TaharezLook/Spinner" targetType="CEGUI/Spinner" renderer="Core/Default" lookNFeel="TaharezLook/Spinner" />							
	<FalagardMapping windowType="TaharezLook/Tooltip" targetType="CEGUI/Tooltip" renderer="Core/Tooltip" lookNFeel="TaharezLook/Tooltip" />							
	<FalagardMapping windowType="TaharezLook/StaticImage" targetType="DefaultWindow" renderer="Core/StaticImage" lookNFeel="TaharezLook/StaticImage" />							
	<FalagardMapping windowType="TaharezLook/StaticText"  targetType="DefaultWindow" renderer="Core/StaticText"  lookNFeel="TaharezLook/StaticText" />							
	<FalagardMapping windowType="TaharezLook/ItemListbox" targetType="CEGUI/ItemListbox" renderer="Core/ItemListbox" lookNFeel="TaharezLook/ItemListbox" />							
	<FalagardMapping windowType="TaharezLook/ListboxItem" targetType="CEGUI/ItemEntry"   renderer="Core/ItemEntry"   lookNFeel="TaharezLook/ListboxItem" />							
	<FalagardMapping windowType="TaharezLook/GroupBox" targetType="DefaultWindow"   renderer="Core/Default"   lookNFeel="TaharezLook/GroupBox" />							
    <FalagardMapping windowType="TaharezLook/Tree" targetType="CEGUI/Tree"   renderer="Core/Tree"   lookNFeel="TaharezLook/Tree" />								
</GUIScheme>

Imageset

  • Imageset图像集,对应一张图片。Image对应该图片上一块区域。Image数量没有限制。
  • 例:
<Imageset autoScaled="vertical" imagefile="TaharezLook.png" name="TaharezLook" nativeHorzRes="1280" nativeVertRes="720" version="2">							
    <Image height="64" name="ClientBrush" width="64" xPos="2" yPos="2" />							
    <Image height="1" name="GenericBrush" width="1" xPos="9" yPos="71" />							
	省略...						
</Imagset>		

Font资源

  • CEGUI系统的字体资源。支持两种类型的Font: FreeTypeFont/ PixmapFont,即矢量字体和位图字体。
  • 例:
	<?xml version="1.0" ?>								
	<Font version="3" name="DejaVuSans-12" filename="DejaVuSans.ttf" 								
	type="FreeType" size="12" nativeHorzRes="1280" nativeVertRes="720" autoScaled="vertical"/>	

外观资源

  • 外观文件与渲染窗口有关。渲染窗口中定义的子窗口、命名区域在外观文件中需存在相对应的定义。外观文件定义内容非常多,相关内容参考下面的官方文档。
    http://static.cegui.org.uk/docs/0.8.7/fal_element_ref.html

资源加载流程分析

Scheme对象,是CEGUI提供的用来统一加载资源的对象。通过它利用Scheme文件,可一键加载CEGUI程序使用的各类资源文件。
Scheme只是统一的入口,也可以使用CEGUI提供的各类资源加载对象加载资源。
scheme会调用各类资源对象,进行资源加载。所以了解scheme加载即可了解各类资源加载流程。

  • Block图

加载资源前,需要告知CEGUI系统其资源组目录(各类资源的目录设定)

  • 例:设定schemes资源组。
// 设定schemes资源组。
CEGUI::System::getSingleton().getResourceProvider().setResourceGroupDirectory("schemes", "path")
CEGUI::Scheme::setDefaultResourceGroup("schemes");
// 加载scheme文件。
SchemeManager::getSingleton().createFromFile("TaharezLook.scheme"); 
  • Scheme资源加载流程(以OpenGLRender为例)
  1. shcemeManager默认是自动加载(方便一键加载资源)。可设定非自动加载,在需要时通过各资源对象加载。
  2. 资源加载为同步加载,大量资源加载会比较耗时。
  3. 同名资源,不会重复加载。

以上是关于CEGUI资源加载流程的主要内容,如果未能解决你的问题,请参考以下文章

CEGUI资源加载流程

CEGUI字体加载优化

CEGUI字体加载优化

CEGUI字体加载优化

CEGUI Window环境编译

CEGUI Window环境编译