Jump to content
  • Advertisement
Sign in to follow this  
domin

c++ - Converting string to regular function

This topic is 3739 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

Hi all, is there any way to convert standart text variable (for example: char Text[1024]) to function? Of course assuming that text variable contains full function code. Or, if text variable contains function code how to call it? Thanks for any suggestions!

Share this post


Link to post
Share on other sites
Advertisement
Not short of including a compiler with your program and calling the compiler at runtime. Consider instead using a scripting language like Python, Lua or Angelscript.

Share this post


Link to post
Share on other sites
I want to use it in DirectX FX files - each FX file (as a shader container) needs special processing (code) and I want to put that code in the FX file as a string and at runtime get that string and execute it just before starting the effect.

Share this post


Link to post
Share on other sites
You'll want to use some kind of scripting language for this; if the nature of the prologue code you're putting in the .fx file is very simple, you may be able to simply hand-roll your own crude 'interpreted language' and use that. Otherwise you may need to look in to embedding something like Lua. You could do this with C++, too, but it would be extremely cumbersome (you'd need to host yourself a compiler, et cetera).

It seems like you're trying to take a code-driven approach to what should be data-driven, however. That is, you want to write code to do some effect-specific setup that you should perhaps attempt to generalize into a data-driven model. What kind of things do you see this prologue code doing for you?

Share this post


Link to post
Share on other sites
One thing you might be able to do is instead of putting C++ code into the fx file you'd put the fx file in with the C++ code, as a string, and load them as a DLL - something akin to Yann's shaders.

Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
What kind of things do you see this prologue code doing for you?


Quoted for emphasis. The best design choice really hinges on this question.

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!