static void make_fb() { // tcol is a 2D RGB texsize x texsize texture // RGB is a constant that represents 8-bit RGB texture // See the definition of TexFormat enum in texture.h for other values allowed. // Stencil may require new hardware/drivers to work properly. tcol = new Texture(RGB,texsize,texsize); // tdepth is a depth texture, i.e. it stores depth values as the values of texels. tdepth = new Texture(Depth,texsize,texsize); // allocate new Framebuffer fb = new Framebuffer; // attach color and depth textures to it; the tcol texture will play the role of color // buffer and tdepth - of the depth buffer. fb->attachColor(tcol); fb->attachDepth(tdepth); // Print out the status of the frame buffer. In particular, if the textures are of // wrong type/format, the framebuffer will not be `complete', i.e. suitable for // rendering into it. If this is the case, you should get a message complaining // about it in the terminal. For example, it is wrong to use a color texture as // the depth texture or the other way around. The restrictions are mostly common // sense. See specification for more details. fb->printLog(); }
void initializeGL() { vec2 qbuf[4]; qbuf[0] = vec2(-1,-1); qbuf[1] = vec2(1,-1); qbuf[2] = vec2(-1,1); qbuf[3] = vec2(1,1); Buffer *q = new Buffer(4,qbuf); vaQuad = new VertexArray; vaQuad->attachAttribute(0,q); pgmPhong = Program::createProgram(ShaderFile(Vert,"dpeel-shaders/vtxPhong.glsl"), ShaderFile(Frag,"dpeel-shaders/frgPhong.glsl")); pgmQuad = Program::createProgram(ShaderFile(Vert,"dpeel-shaders/vtxQuad.glsl"), ShaderFile(Frag,"dpeel-shaders/frgQuad.glsl")); Mesh M(getArgv()[1]); center = M.getCenter(); mx = M.getUpperCorner(); mn = M.getLowerCorner(); maxdim = M.getMaxDim(); ts = M.getTriangleCount(); vloc = new Buffer(M.getVertexCount(),M.getVertexTable()); vnormal = new Buffer(M.getVertexCount(),M.getVertexNormals()); ix = new IndexBuffer(M.getTriangleCount(),M.getTriangleTable()); vaGouraudPhong = new VertexArray(); vaGouraudPhong->attachAttribute(0,vloc); vaGouraudPhong->attachAttribute(1,vnormal); glDisable(GL_CULL_FACE); glClearColor(0.0, 0.0, 0.0, 0.0); glClearDepth(0.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); texsize = 800; fb = new Framebuffer; tex_depth[0] = new Texture(Depth,texsize,texsize); // clear tex_depth[1] = new Texture(Depth,texsize,texsize); tex_color = new Texture(RGBA,texsize,texsize); fb->attachDepth(tex_depth[0]); glClearDepth(1.0); fb->attachColor(tex_color); tex_color->bind(1); tex_depth[0]->nearest(); tex_depth[1]->nearest(); tex_color->nearest(); beginMenu(); addMenuEntry("Peeling",do_peel); addMenuEntry("Naive",do_naive); endMenu(); glutAttachMenu(GLUT_RIGHT_BUTTON); glGenQueries(1,&query); }