本文整理汇总了C++中VertexArray::setElementIndexArray方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexArray::setElementIndexArray方法的具体用法?C++ VertexArray::setElementIndexArray怎么用?C++ VertexArray::setElementIndexArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexArray
的用法示例。
在下文中一共展示了VertexArray::setElementIndexArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
//.........这里部分代码省略.........
planetShader->link();
planetShader->bind();
(*planetShader)["u_Texture"].set1i(1);
planetShader->unbind();
Registry::shaders["planet"] = planetShader;
planetShader = new ShaderProgram("shaders/planet.vert", "shaders/atmosphere.frag");
planetShader->bindAttribLocation("in_Position", 0);
planetShader->bindAttribLocation("in_Normal", 1);
planetShader->bindAttribLocation("in_TextureCoords", 2);
planetShader->bindFragDataLocation("out_Color", 0);
planetShader->link();
planetShader->bind();
(*planetShader)["u_Texture"].set1i(1);
planetShader->unbind();
Registry::shaders["planet-atmosphere"] = planetShader;
// ----- Screen quad -----
float quadCoords[] = {0, 0, 1, 0, 1, 1, 0, 1};
unsigned int quadIndices[] = {0, 1, 3, 3, 1, 2};
VertexArray *quadVao = new VertexArray(VertexArray::Triangles, 6);
Buffer *quadCoordsBuffer = new Buffer(Buffer::Array, Buffer::StaticDraw);
quadCoordsBuffer->data(8 * sizeof(float), reinterpret_cast<const void*>(quadCoords));
Buffer *quadIndicesBuffer = new Buffer(Buffer::ElementArray, Buffer::StaticDraw);
quadIndicesBuffer->data(6 * sizeof(unsigned int), reinterpret_cast<const void*>(quadIndices));
quadVao->addAttrib(0, VertexAttrib(quadCoordsBuffer, 2, VertexAttrib::Float));
quadVao->setElementIndexArray(ElementIndexArray(quadIndicesBuffer));
Registry::screenQuad = quadVao;
// ----- Spaceship -----
Registry::textures["ship-diffuse"] = loadPngTexture("textures/ship-diffuse.png", true);
Registry::textures["ship-emit"] = loadPngTexture("textures/ship-emit.png", true);
Registry::textures["ship-normal"] = loadPngTexture("textures/ship-normal.png", true);
Registry::textures["ship-specular"] = loadPngTexture("textures/ship-specular.png", true);
Registry::models["ship"] = loadCobjModel("models/ship.cobj");
ShaderProgram *shipShader = new ShaderProgram("shaders/ship.vert", "shaders/default.frag");
shipShader->bindAttribLocation("in_Position", 0);
shipShader->bindAttribLocation("in_Normal", 1);
shipShader->bindAttribLocation("in_TextureCoords", 2);
shipShader->bindAttribLocation("in_Tangent", 3);
shipShader->bindFragDataLocation("out_Color", 0);
shipShader->link();
Registry::shaders["ship"] = shipShader;
shipShader->bind();
(*shipShader)["u_DiffuseTexture"].set1i(1);
(*shipShader)["u_NormalTexture"].set1i(2);
(*shipShader)["u_EmitTexture"].set1i(3);
(*shipShader)["u_SpecularTexture"].set1i(4);
shipShader->unbind();
// ----- Overlay -----
ShaderProgram *overlayShader = new ShaderProgram("shaders/overlay.vert", "shaders/overlay.frag");
overlayShader->bindAttribLocation("in_Position", 0);
overlayShader->bindFragDataLocation("out_Color", 0);