opengl cg or glsl

Started by
4 comments, last by maxgpgpu 11 years, 10 months ago
hello.
I'm creating a little opengl engine for my little tests and for a commercial use.
Now i wish choose to using cg or glsl.
I see that directx hlsl has a reflection for enumerate variables and and texture used by the shader program.
Is possible do something of similar in cg or glsl?
In wild magic(the 3d engine)there is a parsing of compiled cg shader for that ,is the only method?
is possible using the same technique in glsl?
And ... What do you recommend ?use cg or glsl?
also for portability and ,may be ,using it in tablet or smartphones
Advertisement
If you are going to release for tablets and phones, your only option currently is GLSL for OpenGLES.

For OpenGLES you can query active uniforms with glGetActiveUniform and glGetProgram

If you are going to release for tablets and phones, your only option currently is GLSL for OpenGLES.

For OpenGLES you can query active uniforms with glGetActiveUniform and glGetProgram


i see that glGetActiveUniform and glGetProgram are compatible also with glsl (not glsl for opengl es,opengl 3 or 4 ,is correct?) then thanks of all , i choose glsl
I'm not sure what you ask if anything...

These glGet-commands are available in all OpenGL-versions that support a programmable pipeline. (GLES 2.0+, GL 3.0+)

Its not part of GLSL spec, its part of the OpenGL spec, they are used to communicate with the GLSL code from your application code.

GLSL is a separate specification, and GLSL ES v1.0 is the one you use with OpenGL ES 2.0.
GLSL ES v1.0 is roughly equivalent to GLSL v1.2 used in PCs

If you want to run the same code on both platforms, I'd recommend making it work on GLES first, since its (more or less) a subset of GL


i see that glGetActiveUniform and glGetProgram are compatible also with glsl (not glsl for opengl es,opengl 3 or 4 ,is correct?) then thanks of all , i choose glsl


Compatible? What does that mean?
These are function that are part of the OpenGL spec. glGetProgram is available since GL 2.0.
glGetActiveUniform is available since GL 2.1.

You have the GL 2.1 references pages here http://www.opengl.org/sdk/docs/man/
and a lot of documentation in the documentation section here http://www.opengl.org/

For GL ES, you need to get the spec from khronos.org
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
GLSL

This topic is closed to new replies.

Advertisement