Alright, now that I have a bit more time and aren't typing on my phone.
The following tests were done with the following, fairly standard, layout:
Let's look at something as simple as checking if our combat type, be it full manual, legacy, revolution - sorry, you're going to need to be logged in for this, but please, feel free to run both. The combat icon has a texture IDs 364748 and 368253. For both cases, I had the full manual showing. I tried to made the SRL-GLX version as efficient as possible, however it matches (apart from using Cases) the include:
Simba Code:
program BM;
{$include_once ogLib/lib/core/core.simba}
Function glGetTextures(IDs: TIntegerArray): glTextureArray; overload;
var
Size, I, J: Cardinal;
Ptr: Pointer;
Begin
J := 0;
Result := [];
Ptr := GLXTextures(Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
Begin
if (IDs.Contains(Integer(Ptr^))) then
begin
Result[J] := glTexture(Ptr^);
Inc(J);
end;
Ptr.Inc(sizeof(glTexture));
End;
SetLength(Result, J);
End;
Function GL_CombatMode: string;
Var TextureArray:glTextureArray;
Begin
If Length(TextureArray:=glGetTextures([364748,368253])) Then
Begin
Case textureArray[0].ID Of
368253:Result:='revolution';
364748:
Case textureArray[0].ColourID Of
7234886:Result:='full manual';
7496771:Result:='momentum';
End;
End;
End;
Exit(Result);
End;
//~ IDs:
//~ 364748 - Full Manual/Momentum
//~ 368253 - Revolution
//~ ColourIDs:
//~ 7234886 - Full Manual
//~ 7496771 - Momentum
const
loopCount:int32=10000;
var
timeEnd,
timeStart:int64;
begin
ogl.setup();
timeStart:=getSystemTime();
for 0 to loopCount do
GL_CombatMode;
timeEnd:=getSystemTime();
writeln('end GLX test, time taken = ', timeEnd-timeStart);
end.
Code:
14:43:50 | BM > setup
end GLX test, time taken = 216515
Successfully executed.
Analyzing this, we can see that glGetTextures() is looking through each and every texture, starting first-drawn to the last, and looking for the texture IDs 364748 and 368253. Even if it finds it right away, which it won't because it's one of the last drawn, it keeps going and then returns the results as a glTextureArray. Regardless, it's still operating similar to the pointer/const method you posted above.
Now, if I were to do the same, using my method:
Simba Code:
program BM;
{$include_once ogLib/lib/core/core.simba}
function GL_CombatMode:string;
var
funcPointer:pointer;
funcPointerSize:uInt32=0;
begin
funcPointer:=glTextures(funcPointerSize)+(36*(funcPointerSize-1));
for 0 to funcPointerSize div 4 do
begin
case 0+funcPointer^ of
364748: //~ Full Manual/Momentum
begin
case 0+(funcPointer+4)^ of
7234886:result:='full manual';
7496771:result:='momentum';
end;
break;
end;
368253: //~ Revolution
begin
result:='revolution';
break;
end;
end;
funcPointer:=funcPointer-36;
end;
exit(result);
end;
const
loopCount:int32=10000;
var
timeEnd,
timeStart:int64;
begin
ogl.setup();
timeStart:=getSystemTime();
for 0 to loopCount do
GL_CombatMode;
timeEnd:=getSystemTime();
writeln('end ogLib test, time taken = ', timeEnd-timeStart);
end.
Code:
14:53:38 | BM > setup
end ogLib test, time taken = 31
Successfully executed.
Since, from debugging, we know that the combat icon is one of the last drawn textures, it's safe to assume we should start at the end and it'll be within the first 1/4 of textures found. For that reason, we use:
Simba Code:
funcPointer:=glTextures(funcPointerSize)+(36*(funcPointerSize-1));
for 0 to funcPointerSize div 4 do
It starts at the end. When it finds the result it's looking for, it stops. That's why I wrote my own include. :P.
@bonsai