PDA

View Full Version : OpenGL intellisense/ syntax



anoop4real
02-28-2010, 09:00 PM
Hi,

I am not sure whether this is the right place to put this post (I couldnt find any other place). After working in C#/vb.net 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?

-Anoop

Alfonse Reinheart
02-28-2010, 09:19 PM
After working in C#/vb.net 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.

Ilian Dinev
02-28-2010, 09:23 PM
Edit: whoops, I misread "OpenGL" for "GLSL". Oh well, leaving my original post anyway:


Yes, it's called the C++ Text Editor :D .

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;
}vec2;
typedef struct __vec3{
float x,y,z;
vec2 xx,xy,xz,yx,yy,yz,zx,zy,zz;
}vec3;
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;
}vec4;
typedef struct{
vec4 x,y,z,w;
}mat4;
#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);
GENFUNC3(faceforward);
float length(vec2); float length(vec3); float length(vec4);
GENFUNC(normalize);
GENFUNC2(reflect);
vec3 refract(vec3 I,vec3 N, float eta );

GENFUNC(dFdx);
GENFUNC(dFdy);
GENFUNC(fwidth);
#endif



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



precision highp float;
precision mediump int;

#if IS_VERTEX
#define varying out
#endif
#if IS_FRAGMENT
#define varying in
#endif

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


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


http://img246.imageshack.us/img246/3953/glslintellisense.png (http://img246.imageshack.us/i/glslintellisense.png/)



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).

anoop4real
02-28-2010, 11:17 PM
After working in C#/vb.net 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.

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

anoop4real
03-01-2010, 01:45 AM
Hi,

After searching in MSDN I have atleast found a way to have syntax highlighting. I just followed the link MSDN (http://msdn.microsoft.com/en-us/library/zy61y8b8(VS.80).aspx), I created a file with all the OpenGl APIs and now I have my methods shown atleast in colors.

-Anoop

Stephen A
03-01-2010, 04:43 AM
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. (http://www.opentk.com/node/689)