Skip to content

Instantly share code, notes, and snippets.

@mattnewport
Created November 10, 2014 23:08
Show Gist options
  • Save mattnewport/1352a031be58bde028c0 to your computer and use it in GitHub Desktop.
Save mattnewport/1352a031be58bde028c0 to your computer and use it in GitHub Desktop.
Simple Mesh initialization
#include <vector>
using namespace std;
struct Vector3 { float x, y, z; };
struct Mesh {
vector<Vector3> positions;
vector<int> indices;
};
int main() {
// initialize a Mesh with explicit verts and indices
Mesh myMesh { { { 0.f, 0.f, 0.f }, { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f } },
{ 0, 1, 2 } };
// initialize a Mesh with iterator pairs
Mesh mySecondMesh { { begin(myMesh.positions), end(myMesh.positions) },
{ begin(myMesh.indices), end(myMesh.indices) } };
// initialize a Mesh as a copy of an existing mesh
Mesh myThirdMesh = myMesh;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment