Texture::Texture(const Image& image, MipmapGeneration mipmapGeneration, TextureFiltering filtering, bool clamp, const GLInfo& glInfo)
{
   glGenTextures(1, &id);

   Bind();

   bool linearFiltering = (filtering == TextureFiltering::Linear);

   GLint minFilterParam;

   if (mipmapGeneration == MipmapGeneration::None)
   {
      minFilterParam = linearFiltering ? GL_LINEAR : GL_NEAREST;
   }
   else
   {
      minFilterParam = linearFiltering ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR;
   }

   GLint magFilterParam = linearFiltering ? GL_LINEAR : GL_NEAREST;

   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilterParam);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilterParam);

   GenerateMipmaps(image, mipmapGeneration, glInfo);

   bool doClamp = (clamp && (GLEW_VERSION_1_2 || glewIsExtensionSupported("GL_EXT_texture_edge_clamp")));

   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, doClamp ? GL_CLAMP_TO_EDGE : GL_REPEAT);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, doClamp ? GL_CLAMP_TO_EDGE : GL_REPEAT);
}
void Texture::GenerateMipmaps(const Image& image, MipmapGeneration mipmapGeneration, const GLInfo& glInfo) const
{
   Texture::SetUnpackAlignmentForPixelComponents(image.NumPixelComponents());

   Texture::SendTextureData(image, 0);

   if (mipmapGeneration == MipmapGeneration::Manual)
   {
      GenerateManualMipmaps(image);
      return;
   }

   if (mipmapGeneration == MipmapGeneration::GLGenerateMipMap)
   {
      GLInfo::Vendor vendor = glInfo.GetVendor();

      if ((vendor == GLInfo::Vendor::Microsoft) || (vendor == GLInfo::Vendor::Unknown))
      {
         GenerateMipmapsLegacy(image);
         return;
      }

      bool vendorIsATI = (vendor == GLInfo::Vendor::ATI);

      if (GLEW_VERSION_3_0)
      {
         if (vendorIsATI)
         {
            glEnable(GL_TEXTURE_2D);
         }

         glGenerateMipmap(GL_TEXTURE_2D);
         return;
      }

      if (GLEW_VERSION_2_1 && glewIsExtensionSupported("GL_EXT_framebuffer_object"))
      {
         if (vendorIsATI)
         {
            glEnable(GL_TEXTURE_2D);
         }

         glGenerateMipmapEXT(GL_TEXTURE_2D);
         return;
      }
   }

   if (mipmapGeneration == MipmapGeneration::None)
   {
      return;
   }

   GenerateMipmapsLegacy(image);
}
	void OpenGLRenderManager::initialise(OpenGLImageLoader* _loader)
	{
		MYGUI_PLATFORM_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice");
		MYGUI_PLATFORM_LOG(Info, "* Initialise: " << getClassTypeName());

		mVertexFormat = VertexColourType::ColourABGR;

		mUpdate = false;
		mImageLoader = _loader;

		glewInit();

		mPboIsSupported = glewIsExtensionSupported("GL_EXT_pixel_buffer_object") != 0;

		MYGUI_PLATFORM_LOG(Info, getClassTypeName() << " successfully initialized");
		mIsInitialise = true;
	}
Exemple #4
0
bool ceDeviceGL20::CheckExtension (const char* extension)
{
  return glewIsExtensionSupported (extension);
}