本文整理汇总了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();
}
}