summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2017-12-01 13:22:27 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2017-12-01 13:22:27 +0100
commit39176274946d70ff520f265dee8fbd16d5fe0000 (patch)
tree318801d93146752050c9a492654ae3738820e3b9 /3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
parent6829ecb3b037d6bfbe0b84e818d17d712f71bce6 (diff)
Updated GENie, BGFX, BX, added BIMG since it is separated now, updated all shader binaries and MAME part of code to support new interfaces [Miodrag Milanovic]
Diffstat (limited to '3rdparty/bgfx/examples/00-helloworld/helloworld.cpp')
-rw-r--r--3rdparty/bgfx/examples/00-helloworld/helloworld.cpp88
1 files changed, 59 insertions, 29 deletions
diff --git a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
index bfd2a1c67c6..a66acd13fba 100644
--- a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
+++ b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp
@@ -7,15 +7,25 @@
#include "common.h"
#include "bgfx_utils.h"
#include "logo.h"
+#include "imgui/imgui.h"
+
+namespace
+{
class ExampleHelloWorld : public entry::AppI
{
- void init(int _argc, char** _argv) BX_OVERRIDE
+public:
+ ExampleHelloWorld(const char* _name, const char* _description)
+ : entry::AppI(_name, _description)
+ {
+ }
+
+ void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) override
{
Args args(_argc, _argv);
- m_width = 1280;
- m_height = 720;
+ m_width = _width;
+ m_height = _height;
m_debug = BGFX_DEBUG_TEXT;
m_reset = BGFX_RESET_VSYNC;
@@ -27,25 +37,43 @@ class ExampleHelloWorld : public entry::AppI
// Set view 0 clear state.
bgfx::setViewClear(0
- , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
- , 0x303030ff
- , 1.0f
- , 0
- );
+ , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
+ , 0x303030ff
+ , 1.0f
+ , 0
+ );
+
+ imguiCreate();
}
- virtual int shutdown() BX_OVERRIDE
+ virtual int shutdown() override
{
+ imguiDestroy();
+
// Shutdown bgfx.
bgfx::shutdown();
return 0;
}
- bool update() BX_OVERRIDE
+ bool update() override
{
- if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
+ if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
+ imguiBeginFrame(m_mouseState.m_mx
+ , m_mouseState.m_my
+ , (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
+ | (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
+ | (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
+ , m_mouseState.m_mz
+ , uint16_t(m_width)
+ , uint16_t(m_height)
+ );
+
+ showExampleDialog(this);
+
+ imguiEndFrame();
+
// Set view 0 default viewport.
bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
@@ -55,25 +83,23 @@ class ExampleHelloWorld : public entry::AppI
// Use debug font to print information about this example.
bgfx::dbgTextClear();
- bgfx::dbgTextImage(bx::uint16_max(uint16_t(m_width /2/8 ), 20)-20
- , bx::uint16_max(uint16_t(m_height/2/16), 6)-6
- , 40
- , 12
- , s_logo
- , 160
- );
- bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
- bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
-
- bgfx::dbgTextPrintf(0, 4, 0x0f, "Color can be changed with ANSI \x1b[9;me\x1b[10;ms\x1b[11;mc\x1b[12;ma\x1b[13;mp\x1b[14;me\x1b[0m code too.");
+ bgfx::dbgTextImage(
+ bx::uint16_max(uint16_t(m_width /2/8 ), 20)-20
+ , bx::uint16_max(uint16_t(m_height/2/16), 6)-6
+ , 40
+ , 12
+ , s_logo
+ , 160
+ );
+ bgfx::dbgTextPrintf(0, 1, 0x0f, "Color can be changed with ANSI \x1b[9;me\x1b[10;ms\x1b[11;mc\x1b[12;ma\x1b[13;mp\x1b[14;me\x1b[0m code too.");
const bgfx::Stats* stats = bgfx::getStats();
- bgfx::dbgTextPrintf(0, 6, 0x0f, "Backbuffer %dW x %dH in pixels, debug text %dW x %dH in characters."
- , stats->width
- , stats->height
- , stats->textWidth
- , stats->textHeight
- );
+ bgfx::dbgTextPrintf(0, 2, 0x0f, "Backbuffer %dW x %dH in pixels, debug text %dW x %dH in characters."
+ , stats->width
+ , stats->height
+ , stats->textWidth
+ , stats->textHeight
+ );
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
@@ -85,10 +111,14 @@ class ExampleHelloWorld : public entry::AppI
return false;
}
+ entry::MouseState m_mouseState;
+
uint32_t m_width;
uint32_t m_height;
uint32_t m_debug;
uint32_t m_reset;
};
-ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld);
+} // namespace
+
+ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld, "00-helloworld", "Initialization and debug text.");