Added examples.
This commit is contained in:
parent
b505078b38
commit
1621cc851a
69 changed files with 2087 additions and 1243 deletions
examples/00-helloworld
54
examples/00-helloworld/helloworld.cpp
Normal file
54
examples/00-helloworld/helloworld.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
|
||||
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bx/bx.h>
|
||||
#include "../common/dbg.h"
|
||||
|
||||
void fatalCb(bgfx::Fatal::Enum _code, const char* _str)
|
||||
{
|
||||
DBG("%x: %s", _code, _str);
|
||||
}
|
||||
|
||||
int _main_(int _argc, char** _argv)
|
||||
{
|
||||
bgfx::init(BX_PLATFORM_WINDOWS, fatalCb);
|
||||
bgfx::reset(1280, 720);
|
||||
|
||||
// Enable debug text.
|
||||
bgfx::setDebug(BGFX_DEBUG_TEXT);
|
||||
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, 1280, 720);
|
||||
|
||||
// Set view 0 clear state.
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR_BIT|BGFX_CLEAR_DEPTH_BIT
|
||||
, 0x303030ff
|
||||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
|
||||
while (true)
|
||||
{
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if not other draw calls are submitted to view 0.
|
||||
bgfx::submit(0);
|
||||
|
||||
// Use debug font to print information about this example.
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
|
||||
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
|
||||
|
||||
// Advance to next frame. Rendering thread will be kicked to
|
||||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
}
|
||||
|
||||
// Shutdown bgfx.
|
||||
bgfx::shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in a new issue