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


C++ Args::enableG3DArgs方法代码示例

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


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

示例1: configureShaderArgs

void Earth::configureShaderArgs(RenderDevice* rd) {

	rd->clear();

	rd->pushState();

//	rd->setRenderMode(RenderDevice::RENDER_WIREFRAME); 
	Args args;
	args.enableG3DArgs(true);
	args.setUniform("wsLight", light->position().xyz().direction());
	args.setUniform("lightColor", light->color);
	args.setUniform("wsEyePosition", defaultCamera->frame().translation);

	args.setAttributeArray("texCoord0", gpuTexCoords);
	args.setUniform("textureSampler", tex, Sampler::video());

	args.setAttributeArray("vertex", gpuVerts);
	args.setAttributeArray("normal", gpuNorms);

	args.setIndexStream(gpuIndices);
	args.setPrimitiveType(PrimitiveType::TRIANGLES);
	
	//TODO: Set the attribute arrays and primitive types to draw the geometry
	//      that you created in setupGeometry().
	
	rd->apply(shader, args);	
	
	rd->popState();

}
开发者ID:kennybello,项目名称:EarthquakeVisualization,代码行数:30,代码来源:Earth.cpp

示例2: renderCharVertexArray

void GFont::renderCharVertexArray(RenderDevice* renderDevice, const Array<CPUCharVertex>& cpuCharArray, Array<int>& indexArray) const {

    // Avoid the overhead of Profiler events by not calling LAUNCH_SHADER...
    static const shared_ptr<Shader> fontShader = Shader::getShaderFromPattern("GFont_render.*");

    renderDevice->setBlendFunc(RenderDevice::BLEND_SRC_ALPHA, RenderDevice::BLEND_ONE_MINUS_SRC_ALPHA);
    renderDevice->setCullFace(CullFace::NONE);

    const shared_ptr<VertexBuffer>& vb = VertexBuffer::create((cpuCharArray.size() * sizeof(CPUCharVertex)) + (indexArray.size() * sizeof(int)) + 8, VertexBuffer::WRITE_EVERY_FRAME);

    IndexStream indexStream(indexArray, vb);
    AttributeArray interleavedArray(cpuCharArray.size() * sizeof(CPUCharVertex), vb);

    CPUCharVertex dummy;
#   define OFFSET(field) ((size_t)(&dummy.field) - (size_t)&dummy)
        AttributeArray  texCoordArray   (dummy.texCoord,    cpuCharArray.size(), interleavedArray, OFFSET(texCoord),    sizeof(CPUCharVertex));
        AttributeArray  positionArray   (dummy.position,    cpuCharArray.size(), interleavedArray, OFFSET(position),    sizeof(CPUCharVertex));
        AttributeArray  colorArray      (dummy.color,       cpuCharArray.size(), interleavedArray, OFFSET(color),       sizeof(CPUCharVertex));
        AttributeArray  borderColorArray(dummy.borderColor, cpuCharArray.size(), interleavedArray, OFFSET(borderColor), sizeof(CPUCharVertex));
#   undef OFFSET
    
    CPUCharVertex* dst = (CPUCharVertex*)interleavedArray.mapBuffer(GL_WRITE_ONLY);
    System::memcpy(dst, cpuCharArray.getCArray(), cpuCharArray.size() * sizeof(CPUCharVertex));
    interleavedArray.unmapBuffer();

    Args args;
    args.enableG3DArgs(false); // Lower CPU overhead for uniform bind

    args.setAttributeArray("g3d_Vertex",    positionArray);
    args.setAttributeArray("g3d_TexCoord0", texCoordArray);
    args.setAttributeArray("borderColor",   borderColorArray);    
    args.setAttributeArray("color",         colorArray);
    args.setIndexArray(indexStream);
    args.setPrimitiveType(PrimitiveType::TRIANGLES);

    args.setUniform("g3d_ObjectToScreenMatrixTranspose", RenderDevice::current->objectToScreenMatrix().transpose()); 
    args.setUniform("textureMatrix",        Matrix4(m_textureMatrix));
    args.setUniform("borderWidth",          Vector2(m_textureMatrix[0], m_textureMatrix[5]));
    args.setUniform("textureLODBias",       -0.6f);
    args.setUniform("fontTexture",          m_texture, Sampler::defaults());
    args.setUniform("alphaThreshold",       1.0f / 255.0f);
    args.setUniform("translation",          Vector2(0, 0));
    
    RenderDevice::current->apply(fontShader, args);
}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:45,代码来源:GFont.cpp


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