• 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

    • Same, we had Macs. I had no trouble transitioning though.
    • Visual Studio Professional 2022 + The Premium Learn to Code Bundle drops to lowest price by Steven Parker Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save $1,960 on this Microsoft Visual Studio Professional 2022 + The 2024 Premium Learn to Code Certification Bundle. This deal consists of the following items: Microsoft Visual Studio Professional 2022 Learn to Code with Python 3 CHATGPT Series: OPENAI Fundamentals 2024 MySQL & SQL for Beginners The Complete Python Course: Learn Python by Doing in 2024 Google Assistant Automation IoT Development Computer Vision & Deep Learning with OpenCV and Python: Build 15 Projects JavaScript Complete Guide with Practical JavaScript Projects Web Development with Vuex (2024) Flutter & Dart: Complete Flutter Dart Programming Course Java Programming for Complete Beginners Salesforce Platform App Builder Certification Training ChatGPT for Salesforce Development 2024 Complete Ruby on Rails 6 Bootcamp Game Development and Coding for Kids 14 coding courses and nearly 244 hours of content.Here's deal: This Microsoft Visual Studio Professional 2022 + The 2024 Premium Learn to Code Certification Bundle normally costs $1,999, but you can pick it up for just $55.97 for a limited time, that's a saving of $1,943 (97%) off. For a full description, specs, and instructor info, click the link below. Use MSO8 when checking out for additional $8 off. Coupon Expires June 29. Get this bundle deal for just $41.97, or learn more Although priced in U.S. dollars, this deal is available for digital purchase worldwide. We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • I still use "Everything Search" for all my device searches including OneDrive. It just got another update. Extremely fast because when you open it for the first time after a Windows Boot it caches everything. Takes a few seconds, but from the 2nd open on it finds all searches in real time as you type what you are searching for in the search area.
  • Recent Achievements

    • One Month Later
      HarryTaylor earned a badge
      One Month Later
    • Week One Done
      HarryTaylor earned a badge
      Week One Done
    • Week One Done
      habso earned a badge
      Week One Done
    • Week One Done
      DXB APPS earned a badge
      Week One Done
    • One Month Later
      DecaffKnight94 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      658
    2. 2
      ATLien_0
      248
    3. 3
      Michael Scrip
      233
    4. 4
      Steven P.
      148
    5. 5
      +FloatingFatMan
      146
  • Tell a friend

    Love Neowin? Tell a friend!