• 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.
  • Posts

    • Larry likes animals.  Mommy acts sh!t
    • vPro is a platform that has features aimed at companies, remote management, security, threats detection, drivers that are stable for 15 months, and many other things. And this includes Core, Core Ultra (which are excellent), and a set of Xeon. And this exists for years, and a Intel platform also includes networking Ethernet and WiFi (this requires years of development), a host of security features, power management, storage technologies, This does not exist in such a complete and coherent platform at AMD… And. please, no Windows 10 PC is going to turn into dust in a second, there is 3 years of extended support… for old laptops, there is no reason not to switch, and that backup feature is unrelated.
    • When will the US stop the monster ? They ###### everyone, customers, victims, employees, all the suppliers: the story behind every hw parts is the same, acquired, outsourced, but poaching employees is the cheapest way. The narrative arcs from the last 15 years, all partially or entirely deceptive: security (they stopped with that one, not sustainable), privacy, with the secure cloud ahah, the local AI ahah, selling the user base to Google, ahah, that’s the privacy you will enjoy. Innovations, it became a running gag, when everything is average and years late. The competition: on macOs all their crappy services, 20 apps, that you cannot even hide. They have business practices that no other company could adopt, they would be sued, Apple, on a pedestal for being the greatest parasite company (they capture a lot of wealth, give nothing back, except tens of billion in buybacks every year). Ah, the M socs, they hit a wall (long ago) and still market them as having AAA gaming abilities, they do not, one more fraud. At least there is some fun, Apple building fabs in cooperation with TSMC… ahahahah how are they involved ? Catering ? They provide the cloths ? It’s really sad to see that in the US corruption and mediocrity have reached a level so that companies like Apple or Tesla are getting so much help and support from the administrations, and other entities… that they do not even try to hide today. I wonder when will we know how much the news outlets are being paid to regurgitate anything Apple wants.. This is decay and it’s ugly.
    • it might be a work or school thing. at my work, a disclaimer pops up stating that "you should use google chrome or edge for the best possible experience." at my school, the disclaimer says just to use google chrome. i'm sure a lot of IT guys just want to make it easy and tell employees to use google chrome because of the apparent trends in web developers testing and all. i'm sure that can have big ramifications on browser usage for average users since "if my IT dep permits it, then it's good". i liked that my work also stated Edge, but i've seen "use google chrome" a lot more without mentioning edge. matter of fact, my employer removed firefox from all devices.
  • Recent Achievements

    • Week One Done
      Ricky Chan earned a badge
      Week One Done
    • Week One Done
      maimutza earned a badge
      Week One Done
    • Week One Done
      abortretryfail earned a badge
      Week One Done
    • First Post
      Mr bot earned a badge
      First Post
    • First Post
      Bkl211 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      483
    2. 2
      +FloatingFatMan
      263
    3. 3
      snowy owl
      240
    4. 4
      ATLien_0
      227
    5. 5
      Edouard
      188
  • Tell a friend

    Love Neowin? Tell a friend!