OpenGL intellisense/ syntax


I am not sure whether this is the right place to put this post (I couldnt find any other place). After working in C#/ with intellisense I am finding it difficult to work with OpenGL which is not having good intellisense, Is there any OpenGL intellisense plugin for Visual Studio?


After working in C#/ with intellisense I am finding it difficult to work with OpenGL which is not having good intellisense

OpenGL is a API, not a language. The API is defined in C/C++, but it does have bindings in other languages. That Visual C++'s Intellisense isn’t that good is not something that is OpenGL’s problem.

Edit: whoops, I misread “OpenGL” for “GLSL”. Oh well, leaving my original post anyway:

Yes, it’s called the C++ Text Editor :smiley: .

Make a file, named i.e “glsl.h” with such contents:

#ifdef _WIN32
	// this below is helpers stuff for the VS2k5 IDE
	#define IS_VERTEX 1
	#define IS_FRAGMENT 1
	#define IS_GEOMETRY 1

	typedef struct __vec2{
		float x,y;
		__vec2 xx,yy,xy,yx;
	typedef struct __vec3{
		float x,y,z;
		vec2 xx,xy,xz,yx,yy,yz,zx,zy,zz;
	typedef struct __vec4{
		float x,y,z,w;
		vec2 xx,xy,xz,xw, yx,yy,yz,yw, zx,zy,zz,zw, wx,wy,wz,ww;
		vec3 xyz;
	typedef struct{
		vec4 x,y,z,w;
	#define uniform
	#define varying

	#define sampler2D int
	#define samplerRECT int

	vec4 texture2D(sampler2D texture,vec2 coord);
	vec4 textureRect(samplerRECT texture,vec2 coord);
	vec4 shadow2D(sampler2DShadow,vec3 coord);
	vec4 shadow2DProj(sampler2DShadow,vec4 coord);

	vec4 gl_Position;
	float gl_PointSize;
	vec4 gl_FragCoord;
	//vec4 gl_FragColor;
	//vec4 gl_FragData[4];
	float gl_FragDepth;

	#define GENFUNC(name)  float name(float); vec2 name(vec2); vec3 name(vec3); vec4 name(vec4)
	#define GENFUNC2(name) float name(float,float); vec2 name(vec2,vec2); vec3 name(vec3,vec3); vec4 name(vec4,vec4)
	#define GENFUNC3(name) float name(float,float,float); vec2 name(vec2,vec2,vec2); vec3 name(vec3,vec3,vec3); vec4 name(vec4,vec4,vec4)

	GENFUNC(sin);	GENFUNC(cos);	GENFUNC(tan);
	GENFUNC(asin);	GENFUNC(acos);	GENFUNC(atan);	GENFUNC2(atan);

	GENFUNC(radians);	GENFUNC(degrees);

	GENFUNC2(pow);	GENFUNC(log);	GENFUNC(exp2);	GENFUNC(log2);	GENFUNC(sqrt);	GENFUNC(inversesqrt);

	GENFUNC(abs);	GENFUNC(ceil);
	float clamp(float,float,float);vec2 clamp(vec2,float,float);vec3 clamp(vec3,float,float); vec4 clamp(vec4,float,float);

	GENFUNC(saturate);	GENFUNC(floor);	GENFUNC(fract);	GENFUNC2(max);	GENFUNC2(min);	GENFUNC3(mix);	GENFUNC2(mod);	GENFUNC(sign);	GENFUNC3(smoothstep);	GENFUNC2(step);

	vec3 cross(vec3,vec3);
	float distance(vec2,vec2); float distance(vec3,vec3); float distance(vec4,vec4);
	float dot(vec2,vec2); float dot(vec3,vec3); float dot(vec4,vec4);
	float length(vec2); float length(vec3); float length(vec4);
	vec3 refract(vec3 I,vec3 N, float eta );


//vec3 ilTriangleNormal(in vec3 varPos){
//	return normalize(cross(dFdy(varPos),dFdx(varPos)));

precision highp float;
precision mediump int;

	#define varying out
	#define varying in

#define saturate(X) clamp((X),0,1)

#line 1 1 // trick, by someone on the opengl forums

You need to implement some simple pre-parse of the glsl file when loading it: to prepend the #include file (simply replace the first line).

Thanks for the info :)… that means I have to live with whatever I have got right?


After searching in MSDN I have atleast found a way to have syntax highlighting. I just followed the link MSDN, I created a file with all the OpenGl APIs and now I have my methods shown atleast in colors.


You can use OpenGL with C# and get superior intellisense that way. Not always applicable, but it’s an option if you can use it.

Looks like this.