Difference between revisions of "GUI Extension"
(GUI extension page) |
m |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[category: Extensions]] | [[category: Extensions]] | ||
− | {| border="0" | + | {| border="0" |
| {{ContentBlock|width=800|color=white |content=The GUI extensions adds a GUi system to Horde3D which can be used to display both 3D GUIs and 2D menus. This is done by defining a common GUI scene node which renders 2D geometry at the local xy plane of the scene node. All GUI elements are skinnable. The GUI uses wchar_t for all strings. | | {{ContentBlock|width=800|color=white |content=The GUI extensions adds a GUi system to Horde3D which can be used to display both 3D GUIs and 2D menus. This is done by defining a common GUI scene node which renders 2D geometry at the local xy plane of the scene node. All GUI elements are skinnable. The GUI uses wchar_t for all strings. | ||
Line 19: | Line 19: | ||
* Check boxes | * Check boxes | ||
* Group boxes | * Group boxes | ||
+ | |||
+ | = Position system = | ||
+ | |||
+ | For pixel-perfect layouts at all (and even at varying) screen sizes, a combination of relative and absolute addressing is used. A position (or size) is built from 4 values, 2 absolute ones in pixels, and to values relative to the screen size. For example the position (0.5, 10, 0.25, -20) with a screensize of 1280 * 1024 pixels would result in the absolute position with x = 0.5 * 1280 + 10 = 650 and y = 0.25 * 1024 - 20 = 236. | ||
+ | |||
+ | = Rendering = | ||
+ | The GUI resource only provides position and UV coordinate information for the vertices, the normals are assumed to be along the local z axis. | ||
+ | |||
+ | The GUI scene node only can render quads, and the quads are put together in batches. The batches are cached and only updated when necessary (though this can still be optimized, much more is updated than what would be necessary atm). | ||
+ | |||
+ | The font glyphs are rendered in software once when they are used for the first time and then saved to a texture specified in the font resource (for an example resource see the GUI example in the repository). | ||
= Usage example = | = Usage example = | ||
Line 24: | Line 35: | ||
The following code creates a GUI with one button and one edit box: | The following code creates a GUI with one button and one edit box: | ||
− | < | + | {{CppSourceCode|description=Creating a GUI|code= |
+ | <source lang="cpp" line="0"> | ||
H3DRes fontMatRes = h3dAddResource( H3DResTypes::Material, "overlays/font.material.xml", 0 ); | H3DRes fontMatRes = h3dAddResource( H3DResTypes::Material, "overlays/font.material.xml", 0 ); | ||
// GUI skin | // GUI skin | ||
Line 53: | Line 65: | ||
// Set an action ID for the button | // Set an action ID for the button | ||
h3dguiSetElementParamI( gui, button, H3DElementParam::ActionIdI, 1 ); | h3dguiSetElementParamI( gui, button, H3DElementParam::ActionIdI, 1 ); | ||
− | </ | + | </source>}} |
Mouse and keyboard input are injected like this: | Mouse and keyboard input are injected like this: | ||
− | < | + | {{CppSourceCode|description=Generating events|code= |
+ | <source lang="cpp" line="0"> | ||
// Insert printable char | // Insert printable char | ||
h3dguiInsertChar( gui, 'A' ); | h3dguiInsertChar( gui, 'A' ); | ||
Line 66: | Line 79: | ||
// Insert left mouse button event (0 = left mouse button, 1 = pressed) | // Insert left mouse button event (0 = left mouse button, 1 = pressed) | ||
h3dguiSetMouseButton( gui, 0, 1 ); | h3dguiSetMouseButton( gui, 0, 1 ); | ||
− | </ | + | </source>}} |
Events from the GUI are handled like this: | Events from the GUI are handled like this: | ||
− | < | + | {{CppSourceCode|description=Handling events|code= |
+ | <source lang="cpp" line="0"> | ||
while( h3dguiHasEvent( gui ) ) | while( h3dguiHasEvent( gui ) ) | ||
{ | { | ||
Line 79: | Line 93: | ||
} | } | ||
} | } | ||
− | </ | + | </source>}} |
There also is an example showing how to use a 3D GUI in the repository at Extensions/GUI/Sample. | There also is an example showing how to use a 3D GUI in the repository at Extensions/GUI/Sample. | ||
Line 98: | Line 112: | ||
}} <!-- Right panel --> | }} <!-- Right panel --> | ||
− | | valign="top" |{{Extension_Summary| | + | |valign="top" |{{Extension_Summary |
− | + | |name = GUI Extension | |
− | screenshot = | + | |screenshot = H3DGUIsmall.jpg |
− | description = The GUI extension adds a tightly integrated GUI system to Horde3D.| | + | |description = The GUI extension adds a tightly integrated GUI system to Horde3D. |
− | horde3dversion = svn head| | + | |horde3dversion = svn head |
− | author = Mathias Gottschlag| | + | |released = 2010-01-25 |
+ | |author = Mathias Gottschlag| | ||
}} | }} | ||
|} | |} |
Latest revision as of 20:29, 25 January 2010
|
|