procedure TForm1.LoadSkyBox(pComponents : Cardinal);
const
SkyBoxName : array[0..5] of String = ('BK', 'A1', 'DN', 'UP', 'LF', 'RT');
var
i : Integer;
begin
ActivateRenderingContext(FDC, FRC);
for i := 0 to High(SkyBoxTexture) do
begin
if SkyBoxTexture[i] = nil then
begin
SkyBoxTexture[i] := TGLBmp.Create;
SkyBoxTexture[i].LoadImage(SkyBoxName[i]+'.jpg');
end;
with SkyBoxTexture[i] do
begin
begin
if TextureID > 0 then
glDeleteTextures(1, @TextureID);
glGenTextures(1, @TextureID);
glBindTexture(GL_TEXTURE_2D, TextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
gluBuild2DMipmaps(GL_TEXTURE_2D, pComponents, GetWidth, GetHeight,
GL_RGBA,GL_UNSIGNED_BYTE, GetData);
end;
end;
end;
GenerateSkyBox(48, 48, 48);
DeActivateRenderingContext;
end;
|