°ÔÀӺ긮¿À¿¡ AntTweakBar UI¸¦ Àû¿ëÇغ¸ÀÚ.
AntTweakBar´Â À¯´ÏÄÚµå´Â ¾ÈµÇÁö¸¸ ±âÁ¸ °ÔÀÓ¿¡ Àû¿ëÇϴ°ÍÀº ½±´Ù.
°ÔÀÓÅøÀ» ¸¸µé¶§ Àû¿ë Çϸé ÁÁÀ»°Í °°´Ù.
°ÔÀӺ긮¿À Tutorial05¿¡ AntweakBar¸¦ Àû¿ëÇÑ´Ù.
1. ¶óÀ̺귯¸®
AntTweakBar.lib
2. ÇÊ¿äÇÑ DLL
AntTweakBar.dll or AntTweakBar64.dll
3. Çì´õÆÄÀÏ¿¡ ´ÙÀ½ÀÇ Çì´õ¸¦ Æ÷ÇÔ ½ÃŲ´Ù.
#include <AntTweakBar.h>
4. µð¹ÙÀ̽º ÃʱâÈ
TwInit(TW_DIRECT3D9, pkDevice);
5. TwBar »ý¼º
TwBar *bar = TwNewBar("TweakBar");
bool Transforms::CreateUISystem()
{
NiSample::CreateUISystem();
NiRenderer* pkRenderer = NiRenderer::GetRenderer();
if (NiIsKindOf(NiDX9Renderer, pkRenderer))
{
const LPDIRECT3DDEVICE9 pkDevice
= ((NiDX9Renderer*)pkRenderer)->GetD3DDevice();
TwInit(TW_DIRECT3D9, pkDevice);
Ni2DBufferPtr pkBackBuffer =
pkRenderer->GetDefaultBackBuffer();
TwWindowSize(
pkBackBuffer->GetWidth(), pkBackBuffer->GetHeight());
int numSec =
100;
// number of strip sections
float color[] = { 1, 0, 0 }; //
strip color
unsigned int bgColor =
D3DCOLOR_ARGB(255, 128, 196, 196); // background color
TwBar *bar = TwNewBar("TweakBar");
int barPos[2] = {500, 240};
TwSetParam(bar, NULL, "position",
TW_PARAM_INT32, 2, &barPos);
TwDefine(" GLOBAL help='This
example shows how to integrate AntTweakBar in a DirectX9 application.'
");
TwDefine(" TweakBar color='128
224 160' text=dark ");
TwAddVarRW(bar, "NumSec",
TW_TYPE_INT32, &numSec, " label='Strip length' min=1 max=1000
keyIncr=s keyDecr=S help='Number of segments of the strip.' ");
TwAddVarRW(bar, "Color",
TW_TYPE_COLOR3F, &color, " label='Strip color' ");
TwAddVarRW(bar, "BgColor",
TW_TYPE_COLOR32, &bgColor, " label='Background color' ");
static int num = 100;
TwAddVarRO(bar, "Width",
TW_TYPE_INT32, &num, " label='wnd width' help='Current graphics
window width.' ");
TwAddVarRO(bar, "Height",
TW_TYPE_INT32, &num, " label='wnd height' help='Current graphics
window height.' ");
}
return true;
}
6. ·»´õ¸µ
TwDraw·Î ·»´õ¸µ
void Transforms::RenderFrame()
{
NiSample::RenderFrame();
TwDraw();
}
7, ¸¶¿ì½º À̺¥Æ® ó¸®AntTweakBar¿¡¼ ¸¶¿ì½º 󸮸¦ À§ÇØ m_bExclusiveMouse °ªÀ» false·Î ¼³Á¤ÇÑ´Ù.
Transforms::Transforms() : NiSample("Tutorial: Transforms", DEFAULT_WIDTH,
DEFAULT_HEIGHT, true)
{
......
m_bExclusiveMouse = false;
}
TwEventWin·Î À©µµ¿ìÁî À̺¥Æ® ó¸®
bool Transforms::OnDefault(NiEventRef pkEventRecord)
{
if(NiSample::OnDefault(pkEventRecord))
return true;
if(!m_spCursor)
return false;
if (pkEventRecord->uiMsg == WM_MOUSEMOVE ||
pkEventRecord->uiMsg == WM_RBUTTONDOWN || WM_LBUTTONDOWN)
{
int iMouseX, iMouseY;
m_spCursor->GetScreenSpacePosition(iMouseX, iMouseY);
unsigned int uiMouseX = (iMouseX
> 0) ? iMouseX : 0;
unsigned int uiMouseY = (iMouseY
> 0) ? iMouseY : 0;
LPARAM lParam = uiMouseY <<
16;
lParam |= uiMouseX;
if(
TwEventWin(pkEventRecord->hWnd, pkEventRecord->uiMsg,
pkEventRecord->wParam, lParam) )
return true;
if(pkEventRecord->uiMsg ==
WM_LBUTTONDOWN)
{
SetCursorPos(uiMouseX, uiMouseY);
}
}
else if( TwEventWin(pkEventRecord->hWnd,
pkEventRecord->uiMsg, pkEventRecord->wParam,
pkEventRecord->lParam) )
return true;
return false;
}
8. ÇØÁ¦
TwTerminate ÇÔ¼ö·Î »ç¿ëÇÑ ¸®¼Ò½º¸¦ ÇØÁ¦ ÇÑ´Ù.
void Transforms::Terminate()
{
TwTerminate();
NiSample::Terminate();
}
* ¹ö±× *
°ÔÀӺ긮¿À ¸¶¿ì½º Ä¿¼°¡ AntTweakBar ÀÎÅÍÆäÀ̽ºÀÇ ¾Æ·¡¿¡ ·»´õ¸µ µÈ´Ù.
ÀÌ ¹®Á¦´Â ÇØ°áÇÏÁö ¸øÇß´Ù.
|