Jump to content
  • Advertisement
Sign in to follow this  
Chaotis

OpenGL Getting Useful System Information

This topic is 4676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've looked around everywhere and posted on several forums but so far I haven't gotten a single useful answer to this: I've been using OpenGL for quite some time now and now want to make my demo's a little smarter in how they set things up. But to do so I want to be able to find information about the current system it's running on and enable/disable things as such. I have no problems with extensions but it's other types of information that I can't find. -RAM/VRAM -Processor speed/maker/cores -Textures per pass -Pixel/Vertex Shader version/pipelines I'm sure there are a few other related ones that just don't come to mind at the moment. I have seen a few ways to get this information on DX but that's why I posted it here in the OpenGL forum. So far I haven't been able to find any functions in OpenGL to get this kind of information but if there are any other supplementary libraries that would do it I would be just as happy. Thanks in advance for any help. ~Chao

Share this post


Link to post
Share on other sites
Advertisement
Here's some code from my engine (it may not compile as it is btw) :


bool cRender::Init(void)
{

//
// Recuperation des ecrans et modes d'affichages disponibles
//
DISPLAY_DEVICE display;
int displaynum = 0;
memset(&display, 0, sizeof(display));
display.cb = sizeof(display);

// Liste des moniteurs installes
while(EnumDisplayDevices(NULL, displaynum++, &display, NULL))
{
// Moniteur de rendu
if (display.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
{
// DebugManager->Print(Debug, __FUNCTION__, "%s", display.DeviceString);

DEVMODE devmode;
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(devmode);
int num = 0;
while (EnumDisplaySettings(display.DeviceName, num++, &devmode))
{
if (devmode.dmBitsPerPel >=16 && devmode.dmPelsWidth >= 640 && devmode.dmPelsHeight >= 480)
{
ScreenModes.push_back(devmode);
// DebugManager->Print(Debug, __FUNCTION__, "%ix%ix%i@%i",
// devmode.dmPelsWidth, devmode.dmPelsHeight, devmode.dmBitsPerPel, devmode.dmDisplayFrequency);
}
}
}
}




//
// matrix stack
//
glGetIntegerv(GL_MATRIX_MODE, &val); // Initial matrix mode
int val = 0;
char *txt = NULL;
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &val);
log << "<b>GL_MAX_MODELVIEW_STACK_DEPTH</b> = " << val << NewLine;

glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &val);
log << "<b>GL_MAX_PROJECTION_STACK_DEPTH</b> = " << val << NewLine;

glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &val);
log << "<b>GL_MAX_TEXTURE_STACK_DEPTH</b> = " << val << NewLine;


//
// Infos sur la carte graphique
//
txt = (char *)glGetString(GL_VENDOR);
log << "<b>GL_VENDOR</b> = " << txt << NewLine;

txt = (char *)glGetString(GL_RENDERER);
log << "<b>GL_RENDERER</b> = " << txt << NewLine;

txt = (char *)glGetString(GL_VERSION);
log << "<b>GL_VERSION</b> = " << txt << NewLine;

txt = (char *)glGetString(GL_SHADING_LANGUAGE_VERSION);
log << "<b>GL_SL_VERSION</b> = " << txt << NewLine;

txt = (char *)glGetString(GL_EXTENSIONS );
log << "<b>GL_EXTENSIONS</b> = " << txt << NewLine;
log << wglGetExtensionsStringEXT();


//
// Initialisation de toutes les extensions
egl_InitExtensions();
ewgl_InitExtensions();

// ARB_vertex_buffer_object
if (EGL_HAS_GL_ARB_vertex_buffer_object)
{
DeviceCaps.HasVBO = true;
log << "ARB_vertex_buffer_object supported." << NewLine;
}

// GL_EXT_compiled_vertex_array
if (EGL_HAS_GL_EXT_compiled_vertex_array)
{
DeviceCaps.HasCVA = true;
log << "GL_EXT_compiled_vertex_array supported." << NewLine;
}

// ARB_vertex_program
if (EGL_HAS_GL_ARB_vertex_program)
{
DeviceCaps.HasVertexProgram = true;
log << "ARB_vertex_program supported." << NewLine;
}

// ARB_fragment_program
if (EGL_HAS_GL_ARB_fragment_program)
{
DeviceCaps.HasFragmentProgram = true;
log << "ARB_fragment_program supported." << NewLine;
}

// Transpose Matrix
if (EGL_HAS_GL_ARB_transpose_matrix)
{
HasTransposeMatrix = true;
log << "ARB_transpose_matrix supported." << NewLine;
}

// Transpose Matrix
if (EGL_HAS_GL_ARB_shader_objects)
{
DeviceCaps.HasShaderObjects = true;
log << "GL_ARB_shader_objects supported." << NewLine;
}


// Texture's part
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint *)param); // Max texture units
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)param); // Max texture size
glGetIntegerv(GL_MAX_LIGHTS, (GLint *)param); // Mas number of lights



// ARB_texture_compression
if (RenderManager->IsExtensionAvailable("ARB_texture_compression"))
{
TextureCompression = true;
log << "ARB_texture_compression supported";

// GL_EXT_texture_compression_s3tc
if (RenderManager->IsExtensionAvailable("GL_EXT_texture_compression_s3tc"))
{
TextureCompressionS3TC = true;
log << "GL_EXT_texture_compression_s3tc supported";
}

// GL_SGIS_generate_mipmap
if (RenderManager->IsExtensionAvailable("GL_SGIS_generate_mipmap"))
{
AutoGenerateMipMap = true;
log << "GL_SGIS_generate_mipmap supported";
}

// GL_EXT_texture_compression_s3tc
if (RenderManager->IsExtensionAvailable("GL_EXT_texture_filter_anisotropic"))
{
log << "GL_EXT_texture_filter_anisotropic supported";
}
}

// GL_EXT_bgra
if (RenderManager->IsExtensionAvailable("GL_EXT_bgra"))
{
BGRAFormat = true;
log << "Native BGRA texture format supported";
}


}

Share this post


Link to post
Share on other sites
And the hardware's part


string txt;

OSVERSIONINFOEX version;
memset(&version, 0, sizeof(OSVERSIONINFOEX));
version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (GetVersionEx((OSVERSIONINFO *)&version))
{
switch(version.dwPlatformId)
{
// Famille NT
case VER_PLATFORM_WIN32_NT:
{
if ( version.dwMajorVersion == 5 && version.dwMinorVersion == 2 )
txt = "Microsoft Windows Server 2003 family";

if ( version.dwMajorVersion == 5 && version.dwMinorVersion == 1 )
txt = "Microsoft Windows XP";

if ( version.dwMajorVersion == 5 && version.dwMinorVersion == 0 )
txt = "Microsoft Windows 2000";

if ( version.dwMajorVersion <= 4 )
txt = "Microsoft Windows NT";

// Service pack ?
if (version.szCSDVersion) txt += version.szCSDVersion;

}
break;

// Famille 9x
case VER_PLATFORM_WIN32_WINDOWS:
{
if (version.dwMajorVersion == 4 && version.dwMinorVersion == 0)
{
txt = "Microsoft Windows 95 ";
if ( version.szCSDVersion[1] == 'C' || version.szCSDVersion[1] == 'B' )
txt += "OSR2";
}

if (version.dwMajorVersion == 4 && version.dwMinorVersion == 10)
{
txt = "Microsoft Windows 98 ";
if (version.szCSDVersion[1] == 'A') txt += "SE ";
}

if (version.dwMajorVersion == 4 && version.dwMinorVersion == 90)
{
txt = "Microsoft Windows Millennium Edition";
}
}
break;

default:
txt = "Unknown Operating System !!";
break;
}

}
else
txt = "Unable to gather hardware informations.";

log << txt << ::NewLine;

// Memoire dispo
MEMORYSTATUS statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatus(&statex);
log << "Available memory " << (statex.dwTotalPhys>>20) << "Mo (" << (statex.dwAvailPhys>>20)<< "Mo free)" << ::NewLine;



// Informations sur le(s) processeur(s)
SYSTEM_INFO sinfo;
GetSystemInfo(&sinfo);
log << "Number of processor(s) : " << sinfo.dwNumberOfProcessors;


// Lecture depuis la base de registre
HKEY key;
long result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Hardware\\Description\\System\\CentralProcessor\\0",
0, KEY_QUERY_VALUE, &key);

if (result == ERROR_SUCCESS)
{
txt.reserve(1024);
txt.clear();

// Type de cpu - ProcessorNameString
DWORD size = 1024;
RegQueryValueEx(key, "ProcessorNameString", NULL, NULL, (LPBYTE)txt.c_str(), &size);
log << txt << ::NewLine;

// Identifiant - Identifier
size = 1024;
txt.clear();
RegQueryValueEx(key, "Identifier", NULL, NULL, (LPBYTE)txt.c_str(), &size);
log << txt;

RegCloseKey(key);
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!