void MipMapGenerator::generateMipMapDesktop (gdx_cpp::graphics::Pixmap::ptr pixmap,int textureWidth,int textureHeight,bool disposePixmap) { if (Gdx::graphics->isGL20Available() && (Gdx::graphics->supportsExtension("GL_ARB_framebuffer_object") || Gdx::graphics ->supportsExtension("GL_EXT_framebuffer_object"))) { Gdx::gl->glTexImage2D(GL_TEXTURE_2D, 0, pixmap->getGLInternalFormat(), pixmap->getWidth(), pixmap->getHeight(), 0, pixmap->getGLFormat(), pixmap->getGLType(), pixmap->getPixels()); Gdx::gl20->glGenerateMipmap(GL_TEXTURE_2D); if (disposePixmap) pixmap->dispose(); } else if (Gdx::graphics->supportsExtension("GL_SGIS_generate_mipmap")) { if ((Gdx::gl20 == NULL) && textureWidth != textureHeight) { throw std::runtime_error("texture width and height must be square when using mipmapping in OpenGL ES 1.x"); } Gdx::gl->glTexParameterf(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); Gdx::gl->glTexImage2D(GL_TEXTURE_2D, 0, pixmap->getGLInternalFormat(), pixmap->getWidth(), pixmap->getHeight(), 0, pixmap->getGLFormat(), pixmap->getGLType(), pixmap->getPixels()); if (disposePixmap) pixmap->dispose(); } else { generateMipMapCPU(pixmap, textureWidth, textureHeight, disposePixmap); } }
void MipMapGenerator::generateMipMapGLES20 (gdx_cpp::graphics::Pixmap::ptr pixmap,bool disposePixmap) { Gdx::gl->glTexImage2D(GL_TEXTURE_2D, 0, pixmap->getGLInternalFormat(), pixmap->getWidth(), pixmap->getHeight(), 0, pixmap->getGLFormat(), pixmap->getGLType(), pixmap->getPixels()); Gdx::gl20->glGenerateMipmap(GL_TEXTURE_2D); if (disposePixmap) pixmap->dispose(); }