int main(){ iso.primitive(Graphics::TRIANGLES); win.create(Window::Dim(800,600), "Rob's Game of Life", 140); win.add(new StandardWindowKeyControls); win.add(new NavInputControl(nav)); Window::startLoop(); }
int main(){ double world_radius = 50; nav.smooth(0.8); lens.near(1).far(world_radius); // set up mesh: mesh.primitive(Graphics::TRIANGLES); double tri_size = 2; int count = 4000; for (int i=0; i<count; i++) { double x = rnd::uniformS(world_radius); double y = rnd::uniformS(world_radius); double z = rnd::uniformS(world_radius); for (int v=0; v<3; v++) { mesh.color(HSV(float(i)/count, v!=2, 1)); mesh.vertex(x+rnd::uniformS(tri_size), y+rnd::uniformS(tri_size), z+rnd::uniformS(tri_size)); } } // set up grid: grid.primitive(Graphics::LINES); double stepsize = 1./2; for (double x=-1; x<=1; x+= stepsize) { for (double y=-1; y<=1; y+= stepsize) { grid.vertex(x, y, 1); grid.vertex(x, y, -1); }} for (double x=-1; x<=1; x+= stepsize) { for (double z=-1; z<=1; z+= stepsize) { grid.vertex(x, 1, z); grid.vertex(x, -1, z); }} for (double y=-1; y<=1; y+= stepsize) { for (double z=-1; z<=1; z+= stepsize) { grid.vertex(1, y, z); grid.vertex(-1, y, z); }} grid.scale(world_radius); // set up cube: cube.color(1,1,1,1); cube.primitive(Graphics::TRIANGLES); addCube(cube); cube.generateNormals(); win.create(Window::Dim(100, 0, 640, 480), "Cube Map FBO Example", 60); win.displayMode(win.displayMode() | Window::STEREO_BUF); win.add(new StandardWindowKeyControls); win.add(new NavInputControl(nav)); MainLoop::start(); return 0; }
int main(){ for(int i=0; i<800; ++i){ int Nv = rnd::prob(0.5) ? (rnd::prob(0.5) ? addCube(shapes) : addDodecahedron(shapes)) : addIcosahedron(shapes); Mat4f xfm; xfm.setIdentity(); xfm.scale(Vec3f(rnd::uniform(1.,0.1), rnd::uniform(1.,0.1), rnd::uniform(1.,0.1))); xfm.translate(Vec3f(rnd::uniformS(8.), rnd::uniformS(8.), rnd::uniformS(8.))); //xfm.rotate(rnd::uniform(), rnd::uniform(), rnd::uniform()); shapes.transform(xfm, shapes.vertices().size()-Nv); for(int i=0; i<Nv; ++i){ float f = float(i)/Nv; shapes.color(HSV(f*0.1+0.2,1,1)); } } shapes.primitive(Graphics::TRIANGLES); shapes.decompress(); shapes.generateNormals(); win1.add(new StandardWindowKeyControls); win1.create(Window::Dim(800, 600)); MainLoop::start(); return 0; }
int main() { win1.add(new StandardWindowKeyControls); win1.create(Window::Dim(800, 600)); MainLoop::start(); return 0; }
int main (int argc, char * const argv[]) { searchpaths.addAppPaths(argc, argv); searchpaths.addSearchPath(searchpaths.appPath() + "../../share"); searchpaths.print(); // load in a "scene" FilePath path = searchpaths.find("ducky.obj"); printf("reading %s\n", path.filepath().c_str()); ascene = Scene::import(path.filepath()); if (ascene==0) { printf("error reading %s\n", path.filepath().c_str()); return -1; } else { ascene->getBounds(scene_min,scene_max); scene_center = (scene_min + scene_max) / 2.f; ascene->dump(); } File frag_file(searchpaths.find("basicFragment.glsl"), "r", true); File vert_file(searchpaths.find("basicVertex.glsl"), "r", true); printf("frag_file %s\n", frag_file.path().c_str()); printf("vert_file %s\n", vert_file.path().c_str()); frag.source(frag_file.readAll(), Shader::FRAGMENT); vert.source(vert_file.readAll(), Shader::VERTEX); win1.add(new StandardWindowKeyControls); win1.create(Window::Dim(640, 480)); Image img(searchpaths.find("hubble.jpg").filepath()); tex.allocate(img.array()); MainLoop::start(); return 0; }
int main(){ { int Nv = addTetrahedron(solids[0]); solids[0].primitive(Graphics::TRIANGLES); for(int i=0; i<Nv; ++i){ float f = float(i)/Nv; solids[0].color(HSV(f*0.2+0.4,1,1)); } solids[0].decompress(); solids[0].generateNormals(); } { int Nv = addCube(solids[1]); solids[1].primitive(Graphics::TRIANGLES); for(int i=0; i<Nv; ++i){ float f = float(i)/Nv; solids[1].color(HSV(f*0.1+0.2,1,1)); } solids[1].decompress(); solids[1].generateNormals(); } { int Nv = addOctahedron(solids[2]); solids[2].primitive(Graphics::TRIANGLES); for(int i=0; i<Nv; ++i){ float f = float(i)/Nv; solids[2].color(HSV(f*0.1+0.1,1,1)); } solids[2].decompress(); solids[2].generateNormals(); } { int Nv = addDodecahedron(solids[3]); solids[3].primitive(Graphics::TRIANGLES); for(int i=0; i<Nv; ++i){ float f = float(i)/Nv; solids[3].color(HSV(f*0.1,1,1)); } solids[3].decompress(); solids[3].generateNormals(); } { int Nv = addIcosahedron(solids[4]); solids[4].primitive(Graphics::TRIANGLES); for(int i=0; i<Nv; ++i){ float f = float(i)/Nv; solids[4].color(HSV(f*0.1 + 0.7,1,1)); } solids[4].decompress(); solids[4].generateNormals(); } win.add(new StandardWindowKeyControls); win.create(); MainLoop::start(); }