procedure MakeMultipleTexture(N: integer;
var MTexture:
array of TMmtTex);
var
mtCount : integer;
K : integer;
nRet : TGLenum;
OkDelete : Bool;
begin
mtCount := high(MTexture) - low(MTexture) + 1;
OkDelete := False;
// Array Redimensionieren
SetLength(Texture, mtCount);
if mtCount > 0
then
begin
for K := 0
to (mtCount - 1)
do
begin
Texture[K] := MTexture[k].Texture;
if Texture[K] <> 0
then
OkDelete := True;
end;
// befinden sich Texturen im Array dann löschen
if OkDelete
then
begin
glDeleteTextures(mtCount, @Texture[1]);
glGenTextures(mtCount, @Texture[1]);
end;
nRet := glGetError;
// Überprüfung ob ein OpenGL Fehler aufgetreten ist
if nRet = 0
then
begin
// alles OK Aktuelle Texture laden
// und ins OpenGl Format konvertieren
for K := 0
to (mtCount - 1)
do
begin
SetLength(mPixelArray, 0);
if CreateGLTextureFromFile(MTexture[K].FullName,
xSize, ySize, MTexture[K].Square, K)
then
begin
MTexture[k].Texture := Texture[K];
glBindTexture(GL_TEXTURE_2D, Texture[K]);
nRet := glGetError;
if nRet = 0
then
begin
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4, xSize, ySize,
0, GL_RGBA, GL_UNSIGNED_BYTE, @mPixelArray[0]);
end;
end;
end;
end;
end;
end;