void SpectraDefaultGPUMatrixTransf::BeginBatch() { using namespace oglplus; gl_canvas->SetCurrent(*gl_context); transf_prog.Use(); Texture::Active(0); matrix_tex.Bind(Texture::Target::Buffer); prog_matrix_data.Set(0); Texture::Active(1); input_tex.Bind(Texture::Target::Buffer); prog_input_data.Set(1); prog_input_size.Set(int(in_size)); vao.Bind(); Context gl; gl.Enable(Capability::RasterizerDiscard); }
Example(std::size_t w, std::size_t h) : width(w) , height(h) , font_file("fonts", "FreeSans", ".ttf") , font(font_file) { using namespace oglplus; tex.Bind(TextureTarget::Rectangle); fbo.Bind(FramebufferTarget::Read); PrepareText(); }
//------------------------------------------------------------------------------ oglplus::Texture Example::MakePalette(void) { oglplus::Texture palette; oglplus::Texture::Active(0); palette.Bind(oglplus::TextureTarget::_1D); GeneratePaletteImage(); oglplus::Texture::MinFilter(oglplus::TextureTarget::_1D, oglplus::TextureMinFilter::Linear); oglplus::Texture::MagFilter(oglplus::TextureTarget::_1D, oglplus::TextureMagFilter::Linear); oglplus::Texture::WrapS(oglplus::TextureTarget::_1D, oglplus::TextureWrap::Repeat); oglplus::Texture::WrapT(oglplus::TextureTarget::_1D, oglplus::TextureWrap::Repeat); return palette; }
void LoadBRDFMap(const std::string& filename) { FREE_IMAGE_FORMAT formato = FreeImage_GetFileType(filename.c_str(), 0); FIBITMAP* imagen = FreeImage_Load(formato, filename.c_str()); FIBITMAP* temp = imagen; imagen = FreeImage_ConvertTo24Bits(imagen); FreeImage_Unload(temp); int w = FreeImage_GetWidth(imagen); int h = FreeImage_GetHeight(imagen); GLubyte* textura = new GLubyte[3 * w * h]; memset(textura, 0, 3 * w * h); char* pixeles = (char*)FreeImage_GetBits(imagen); size_t span = FreeImage_GetLine(imagen); for(int y = 0; y < h; y++) { char* pCurrentImageLine = &pixeles[y * span]; GLubyte* pCurrentTextureLine = &textura [y * w * 3]; for(int x = 0; x < w; x++) { pCurrentTextureLine[x * 3 + 2] = pCurrentImageLine[x * 3 + 0]; pCurrentTextureLine[x * 3 + 1] = pCurrentImageLine[x * 3 + 1]; pCurrentTextureLine[x * 3 + 0] = pCurrentImageLine[x * 3 + 2]; } } oglplus::Texture::Active(0); mapTexture.Bind(oglplus::TextureTarget::_2D); oglplus::Texture::Image2D (oglplus::TextureTarget::_2D, 0, oglplus::PixelDataInternalFormat::RGB, w, h, 0, oglplus::PixelDataFormat::RGB, oglplus::DataType::UnsignedByte, textura); oglplus::Texture::MinFilter(oglplus::TextureTarget::_2D, oglplus::TextureMinFilter::Linear); oglplus::Texture::MagFilter(oglplus::TextureTarget::_2D, oglplus::TextureMagFilter::Linear); oglplus::Texture::WrapS(oglplus::TextureTarget::_2D, oglplus::TextureWrap::Repeat); oglplus::Texture::WrapT(oglplus::TextureTarget::_2D, oglplus::TextureWrap::Repeat); delete[] textura; FreeImage_Unload(imagen); }