// draws a single frame static void Render() { // clear everything glClearColor(0, 0, 0, 1); // black glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); std::list<ModelInstance>::const_iterator item; for ( item = gInstances.begin(); item != gInstances.end(); ++item) RenderInstance(*item); // swap the display buffers (displays what was just drawn) glfwSwapBuffers(gWindow); }
void Render(GLFWwindow* window) { // clear everything glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); std::list<ModelInstance>::const_iterator it; for (it = gInstances.begin(); it != gInstances.end(); ++it) { RenderInstance(*it); } glfwSwapBuffers(window); }
// draws a single frame static void Render() { // clear everything glClearColor(0, 0, 0, 1); // black glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // render all the instances std::list<ModelInstance>::const_iterator it; for(it = gInstances.begin(); it != gInstances.end(); ++it){ RenderInstance(*it, gCamera.matrix()); } // swap the display buffers (displays what was just drawn) glfwSwapBuffers(); }
void World::RenderGroup(SceneGroup *i, mat4 t) { int ii, time = 0; // sphere vars double r; MaterialInfo m; // light vars LightInfo l; // camera vars CameraInfo f; // if this is a terminal node if (i->getChildCount() == 0) { // if this node is a sphere if (i->computeSphere(r,m,time)) { _spheres.push_back(Sphere(vec4(0,0,0,1), r, m, t)); } else if (i->computeLight(l)) { if (l.type == LIGHT_POINT) { _lights[l.type].push_back(Light(vec3(t*vec4(0,0,0,1),VW),0, l)); }else if (l.type == LIGHT_DIRECTIONAL){ _lights[l.type].push_back(Light(0,vec3(t*vec4(0,0,-1,0),VW), l)); }else if (l.type == LIGHT_AMBIENT) _ambientLight = l.color; } else if (i->computeCamera(f)) { vec4 eye(0.0, 0.0, 0.0, 1.0); vec4 LL(f.sides[FRUS_LEFT], f.sides[FRUS_BOTTOM], -1*f.sides[FRUS_NEAR], 1.0); vec4 UL(f.sides[FRUS_LEFT], f.sides[FRUS_TOP], -1*f.sides[FRUS_NEAR], 1.0); vec4 LR(f.sides[FRUS_RIGHT], f.sides[FRUS_BOTTOM], -1*f.sides[FRUS_NEAR], 1.0); vec4 UR(f.sides[FRUS_RIGHT], f.sides[FRUS_TOP], -1*f.sides[FRUS_NEAR], 1.0); _view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT); } } else { // expand and traverse this node for(ii=0; ii<i->getChildCount();ii++) RenderInstance(i->getChild(ii), t); } }
void World::loadScene(string filename) { // for as4, you can optionally hard-code the scene. For as5 and as6 it must be loaded from a file. Scene *scene = new Scene(filename); RenderInstance(scene->getRoot(),mat4(vec4(1,0,0,0),vec4(0,1,0,0),vec4(0,0,1,0),vec4(0,0,0,1))); }