Войти
ПрограммированиеФорумГрафика

Как узнать версию драйверов в OpenGL?

#0
10:14, 18 дек. 2006

Как узнать версию драйверов в OpenGL?
Или можно пользоваться только версией OpenGL?
Можно ли точно сказать что если версия OpenGL подходящая то и дрова нормальные?


#1
11:33, 18 дек. 2006

Pa3DBaKp9IK

Ты являешься счастливым обладателем базы данных драйверов (как уже выпущенных, так и грядущих) всех вендоров? Если нет, то о чем тебе поведает версия драйвера?

#2
11:33, 18 дек. 2006
#pragma once


//----------------------------------------------------------------------------------------------------

class leu_hwinfo
{
private:
  bool enabled;

  float max_anisolevel;
  bool npot_textures_support;
  bool glsl_vp_support;
  bool glsl_fp_support;
  bool arb_vp_support;
  bool arb_fp_support;
  bool cubemap_support;
  bool vbo_support;
  bool point_sprite_support;
  bool gen_mipmap_support;
  bool rect_textures_support;
  std::string path_to_icd;
  std::string icd_version;
  bool fp_framebuffer_support;
  bool fp_fsaa_support;
  bool fp_textures_support;
  bool fsaa_support;
  bool occlusion_query_support;
  enum leu_hwi_osv
  {
    LEU_HWI_WINNT4,
    LEU_HWI_WIN2K,
    LEU_HWI_WINXP,
    LEU_HWI_WIN2003,
    LEU_HWI_UNKNOWN_WIN
  } os_version;
  unsigned int os_build;
  DWORD os_version_major, os_version_minor;
  DWORD os_servicepack_major, os_servicepack_minor;
  enum gl_vendor
  {
    VN_UNKNOWN,
    VN_NVIDIA,
    VN_ATI,
  } vendor;
  DWORD icd_version_major, icd_version_minor;
  bool fbo_support;
  bool i3d_textures_support;

public:
  leu_hwinfo();
  virtual ~leu_hwinfo();

  void reset();
  void enable();
  void collect_os();
  bool is_nt() const;
  void collect_gl();
  void dump() const;
  bool hardware_check() const;

  bool get_rect_texture_support() const;
  bool get_fbo_support() const;
  float get_aniso_level() const;
  bool get_3d_texture_support() const;

};


//----------------------------------------------------------------------------------------------------

#include "system/pchg.h"
#include "components/leu_hwinfo.h"

using std::string;

//----------------------------------------------------------------------------------------------------
leu_hwinfo::leu_hwinfo()
{
  reset();
}
//----------------------------------------------------------------------------------------------------
leu_hwinfo::~leu_hwinfo()
{
}
//----------------------------------------------------------------------------------------------------
void leu_hwinfo::reset()
{
  enabled=false;
  max_anisolevel=0.0f;
  npot_textures_support=false;;
  glsl_vp_support=false;
  glsl_fp_support=false;
  arb_vp_support=false;
  arb_fp_support=false;
  cubemap_support=false;
  vbo_support=false;
  point_sprite_support=false;
  gen_mipmap_support=false;
  rect_textures_support=false;
  path_to_icd=UNDEFINE_STRING;
  icd_version=UNDEFINE_STRING;
  fp_framebuffer_support=false;
  fp_fsaa_support=false;
  fp_textures_support=false;
  fsaa_support=false;
  occlusion_query_support=false;
  os_version=LEU_HWI_UNKNOWN_WIN;
  os_build=0;
  os_version_major=0; os_version_minor=0;
  os_servicepack_major=0; os_servicepack_minor=0;
  vendor=VN_UNKNOWN;
  icd_version_major=0; icd_version_minor=0;
  fbo_support=false;
  i3d_textures_support=false;
}
//----------------------------------------------------------------------------------------------------
void leu_hwinfo::collect_os()
{
  //определяем версию ОС, в которой запущен движок
  OSVERSIONINFOEX osv;
  osv.dwOSVersionInfoSize=sizeof(OSVERSIONINFOEX);
  if(GetVersionEx((LPOSVERSIONINFOA)(&osv))!=NULL)
  {
    if(osv.dwMajorVersion==5 && osv.dwMinorVersion==2)
      os_version=LEU_HWI_WIN2003;
    else if(osv.dwMajorVersion==5 && osv.dwMinorVersion==1)
      os_version=LEU_HWI_WINXP;
    else if(osv.dwMajorVersion==5 && osv.dwMinorVersion==0)
      os_version=LEU_HWI_WIN2K;
    else if(osv.dwMajorVersion==4 && osv.dwMinorVersion==0)
      os_version=LEU_HWI_WINNT4;
    else
      os_version=LEU_HWI_UNKNOWN_WIN;

    os_build=osv.dwBuildNumber;
    os_version_major=osv.dwMajorVersion;
    os_version_minor=osv.dwMinorVersion;
    os_servicepack_major=osv.wServicePackMajor;
    os_servicepack_minor=osv.wServicePackMinor;

  }
  else
    os_version=LEU_HWI_UNKNOWN_WIN;
}
#3
11:34, 18 дек. 2006
void leu_hwinfo::collect_gl()
{
  const char *glvendor=reinterpret_cast<const char*>( glGetString(GL_VENDOR) );

  //получаем информацию о версии драйвера OpenGL
  //версию драйвера пытаемся определить только для Win2000, WinXP, Win2003Server
  if( is_nt() )  
  {
    try
    {
      //определяем путь к dll драйвера
      char *SystemDir=new char[MAX_PATH];
      GetSystemDirectory(SystemDir,MAX_PATH);
      string ICDdllPath=SystemDir;
      delete[] SystemDir;
      
      const char* nvd="NVIDIA Corporation";
      const char* atid="ATI Technologies Inc";

      if(strstr(glvendor,nvd)!=NULL)
      {
        vendor=VN_NVIDIA;
        ICDdllPath+="\\nvoglnt.dll";
      }
      else if(strstr(glvendor,atid)!=NULL)
      {
        vendor=VN_ATI;
        ICDdllPath+="\\atioglxx.dll";
      }

      if(vendor!=VN_UNKNOWN)
      {
        path_to_icd=ICDdllPath;

        DWORD dummy;
        DWORD size=GetFileVersionInfoSize(ICDdllPath.c_str(),&dummy);
        void* Buf;
        VS_FIXEDFILEINFO *qbuf;
        DWORD len;

        if(size>0)
        {
          Buf = malloc(size);
          GetFileVersionInfo(ICDdllPath.c_str(), 0, size, Buf);

          if(VerQueryValue(Buf, TEXT("\\"), (LPVOID*)(&qbuf), (PUINT)(&len)) )
          {
            //DWORD fms = qbuf->dwFileVersionMS;
            //DWORD fls = qbuf->dwFileVersionLS;
            icd_version_major = qbuf->dwProductVersionMS;
            icd_version_minor = qbuf->dwProductVersionLS;

            icd_version=
              IntToStr(HIWORD(icd_version_major))+"."+
              IntToStr(LOWORD(icd_version_major))+"."+
              IntToStr(HIWORD(icd_version_minor))+"."+
              IntToStr(LOWORD(icd_version_minor));
        
          }
          else
            LOG_STRING(LOG_ERROR,"Cannot execute VerQueryValue. Action cancelled.");

          free(Buf);
        }
        else
          LOG_STRING(LOG_ERROR,"Cannot execute GetFileVersionInfoSize. Action cancelled.");
      }
      else
        LOG_STRING(LOG_WARNING,"Unknown OpenGL vendor for getting information about OpenGL ICD Driver. Action cancelled.");
    }
    catch(...)
    {
      LOG_STRING(LOG_ERROR,"Critical error during getting information about OpenGL ICD Driver. Action cancelled.");
    }
  }
  else
    LOG_STRING(LOG_WARNING,"Cannot get information about OpenGL ICD Driver for current OS version. Action cancelled.");

glewInit();
#pragma warning(disable: 4800)
  gen_mipmap_support=static_cast<bool>( GLEW_SGIS_generate_mipmap );
  vbo_support=static_cast<bool>( GLEW_ARB_vertex_buffer_object );
  cubemap_support=static_cast<bool>( GLEW_ARB_texture_cube_map );
  arb_vp_support=static_cast<bool>( GLEW_ARB_vertex_program );
  arb_fp_support=static_cast<bool>( GLEW_ARB_fragment_program );
  point_sprite_support=static_cast<bool>( GLEW_ARB_point_sprite );
  rect_textures_support=static_cast<bool>(GLEW_NV_texture_rectangle) || static_cast<bool>(GLEW_EXT_texture_rectangle) || static_cast<bool>(GLEW_ARB_texture_rectangle);
  npot_textures_support=static_cast<bool>( GLEW_ARB_texture_non_power_of_two );
  fp_framebuffer_support=( static_cast<bool>( WGLEW_ATI_pixel_format_float ) || static_cast<bool>( WGLEW_ARB_pixel_format ) ) && static_cast<bool>( GLEW_ARB_color_buffer_float );
  fp_fsaa_support=false; //???
  fp_textures_support=static_cast<bool>( GLEW_ATI_texture_float ) || static_cast<bool>( GLEW_ARB_texture_float );
  if(! GLEW_EXT_texture_filter_anisotropic )
    max_anisolevel=0.0f;
  else
    glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisolevel);
  glsl_vp_support=static_cast<bool>( GLEW_ARB_shader_objects ) && static_cast<bool>( GLEW_ARB_shading_language_100 ) && static_cast<bool>( GLEW_ARB_vertex_shader );
  glsl_fp_support=static_cast<bool>( GLEW_ARB_shader_objects ) && static_cast<bool>( GLEW_ARB_shading_language_100 ) && static_cast<bool>( GLEW_ARB_fragment_shader );
  fsaa_support=static_cast<bool>( GLEW_ARB_multisample );
  occlusion_query_support=static_cast<bool>( GLEW_ARB_occlusion_query );
  fbo_support=static_cast<bool>( GLEW_EXT_framebuffer_object );
  i3d_textures_support=static_cast<bool>( GLEW_EXT_texture3D );
#pragma warning(default: 4800)

}
#4
11:34, 18 дек. 2006
//----------------------------------------------------------------------------------------------------
void leu_hwinfo::enable()
{
  enabled=true;
}
//----------------------------------------------------------------------------------------------------
void leu_hwinfo::dump() const
{
  //os
  if(os_version==LEU_HWI_WIN2003)
    LOG_STRING(LOG_NOTE,"OS version: Windows Server 2003");
  else if(os_version==LEU_HWI_WINXP)
    LOG_STRING(LOG_NOTE,"OS version: Windows XP");
  else if(os_version==LEU_HWI_WIN2K)
    LOG_STRING(LOG_NOTE,"OS version: Windows 2000");
  else if(os_version==LEU_HWI_WINNT4)
    LOG_STRING(LOG_NOTE,"OS version: Windows NT 4.0");
  else
  {
    LOG_STRING(LOG_NOTE, "OS version unknown.");
    LOG_NUMBER(LOG_NOTE, "OS major version:", os_version_major);
    LOG_NUMBER(LOG_NOTE, "OS minor version:", os_version_minor);
  }

  LOG_NUMBER(LOG_NOTE, "Build: ", os_build);
  LOG_NUMBER(LOG_NOTE, "Service pack major: ", os_servicepack_major);
  LOG_NUMBER(LOG_NOTE, "Service pack minor: ", os_servicepack_minor);

  //icd
  LOG_2STRING(LOG_NOTE,"Path to OpenGL ICD driver DLL: ", path_to_icd);
  LOG_2STRING(LOG_NOTE,"Driver DLL version:", icd_version);

  if  (
      (vendor==VN_NVIDIA && LOWORD(icd_version_minor)<6600)
      ||
      (vendor==VN_ATI && LOWORD(icd_version_minor)<4955)
    )
  {
    LOG_STRING(LOG_WARNING,"Obsolete video-driver version. Update recommended.");
    MessageBox(NULL, "Obsolete video-driver version. Correct functionality not garranteed.", "Warning", MB_OK);
  }

  LOG_BOOL(LOG_NOTE,"Automatic mipmap generate: ", gen_mipmap_support);
  LOG_BOOL(LOG_NOTE,"Cubemap support: ", cubemap_support);
  LOG_BOOL(LOG_NOTE,"arb_vp support: ", arb_vp_support);
  LOG_BOOL(LOG_NOTE,"arb_fp support: ", arb_fp_support);
  LOG_BOOL(LOG_NOTE,"Point sprites support: ", point_sprite_support);
  LOG_BOOL(LOG_NOTE,"Rect textures support: ", rect_textures_support);
  LOG_BOOL(LOG_NOTE,"Npot textures support: ", npot_textures_support);
  LOG_BOOL(LOG_NOTE,"FP framebuffer support: ", fp_framebuffer_support);
  LOG_BOOL(LOG_NOTE,"FP FSAA support: ", fp_fsaa_support);
  LOG_BOOL(LOG_NOTE,"FP textures support: ", fp_textures_support);
  LOG_NUMBER(LOG_NOTE,"Anisolevel support: ", max_anisolevel);
  LOG_BOOL(LOG_NOTE,"GLSL vp support: ", glsl_vp_support);
  LOG_BOOL(LOG_NOTE,"GLSL FP support: ", glsl_fp_support);
  LOG_BOOL(LOG_NOTE,"Multisampling support: ", fsaa_support);
  LOG_BOOL(LOG_NOTE,"Occlusion query support: ", occlusion_query_support);
  LOG_BOOL(LOG_NOTE,"Cubemap support: ", cubemap_support);
  LOG_BOOL(LOG_NOTE,"Framebufferobject support: ", fbo_support);
  LOG_BOOL(LOG_NOTE,"3D textures support: ", i3d_textures_support);

}
//----------------------------------------------------------------------------------------------------
bool leu_hwinfo::hardware_check() const
{
  const char *glversion=reinterpret_cast<const char*>( glGetString(GL_VERSION) );
  
  if(glversion[0]=='1' && glversion[1]=='.' && glversion[2]<'4')
  {
    LOG_STRING(LOG_ERROR,"Cannot run this program on that hardware, because was detected obsolete OpenGL version. Update hardware strongly recommended.");
    return false;
  }
  
  if(!gen_mipmap_support )
  {
    LOG_STRING(LOG_ERROR,"Cannot run this program on that hardware, because automatic mipmap generation is not support.");
    return false;
  }

  if(!vbo_support )
  {
    LOG_STRING(LOG_ERROR,"Cannot run this program on that hardware, because ARB_vertex_buffer_object is not support.");
    return false;
  }

  if(!cubemap_support )
  {
    LOG_STRING(LOG_ERROR,"Cannot run this program on that hardware, because cubemap textures is not support.");
    return false;
  }

  if(!glsl_vp_support || !glsl_fp_support)
  {
    LOG_STRING(LOG_ERROR,"Cannot run this program on that hardware, because GLSL is not support.");
    return false;
  }

  if(!rect_textures_support )
  {
    LOG_STRING(LOG_ERROR,"Cannot run this program on that hardware, because rect textures is not support.");
    return false;
  }

  if(!fbo_support )
  {
    LOG_STRING(LOG_ERROR,"Cannot run this program on that hardware, because FBO is not support.");
    return false;
  }

  return true;
}
//----------------------------------------------------------------------------------------------------
bool leu_hwinfo::is_nt() const
{
  return
      os_version==leu_hwinfo::LEU_HWI_WIN2K
    ||  os_version==leu_hwinfo::LEU_HWI_WINXP
    ||  os_version==leu_hwinfo::LEU_HWI_WIN2003;
}
//----------------------------------------------------------------------------------------------------
bool leu_hwinfo::get_rect_texture_support() const
{
  return rect_textures_support;
}
//----------------------------------------------------------------------------------------------------
bool leu_hwinfo::get_fbo_support() const
{
  return fbo_support;
}
//----------------------------------------------------------------------------------------------------
float leu_hwinfo::get_aniso_level() const
{
  return max_anisolevel;
}
//----------------------------------------------------------------------------------------------------
bool leu_hwinfo::get_3d_texture_support() const
{
  return i3d_textures_support;
}
//----------------------------------------------------------------------------------------------------

извините за размеры, нету времени выдирать.

#5
11:40, 18 дек. 2006

втихаря копи-пастя, не забываем постить хвалебные песни YgriK'у - изначально это был его код. :)

#6
19:37, 27 дек. 2006

чегото моя девичья ГЛ-память с 97-года такое слабо припоминает, но чегото вроде было еще и для Вин95 :)))

#7
17:33, 5 янв. 2007
void getGlVersion( int *major, int *minor )
{
    const char* verstr = (const char*)glGetString( GL_VERSION );
    if( (verstr == NULL) || (sscanf( verstr, "%d.%d", major, minor ) != 2) )
    {
        *major = *minor = 0;
        fprintf( stderr, "Invalid GL_VERSION format!!!\n" );
    }
}


int gl_major, gl_minor;
getGlVersion(&gl_major, &gl_minor);
printf("GL_VERSION major=%d minor=%d\n", gl_major, gl_minor);
ПрограммированиеФорумГрафика

Тема в архиве.