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


C++ DrawTriangle函数代码示例

本文整理汇总了C++中DrawTriangle函数的典型用法代码示例。如果您正苦于以下问题:C++ DrawTriangle函数的具体用法?C++ DrawTriangle怎么用?C++ DrawTriangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: DrawTriangle

void PolygonShapeBuilder::DrawRectangle(
    const Vector2& position,
    float width,
    float height,
    const Vector2& originPivot,
    const Color& color)
{
    if (width <= 0 || height <= 0) {
        return;
    }

    Vector2 anchorOffset = Vector2{width, height} * originPivot;
    const auto minX = position.X - anchorOffset.X;
    const auto minY = position.Y - anchorOffset.Y;
    const auto maxX = position.X + width - anchorOffset.X;
    const auto maxY = position.Y + height - anchorOffset.Y;

    std::array<Vector3, 4> rectVertices = {{
        Vector3{minX, minY, 0.0f},
        Vector3{minX, maxY, 0.0f},
        Vector3{maxX, maxY, 0.0f},
        Vector3{maxX, minY, 0.0f},
    }};

    auto colorVector = color.ToVector4();

    DrawTriangle(
        rectVertices[0], rectVertices[1], rectVertices[2],
        colorVector, colorVector, colorVector);
    DrawTriangle(
        rectVertices[2], rectVertices[3], rectVertices[0],
        colorVector, colorVector, colorVector);
}
开发者ID:mogemimi,项目名称:pomdog,代码行数:33,代码来源:PolygonShapeBuilder.cpp

示例2: DrawRectangle

// DrawQuads (GL_QUADS)
void nuiSoftwarePainter::DrawQuadStrip(const nuiRenderArray* pArray)
{
  int32 i;
  int32 count = (pArray->GetSize() - 2) / 2;
  for (i = 0; i < count; i++)
  {
    int32 ii = i << 1;

    // Is the quad a special case?
    const std::vector<nuiRenderArray::Vertex>& rCoords = pArray->GetVertices();

    float x0 = rCoords[ii].mX, y0 = rCoords[ii+1].mY;
    float x1 = rCoords[(ii+1)].mX, y1 = rCoords[(ii+1)].mY;
    float x2 = rCoords[(ii+2)].mX, y2 = rCoords[(ii+2)].mY;
    float x3 = rCoords[(ii+3)].mX, y3 = rCoords[(ii+3)].mY;
    if (x0 == x3 && x1 == x2 && y0 == y1 && y2 == y3)
    {
      // This is an axis aligned rectangle
      DrawRectangle(pArray, ii, ii+1, ii+3, ii+2);
    }
    else
    {
      // This is not a special quad, draw two triangles:
      DrawTriangle(pArray, ii, ii+1, ii+2);
      DrawTriangle(pArray, ii+1, ii+3, ii+2);
    }
  }
}
开发者ID:jbl2024,项目名称:nui3,代码行数:29,代码来源:nuiSoftwarePainter.cpp

示例3: submitMesh

    void KGEDevice::SoftRasterization(HDC hdc)
    {
        submitMesh();
        transformVertexes();
        /// TODO
        /// for test hard code
        DrawPoint(hdc, 100, 100, Vector4(1, 0, 0, 1));
        DrawLine(hdc, 200, 247, 300, 405, Vector4(1, 0, 0, 1));
        DrawTriangle(hdc, 500, 200, 400, 300, 700, 400, Vector4(0, 1, 0, 1));

        int nIDtri = (int)_transformMesh->triList.size();
        for (int i = 0; i<nIDtri; i++){
            const KGETriangle & IDtri = _transformMesh->triList[i];
            const int vID0 = IDtri.vID(0);
            const int vID1 = IDtri.vID(1);
            const int vID2 = IDtri.vID(2);
            if (vID0 == -1)continue;
            KGEVertex v0, v1, v2;
            v0 = _transformMesh->GetVertex(vID0);
            v1 = _transformMesh->GetVertex(vID1);
            v2 = _transformMesh->GetVertex(vID2);

            DrawTriangle(hdc, v0.pos.x, v0.pos.y, v1.pos.x, v1.pos.y, v2.pos.x, v2.pos.y, v0.color);
        }
        /// end test hard code
    }
开发者ID:iamkevinf,项目名称:KGESR,代码行数:26,代码来源:KGEDevice.cpp

示例4: DrawTriangleFan

static void DrawTriangleFan(State * state, GLuint index) {
	SelectArrayElement(state, index, state->vertexQueue + state->nextIndex);

	if (state->primitiveState == 3) {
		// even triangle
		GLuint prevIndex = (state->nextIndex - 1) > state->nextIndex ? state->nextIndex + 2 : state->nextIndex - 1;
		GLuint prevIndex2 = (state->nextIndex - 2) > state->nextIndex ? state->nextIndex + 1 : state->nextIndex - 2;
		DrawTriangle(state, state->vertexQueue + prevIndex, state->vertexQueue + prevIndex2, 
				     state->vertexQueue + state->nextIndex);
		state->primitiveState = 2;
	} else if (state->primitiveState == 2) {
		// odd triangle
		GLuint prevIndex = (state->nextIndex - 1) > state->nextIndex ? state->nextIndex + 2 : state->nextIndex - 1;
		GLuint prevIndex2 = (state->nextIndex - 2) > state->nextIndex ? state->nextIndex + 1 : state->nextIndex - 2;
		DrawTriangle(state, state->vertexQueue + prevIndex2, state->vertexQueue + prevIndex, 
					 state->vertexQueue + state->nextIndex);
		state->primitiveState = 3;
	} else if (state->primitiveState == 1) {
		// remember seen second vertex
		state->primitiveState = 2;
	} else if (state->primitiveState == 0) {
		// remember seen first vertex
		state->primitiveState = 1;
	}

	if (++state->nextIndex == 3) {
		state->nextIndex = 1;
	}
}
开发者ID:mew-cx,项目名称:Vincent_ES_2.x,代码行数:29,代码来源:render.c

示例5: p9

void p9(void) {
	SetDrawScreen(DX_SCREEN_BACK);

	char keybuf[256];

	while (ProcessMessage() == 0 && GetHitKeyStateAll(keybuf) == 0 && keybuf[KEY_INPUT_ESCAPE] == 0) {
		ClearDrawScreen();
		DrawLine(10, 10, 200, 10, GetColor(255, 0, 0));
		DrawLine(10, 20, 200, 20, GetColor(0, 255, 0));
		DrawLine(10, 30, 200, 30, GetColor(0, 0, 255));
		SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100);	//	αブレンド
		DrawBox(5, 5, 205, 35, GetColor(255, 255, 255), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, TRUE);	//	ブレンドなし
		DrawBox(100, 100, 201, 201, GetColor(255, 0, 0), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_ADD, 255);	//	加算ブレンド
		DrawCircle(150, 150, 50, GetColor(0, 255, 255), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_SUB, 255);	//	減算ブレンド
		DrawCircle(150, 150, 30, GetColor(0, 100, 100), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_INVSRC, 255);	//	反転ブレンド
		DrawOval(300, 200, 30, 25, GetColor(0, 0, 0), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_MULA, 255);	//	乗算ブレンド
		DrawOval(300, 200, 25, 30, GetColor(0, 100, 100), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
		DrawPixel(320, 240, GetColor(255, 255, 255));
		DrawTriangle(5, 5, 205, 5, 5, 35, GetColor(0, 0, 0), TRUE);
		DrawTriangle(5, 5, 205, 5, 5, 35, GetColor(255, 255, 255), FALSE);

		ScreenFlip();
	}
}
开发者ID:kyushu-pc,项目名称:kpc,代码行数:30,代码来源:Paint2.cpp

示例6: glPushMatrix

void Rat::draw(Maze &maze)
{
    if(maze.current_view == maze.rat_view)
    {
        return; // drawing yourself in rat view looks bad.
    }
    glPushMatrix();
    
    glTranslated(mX, mY, 0.0);//3rd
    glRotated(mDegrees, 0.0, 0.0, 1.0);//2nd
    glScaled(.5, .5, 1);//1st
    glTranslated(-mX, -mY, 0);
    
    glColor3d(.75, .75, .75);
    
    DrawTriangle(mX-.5, mY-.5, mX+.5, mY-.5, mX, mY); //outerearright
    DrawTriangle(mX-.5, mY+.5, mX+.5, mY+.5, mX, mY); //outerearleft
    DrawCircle(mX, mY, .3); //head
    glColor3d(1, .8, .89);
    DrawTriangle(mX-.3, mY-.4, mX+.3, mY-.4, mX, mY-.2); //innerearright
    DrawTriangle(mX-.3, mY+.4, mX+.3, mY+.4, mX, mY+.2); //innerearleft
    glColor3d(1, 1, 1);
    DrawCircle(mX, mY-.1, .1);//eyeright
    DrawCircle(mX, mY+.1, .1);//eyeleft
    glColor3d(0, 0, 0);
    DrawCircle(mX+.05, mY-.1, .05);//pupilright
    DrawCircle(mX+.05, mY+.1, .05);//pupilleft
    DrawCircle(mX+.35, mY, .1);//nose
    glPopMatrix();
}
开发者ID:codybrowncit,项目名称:C-plus-plus,代码行数:30,代码来源:rat.cpp

示例7: DrawTriangle

// DrawTrianglesStrip (GL_TRIANGLE_STRIP)
void nuiSoftwarePainter::DrawTrianglesStrip(const nuiRenderArray* pArray)
{
  int32 i;
  int32 count = pArray->GetSize() - 2;
  for (i = 0; i < count; i++)
  {
    if (i & 1)
      DrawTriangle(pArray, i, i + 1, i + 2);
    else
      DrawTriangle(pArray, i + 1, i, i + 2);
  }
}
开发者ID:jbl2024,项目名称:nui3,代码行数:13,代码来源:nuiSoftwarePainter.cpp

示例8: render

//function to draw
void render()
{
	//set the clear colour
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	//clear the colour and depth-buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	DrawTriangle(TR1);
	DrawTriangle(TR2);

	//requirte to swap the back and front buffer
	SDL_GL_SwapWindow(window);

}
开发者ID:TomZoy,项目名称:GP2Labs-ztompa200,代码行数:16,代码来源:main.cpp

示例9: POMDOG_ASSERT

void PolygonShapeBuilder::DrawCircle(
    const Vector3& position,
    float radius,
    int segments,
    const Color& color)
{
    POMDOG_ASSERT(segments >= 3);
    POMDOG_ASSERT(radius >= 0);

    if (radius <= 0) {
        return;
    }

    if (segments < 3) {
        return;
    }

    POMDOG_ASSERT(radius > 0);
    POMDOG_ASSERT(segments >= 3);

    Radian<float> centralAngle = Math::TwoPi<float> / segments;
    auto prevPoint = position + Vector3{radius, 0, 0};

    auto colorVector = color.ToVector4();

    for (int i = 0; i < segments; ++i) {
        auto rad = centralAngle * static_cast<float>(i + 1);
        auto cos = std::cos(rad.value);
        auto sin = std::sin(rad.value);
        auto nextPoint = position + Vector3{radius * Vector2{cos, sin}, 0};
        DrawTriangle(nextPoint, prevPoint, position,
            colorVector, colorVector, colorVector);
        prevPoint = nextPoint;
    }
}
开发者ID:mogemimi,项目名称:pomdog,代码行数:35,代码来源:PolygonShapeBuilder.cpp

示例10: DrawTriangle

void NCLDebug::DrawPolygon(int n_verts, const Vector3* verts, const Vector4& colour)
{
	for (int i = 2; i < n_verts; ++i)
	{
		DrawTriangle(verts[0], verts[i - 1], verts[i], colour);
	}
}
开发者ID:p10petr,项目名称:Team-Project-Newcastle,代码行数:7,代码来源:NCLDebug.cpp

示例11: DrawEnemyBullet

//敵弾の表示
void DrawEnemyBullet(){
	for(int i=0; i<EnemyBulletNum; i++)
		if(EnemyBullet[i].flag == true){
			DrawLine((int)EnemyBullet[i].x, (int)EnemyBullet[i].y, (int)EnemyBullet[i].x, (int)(EnemyBullet[i].y-10), GetColor(255,0,0));
			DrawTriangle((int)EnemyBullet[i].x, (int)(EnemyBullet[i].y+5), (int)(EnemyBullet[i].x-3), (int)EnemyBullet[i].y, (int)(EnemyBullet[i].x+3), (int)EnemyBullet[i].y, GetColor(255, 0, 0), TRUE);
		}
}
开发者ID:TetsuyaNegishi,项目名称:invader,代码行数:8,代码来源:EnemyBullet.cpp

示例12: __MAX

/**
 * Create the region for an OSD slider.
 * Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON
 */
static subpicture_region_t *OSDIcon(int type, const video_format_t *fmt)
{
    const float size_ratio   = 0.05;
    const float margin_ratio = 0.07;

    const int size   = __MAX(fmt->i_visible_width, fmt->i_visible_height);
    const int width  = size * size_ratio;
    const int height = size * size_ratio;
    const int x      = fmt->i_x_offset + fmt->i_visible_width - margin_ratio * size - width;
    const int y      = fmt->i_y_offset                        + margin_ratio * size;

    subpicture_region_t *r = OSDRegion(__MAX(x, 0),
                                       __MIN(y, (int)fmt->i_visible_height - height),
                                       width, height);
    if (!r)
        return NULL;

    if (type == OSD_PAUSE_ICON) {
        int bar_width = width / 3;
        DrawRect(r, STYLE_FILLED, 0, 0, bar_width - 1, height -1);
        DrawRect(r, STYLE_FILLED, width - bar_width, 0, width - 1, height - 1);
    } else if (type == OSD_PLAY_ICON) {
        int mid   = height >> 1;
        int delta = (width - mid) >> 1;
        int y2    = ((height - 1) >> 1) * 2;
        DrawTriangle(r, STYLE_FILLED, delta, 0, width - delta, y2);
    } else {
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:31,代码来源:video_widgets.c

示例13: BulletPolygon

void NS_DIM_PREFIX BulletPolygon(DOUBLE *points, INT nb, DOUBLE intensity, long color)
{
  DOUBLE z0, z1, z2;
  POINT p0, p1, p2;
  INT k;

  p0.x = (INT)((*points++) - XShift + 0.5);
  p0.y = (INT)((*points++) - YShift + 0.5);
  if (BulletDim == 3)
    z0   = *points++;
  else
    z0 = 0.0;
  for (k = 1; k < nb-1; k++) {
    p1.x = (INT)((*points++) - XShift + 0.5);
    p1.y = (INT)((*points++) - YShift + 0.5);
    if (BulletDim == 3)
      z1 = *points++;
    else
      z1 = 0.0;
    p2.x = (INT)((*points++) - XShift + 0.5);
    p2.y = (INT)((*points++) - YShift + 0.5);
    if (BulletDim == 3)
      z2 = *points;
    else
      z2 = 0.0;
    points -= 2;
    DrawTriangle(p0, z0, p1, z1, p2, z2, intensity, color);
  }
}
开发者ID:rolk,项目名称:ug,代码行数:29,代码来源:bullet.c

示例14: dc

void CSplitterControlEx::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	CRect rtClient;
	GetClientRect(rtClient);

	CRect rtButton;

	if (m_nType == SPS_VERTICAL)
	{
		rtButton = rtClient;
		rtButton.top = rtClient.Height()/2 - 25;
		rtButton.bottom = rtClient.Height()/2 + 25;
	}

	if(m_nType == SPS_HORIZONTAL)
	{
		rtButton = rtClient;
		rtButton.left = rtClient.Width()/2 - 25;
		rtButton.right = rtClient.Width()/2 + 25;
	}

	m_rtBtn = rtButton;

	Draw(&dc, rtClient);

	if(m_bHover)
	{
		if(m_bPress)
		{
			dc.FillSolidRect(rtButton, RGB(123, 30, 30));
			DrawTriangle(&dc, rtButton, RGB(155, 85, 85), !m_nflag);
		}
		else
		{
			dc.FillSolidRect(rtButton, RGB(249, 177, 25));	//RGB(90, 13, 13)
			DrawTriangle(&dc, rtButton, RGB(153, 0, 0), !m_nflag);	//RGB(242, 233, 233)
		}
	}
	else
	{
		dc.FillSolidRect(rtButton, RGB(162, 40, 40));
		DrawTriangle(&dc, rtButton, RGB(242, 233, 233), !m_nflag);
	}
}
开发者ID:techpub,项目名称:archive-code,代码行数:46,代码来源:SplitterControlEx.cpp

示例15: q0

void dSceneRender::DrawCylinder(int segments, dFloat radius, dFloat heigh)
{
	dVector q0 ( heigh / 2.0f, radius, 0.0f, 0.0f);
	dVector q1 (-heigh / 2.0f, radius, 0.0f, 0.0f);
	dMatrix rotation (dPitchMatrix(2.0f * 3.1614f/segments));
	dVector cap0[1024];
	dVector cap1[1024];
	dAssert (segments < sizeof (cap0)/sizeof (cap0[0]));
	cap0[segments] = q0;
	cap1[segments] = q1;
	for (int i = 0; i < segments; i ++) {
		cap0[i] = q0;
		cap1[i] = q1;
		q0 = rotation.RotateVector(q0);
		q1 = rotation.RotateVector(q1);
	}
	dVector normal0 ( 1.0f, 0.0f, 0.0f, 0.0f);
	dVector normal1 (-1.0f, 0.0f, 0.0f, 0.0f);

	BeginTriangle();	
	for (int i = 2; i < segments; i ++) {
		SubmitNormal(normal0);
		DrawTriangle(cap0[0], cap0[i-1], cap0[i]);

		SubmitNormal(normal1);
		DrawTriangle(cap1[0], cap1[i], cap1[i - 1]);
	}

	for (int i = 0; i < segments; i ++) {
		dVector p0 (cap0[i]);
		dVector p1 (cap0[i + 1]);
		dVector p2 (cap1[i + 1]);
		dVector p3 (cap1[i]);

		dVector normal ((p1 - p0) * (p2 - p0));
		normal = normal.Scale (1.0f / dSqrt(normal % normal));

		SubmitNormal(normal);
		DrawTriangle(p0, p2, p1);

		SubmitNormal(normal);
		DrawTriangle(p0, p3, p2);
	}
	End();	
}
开发者ID:Hurleyworks,项目名称:MiniNewton,代码行数:45,代码来源:dSceneRender.cpp


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