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