CubeExample(void) : n(16) , screen_prog() , draw_prog() , screen(List("Position")("TexCoord").Get(), shapes::Screen(), screen_prog) , cube(List("Position").Get(), shapes::Cube(), draw_prog) { draw_prog.Use(); UniformBlock(draw_prog, "OffsetBlock").Binding(0); cube_pos<< BufferIndexedTarget::Uniform << 0 << BufferUsage::StaticDraw << OffsetData(n); ProgramUniformSampler(screen_prog, "Palette").Set(0); Texture::Active(0); palette << Texture::Target::_1D << TextureFilter::Nearest << TextureWrap::ClampToEdge << images::LinearGradient( 16, Vec3f(0, 0, 0), std::map<GLfloat, Vec3f>({ { 0.0/16.0, Vec3f(0.0, 0.0, 0.0)}, { 1.0/16.0, Vec3f(0.5, 0.0, 1.0)}, { 3.0/16.0, Vec3f(0.0, 0.0, 1.0)}, { 6.0/16.0, Vec3f(0.0, 0.6, 0.6)}, { 8.0/16.0, Vec3f(0.0, 1.0, 0.0)}, { 11.0/16.0, Vec3f(0.6, 0.6, 0.0)}, { 13.0/16.0, Vec3f(1.0, 0.1, 0.0)}, { 16.0/16.0, Vec3f(0.7, 0.0, 0.0)} }) ); ProgramUniformSampler(screen_prog, "Tex").Set(1); Texture::Active(1); tex << Texture::Target::Rectangle << TextureMinFilter::Nearest << TextureMagFilter::Nearest << TextureWrap::ClampToEdge << images::ImageSpec( 64, 64, Format::Red, InternalFormat::R8, DataType::UnsignedByte ); rbo << Renderbuffer::Target::Renderbuffer << images::ImageSpec(64, 64, InternalFormat::DepthComponent); fbo << Framebuffer::Target::Draw << FramebufferAttachment::Color << tex << FramebufferAttachment::Depth << rbo << FramebufferComplete(); gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.ClearDepth(1.0f); gl.Enable(Capability::CullFace); }
DataBuffer(const Program& prog, GLuint tex_unit, GLuint width, GLuint height) { Texture::Active(tex_unit); ProgramUniformSampler(prog, "DataMap").Set(tex_unit); tex << Texture::Target::Rectangle << TextureFilter::Linear << TextureWrap::ClampToEdge << images::ImageSpec( width, height, Format::RGBA, InternalFormat::RGBA32F, PixelDataType::Float ); rbo << Renderbuffer::Target::Renderbuffer << images::ImageSpec(width, height, InternalFormat::DepthComponent32); fbo << Framebuffer::Target::Draw << FramebufferAttachment::Color << tex << FramebufferAttachment::Depth << rbo << FramebufferComplete(); }
DepthBuffer(const Program& prog, GLuint tex_unit, GLuint tex_side) : side(tex_side) { Texture::Active(tex_unit); ProgramUniformSampler(prog, "DepthMap").Set(tex_unit); tex << Texture::Target::_2D << TextureFilter::Nearest << TextureWrap::ClampToEdge << images::ImageSpec( side, side, Format::DepthComponent, InternalFormat::DepthComponent32, PixelDataType::Float ); rbo << Renderbuffer::Target::Renderbuffer << images::ImageSpec(side, side, InternalFormat::R8); fbo << Framebuffer::Target::Draw << FramebufferAttachment::Color << rbo << FramebufferAttachment::Depth << tex << FramebufferComplete(); }