Visual Studio / GLSL Integration

Right now I’m writing GLSL shaders and using them within a Visual Studio 2005 C++ / OpenGL project, and the experience is a bit lacking. I’m looking for ways to improve the integration between the two, beyond Visual Studio thinking the .glsl files are just plain text. Things that would be great: language support in the form of syntax highlighting, auto indenting, etc., and compilation support.

For syntax highlighting, I’ve seen a few websites about extending Visual Studio with your own custom parser to define a custom language. Has anyone done this for GLSL? If not, maybe I can convince my boss to let me spend some time on it.

For compilation support, I’d like to compile my shaders as part of the build process so I can get errors in the GLSL before I run the program. Is there a (reference) GLSL command line compiler? I found 3DLabs GLSLValidate program, but that’s a GUI which really is not what I’m looking for. Currently, I have NVIDIA’s cgc filling the role with “-oglsl -profile glslf” options, but it’s a poor solution (e.g., I’m currently getting a “warning C7506: OpenGL does not define the global function dot” message which is just silly).

Also, to do the cgc compilation I currently have to go to the properties of each .glsl file and add custom build steps to each one. I’d much rather define a rule that any file with a suffix of .glsl gets this build step applied…

Anyway, I imagine lots of other people are in a similar situation - what are your solutions? How do you make GLSL development as painless as possible? Unfortunately, I have to use Visual Studio 2005 (I miss developing in linux) so alternatives aren’t an option for me…Thanks!

-stephen diverdi

For syntax highlighting, just create a usertype.dat file with all the keywords and put in <MSVC>\Common7\IDE. The go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Languages\File Extensions and add the extensions you need highlighted and copy the value from .cpp.

For compiling, you could create your own small console app that simply creates a GL context and compiles the file and outputs the infolog.

You could try my project at http://lumina.sourceforge.net I wrote to test shaders without setting up a complete C/C++ program. You could use it to write the shaders and test them. Later you can load them together with models from a (XML) file.

With cgc you are a little bit on the wrong track:
GLSL shader code should be compiled just in time. But cgc is usefull to get an overview about the assembler code.
The “glslf” profile is not to compile GLSL code, it’s for generatin GLSL code from a CG shader. Try vp40/fp40 profiles to generate assembler code for the GF6/7 series.

Ah, yeah, I’ve seen this suggestion before - but won’t that just treat the GLSL as C++ code? It doesn’t seem like a proper solution, but I guess I should give it a shot. Is GLSL C-like enough that it pretty much works? I guess I’m wondering, with how common a language GLSL is, why the work hasn’t been done to give it first-class treatment in the most common IDE. shrug

For compiling, you could create your own small console app that simply creates a GL context and compiles the file and outputs the infolog.

Yeah, sure, I could write something. I’d rather someone else has already written it and I can find it by asking on here. =)

That looks like a pretty slick environment, but not really what I’m looking for - I’m writing large applications that include a GPGPU component for offloading some processing. So most of my time is spent inside Visual Studio working on the main code, and shader development is a small part of that. The shaders also don’t do anything interesting without a lot of CPU support. So, a specific shader IDE isn’t really the right solution here as I’d have to shoehorn the rest of the application development into the shader IDE framework.

With cgc you are a little bit on the wrong track:
GLSL shader code should be compiled just in time. But cgc is usefull to get an overview about the assembler code.
The “glslf” profile is not to compile GLSL code, it’s for generatin GLSL code from a CG shader. Try vp40/fp40 profiles to generate assembler code for the GF6/7 series.

I think you’ve misunderstood what I’m using cgc for here - I don’t care about the output of cgc, I just want to generate compile errors when I build my project, not when I run it. For example, w/o using cgc, if I modify a shader and make a syntax error, I have to build the rest of my code, start the debugger, go through the startup, and then when the shader is loaded and compiled I get the error. Using cgc as part of the build process I can just do a quick compile of the shaders during the build (and throw out the results) to see if there are syntax errors. However, as I said, cgc (with the -oglsl flag) doesn’t seem to do that 100% correctly.

You’re right though about the -profile glslf option - thanks for clearing that up for me. But since I’m not using the output of the compiler anyway, I don’t think it matters.

A really slick GLSL add on for VS would be pretty sweet.

If you want to get fancy with it you’ll need the VS SDK. There’s even an IDE sample called “MyC” that demonstrates a basic C-like editor using the MPLex/MPPG tools. You could add auto completion, etc… all the bells and whistles. You could also go the full VS integration route but that looks to be a bit more involved. In fact it all seems a bit much for simple text coloring.

Then there’s Scintilla and friends… stand-alone text editors and such.

Anyhoo, I’m not ashamed to say I’d relish such conveniences. If you’ve got the time then I’ll definitely be interested in it when it’s done :-).

FYI:
http://glintercept.nutty.org/Ver0_4/shaderedit.png

(Able to run standalone with a built in 3Dlabs validator)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.