Results 1 to 2 of 2

Thread: Vector offset!

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    24

    Vector offset!

    Hi!

    How can I specify that indexing of float4 should start at index 1 instead of 0? Example:

    Offset = 1;
    for (i = 0; i < Len; i++) v[i+Offset] = 1;

    How can the same be achieved if the v is declared as float4 *?

    Thanks!
    Atmapuri

  2. #2

    Re: Vector offset!

    For offset, you should be sure to not overflow of array :

    Code :
    Offset = 1;
    for (i = Offset; i < Len; i++)
    {
      v[i] = 1;
    }
    or
    Code :
    Offset = 1;
    for (i = 0; i < Len -Offset; i++)
    {
      v[i+Offset] = 1;
    }

    For assign to float4, pending expert post, you can try:
    Code :
    v[i] = (float4) (1.0, 1.0, 1.0, 1.0);
    or
    Code :
    v[i] = (float4) 1.0;
    or
    Code :
    v[i].x = 1.0;
    v[i].y = 1.0;
    v[i].z = 1.0;
    v[i].w = 1.0;

    Hope it can help.

Similar Threads

  1. Replies: 0
    Last Post: 01-31-2012, 10:29 AM
  2. Replies: 1
    Last Post: 10-01-2009, 05:04 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
  •