Getting NULL insted of information from glGetString(GLenum)

Getting NULL insted of information from glGetString(GLenum)

Post by Dr. Antoni Kajetan Wiso » Thu, 21 Oct 1999 04:00:00



Hi folks!

I have a small problem with OpenGL. Because I am not very deep in this topic, I
do not know what to do further. If any one can help me, please post it. Here is
an excerpt of my problem, which should run without any problem after
compilation:

#include <stdio.h>                //Standard C I/O functions
#include <windows.h>            //For Win32-API Applications
#include <gl/gl.h>              //OpenGL

/* Declaration of prototypes */
LONG __cdecl main();

/* Mainprog */

LONG __cdecl main()
{
  char* vendor = (char*)glGetString((GLenum)GL_VENDOR);
  char* renderer = (char*)glGetString((GLenum)GL_RENDERER);
  char* version = (char*)glGetString((GLenum)GL_VERSION);
  char* extensions = (char*)glGetString((GLenum)GL_EXTENSIONS);

  glFlush();

  printf("Vendor: %s\n", vendor);
  printf("Renderer: %s\n", renderer);
  printf("Version: %s\n", version);
  printf("Extensions: %s", extensions);

  return (LONG)0;

Quote:}

Thanks!

Jakob Wisor

 
 
 

Getting NULL insted of information from glGetString(GLenum)

Post by Marcin Romaszewic » Thu, 21 Oct 1999 04:00:00


You must have a valid rendering context before you can call glGetString.
Open up a window, get a context, and then call glGetString and you will
get the correct behavior.

-- Marcin


Quote:

> Hi folks!

> I have a small problem with OpenGL. Because I am not very deep in this topic, I
> do not know what to do further. If any one can help me, please post it. Here is
> an excerpt of my problem, which should run without any problem after
> compilation:

> #include <stdio.h>              //Standard C I/O functions
> #include <windows.h>            //For Win32-API Applications
> #include <gl/gl.h>              //OpenGL

> /* Declaration of prototypes */
> LONG __cdecl main();

> /* Mainprog */

> LONG __cdecl main()
> {
>   char* vendor = (char*)glGetString((GLenum)GL_VENDOR);
>   char* renderer = (char*)glGetString((GLenum)GL_RENDERER);
>   char* version = (char*)glGetString((GLenum)GL_VERSION);
>   char* extensions = (char*)glGetString((GLenum)GL_EXTENSIONS);

>   glFlush();

>   printf("Vendor: %s\n", vendor);
>   printf("Renderer: %s\n", renderer);
>   printf("Version: %s\n", version);
>   printf("Extensions: %s", extensions);

>   return (LONG)0;
> }

> Thanks!

> Jakob Wisor


 
 
 

Getting NULL insted of information from glGetString(GLenum)

Post by Paul Mart » Fri, 22 Oct 1999 04:00:00



Quote:> You must have a valid rendering context before you can call glGetString.
> Open up a window, get a context, and then call glGetString and you will
> get the correct behavior.

The context must also be made current to the window or drawing surface with
a call to <glx|wgl|whatever>MakeCurrent.
--
   -Paul Martz
    Hewlett Packard Workstation Systems Lab
    Remove DONTSPAM to reply
 
 
 

Getting NULL insted of information from glGetString(GLenum)

Post by Phil Frisbie, Jr » Fri, 22 Oct 1999 04:00:00



Quote:

> Hi folks!

> I have a small problem with OpenGL. Because I am not very deep in this topic, I
> do not know what to do further. If any one can help me, please post it. Here is
> an excerpt of my problem, which should run without any problem after
> compilation:

You are wrong, this program should NOT run.

Quote:

> #include <stdio.h>              //Standard C I/O functions
> #include <windows.h>            //For Win32-API Applications
> #include <gl/gl.h>              //OpenGL

> /* Declaration of prototypes */
> LONG __cdecl main();

First, the proper prototype for main is:

int main(int argc, char **argv);

Quote:> /* Mainprog */

> LONG __cdecl main()
> {
>   char* vendor = (char*)glGetString((GLenum)GL_VENDOR);
>   char* renderer = (char*)glGetString((GLenum)GL_RENDERER);
>   char* version = (char*)glGetString((GLenum)GL_VERSION);
>   char* extensions = (char*)glGetString((GLenum)GL_EXTENSIONS);

You cannot call OpenGL functions without creating a context and making
it current. To create a context you need to create a window, so you
might as well start with a full Windows app instead of a console app. Or
use GLUT to avoid the Windows API.

Quote:

>   glFlush();

There is no reason to cal glFlush if you have not rendered anything.

Quote:

>   printf("Vendor: %s\n", vendor);
>   printf("Renderer: %s\n", renderer);
>   printf("Version: %s\n", version);
>   printf("Extensions: %s", extensions);

>   return (LONG)0;
> }

> Thanks!

> Jakob Wisor

Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com
 
 
 

1. glGetString() always returns (null)

This piece of code only returns four (null).
Is that normal or my code is just not correct?
I'm under linux using NVidia 3123 drivers on a pine TNT2
compiled like this: gcc -o GLext Glext.c -lGL -Wall

#include <stdio.h>
#include <GL/gl.h>

int main(void)
{
        char *vendor;           /* GL_VENDOR     */
        char *renderer;         /* GL_RENDERER   */
        char *version;          /* GL_VERSION    */
        char *ext;              /* GL_EXTENSIONS */

        vendor = (char *) glGetString(GL_VENDOR);
        printf("%s\n", vendor);

        renderer = (char *) glGetString(GL_RENDERER);
        printf("%s\n", renderer);

        version = (char *) glGetString(GL_VERSION);
        printf("%s\n", version);

        ext = (char *) glGetString(GL_EXTENSIONS);
        printf("%s\n", ext);

        return 0;

2. Feather and LParser (output to POV)

3. Why is glGetString(GL_VERSION)==NULL ?

4. FT: Truespace3 for Infini-D

5. glGetString returns NULL

6. PS5 Selective Color Corr.differs on Mac and PC

7. Getting Depth Information

8. WTB: RAT MESH 3D Studio Max

9. Getting information about P's immediate vicinity

10. GLenum?

11. Getting Matrix Information While Using OpenGL

12. Getting x-ray information into a Mac II

13. Information on getting around a serious bug in 3DS 4