Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: FreeGLUT on VirtualBox

  1. #1

    FreeGLUT on VirtualBox. Console message: fgInitGL2: fghGenBuffers is NULL

    Hello,

    This code works fine. It draws two line. I run it on Virtual Box, Windows XP, Visual Studio 2010 Express Edition

    But it shows this message in console:
    freeglut (C:\Projects\Axes_CppOpenGL15FreeGLUT\Debug\Axes_C ppOpenGL15FreeGLUT.ex
    e): fgInitGL2: fghGenBuffers is NULL
    But when I uncomment this line it draws nothing:
    Code :
    //Enable2D(width, height);

    Code with commented line of code on Enable2D, this draws two lines:

    Code :
    #include <GL\freeglut.h>
     
    // Window size
    int width = 512;
    int height = 512;
     
    void Draw()
    {
        // clear (has to be done at the beginning)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();
     
        // Draw X axis
        glBegin(GL_LINES);
        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex2f(0.0f, 0.0f);
        glVertex2f(10.0f, 0.0f);
        glEnd();
     
        // Draw X axis
        glBegin(GL_LINES);
        glColor3f(0.0f, 1.0f, 0.0f);
        glVertex2f(0.0f, 0.0f);
        glVertex2f(0.5f, 0.5f);
        glEnd();
     
        // Swap buffers (has to be done at the end)
        glutSwapBuffers();
    }
     
    void Enable2D(int width, int height)
    {
        glViewport(0, 0, width, height);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0.0f, width, 0.0f, height, 0.0f, 1.0f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    }
     
    // Program entry point
    int main(int argc, char** argv) {
        // Initialize opengl (via glut)
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
        glutInitWindowSize(width, height);
        glutCreateWindow("Axes");
     
        glutDisplayFunc(Draw);
     
        // setup scene to 2d mode and set draw color to white
        //Enable2D(width, height);
        glColor3f(1.0f, 1.0f, 1.0f);
     
        // Start the whole thing
        glutMainLoop();
        return 0;
    }
    Last edited by 8Observer8; 05-22-2017 at 04:25 AM.

  2. #2
    There was some errors in my code. Now it works correct. But I didn't find in internet why this message is showed:
    freeglut (C:\Projects\Axes_CppOpenGL15FreeGLUT\Debug\Axes_C ppOpenGL15FreeGLUT.ex
    e): fgInitGL2: fghGenBuffers is NULL
    Corrected code:
    Code :
    #include <GL\freeglut.h>
     
    // Window size
    int width = 512;
    int height = 512;
     
    void Draw()
    {
        // clear (has to be done at the beginning)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();
     
        // Draw X axis
        glBegin(GL_LINES);
        glColor3f(1.0f, 0.0f, 0.0f);
        glVertex2f(-width / 2.0f, 0.0f);
        glVertex2f(width / 2.0f, 0.0f);
        glEnd();
     
        // Draw X axis
        glBegin(GL_LINES);
        glColor3f(0.0f, 1.0f, 0.0f);
        glVertex2f(0.0f, -height / 2.0f);
        glVertex2f(0.0f, height / 2.0f);
        glEnd();
     
        // Swap buffers (has to be done at the end)
        glutSwapBuffers();
    }
     
    void Enable2D(int width, int height)
    {
        glViewport(0, 0, width, height);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-width / 2.0f, width / 2.0f, -height / 2.0f, height / 2.0f, 0.0f, 1.0f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    }
     
    // Program entry point
    int main(int argc, char** argv)
    {
        // Initialize opengl (via glut)
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
        glutInitWindowSize(width, height);
        glutCreateWindow("Axes");
     
        glutDisplayFunc(Draw);
     
        // setup scene to 2d mode and set draw color to white
        Enable2D(width, height);
        glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
     
        // Start the whole thing
        glutMainLoop();
        return 0;
    }
    Last edited by 8Observer8; 05-22-2017 at 03:59 PM.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,523
    It just means that you aren't using OpenGL 2.0 or later.

    The latest versions of FreeGLUT have two versions of the code for drawing shapes (tetrahedron, cube, etc). If the OpenGL version is prior to 2.0, it uses client-side arrays (which don't work with OpenGL 3.0+ core profile). If it's 2.0 or later, it uses buffer objects (which don't work with OpenGL versions prior to 2.0). To detect which version is being used, it checks for the existence of the functions which the 2.0+ code uses, starting with glGenBuffers(). If any of the function pointers are null, it prints a warning and assumes that a pre-2.0 version is in use.

  4. #4
    Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    429
    I think this is related to the fact that you are using OpenGL threw a virtual machine, on Windows. You might be stuck with OpenGL 1.1.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,728
    This depends.

    The free VMWare Player, for example, provides hardware accelerated OpenGL 2.1 on Windows via Gallium and is capable of running something like Quake at 250 fps on Intel integrated graphics on the host and without hardware virtualization. Other virtualization software may be different; the important point is: it's not because you're using a virtual machine, it's your virtualization software.

  6. #6
    Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    429
    Quote Originally Posted by mhagain View Post
    This depends.

    The free VMWare Player, for example, provides hardware accelerated OpenGL 2.1 on Windows via Gallium and is capable of running something like Quake at 250 fps on Intel integrated graphics on the host and without hardware virtualization. Other virtualization software may be different; the important point is: it's not because you're using a virtual machine, it's your virtualization software.
    Thanks for the precision mhagain.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •