Hello! :) It's my first time here.

I don't know why GLSL is better to Nvidia Cg! :( I'm working on skeletal animation in GPU. With Nvidia Cg it's just fine, but when I try to use GLSL, just don't work!
I'm using a Nvidia card in my new computer. In many blogs, many people say that Nvidia Cg don't work in ATI cards, but in my old ATI card it works!! For me GLSL don't work neither in my old ATI card neither in my new Nvidia card!

Why Many people say that GLSL is better than Nvidia Cg? I don't understand!! :(

Please answer to my question.

Dani AI

Generated

In this thread reported GLSL failing at first, then later posted that the same skeletal-animation + shadow code started working. That pattern is common: Nvidia’s Cg historically hid a few platform/driver details and sometimes “just worked” on certain cards, while GLSL is the OpenGL‑native, vendor‑neutral language that requires being explicit about the GL state and bindings. GLSL’s advantage is portability and direct control, but that explicitness is also why beginners hit frustrating failures that look like “it doesn’t work.”

Common causes and quick checks (most likely culprits for a GLSL-only failure):

  • Always read compile/link logs: glGetShaderInfoLog and glGetProgramInfoLog — those messages explain most problems.
  • Confirm the GLSL #version matches the created GL context (core vs compatibility). Using core profile without updating shaders (or relying on legacy built‑ins like gl_ModelViewProjectionMatrix) will silently fail.
  • Verify attribute bindings: either use layout(location=...) in the shader or call glBindAttribLocation before linking; mismatched attribute indices are a frequent source of “no geometry” or wrong transforms.
  • Integer bone indices require integer attribute calls: use glVertexAttribIPointer for ivec4 attributes (older drivers forced packing into floats).
  • Uniform limits: check GL_MAX_VERTEX_UNIFORM_COMPONENTS (or vectors). If the bone matrix array is too large, switch to a texture/UBO/SSBO (depending on GL version) or a matrix palette texture approach.
  • Enable GL debug output (or use RenderDoc / apitrace) and check glGetError frequently.

Small example of the essential debug pattern:

const char* glsl = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
printf("GLSL version: %s\n", glsl);

GLint ok = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
if (!ok) {
  GLint len = 0; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
  std::string log(len, ' '); glGetShaderInfoLog(shader, len, nullptr, &log[0]);
  fprintf(stderr, "Shader compile log:\n%s\n", log.c_str());
}

For skeletal skinning specifically: if indexing a uniform array of matrices fails on some cards, that’s a driver limitation — either reduce bone count, unroll the skinning loop, or move the matrices into a texture/UBO. The most useful information to post when asking for help is the shader sources, compile/link logs, GL/GLSL version strings, and the GPU/driver reported by glGetString(GL_RENDERER)/GL_VENDOR — that lets others pinpoint whether the issue is shader syntax, attribute bindings, uniform limits, or a driver quirk.

YYYEEEEESSSSSSSSSSSSSSS!!! :))))) Now I can already use GLSL!!! In skeletal animation, in shadow mapping, and in skeletal animation and shadow mapping together!!! You're right! GLSL is better than Nvidia Cg!!! :)))))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.