• 0

OpenGL: glGetString(GL_VERSION)


Question

Okay, I'm starting to learn OpenGL and I'm playing around with the syntax. However, all I want to do here is to simply display what OpenGL version I have running...I know there are programs out there that can tell me, but I want to write my own very basic program.

After hours of searching google, all I can find out is that I need the following command:

glGetString(GL_VERSION);

But what am I doing wrong?

Below is a quick program and I don't know why it's not compiling. One of the errors messages is:

c:\Documents and Settings\DjmUK\My Documents\Visual Studio Projects\Ogl_01\Ogl_01\Test_03.cpp(4): error C2440: 'initializing' : cannot convert from 'int' to 'const GLubyte *'

Any help or a very simple program like below would be greatful.

Thanks in advance.

#include <windows.h>

#include <GL/gl.h>

#include <stdio.h>

void main()

{

printf("Version=", glGetString(GL_VERSION));

}

Link to comment
https://www.neowin.net/forum/topic/222661-opengl-glgetstringgl_version/
Share on other sites

6 answers to this question

Recommended Posts

  • 0
  DjmUK said:
Okay, I'm starting to learn OpenGL and I'm playing around with the syntax. However, all I want to do here is to simply display what OpenGL version I have running...I know there are programs out there that can tell me, but I want to write my own very basic program.

After hours of searching google, all I can find out is that I need the following command:

glGetString(GL_VERSION);

But what am I doing wrong?

Below is a quick program and I don't know why it's not compiling. One of the errors messages is:

c:\Documents and Settings\DjmUK\My Documents\Visual Studio Projects\Ogl_01\Ogl_01\Test_03.cpp(4): error C2440: 'initializing' : cannot convert from 'int' to 'const GLubyte *'

Any help or a very simple program like below would be greatful.

Thanks in advance.

#include <windows.h>

#include <GL/gl.h>

#include <stdio.h>

void main()

{

printf("Version=", glGetString(GL_VERSION));

}

printf("Version=%s", glGetString(GL_VERSION));

  • 0

Then I must be doing something wrong, I added your line into the program and the following 2 errors appear.

OGL_01 fatal error LNK1120: 1 unresolved externals

OGL_01 error LNK2001: unresolved external symbol "unsigned char const * __stdcall glGetString(unsigned int)" (?glGetString@@$$J14YGPBEI@Z)

Specs:

GeForce 2 Pro (Drivers have OpenGL 1.5.2)

WinXP Pro - SP2

Is it a case of my opengl header files being wrong, if so how would I fix the problem :( (this is soooo wierd). I'm gonna' uninstall .NET 2003 and reinstall V6.0, maybe I got the settings mixed up.

  • 0

Looks like I'll have to stick with VS7 (.NET), because I uninstalled VS7 then rebooted and somehow VS6 will NOT install. The most likely reason for this is because SP2 is incompatible.

So, I'm reinstalling VS7 and I'll then try that new line you provided as soon as I've configured all the dependencies (includes, headers & directories etc.).

I'll let you know how it turns out. Won't be long now.

  • 0

All sorted, it was my dependencies - however, I get the result "Version=(NULL)". Even with:

printf("Version=%s", (char*)glGetString(GL_VERSION));

printf("Version=%s", (char*)glGetString(GL_EXTENSIONS));

printf("Version=%s", (char*)glGetString(GL_RENDERER));

I receive the same output.

  • 0
  DjmUK said:
All sorted, it was my dependencies - however, I get the result "Version=(NULL)". Even with:

printf("Version=%s", (char*)glGetString(GL_VERSION));

printf("Version=%s", (char*)glGetString(GL_EXTENSIONS));

printf("Version=%s", (char*)glGetString(GL_RENDERER));

I receive the same output.

Odd, perhaps adding const to it will fix it. Otherwise I'm not sure.

printf("Version=%s", (const char*)glGetString(GL_VERSION));

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.