Results 1 to 6 of 6

Thread: glBindAttribLocation with Cg

  1. #1
    Member Newbie
    Join Date
    Jul 2009
    Posts
    38

    glBindAttribLocation with Cg

    How can I use glBindAttribLocation with Cg? The function expects uint-type value, not CGprogram

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: glBindAttribLocation with Cg

    You generally specify the attrib-slot inside the shader

    (this is Cg-style GLSL)
    Code :
    attribute vec4 inPos : ATTR0;
    attribute vec3 inN : ATTR1;

  3. #3
    Member Newbie
    Join Date
    Jul 2009
    Posts
    38

    Re: glBindAttribLocation with Cg

    Wow. I didn't expect that simply putting these ATTRx would work. No I have something like this:
    Code :
    struct VS_INPUT
    {
    	float4 position: POSITION: ATTR0;
    	float3 normal: NORMAL: ATTR2;
    	float2 texCoord0: TEXCOORD0: ATTR8;
    };
    And this works nicely for OGL and D3D
    Thanks

  4. #4
    Member Newbie
    Join Date
    Jul 2009
    Posts
    38

    Re: glBindAttribLocation with Cg

    Oh no... I thought this would work for D3D yet VS30 doesn't recognize semantic ATTR*... Does anyone know a way make this work without using preprocessor? I need one Cg shader that would work for VS30, PS30 and ARB/GLSL profiles

  5. #5
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,294

    Re: glBindAttribLocation with Cg

    Cg could be problematic in GLSL profile, afaik. (from what I've read on this board, and the Cg->GLSL converted code I've seen cgc.exe produces)
    But for DX, ARB and NVx0 profiles instead of ATTRx you'd better use the :POSITION, :NORMAL, :TEXCOORDx semantics. The downside is that you'll have to use the glVertexPointer/glNormalPointer/etc instead of glVertexAttribPointer .

    Cg can be a mess with ATi cards via OpenGL; but at least it'll work nicely for those cards via DX.

  6. #6
    Member Newbie
    Join Date
    Jul 2009
    Posts
    38

    Re: glBindAttribLocation with Cg

    Yes... I thought that Cg would be a good idea for shaders but now I see it's hard to handle OGL+Cg+ATI. In my future engine I'll surely use explicitly GLSL and HLSL instead of Cg. By now I shall use glVertexPointer/glNormalPointer/etc. I've made some small test-application and so far it works with both NVidia and ATI (at least on two GPUs I've tested). Hope that when I switch from ARB to GLSL none of the new problems arrive...
    Again, thanks for your contribution.

Similar Threads

  1. glBindAttribLocation after glLinkProgram
    By kaerimasu in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 08-18-2010, 04:45 AM
  2. glBindAttribLocation vs NVidia
    By James Newman in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-01-2009, 09:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean