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


C++ VertexShader::Bind方法代码示例

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


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

示例1: DrawTextPrivate


//.........这里部分代码省略.........
					BitmapFont::CharDescriptor charData = font->GetData(renderText.at(i), data.bBold);

					fontWidthNDC = charData.aspectRatio * fontHeightNDC; 

					pData->px = renderCursorX;
					pData->py = data.posY;
					pData->pz = 0.f;
					pData->cx = color.r;
					pData->cy = color.g;
					pData->cz = color.b;
					pData->u = charData.u1;
					pData->v = charData.v1;

					pData++;

					pData->px = renderCursorX + fontWidthNDC;
					pData->py = data.posY;
					pData->pz = 0.f;
					pData->cx = color.r;
					pData->cy = color.g;
					pData->cz = color.b;
					pData->u = charData.u2;
					pData->v = charData.v1;

					pData++;

					pData->px = renderCursorX + fontWidthNDC;
					pData->py = data.posY - fontHeightNDC;
					pData->pz = 0.f;
					pData->cx = color.r;
					pData->cy = color.g;
					pData->cz = color.b;
					pData->u = charData.u2;
					pData->v = charData.v2;

					pData++;

					pData->px = renderCursorX;
					pData->py = data.posY - fontHeightNDC;
					pData->pz = 0.f;
					pData->cx = color.r;
					pData->cy = color.g;
					pData->cz = color.b;
					pData->u = charData.u1;
					pData->v = charData.v2;

					pData++;

					renderCursorX += fontWidthNDC;
				}
			}
		}

		textVB->Unlock();

		// Create index buffer
		IndexBuffer* textIB = gRenderAPI->CreateIndexBuffer(IFMT_16Bit, numQuads*6, NULL, true);
		short* iData = (short*)textIB->Lock();

		int offset = 0;
		for(unsigned int i=0; i<enqueuedTextData.size(); i++)
		{
			if(enqueuedTextData.at(i).useFont == fnt)
			{
				for(unsigned int j=0; j<enqueuedTextData.at(i).text.length(); j++)
				{
					*iData = offset + 4*j + 0; iData++;
					*iData = offset + 4*j + 1; iData++;
					*iData = offset + 4*j + 3; iData++;

					*iData = offset + 4*j + 2; iData++;
					*iData = offset + 4*j + 3; iData++;
					*iData = offset + 4*j + 1; iData++;
				}

				offset += 4*enqueuedTextData.at(i).text.length();
			}
		}

		textIB->Unlock();

		// Vertex shader
		VertexShader* vShader = gRenderManager.GetPassthroughShader(VFMT_P3C3U2, INTERPOLANT_MeshUV | INTERPOLANT_MeshColor);
		vShader->Bind();

		// Pixel shader
		simpleFontPixelShader->SetValues(engineFonts[fnt]->GetTexture(), SamplerState::TrilinearWrap);
		simpleFontPixelShader->Bind();

		gRenderAPI->SetVertexBuffer(0, textVB);
		gRenderAPI->SetIndexBuffer(textIB);
		gRenderAPI->DrawIndexed(TOPOLOGY_TriangleList, numQuads*2);

		// Clean up the buffers
		gRenderAPI->DestroyVertexBuffer(textVB);
		gRenderAPI->DestroyIndexBuffer(textIB);
	}

	gRenderAPI->EndPerfEvent();
}
开发者ID:SakibSaikia,项目名称:RedeyeEngine,代码行数:101,代码来源:RenderManager.cpp


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