当前位置: 首页>>代码示例>>C++>>正文


C++ DrawNode::onDrawLine方法代码示例

本文整理汇总了C++中DrawNode::onDrawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawNode::onDrawLine方法的具体用法?C++ DrawNode::onDrawLine怎么用?C++ DrawNode::onDrawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DrawNode的用法示例。


在下文中一共展示了DrawNode::onDrawLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render

void GLView::render()
{
	m_render = Director::getInstance()->getRenderer();
	initTexture2d();

	ClippingNode* clippingNode = ClippingNode::create();
	Sprite* stencil = Sprite::createWithFileName("E://5.png");
	Sprite* back = Sprite::createWithFileName("E://3.png");
//	back->setPosition(200, 10);
	stencil->setPosition(200, 10);
	clippingNode->setSprite(back);
	clippingNode->setStencil(stencil);
	clippingNode->setAlpha(1.0);

	bool saveImage = false;  //截图功能 RenderTexure
	bool testClippingNode = false;  //遮罩功能ClippingNode
	bool testDrawNodePoint = false;  //DrawNode功能之画点
	bool testDrawNodeLine = true; //DrawNode功能之画线

	/* Loop until the user closes the window */
	while (!glfwWindowShouldClose(_mainWindow))
	{
		glClearColor(0.2, 0.2, 0.2, 1);
		glClear(GL_COLOR_BUFFER_BIT);
		

		if (saveImage)
		{
			/*  测试 RenderTexture
			Size size = Director::getInstance()->getWinSize();
			RenderTexture* renderTexure = RenderTexture::create(20,20);
			renderTexure->begin();
			renderTexure->end();

			renderTexure->onBegin();
			for (Sprite* sprite : _sprites)
			{
				sprite->setPosition(20, 20);
				sprite->visit(&m_render);
				sprite->setPosition(0, 0);
			}
			m_render.draw();
			renderTexure->onEnd();
			renderTexure->saveToFile("1.png");
			saveImage = false;

			CC_SAFE_DELETE(renderTexure);*/
		}
		else if (testClippingNode){
			/* 测试ClippingNode
			auto _director = Director::getInstance();
			clippingNode->onBeforeVisit();
			
			stencil->visit(&m_render);
			m_render.draw();
			clippingNode->onAfterVisitStencil();

			back->visit(&m_render);
			m_render.draw();

			clippingNode->onAfterVisit();*/
		} else if (testDrawNodePoint)
		{
			DrawNode* drawNode = DrawNode::create();
			CHECK_GL_ERROR_DEBUG();
			for (int i = 1; i <= 100; i++)
			{
				drawNode->drawPoint(Vec2(100+i, 100), 1, Color4F(255.0, 0, 0, 255.0));
			}
			
			drawNode->onDrawPoinit();
	//		CHECK_GL_ERROR_DEBUG();
		}else if (testDrawNodeLine)
		{
			DrawNode* drawNode = DrawNode::create();
			CHECK_GL_ERROR_DEBUG();
			drawNode->drawLine(Vec2(100, 100), Vec2(200, 200), Color4F(255.0, 0, 0, 255.0));
			drawNode->drawLine(Vec2(100, 200), Vec2(200, 100), Color4F(255.0, 0, 0, 255.0));
			drawNode->onDrawLine();
		}
		else{
			
			for (Sprite* sprite : _sprites)
			{
				sprite->visit(&m_render);
			}

			m_render.draw();

		}
		

		/* Swap front and back buffers */
		glfwSwapBuffers(_mainWindow);

		/* Poll for and process events */
		glfwPollEvents();

	}
}
开发者ID:wuqiang22,项目名称:opengl,代码行数:100,代码来源:GLView.cpp


注:本文中的DrawNode::onDrawLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。