Results 1 to 10 of 10

Thread: how use "glGetString(GL_VERSION)" ?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    how use "glGetString(GL_VERSION)" ?

    to know the version i'm using,
    please

    [This message has been edited by airseb (edited 05-10-2003).]

  2. #2
    Member Contributor
    Join Date
    Feb 2003
    Location
    Mitishy
    Posts
    59

    Re: how use "glGetString(GL_VERSION)" ?

    Hi!
    char *version = (char*)glGetString(GL_VERSION);
    hehe...

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    Re: how use "glGetString(GL_VERSION)" ?

    i have a problem, i do this :
    Code :
    #include <gl\GLAUX.h> 
    #include <gl\glut.h> 
    #include <gl\gl.h>
    #include <gl\glext.h>
    #include <iostream.h>
     
     
    void main ()
    {
    	char *version = (char*)glGetString(GL_VERSION);
    		cout <<*version<<endl ;
    }
    and windows say to me that the program have to close
    what's wrong ?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: how use "glGetString(GL_VERSION)" ?

    You have to create a rendering context for any OpenGL function to work.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    Re: how use "glGetString(GL_VERSION)" ?

    can you explain me more ?
    does it mean that i have to put "char *version = (char*)glGetString(GL_VERSION);" in the display function ? with a cout ?

  6. #6
    Member Contributor
    Join Date
    Aug 2002
    Location
    Brooklyn, NY, USA
    Posts
    53

    Re: how use "glGetString(GL_VERSION)" ?

    airseb, I showed you how to use this function. If you don't know anything about typecasting you should spend sometime learning C++. Typecasting is operation of turning one type into another. glGetString returns a null terminated string of type const unsigned char*. You can do this:

    const unsigned char* glver = glGetString(GL_VERSION);

    cout << glVer << endl; // DO NOT PUT A DEREFERENCE OPERATOR infront of glVer

  7. #7
    Member Contributor
    Join Date
    Aug 2002
    Location
    Brooklyn, NY, USA
    Posts
    53

    Re: how use "glGetString(GL_VERSION)" ?

    Originally posted by Bob:
    You have to create a rendering context for any OpenGL function to work.
    What Bob means is you should have OpenGL "initialized" before using any OpenGL functions

  8. #8
    Senior Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    625

    Re: how use "glGetString(GL_VERSION)" ?

    GL is initialized only when you have a window opened by your program. So, you cannot access GL in console mode unless you pop up a window.

    I guess you are a very beginner. Try GLUT or maybe, even better, go for SDL.
    Read the help, see some tutorials on how to pop up a win.

    Once you pop up your gl-enabled window (no matter how you do it), you can call all the GL functions from everywhere. You can put it in the main or in the messageProc or in a Render() function.

    Little note about your cout:
    char *string = "This is a string";
    cout<<*string;

    Program output is -->T<-- and not -->This is a string<--.

    This is becouse *string is a char and not a char* so, when cout will process it it will recognize it as a char and output it. I guess you should have to recheck your pointer math and priorities. Understand pointers, they are important in GL and I find them often useful.

    EDIT: hey, while typing the message, other messages popped up before this! Woah...


    [This message has been edited by Obli (edited 05-10-2003).]

  9. #9
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    Re: how use "glGetString(GL_VERSION)" ?

    ok it works !
    thanks everybody

  10. #10
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    Re: how use "glGetString(GL_VERSION)" ?

    sorry brian of having done a new topic for that but i didn't know that an open gl window had to be opened before GL_VERSION.

    [This message has been edited by airseb (edited 05-11-2003).]

Similar Threads

  1. Unable to get GL_VERSION 2
    By spiral in forum OpenGL: Windows
    Replies: 9
    Last Post: 03-10-2008, 08:35 AM
  2. Replies: 2
    Last Post: 09-21-2007, 02:46 PM
  3. glGetString(GL_VERSION) version detect problem.
    By jbarton in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 03-17-2003, 11:33 AM
  4. glGetString(GL_VERSION) return Null... argh !
    By pech in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 03-11-2002, 02:19 PM
  5. glGetString();
    By Dire_Avenger in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-12-2001, 05:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean