Jump to content
  • Advertisement
Sign in to follow this  
AndyEsser

OpenGL Load OpenGL Commands From A Text File

This topic is 4550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible? I mean, say I had my simple code to render a quad within a text file glBegin bmquads glvertex3f 0,0,0 glvertex3f 0,1,0 glvertex3f 1,0,0 glvertex3f 1,1,0 glend Is there any way I can simply get OGL to loads those commands? Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
No, but what you can do is store the vertices in a file, load them into a vertex array, and render them that way.

You could also read the opengl calls from the file, determine what they were through some interpretive type functions, and then call them as part of a display list creation.

Share this post


Link to post
Share on other sites
If all you were doing is quads, then you could do something like, read in the first word (i.e. the OpenGL command) and then say, if(command == "glBegin") then do some stuff, else if(command == "glVertex3f") do other stuff... But, as you can see, that can become tedious. To do what you're asking, you would need to integrate a scripting language into your program. I would recommend looking into Lua.

Share this post


Link to post
Share on other sites
not unless you want to write a mini lexer/tokeniser and parse all that crap yourself, its probrably easier to just have it load regular 3d models? i can't see any good reason for wanting to load OGL commands from a file?

Share this post


Link to post
Share on other sites
The reason that i want to load ogl commands from a while is that i've written a file that interprets a VRML file from Pro/Desktop or 3ds Max and sorts all the faces etc, then you have to chose a texture as your next step, because that's not included in the VRML file. If it was then i would just load the VRML file straight into my OGL program.

Thanks for your help guys, have to think of some other way :(

Share this post


Link to post
Share on other sites
Hello,

You can always load a DLL with the code. Or you can write a simple parser language as suggested above but I think it would be too complicated for the task. DLLs also allows the user to code in the language he is more comfortable with. Hope this helps,

JVFF

Share this post


Link to post
Share on other sites
Quote:
Original post by jvff
Hello,

You can always load a DLL with the code. Or you can write a simple parser language as suggested above but I think it would be too complicated for the task. DLLs also allows the user to code in the language he is more comfortable with. Hope this helps,

JVFF


Screw writing your own parser, if you are interested in changing certain material properties look into the shader language used for quake3.

Share this post


Link to post
Share on other sites
Quote:
Original post by dawidjoubert
Quote:
Original post by jvff
Hello,

You can always load a DLL with the code. Or you can write a simple parser language as suggested above but I think it would be too complicated for the task. DLLs also allows the user to code in the language he is more comfortable with. Hope this helps,

JVFF


Screw writing your own parser, if you are interested in changing certain material properties look into the shader language used for quake3.


Erm, unless you write your own lexer/parser, how you do expect to parse a script similar to the one Q3 uses? Anyway you look at it, if you have a pure text input that you want to convert to anything else you're going to have some sort of parser in there.

Quite luckily however, there are some very decent parsers/lexers out there. Take a look at boost::spirit and Yacc/flex/bison.

You probably don't want to do any of that however, just look into loading standard model formats.

Share this post


Link to post
Share on other sites
Ofcourse it is possible. The question is how much code you need to write for it. Function pointers would be the way to go if you ask me. Somthing allong the lines of a table that associates function names (strings) with function pointers and some way to translate the argument. A lot of this could be generated automaticaly using the infos contained in the header.

I think using lex and similar stuff would be overkill, but then I haven't used this tools much.

Edit: supposing that you want to do somthing script-like. Not only geometry. Anyway if you want to type the whole stuff, you can simply make it a function and name the file .c

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!