Jump to content
  • Advertisement
Sign in to follow this  
JorenJoestar

OpenGL Confusion - Shader Mess!

This topic is 3994 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 guys...I'm developing my own engine. I want to create something platform indipendent, and I'm stuck on decision about the shaders... HLSL/GLSL is not platform indipendent, so I have to choose Cg? Is it good? Is it supported? If yes, I have to create Cgs with FX Composer 2 and then use NVidia DirectX Sdk to use it on directx? And what if I decide to develop only in one direction - opengl OR directx? I have read that directx has effects (.fx) that makes use of shader very easy. And what about OpenGL??? Thank you in advice!

Share this post


Link to post
Share on other sites
Advertisement
You need to decide what API you're going to use before deciding what shader language to use.

If it's DirectX only, use HLSL (the effect framework simplifies shaders a lot).

Share this post


Link to post
Share on other sites
GLSL is as platform independent as OpenGL, since it's part of OpenGL 2.0. You're talking about API independence, not platform independence. Cg can compile to both DirectX and OpenGL shader programs, so it works with either graphics API.

The Cg tools are like compilers. They compile your program to the low level language understood by the API you're using, just like a C compiler compiles a C program to the language understood by the hardware of the machine you are using.

Share this post


Link to post
Share on other sites
HLSL is almost syntactically equivalent to Cg so one option is to use HLSL with Direct 3D and to use the equivalent shaders as Cg shaders in OpenGL.

ATI also has a tool which converts HLSL shaders to GLSL shaders so that is another route which allows you to avoid Cg altogether as long as you develop your shaders in HLSL.

Share this post


Link to post
Share on other sites
If you are looking for platform independence, then choosing ONLY DirectX is not going to be very useful to you, since it only runs on Windows, but choosing only OpenGL is platform independent (in which case, you may as well use GLSL).

If you are planning on using both DirectX and OpenGL, then you need to provide shaders for both (or use a format, like you mentioned, which can be shared between both).

Share this post


Link to post
Share on other sites
Thank you...this begin to be more understandable!

What do you suggest me to do for a demo?
I'm developing an engine and then a demo...this is something to be used as a presentation because I want to enter the game industry...so what is the best for you for a demo?

Thank you!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!