How do I know if a computer supports OpenGL 2.0? (I want to write shaders)

I'm interested in writing OpenGL shaders, but I'm not sure if my graphics card is good enough to support this, or if my system is configured correctly to use the alternative software (Mesa). How do I know if my computer supports OpenGL shaders? (I am using Ubuntu 10.04). I have tried three tests so far, and I get conflicting answers for each:

1) I downloaded, compiled and successfully executed the OpenGL shader program from the sample code in OpenGL A Primer 3rd Edition located here . However, some other code examples from the same chapter that other OpenGL shaders implement do not start. Some of them even crash my computer or exit window to do funny things with blinking colors, very strange.

2) I ran the following command and got:

$ glxinfo | grep "OpenGL version" OpenGL version string: 1.5 Mesa 7.7.1 

This, apparently, indicates that I am running OpenGL 1.5, but the Mesa version (which, as I understand it, is a software implementation of OpenGL 2.0. Not as fast, but as functional as the real hardware deal) is good enough to run OpenGL 2.0. How can I determine which drive uses my code, OpenGL 1.5 or Mesa 7.7.1?

3) I wrote the code to output the OpenGL version to the computer and received the following output:

 $ ./version OpenGL Version major=1, minor=5 GLSL Version major=0, minor=0 

It says nothing about Mesa and leads me to think that I'm running OpenGL 1.5. Please help me understand which version I'm launching, so I can know if I need to run to the store and buy a new graphics card before I can convince the shaders to work. Thanks!

PS Here is the code:

 #include <GL/glut.h> #include <stdio.h> #include <string.h> 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"); } } void getGlslVersion(int *major, int *minor) { int gl_major, gl_minor; getGlVersion(&gl_major, &gl_minor); *major = *minor = 0; if(gl_major == 1) { /* GL v1.x can provide GLSL v1.00 only as an extension */ const char *extstr = (const char *) glGetString(GL_EXTENSIONS); if ((extstr != NULL) && (strstr(extstr, "GL_ARB_shading_language_100") != NULL)) { *major = 1; *minor = 0; } } else if (gl_major >= 2) { /* GL v2.0 and greater must parse the version string */ const char *verstr = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); if((verstr == NULL) || (sscanf(verstr, "%d.%d", major, minor) != 2)) { *major = *minor = 0; fprintf(stderr, "Invalid GL_SHADING_LANGUAGE_VERSION format!!!\n"); } } } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); int major, minor; getGlVersion(&major, &minor); fprintf(stderr, "OpenGL Version major=%i, minor=%i\n", major, minor); getGlslVersion(&major, &minor); fprintf(stderr, "GLSL Version major=%i, minor=%i\n", major, minor); } void init() {} int main(int argc, char** argv) { glutInit(&argc,argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(0,0); glutCreateWindow("simple"); glutDisplayFunc(display); init(); glutMainLoop(); } 
+4
source share
2 answers

The only way "GL Approved" gets the GL version is to use glGetString (GL_VERSION), and this tells the GL version supported by the driver.

Mesa can implement any version of OpenGL, even if it is implemented in software or hardware, in your case you have OpenGL 1.5, EXECUTED BY MESA 7.7.1, which is an implementation of OpenGL.

The only sure way to find out which specific HW supports a particular version of GL is to check the manufacturer's specifications, as drivers may be outdated and support an older version of GL. An example is the GeForce 8 cards, which were originally supported before OpenGL 2.1, and when OpenGL 3.x appeared, they also supported it, but only using updated drivers.

+5
source

glxinfo will tell you if you have hardware acceleration or not. With Ubuntu, you usually need to explicitly install the appropriate drivers (ATI or NVIDIA) through Synaptic to speed up the hardware.

+1
source

All Articles