Jump to content
  • Advertisement
Sign in to follow this  
LuckyLuciano

OpenGL CgFX and Direct3D?

This topic is 4463 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, I'm currently working on a simple render framework which can use different API's to render it's scene (currently Direct3D9 and OpenGL are supported). Until now I didn't encounter real difficulties but now I'm at the stage where I want to add support for Effect files and I'm a bit stuck. To keep the framework platform independent, Directx .fx files are out of the question, but luckely there is CgFX. I found a lot of articles talking about OpenGL and CgFX but I'm having unsolved questions concerning CgFX-files and Direct3D. It seems there are next to none articles who handle the subject. I know the CgFX files are nearly identical to Directx .fx files, but how far does this go? Can I write CgFX files and use them as if they are .fx files without a problem in my Direct3D9 renderer? Also, I downloaded the nVidia FX Composer and I noticed they don't even support their own format (CgFX)?! Is this because the two formats are identical or is CgFX being dumped? (which would be a shame) Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement
The CGFX API works on directX as well as openGL there are examples in C:\Program Files\NVIDIA Corporation\Cg\examples\Direct3D9_Basic

Most people doing DirectX programing use the DX effects API, but it makes perfect sense to use CGFX if you are doing a cross platform (or at least cross-API) project. That said I've not actually compared the performance of the two APIs (FX and CGFX).

The syntax is different enough that you will have problems if you try and compile FX files with the CGFX compiler and vice-versa. But they are close enough so you can use macros to handle the differences if you had to use different APIs. e.g. define a PIXEL_PROGRAM(_func) macro that defines to "FragmentProgram = compile arbfp1 _func" in CGFX, "PixelShader = compile ps_3_0 _func" in FX.


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!