Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Creating OpenGL commands at runtime

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Ohio
    Posts
    4

    Creating OpenGL commands at runtime

    I am trying to find a way to create OpenGL commands at runtime. I have situation where I need to take information from a text file discribing the object and render it to the screen using OpenGL. However, to do this I need to create the OpenGL commands in a string and then execute them.

    Currently I only know how to hard code the commands within the source and compile / execute them in that manner. I realize I could propably create multiple functions containing the OpenGL commands and call them in that manner but I really do not want to.

    Can someone tell me if there is a way to do this or am I way out of the ball park.

    Thanks

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Lafayette, LA
    Posts
    129

    Re: Creating OpenGL commands at runtime

    Honestly the easiest way I can think of is using an interpreted language like Perl or Python that has an OpenGL wrapper. In that way you can just create the commands in a sctring and let the interpreter execute it.

    Hope it helps

    Dirk

  3. #3
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: Creating OpenGL commands at runtime

    Here are some links you may find cool.

    http://pyopengl.sourceforge.net/
    http://www.py3d.org/links
    http://graphics.cs.lth.se/pyfx/

    I'm a big fan of python and being able to integrate it into your application and have two way interactions from your app and python scripts is really cool. I'm right now starting to integrate it into my little 3d demo engine. It should turn out nicely.

    -SirKnight
    -SirKnight

  4. #4
    Junior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Eastern USA
    Posts
    218

    Re: Creating OpenGL commands at runtime

    For some reason my brain kept reading "OpenGL Commandos" and I couldn't help but imagine this scene of a landing craft hitting a beach and several dozen polygon-rendered texture-mapped guys with the OpenGL logo on their chests streaming off, guns blazing.

    I really need to take a break from computers.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: Creating OpenGL commands at runtime

    Haha. OpenGL commandos, that's funny. Maybe you should live your fantasy and make a game like that.

    Oh and each commando's name is one of the OpenGL function or extension names.

    Wait a min...you're "name" is Omaha and you are picturing a beach landing scene with commandos pouring out? Interesting...

    -SirKnight
    -SirKnight

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Ohio
    Posts
    4

    Re: Creating OpenGL commands at runtime

    Thanks for the advice I will look into the python solution but I really do not think it is going to work. I need to update the information at 30 to 60 fps.

    I guess I will just continue with creating the gazzilion and one function calls.

    Anyway, I like the idea of the OpenGL commandos attacking the beach.

  7. #7
    Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    469

    Re: Creating OpenGL commands at runtime

    When you just want to render a geometric model saved in a file, the easiest way would be loading it, storing the vertices & co in arrays an then looping over them and calling glVertex... Or simply use vertex arrays.

    For general commands, you could save each command as a string and do something like this. It's an ugly way to do it and I wouldn't do it by myself, but maybe you get the idea and expand on it. Or you could implement a parser and make it nice and save

    Code :
     string commands[] = { "glPushMatrix", "glLoadIdentity" ,...}
    for (int i=0; i < num_commands; ++i)
    {
        switch ( command[i])
        {
          case "glPushMatrix": glPushmatrix(); break;
          case "glLoadIdentity": glLoadIdentity(); break;
        }
    }

  8. #8
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: Creating OpenGL commands at runtime

    Just to let you know, scripting languages like python are not slow. Entire 3d engines have actually been written purely in python. If you tried it out I'm sure you would be amazed.

    -SirKnight
    -SirKnight

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    Ohio
    Posts
    4

    Re: Creating OpenGL commands at runtime

    That data is not really stored in a file like that. It is CGM and location data that shows up in a video stream at 30/60/120 hertz. I need to interpet the CGM, mix in some other mapping / user specific information and display it to the screen overtop of the video. Also it needs to have a generic code base that can easily be recompiled on windows, UNIX, MAC, and LINUX. That is why I am using OpenGL to do all of the object drawing.

    I can easily interpet the CGM and location information but I was having some issues with the speed of overlaying all of the interpeted information and transformaing the information on the fly to openGL.

    That is why I was looking for an easier way to handle the creation of the OpenGL commands on the fly.

  10. #10
    Junior Member Regular Contributor
    Join Date
    Jun 2003
    Location
    Virginia
    Posts
    212

    Re: Creating OpenGL commands at runtime

    Omaha, are you a devotee of latestchatty.x? Yes, this is rather cryptic for some people.

Posting Permissions

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