bool initTexture() { GLint MaxSampleMaskWords(0); GLint MaxColorTextureSamples(0); GLint MaxDepthTextureSamples(0); GLint MaxIntegerSamples(0); glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &MaxSampleMaskWords); glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &MaxColorTextureSamples); glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &MaxDepthTextureSamples); glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &MaxIntegerSamples); gli::texture2D Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str())); glGenTextures(texture::MAX, &TextureName[0]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); for(std::size_t Level = 0; Level < Texture.levels(); ++Level) { glTexImage2D( GL_TEXTURE_2D, GLint(Level), GL_RGBA8UI, GLsizei(Texture[Level].dimensions().x), GLsizei(Texture[Level].dimensions().y), 0, GL_BGR_INTEGER, GL_UNSIGNED_BYTE, Texture[Level].data()); } glBindTexture(GL_TEXTURE_2D, 0); glm::ivec2 WindowSize(this->getWindowSize()); glBindTexture(GL_TEXTURE_2D, TextureName[texture::RENDERBUFFER]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, WindowSize.x / FRAMEBUFFER_SIZE, WindowSize.y / FRAMEBUFFER_SIZE, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, TextureName[texture::SPLASHBUFFER]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, WindowSize.x / FRAMEBUFFER_SIZE, WindowSize.y / FRAMEBUFFER_SIZE, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glBindTexture(GL_TEXTURE_2D, 0); return this->checkError("initTexture"); }
bool initTexture() { GLint MaxSampleMaskWords(0); GLint MaxColorTextureSamples(0); GLint MaxDepthTextureSamples(0); GLint MaxIntegerSamples(0); glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &MaxSampleMaskWords); glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &MaxColorTextureSamples); glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &MaxDepthTextureSamples); glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &MaxIntegerSamples); gli::texture2d Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str())); gli::gl GL(gli::gl::PROFILE_GL32); glGenTextures(texture::MAX, &TextureName[0]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 3); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gli::gl::format const Format = GL.translate(gli::FORMAT_RGB8_UINT_PACK8, Texture.swizzles()); for(std::size_t Level = 0; Level < Texture.levels(); ++Level) { glTexImage2D(GL_TEXTURE_2D, GLint(Level), Format.Internal, GLsizei(Texture[Level].extent().x), GLsizei(Texture[Level].extent().y), 0, Format.External, Format.Type, Texture[Level].data()); } glm::ivec2 WindowSize(this->getWindowSize()); glBindTexture(GL_TEXTURE_2D, TextureName[texture::RENDERBUFFER]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, WindowSize.x / FRAMEBUFFER_SIZE, WindowSize.y / FRAMEBUFFER_SIZE, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); return this->checkError("initTexture"); }
bool initTexture() { gli::texture2D Texture(gli::loadStorageDDS(glf::DATA_DIRECTORY + TEXTURE_DIFFUSE)); glGenTextures(texture::MAX, &TextureName[0]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); for(std::size_t Level = 0; Level < Texture.levels(); ++Level) { glTexImage2D( GL_TEXTURE_2D, GLint(Level), GL_RGBA8UI, GLsizei(Texture[Level].dimensions().x), GLsizei(Texture[Level].dimensions().y), 0, GL_BGR_INTEGER, GL_UNSIGNED_BYTE, Texture[Level].data()); } glBindTexture(GL_TEXTURE_2D, 0); GLint MaxSampleMaskWords(0); GLint MaxColorTextureSamples(0); GLint MaxDepthTextureSamples(0); GLint MaxIntegerSamples(0); glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &MaxSampleMaskWords); glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &MaxColorTextureSamples); glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &MaxDepthTextureSamples); glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &MaxIntegerSamples); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, TextureName[texture::MULTISAMPLE]); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, MaxIntegerSamples, GL_RGBA8UI, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, GL_TRUE); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); glBindTexture(GL_TEXTURE_2D, TextureName[texture::COLORBUFFER]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); return glf::checkError("initTexture"); }