• 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

    • With the dwindling number of TV license payers the BBC has to look for alternative avenues for income.
    • Bet they remove some sound card, wifi and bluetooth drivers that are still used today in some prebuilts. Seen some very old drivers still being used for those components. Printers can be bad also with very outdated but still working drivers.
    • If its anything like the TV licence they will send a few men around knocking and a letter every week saying they will take you to court.
    • New leak shows the design of the upcoming Nothing Headphone (1) by David Uzondu We've been hearing about the Nothing Headphone (1) for a while now, and it looks like we finally have our first real look at the headphones. In a new series of images leaked by @nothing_fan_blog on Instagram, the self-proclaimed "official German Nothing Fanpage", we can see Nothing's first over-ear headphones out in the wild. You definitely will not mistake these for anything else on a store shelf. The design has the company's signature see-through aesthetic, with a transparent oval piece on top of a solid rectangular base on the earcups, with three physical buttons for controls. Image via @nothing_fan_blog The headphones are set to launch alongside the Phone (3), which itself is getting rid of the glyph interface that made the company's phones stand out in the first place. It is a bit interesting seeing the new headphones establishing a strong visual identity while the flagship phone abandons its own. There is good news for anyone who values a wired connection for audio quality, as one of the images confirms the presence of a 3.5mm headphone jack. On the other hand, a close-up of the headband shows no visible folding hinges, which could be a minor inconvenience for some people, especially travelers. Image via @nothing_fan_blog As for colors, the leaks reveal both a white and black version. There's reportedly a gray option, but the leaked images did not show that. The more interesting part is the price, which is rumored to come in around $299 in the US and €299 in Europe. This would place the Headphone (1) in a very aggressive position, undercutting top-tier options from Sony and Bose by a significant margin. To compete, they will have to pack in the usual like Active Noise Cancellation. The sound quality also needs to be excellent, so let's hope the previously announced partnership with British audio company KEF works out well. We still don't have other details like battery life or specific driver information. Full details are expected at the official launch event, happening on July 1.
    • Ads in WhatsApp? Is this serious? The day that happens is the day I stop using WhatsApp permanently.
  • Recent Achievements

    • Week One Done
      Crunchy6 earned a badge
      Week One Done
    • One Month Later
      KynanSEIT earned a badge
      One Month Later
    • One Month Later
      gowtham07 earned a badge
      One Month Later
    • Collaborator
      lethalman went up a rank
      Collaborator
    • Week One Done
      Wayne Robinson earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      674
    2. 2
      ATLien_0
      274
    3. 3
      Michael Scrip
      219
    4. 4
      +FloatingFatMan
      170
    5. 5
      Steven P.
      161
  • Tell a friend

    Love Neowin? Tell a friend!