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


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

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


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

示例1: drawDebug

void SkeletonRenderer::drawDebug (Renderer* renderer, const Mat4 &transform, uint32_t transformFlags) {

    Director* director = Director::getInstance();
    director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
    director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);
    
    DrawNode* drawNode = DrawNode::create();
    
    if (_debugSlots) {
        // Slots.
        // DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
        glLineWidth(1);
        Vec2 points[4];
        V3F_C4B_T2F_Quad quad;
        for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
            spSlot* slot = _skeleton->drawOrder[i];
            if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
            spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
            spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices);
            points[0] = Vec2(_worldVertices[0], _worldVertices[1]);
            points[1] = Vec2(_worldVertices[2], _worldVertices[3]);
            points[2] = Vec2(_worldVertices[4], _worldVertices[5]);
            points[3] = Vec2(_worldVertices[6], _worldVertices[7]);
            drawNode->drawPoly(points, 4, true, Color4F::BLUE);
        }
    }
    if (_debugBones) {
        // Bone lengths.
        glLineWidth(2);
        for (int i = 0, n = _skeleton->bonesCount; i < n; i++) {
            spBone *bone = _skeleton->bones[i];
            float x = bone->data->length * bone->a + bone->worldX;
            float y = bone->data->length * bone->c + bone->worldY;
            drawNode->drawLine(Vec2(bone->worldX, bone->worldY), Vec2(x, y), Color4F::RED);
        }
        // Bone origins.
        auto color = Color4F::BLUE; // Root bone is blue.
        for (int i = 0, n = _skeleton->bonesCount; i < n; i++) {
            spBone *bone = _skeleton->bones[i];
            drawNode->drawPoint(Vec2(bone->worldX, bone->worldY), 4, color);
            if (i == 0) color = Color4F::GREEN;
        }
    }
    
    drawNode->draw(renderer, transform, transformFlags);
    director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
开发者ID:EvansThomas,项目名称:spine-runtimes,代码行数:47,代码来源:SkeletonRenderer.cpp

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