Example #1
0
File: main.c Project: yui0/catgl
// 表示の初期化
void caInit(int w, int h)
{
	width = w;
	height = h;
	pixelRatio = (float)width / (float)height;

	vg = nvgCreate(NVG_ANTIALIAS | NVG_STENCIL_STROKES);

	if (loadDemoData(vg, &data) == -1) return;
}
Example #2
0
File: main.c Project: yui0/catgl
// 表示の初期化
void caInit(int w, int h)
{
	width = w;
	height = h;

	// Calculate pixel ration for hi-dpi devices.
	pixelRatio = (float)width / (float)height;

	vg = nvgCreate(NVG_ANTIALIAS);

	//nvgCreateFont(vg, "sans-bold", CATGL_ASSETS("Roboto-Bold.ttf"));
	nvgCreateFontMem(vg, "sans-bold", mplus1pregular, sizeof(mplus1pregular), 0);
	nvgFontFace(vg, "sans-bold");
}
Example #3
0
int _main_(int _argc, char** _argv)
{
	Args args(_argc, _argv);

	uint32_t width = 1280;
	uint32_t height = 720;
	uint32_t debug = BGFX_DEBUG_TEXT;
	uint32_t reset = BGFX_RESET_VSYNC;

	bgfx::init(args.m_type, args.m_pciId);
	bgfx::reset(width, height, reset);

	// Enable debug text.
	bgfx::setDebug(debug);

	// Set view 0 clear state.
	bgfx::setViewClear(0
		, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
		, 0x303030ff
		, 1.0f
		, 0
		);

	imguiCreate();

	NVGcontext* nvg = nvgCreate(1, 0);
	bgfx::setViewSeq(0, true);

	DemoData data;
	loadDemoData(nvg, &data);

	bndSetFont(nvgCreateFont(nvg, "droidsans", "font/droidsans.ttf") );
	bndSetIconImage(nvgCreateImage(nvg, "images/blender_icons16.png", 0) );

	int64_t timeOffset = bx::getHPCounter();

	entry::MouseState mouseState;
	while (!entry::processEvents(width, height, debug, reset, &mouseState) )
	{
		int64_t now = bx::getHPCounter();
		const double freq = double(bx::getHPFrequency() );
		float time = (float)( (now-timeOffset)/freq);

		// Set view 0 default viewport.
		bgfx::setViewRect(0, 0, 0, width, height);

		// This dummy draw call is here to make sure that view 0 is cleared
		// if no other draw calls are submitted to view 0.
		bgfx::touch(0);

		// Use debug font to print information about this example.
		bgfx::dbgTextClear();
		bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/20-nanovg");
		bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: NanoVG is small antialiased vector graphics rendering library.");

		nvgBeginFrame(nvg, width, height, 1.0f);

		renderDemo(nvg, float(mouseState.m_mx), float(mouseState.m_my), float(width), float(height), time, 0, &data);

		nvgEndFrame(nvg);

		// Advance to next frame. Rendering thread will be kicked to
		// process submitted rendering primitives.
		bgfx::frame();
	}

	freeDemoData(nvg, &data);

	nvgDelete(nvg);

	imguiDestroy();

	// Shutdown bgfx.
	bgfx::shutdown();

	return 0;
}
Example #4
0
NVGcontext* nvgCreate(int32_t _edgeaa, bgfx::ViewId _viewId) {
	return nvgCreate(_edgeaa, _viewId, NULL);
}