Why does my checksum not work? I use it on my computer with ATI graphics and it works perfectly fine. When I switch to a computer with Intel graphics, it starts doing random values and they aren't the same. I switch back to my comp, the values are still the same (Static.. Never changes).
At first I thought maybe it's an endian problem but I used (Returns Little Endian):
#include <iostream>
#include <windows.h>
using namespace std;
std::string GetEndianness(void)
{
union
{
uint8_t c[4];
uint32_t i;
} u;
u.i = 0x01020304;
if (0x04 == u.c[0])
return "Little Endian.";
else if (0x01 == u.c[0])
return "Big Endian;";
else
return "Unknown Endian;";
}
int main()
{
std::cout<<GetEndianness();
}
My CheckSum:
DWORD Hook_CheckSum(DWORD *BufferData, int Size)
{
if(!BufferData) return 0x0;
DWORD Temp = 0, Sum = *BufferData;
for(int I = 1; I < (Size / 4); I++)
{
Temp = BufferData[I];
Temp = (DWORD)(Sum >> 29) + Temp;
Temp = (DWORD)(Sum >> 17) + Temp;
Sum = (DWORD)(Sum << 3) ^ Temp;
}
return Sum;
}
My Usage:
DLL_EXTERN void __stdcall HookglBufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage)
{
Buffer.Pointer = data;
Buffer.CheckSum = CheckSum((DWORD*)data, size);
BufferList.push_back(Buffer);
(*orig_glBufferDataARB) (target, size, data, usage);
}
Is there a special case that I'm missing where my checksum will not work? Why only my computer sees it correctly? Anyone have a better idea of what I should use? I'm generating ID's for models. I use the algorithm on the vertex buffer in opengl. Also is there a reason that code would work super fast on my system but on an nvidia/intel, lag like crazy? It's the same code :S