spot the mistake in this algorithm please! [SOLVED]

Started by
21 comments, last by judge dreadz 18 years, 1 month ago
ok, I have an account...
sorry for the mess...
int count = 0;int i, j;read2CPU();for (i = 0; i<size*size*4; i+=4){  float pos[3] = {endPos, endPos[i+1], endPos[i+2]};  j = 0;  while (j < size*size*4)  {    if (j != i)    {      float comparePos[3] = {endPos[j], endPos[j+1], endPos[j+2]};      if((pos[0] == comparePos[0])      && (pos[1] == comparePos[1])      && (pos[2] == comparePos[2]))      {        if (j > i)        {          count = count+1;        }        j = size*size*4;      }    }    j=j+4;  }}printf("\n%i", count);

I hope it is finally ok...

Alfith.
www.geocities.com/gemelli_d
Advertisement
ok hold on guys, a thought is forming in my head... think i might no what the problem is... will report back in 10
ok, i've found it. there was nothing wrong with the algorithm. the problem was where i was calling it from.

its a little complex but i will explain as best i can for the curiosity of others.

i originally wrote the read2CPU function to monitor the texture update in the gpu. the gpu texture update requires mapping the texture by setting the viewport to a 1:1 mapping. the viewport then has to be re-set in the display method at each frame to display the system on screen. so when i called checkDuplication from the display method, the read2CPU function was using an incorrect mapping and not returning the correct data.

ps. i'm not sure if the above method is correct, if anyone knows a more efficient method then resetting the viewport twice every frame, please let me know!

This topic is closed to new replies.

Advertisement