File extensions

I had begun some syntax highliting support for vi (vim, and gvim), but those editors mainly need extensions to detect which syntax it will use. It could be supported in vi 7. I guess it can support it in other ways but I didn’t find out the solution at this moment.

I personally use *.vsh and *.fsh respectively for vertex shader files and fragment shader files.

In a first part, I’d like to know what extensions do you personally use, and also if that can interrest some of you. Notes: vi is mainly a Unix text editor but I know that gvim is supported under Windows too.

Also, I’d like to say that the syntax actually supports almost all things, but I may do a differentiation between vertex and fragment sources (as, and if I’m not wrong, there can have some differences between what can be used depending on the vertex/fragement source).

Is it also possible to support it being written as a string?

One could write a program in a separate file and thus syntax highlight the code like you are doing (which is great!)

But if I want to write say a cpp file with the program as a string, is it possible to come up with a syntax highlighter for it ? (combining a very basic c++ syntax and glsl in a string)

Just a random thought.

i use:
*.frag
*.vert
*.glsl

You can also look into Scintilla which is supported both on windows and linux and has a very nice interface for supporting syntax hi-lighting. It really is pretty easy and great to use because it contains almost all the features of advanced text editors like Visual Studio.
I use extensions
.vsh, .fsh
.vert, .frag
and sometimes
.vsh, .psh

GLIntercept uses Scintilla/Scite for all syntax highlighting. You can run standalone mode or steal all the syntax highlighting config files if you want (GLSL ARB FP/VP NV FP/VP support)

Thank you for the replies. So it seems that it can be of interrest for some of you.

For the direct support inside C/C++ sources, I had a quick look at the vi docs, and it seems it can be supported, however the docs explicitly says it can not work and depends on several things.

I’m pretty sure direct GLSL inside C/C++ sources should be avoided (even if it’s true that it can hide the shaders sources, anyone will be able to inspect the binary seeking for strings and find them easily).

Actually, I notice that .vsh and .fsh have been used by several people, so they are the more common extensions (I also used sometimes .glsl but didn’t really liked it). I’ll also remember for .frag and .vert

Hi Jide,

You mentioned:

I’m pretty sure direct GLSL inside C/C++ sources should be avoided (even if it’s true that it can hide the shaders sources, anyone will be able to inspect the binary seeking for strings and find them easily).

Im new to glsl. Why do you say this? Is it for security reasons or something else ? If its open source, does it matter ?

Thanks

  • Vinay

I used to use *.fsh for fragment shaders and *.vsh for vertex shaders, but these days I use *.shd and store both vertex and fragment shader in the same file, separated with [Vertex shader] and [Fragment shader] tags.

I said that just because some use to write their shader sources inside their code (C/C++…). And I think one of the main interresting point about shaders is that they can be reused, combined… for different uses. So, having them in a separate file (like I mentionned) just put an emphasis on that reusability and that ability to be combined, depending on the needs.
However, some would argue that writing shaders inside their C code just avoid end-users to be able to see the shader sources. And I guess this is not a real good point (despite of security and spy issues).
And this is why I made this topic, I prefer writing shaders in their own files and read them from the main program. Also, security, spying and such are out of topic here (I think I can remember that it was discussed some months ago).

Humus: the point you stippled is interresting, so I should rather avoid making 2 distinct syntaxes highliting and prefer group them in once (one syntax highlight for all GLSL).

Besides vsh/fsh
vert/frag
vsh/psh
glsl/glsl
there is
vs/ps
vs/fs
vp/fp (ARB_vp/fp)

I used vert/frag, then combined to single file -> glsl

Hope this doesn’t scare the editor mode folks too much…

I prefer extensions that start with .gl because they let people who aren’t OpenGL shader programmers know that a file is related to OpenGL. I use:

.glvs = vertex shader
.glfs = fragment shader
.glsl = general or shared shading language code

I like keeping vertex and fragment shaders in separate files so that I can try different combinations without having redundant copies of the code that isn’t changing much. Fewer copies means fewer fixes if a change is necessary. E.g.

tek-glow-fx.glvs (common vertex shader)
tek-glow-fx-01.glfs (fragment shader variant 1)

tek-glow-fx-05.glfs (fragment shader variant 5)

I also create .glsp (shader program) files which specify which .glvs, .glfs, .glsl files get compiled together and which shaders are linked together. A C++ class with a constructor that expects a .glsp filename takes care of the compile and link. There’s a member function to install the shader.

Recently, in a mood of rampant proliferation, I’ve been toying with the idea of .glsi files for specifying the interface (e.g. varying) between a vertex shader and a fragment shader. That makes the interface easy to find, right? :slight_smile:

in Emacs you can associate file extensions with a mode of your choice, for example here is what i use:

  
(setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist))

(setq auto-mode-alist (cons '("\\.vp$" . arbvp-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.fp$" . arbfp-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.arbvp$" . arbvp-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.arbfp$" . arbfp-mode) auto-mode-alist))

(setq auto-mode-alist (cons '("\\.vert$" . glsl-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.frag$" . glsl-mode) auto-mode-alist))

(setq auto-mode-alist (cons '("\\.cg$" . nvidia-cg-mode) auto-mode-alist))

(setq auto-mode-alist (cons '("\\.m$" . octave-mode) auto-mode-alist))

as you can see both .vp and .arbvp extensions will
trigger my mode for editing the !!ARBvp1.0 files.

.vertex.cg
.fragment.cg

.vertex.glsl
.fragment.glsl

Haven’t used assembly shaders in a while, but would use then the following:

.vertex.asm
.fragment.asm

for opengl…

.glsl

and for d3d…

.hlsl

I don’t really need syntax highlighting for the type of shaders I’m using at the moment. I can only imagine that jide has too much time on his hands - like most people who use linux :wink: I prefer actually programming.

Well, when we’ll see you Knackered do things not only for your little proud and presomptuous brain but also for others, I guess the earth will have another spin number… :smiley:

Anyway I retain that people use many different extensions, so I’ll have to look for how to stipple that in another way (with writting some specific chars in the first line of the source it seems it will work). I’ll also send it to the vi mailing list , I hope quiete soon :slight_smile:

EDIT: Also why speaking of D3D ??? Did I went to the wrong forums ??

jide, i m not sure if i missed something, but there is already a glsl mode for vim: glsl
and for nVidia Cg: Cg
and even a hlsl mode hlsl
for those hard working windoze/d3d programmers with
almost no free time :wink:

You’re right, I have mailed the author of vi and it seems he wasn’t aware of that as he said me it’s a good idea. He surely cannot know each syntax highlighting… I didn’t mail to the mailing list as I wanted to wait for a best support.

Anyway, all of this is out now :frowning:

Thank you for letting me know that.

time well spent, jide. Now…onto the programming. Or maybe you’ll do some compiler benchmarking first.
I work with people like you - or rather, I do the work while they do everything to avoid it. It’s most certainly not funny, you should be ashamed of yourself and thanking me for pointing out the error of your ways, rather than hopelessly trying to construct a decent insult for me.

Originally posted by knackered:
time well spent, jide. Now…onto the programming. Or maybe you’ll do some compiler benchmarking first.
I work with people like you - or rather, I do the work while they do everything to avoid it. It’s most certainly not funny, you should be ashamed of yourself and thanking me for pointing out the error of your ways, rather than hopelessly trying to construct a decent insult for me.

And then ?? You’re too clever, you know too much everything so that you never do things that have already been done elsewhere but that you wasn’t aware of… That turns out.

I’m not ashamed, why would I feel ashamed ? I still can use it for myself or help them make a better syntax highlighting or better know file extensions and so on. It’s not a waste of time.

Also, don’t tell you know me please, as you don’t. And I wasn’t insulting you, I was just speaking the way you usually do.

Well I wonder why I’m proving to you.

I love you jide, and I want to have your babies.
You’ve passed the test, the factory is yours!