Archived

This topic is now archived and is closed to further replies.

Zeblar Nagrim

OpenGL OpenGL hardware mode

Recommended Posts

Is there a way to know if you are in software or hardware mode in OpenGL? Of course you can see the diffrence sometimes, but I need a way to check if the user can get hardware acceleration in his computer. Zeblar Nagrim, Lord of Chaos

Share this post


Link to post
Share on other sites
Hi!

You could use the glGetString() function to determine the GL_VENDOR string. If it''s Microsoft (or something similar), then you are running in software mode. Beware, that some people use the SGI OpenGL drivers (which are also software), but their vendor string should also be easy to include in your check. Oh, come to think of it, you can also query the GL_RENDERER string (Don''t know an example return value, though).

Hope this helps,

MK42

Share this post


Link to post
Share on other sites
Hi!

I have never DONE it this way, but I believe that it would be possible to do it this way. Short example:


printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER));


The strings, which are returned should be checked against a list of ''software'' drivers. With OpenGL32.DLL this probably returns ''Microsoft'' (or something similar) as the vendor. Just try it out and see.

Another slight problem occurs with, 3Dfx cards. Some people still don''t have full OpenGL drivers installed. I don''t know whether you bind dynamically to the DLL, or just link to OpenGL32.lib. If you bind dynamically (with LoadLibrary()), then you should also check whether to load the 3Dfx non-ICD driver. It''s called 3dfxvgl.dll or something like that. Or just let the user choose (like most games do, BTW).

Happy coding,

MK42

Share this post


Link to post
Share on other sites
Sorry but I´m a beginner to the Stream I/O Routines.
Please can you show me how you store this information in a char buffer?

Gandalf the White

Share this post


Link to post
Share on other sites
Hi Gandalf!

This is actually NOT stream i/o.

You might just try this:

char buffer[256]; //a bit big, but who cares
strcpy(buffer, glGetString(GL_RENDERER));

glGetString() returns a char*, NULL-terminated string. So, no prob there.

Ciao,

MK42

Share this post


Link to post
Share on other sites
I don''t know the function glGetString so I can''t comment on it but if as you say it returns a char * you should be able to :

    
char *buffer;
buffer = glGetString(GL_VENDOR);

Share this post


Link to post
Share on other sites
This produce the following error:

error C2664: ''strcpy'' : cannot convert parameter 2 from ''const unsigned char *'' to ''const char *''

Strange!

Gandalf the White

Share this post


Link to post
Share on other sites
OOPS!

Then make it:

unsigned char buffer[256];

I think that''ll work. Neuro''s way should also work (again, a cast might be needed) like:

buffer = (char*) glGetString(GL_VENDOR);

It IS returning a string ... you just have to coerce VC++ a bit to interpret it correctly.

Take care,

MK42

Share this post


Link to post
Share on other sites
Hi!

I''m now at home, so I could TRY this in a compiler:

char buffer[256];
strcpy(buffer,(const char *)glGetString(GL_RENDERER));

Alternatively, you can do:

char* buffer;

buffer = (char *)glGetString(GL_RENDERER);

This works ... I know ... I have tried. BTW, I''m not doubting that you know C++. Like I said ... just a bit of coersion needed and VC++ will do as you please. I guess GCC under Linux wouldn''t have cared much about this.

At last,

MK42

Share this post


Link to post
Share on other sites
Another way to do it:

    
PIXELFORMATDESCRIPTOR pfd;
HDC hdc;
int iPixelFormat;

// get the current pixel format index

iPixelFormat = GetPixelFormat(hdc);

// obtain a detailed description of that pixel format

DescribePixelFormat(hdc, iPixelFormat,
sizeof(PIXELFORMATDESCRIPTOR), &pfd);

// check for support:

if ( PFD_GENERIC_ACCELERATED & pfd.dwFlags )
{
//you''ve got hardware acceleration!

}
else
{
//using the generic inplementation

}



Hope that helps.

--TheGoop

Share this post


Link to post
Share on other sites
I made a silly mistake: I forgot (char *). Thank´s MK42. I feel very stupid right now...

Gandalf the White

Share this post


Link to post
Share on other sites
No prob! BTW, TheGoop''s method is probably a lot cleaner (and less error prone). Hmm, I never knew that flag was there ... oh well, you never stop learning.

Happy coding,

MK42

Share this post


Link to post
Share on other sites