- // creating array for scanline
- SetLength(png_rows, Height);
- try
- for Row := 0 to Height - 1 do begin
- png_rows[Row] := Data;
- Inc(png_rows[Row], Row * LineSize)
- end;
-
- // write struct
- png := png_create_write_struct(PNG_LIBPNG_VER_STRING, nil, nil, nil);
- if png = nil then
- raise EglBitmapException.Create('SavePng - couldn''t create write struct.');
-
- // create png info
- png_info := png_create_info_struct(png);
- if png_info = nil then begin
- png_destroy_write_struct(@png, nil);
- raise EglBitmapException.Create('SavePng - couldn''t create info struct.');
- end;
-
- // set read callback
- png_set_write_fn(png, stream, glBitmap_libPNG_write_func, nil);
-
- // set compression
- png_set_compression_level(png, 6);
-
- if InternalFormat in [ifBGR8, ifBGRA8] then
- png_set_bgr(png);
-
- // setup header
- png_set_IHDR(png, png_info, Width, Height, 8, ColorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
-
- // write info
- png_write_info(png, png_info);
-
- // write image data
- png_write_image(png, @png_rows[0]);
-
- // write end
- png_write_end(png, png_info);
-
- // destroy write struct
- png_destroy_write_struct(@png, @png_info);
- finally
- SetLength(png_rows, 0);
- end;
- finally
- quit_libPNG;
- end;
-end;
-{$ENDIF}
-{$IFDEF GLB_PNGIMAGE}
-var
- Png: TPNGObject;
-
- pSource, pDest: pByte;
- X, Y, PixSize: Integer;
- ColorType: Cardinal;
- Alpha: Boolean;
-
- pTemp: pByte;
- Temp: Byte;
-begin
- if not (ftPNG in FormatGetSupportedFiles (InternalFormat)) then
- raise EglBitmapUnsupportedInternalFormat.Create('SavePng - ' + UNSUPPORTED_INTERNAL_FORMAT);
-
- case FInternalFormat of
- ifAlpha, ifLuminance, ifDepth8:
- begin
- ColorType := COLOR_GRAYSCALE;
- PixSize := 1;
- Alpha := False;
- end;
- ifLuminanceAlpha:
- begin
- ColorType := COLOR_GRAYSCALEALPHA;
- PixSize := 1;
- Alpha := True;
- end;
- ifBGR8, ifRGB8:
- begin
- ColorType := COLOR_RGB;
- PixSize := 3;
- Alpha := False;
- end;
- ifBGRA8, ifRGBA8:
- begin
- ColorType := COLOR_RGBALPHA;
- PixSize := 3;
- Alpha := True
- end;
- else
- raise EglBitmapUnsupportedInternalFormat.Create('SavePng - ' + UNSUPPORTED_INTERNAL_FORMAT);
- end;
-
- Png := TPNGObject.CreateBlank(ColorType, 8, Width, Height);
- try
- // Copy ImageData
- pSource := Data;
- for Y := 0 to Height -1 do begin
- pDest := png.ScanLine[Y];
-
- for X := 0 to Width -1 do begin
- Move(pSource^, pDest^, PixSize);
-
- Inc(pDest, PixSize);
- Inc(pSource, PixSize);
-
- if Alpha then begin
- png.AlphaScanline[Y]^[X] := pSource^;
- Inc(pSource);
- end;
- end;
-
- // convert RGB line to BGR
- if InternalFormat in [ifRGB8, ifRGBA8] then begin
- pTemp := png.ScanLine[Y];
-
- for X := 0 to Width -1 do begin
- Temp := pByteArray(pTemp)^[0];
- pByteArray(pTemp)^[0] := pByteArray(pTemp)^[2];
- pByteArray(pTemp)^[2] := Temp;
-
- Inc(pTemp, 3);
- end;
- end;
- end;
-
- // Save to Stream
- Png.CompressionLevel := 6;
- Png.SaveToStream(Stream);
- finally
- FreeAndNil(Png);
- end;
-end;
-{$ENDIF}
-{$ENDIF}
-
-
-procedure TglBitmap.SaveDDS(Stream: TStream);
-var
- Header: TDDSHeader;
- Pix: TglBitmapPixelData;
-begin
- if not FormatIsUncompressed(InternalFormat) then
- raise EglBitmapUnsupportedInternalFormat.Create('SaveDDS - ' + UNSUPPORTED_INTERNAL_FORMAT);
-
- if InternalFormat = ifAlpha then
- FormatPreparePixel(Pix, ifLuminance)
- else
- FormatPreparePixel(Pix, InternalFormat);
-
- // Generell
- FillChar(Header, SizeOf(Header), 0);
-
- Header.dwMagic := DDS_MAGIC;
- Header.dwSize := 124;
- Header.dwFlags := DDSD_PITCH or DDSD_CAPS or DDSD_PIXELFORMAT;
-
- if Width > 0 then begin
- Header.dwWidth := Width;
- Header.dwFlags := Header.dwFlags or DDSD_WIDTH;
- end;
-
- if Height > 0 then begin
- Header.dwHeight := Height;
- Header.dwFlags := Header.dwFlags or DDSD_HEIGHT;
- end;
-
- Header.dwPitchOrLinearSize := fRowSize;
- Header.dwMipMapCount := 1;
-
- // Caps
- Header.Caps.dwCaps1 := DDSCAPS_TEXTURE;
-
- // Pixelformat
- Header.PixelFormat.dwSize := Sizeof(Header.PixelFormat);
- Header.PixelFormat.dwFlags := DDPF_RGB;
-
- if FormatHasAlpha(InternalFormat) and (InternalFormat <> ifAlpha)
- then Header.PixelFormat.dwFlags := Header.PixelFormat.dwFlags or DDPF_ALPHAPIXELS;
-
- Header.PixelFormat.dwRGBBitCount := Trunc(FormatGetSize(InternalFormat) * 8);
- Header.PixelFormat.dwRBitMask := Pix.PixelDesc.RedRange shl Pix.PixelDesc.RedShift;
- Header.PixelFormat.dwGBitMask := Pix.PixelDesc.GreenRange shl Pix.PixelDesc.GreenShift;
- Header.PixelFormat.dwBBitMask := Pix.PixelDesc.BlueRange shl Pix.PixelDesc.BlueShift;
- Header.PixelFormat.dwAlphaBitMask := Pix.PixelDesc.AlphaRange shl Pix.PixelDesc.AlphaShift;
-
- // Write
- Stream.Write(Header, SizeOf(Header));
-
- Stream.Write(Data^, FormatGetImageSize(glBitmapPosition(Width, Height), InternalFormat));
-end;
-
-
-procedure TglBitmap.SaveTGA(Stream: TStream);
-var
- Header: TTGAHeader;
- Size: Integer;
- pTemp: pByte;
-
-
- procedure ConvertData(pTemp: pByte);
- var
- Idx, PixelSize: Integer;
- Temp: byte;
- begin
- PixelSize := fPixelSize;
-
- for Idx := 1 to Height * Width do begin
- Temp := pByteArray(pTemp)^[2];
- pByteArray(pTemp)^[2] := pByteArray(pTemp)^[0];
- pByteArray(pTemp)^[0] := Temp;
-
- Inc(pTemp, PixelSize);
- end;
- end;
-
-
-begin
- if not (ftTGA in FormatGetSupportedFiles (InternalFormat)) then
- raise EglBitmapUnsupportedInternalFormat.Create('SaveTGA - ' + UNSUPPORTED_INTERNAL_FORMAT);
-
- FillChar(Header, SizeOf(Header), 0);
-
- case InternalFormat of
- ifAlpha, ifLuminance, ifDepth8:
- begin
- Header.ImageType := TGA_UNCOMPRESSED_GRAY;
- Header.Bpp := 8;
- end;
- ifLuminanceAlpha:
- begin
- Header.ImageType := TGA_UNCOMPRESSED_GRAY;
- Header.Bpp := 16;
- end;
- ifRGB8, ifBGR8:
- begin
- Header.ImageType := TGA_UNCOMPRESSED_RGB;
- Header.Bpp := 24;
- end;
- ifRGBA8, ifBGRA8:
- begin
- Header.ImageType := TGA_UNCOMPRESSED_RGB;
- Header.Bpp := 32;
- end;
- else
- raise EglBitmapUnsupportedInternalFormat.Create('SaveTGA - ' + UNSUPPORTED_INTERNAL_FORMAT);
- end;
-
- Header.Width := Width;
- Header.Height := Height;
- Header.ImageDes := $20;
-
- if FormatHasAlpha(InternalFormat) then
- Header.ImageDes := Header.ImageDes or $08;
-
- Stream.Write(Header, SizeOf(Header));
-
- // convert RGB(A) to BGR(A)
- Size := FormatGetImageSize(glBitmapPosition(Width, Height), InternalFormat);
- if InternalFormat in [ifRGB8, ifRGBA8] then begin
- GetMem(pTemp, Size);
- end else
- pTemp := Data;
-
- try
- // convert data
- if InternalFormat in [ifRGB8, ifRGBA8] then begin
- Move(Data^, pTemp^, Size);
- ConvertData(pTemp);
- end;
-
- // write data
- Stream.Write(pTemp^, Size);
- finally
- // free tempdata
- if InternalFormat in [ifRGB8, ifRGBA8] then
- FreeMem(pTemp);
- end;
-end;
-
-
-{$IFDEF GLB_SUPPORT_JPEG_WRITE}
-procedure TglBitmap.SaveJPEG(Stream: TStream);
-{$IFDEF GLB_LIB_JPEG}
-var
- jpeg: jpeg_compress_struct;
- jpeg_err: jpeg_error_mgr;
- Row: Integer;
- pTemp, pTemp2: pByte;
-
-
- procedure CopyRow(pDest, pSource: pByte);
- var
- X: Integer;
- begin
- for X := 0 to Width - 1 do begin
- pByteArray(pDest)^[0] := pByteArray(pSource)^[2];
- pByteArray(pDest)^[1] := pByteArray(pSource)^[1];
- pByteArray(pDest)^[2] := pByteArray(pSource)^[0];
-
- Inc(pDest, 3);
- Inc(pSource, 3);
- end;
- end;
-
-begin
- if not (ftJPEG in FormatGetSupportedFiles(InternalFormat)) then
- raise EglBitmapUnsupportedInternalFormat.Create('SaveJpg - ' + UNSUPPORTED_INTERNAL_FORMAT);
-
- if not init_libJPEG then
- raise Exception.Create('SaveJPG - unable to initialize libJPEG.');
-
- try
- FillChar(jpeg, SizeOf(jpeg_compress_struct), $00);
- FillChar(jpeg_err, SizeOf(jpeg_error_mgr), $00);
-
- // error managment
- jpeg.err := jpeg_std_error(@jpeg_err);
- jpeg_err.error_exit := glBitmap_libJPEG_error_exit;
- jpeg_err.output_message := glBitmap_libJPEG_output_message;
-
- // compression struct
- jpeg_create_compress(@jpeg);
-
- // allocation space for streaming methods
- jpeg.dest := jpeg.mem^.alloc_small(@jpeg, JPOOL_PERMANENT, SizeOf(glBitmap_libJPEG_dest_mgr));
-
- // seeting up custom functions
- with glBitmap_libJPEG_dest_mgr_ptr(jpeg.dest)^ do begin
- pub.init_destination := glBitmap_libJPEG_init_destination;
- pub.empty_output_buffer := glBitmap_libJPEG_empty_output_buffer;
- pub.term_destination := glBitmap_libJPEG_term_destination;
-
- pub.next_output_byte := @DestBuffer[1];
- pub.free_in_buffer := Length(DestBuffer);
-
- DestStream := Stream;
- end;
-
- // very important state
- jpeg.global_state := CSTATE_START;
-
- jpeg.image_width := Width;
- jpeg.image_height := Height;
- case InternalFormat of
- ifAlpha, ifLuminance, ifDepth8:
- begin
- jpeg.input_components := 1;
- jpeg.in_color_space := JCS_GRAYSCALE;
- end;
- ifRGB8, ifBGR8:
- begin
- jpeg.input_components := 3;
- jpeg.in_color_space := JCS_RGB;
- end;
- end;
-
- // setting defaults
- jpeg_set_defaults(@jpeg);
-
- // compression quality
- jpeg_set_quality(@jpeg, 95, True);
-
- // start compression
- jpeg_start_compress(@jpeg, true);
-
- // write rows
- pTemp := Data;
-
- // initialing row
- if InternalFormat = ifBGR8 then
- GetMem(pTemp2, fRowSize)
- else
- pTemp2 := pTemp;
-
- try
- for Row := 0 to jpeg.image_height -1 do begin
- // prepare row
- if InternalFormat = ifBGR8 then
- CopyRow(pTemp2, pTemp)
- else
- pTemp2 := pTemp;
-
- // write row
- jpeg_write_scanlines(@jpeg, @pTemp2, 1);
- inc(pTemp, fRowSize);
- end;
- finally
- // free memory
- if InternalFormat = ifBGR8 then
- FreeMem(pTemp2);
- end;
-
- // finish compression
- jpeg_finish_compress(@jpeg);
-
- // destroy compression
- jpeg_destroy_compress(@jpeg);
- finally
- quit_libJPEG;
- end;
-end;
-{$ENDIF}
-{$IFDEF GLB_DELPHI_JPEG}
-var
- Bmp: TBitmap;
- Jpg: TJPEGImage;
-begin
- if not (ftJPEG in FormatGetSupportedFiles (InternalFormat)) then
- raise EglBitmapUnsupportedInternalFormat.Create('SaveJpg - ' + UNSUPPORTED_INTERNAL_FORMAT);
-
- Bmp := TBitmap.Create;
- try
- Jpg := TJPEGImage.Create;
- try
- AssignToBitmap(Bmp);
-
- if FInternalFormat in [ifAlpha, ifLuminance, ifDepth8] then begin
- Jpg.Grayscale := True;
- Jpg.PixelFormat := jf8Bit;
- end;
-
- Jpg.Assign(Bmp);
-
- Jpg.SaveToStream(Stream);
- finally
- FreeAndNil(Jpg);
- end;
- finally
- FreeAndNil(Bmp);
- end;
-end;
-{$ENDIF}
-{$ENDIF}
-
-
-procedure TglBitmap.SaveBMP(Stream: TStream);
-var
- Header: TBMPHeader;
- Info: TBMPInfo;
- pData, pTemp: pByte;
-
- PixelFormat: TglBitmapPixelData;
- ImageSize, LineSize, Padding, LineIdx, ColorIdx: Integer;
- Temp, RedMask, GreenMask, BlueMask, AlphaMask: Cardinal;
-
- PaddingBuff: Cardinal;
-
-
- function GetLineWidth : Integer;
- begin
- Result := ((Info.biWidth * Info.biBitCount + 31) and - 32) shr 3;
- end;
-
-
-begin
- if not (ftBMP in FormatGetSupportedFiles(InternalFormat)) then
- raise EglBitmapUnsupportedInternalFormat.Create('SaveBMP - ' + UNSUPPORTED_INTERNAL_FORMAT);
-
- ImageSize := Trunc(Width * Height * FormatGetSize(InternalFormat));
-
- Header.bfType := BMP_MAGIC;
- Header.bfSize := SizeOf(Header) + SizeOf(Info) + ImageSize;
- Header.bfReserved1 := 0;
- Header.bfReserved2 := 0;
- Header.bfOffBits := SizeOf(Header) + SizeOf(Info);
-
- FillChar(Info, SizeOf(Info), 0);
- Info.biSize := SizeOf(Info);
- Info.biWidth := Width;
- Info.biHeight := Height;
- Info.biPlanes := 1;
- Info.biCompression := BMP_COMP_RGB;
- Info.biSizeImage := ImageSize;
- case InternalFormat of
- ifAlpha, ifLuminance, ifDepth8:
- begin
- Info.biBitCount := 8;
-
- Header.bfSize := Header.bfSize + 256 * SizeOf(Cardinal);
- Header.bfOffBits := Header.bfOffBits + 256 * SizeOf(Cardinal);
-
- Info.biClrUsed := 256;
- Info.biClrImportant := 256;
- end;
- ifLuminanceAlpha, ifRGBA4, ifR5G6B5, ifRGB5A1:
- begin
- Info.biBitCount := 16;
- Info.biCompression := BMP_COMP_BITFIELDS;
- end;
- ifBGR8, ifRGB8:
- Info.biBitCount := 24;
- ifBGRA8, ifRGBA8, ifRGB10A2:
- begin
- Info.biBitCount := 32;
- Info.biCompression := BMP_COMP_BITFIELDS;
- end;
- else
- raise EglBitmapUnsupportedInternalFormat.Create('SaveBMP - ' + UNSUPPORTED_INTERNAL_FORMAT);
- end;
- Info.biXPelsPerMeter := 2835;
- Info.biYPelsPerMeter := 2835;
-
- // prepare bitmasks
- if Info.biCompression = BMP_COMP_BITFIELDS then begin
- Info.biSize := Info.biSize + 4 * SizeOf(Cardinal);
- Header.bfSize := Header.bfSize + 4 * SizeOf(Cardinal);
- Header.bfOffBits := Header.bfOffBits + 4 * SizeOf(Cardinal);
-
- FormatPreparePixel(PixelFormat, InternalFormat);
-
- with PixelFormat.PixelDesc do begin
- RedMask := RedRange shl RedShift;
- GreenMask := GreenRange shl GreenShift;
- BlueMask := BlueRange shl BlueShift;
- AlphaMask := AlphaRange shl AlphaShift;
- end;
- end;
-
- // headers
- Stream.Write(Header, SizeOf(Header));
- Stream.Write(Info, SizeOf(Info));
-
- // colortable
- if Info.biBitCount = 8 then begin
- Temp := 0;
- for ColorIdx := Low(Byte) to High(Byte) do begin
- Stream.Write(Temp, 4);
- Temp := Temp + $00010101;
- end;
- end;
-
- // bitmasks
- if Info.biCompression = BMP_COMP_BITFIELDS then begin
- Stream.Write(RedMask, SizeOf(Cardinal));
- Stream.Write(GreenMask, SizeOf(Cardinal));
- Stream.Write(BlueMask, SizeOf(Cardinal));
- Stream.Write(AlphaMask, SizeOf(Cardinal));
- end;
-
- // image data
- LineSize := Trunc(Width * FormatGetSize(InternalFormat));
- Padding := GetLineWidth - LineSize;
- PaddingBuff := 0;
-
- pData := Data;
- Inc(pData, (Height -1) * LineSize);
-
- // prepare row buffer. But only for RGB because RGBA supports color masks
- // so it's possible to change color within the image.
- if InternalFormat = ifRGB8 then
- GetMem(pTemp, fRowSize)
- else
- pTemp := nil;
-
- try
- // write image data
- for LineIdx := 0 to Height - 1 do begin
- // preparing row
- if InternalFormat = ifRGB8 then begin
- Move(pData^, pTemp^, fRowSize);
- SwapRGB(pTemp, Width, False);
- end else
- pTemp := pData;
-
- Stream.Write(pTemp^, LineSize);
-
- Dec(pData, LineSize);
-
- if Padding > 0 then
- Stream.Write(PaddingBuff, Padding);
- end;
- finally
- // destroy row buffer
- if InternalFormat = ifRGB8 then
- FreeMem(pTemp);
- end;
-end;
-
-
-procedure TglBitmap.Bind(EnableTextureUnit: Boolean);
-begin
- if EnableTextureUnit then
- glEnable(Target);
-
- if ID > 0 then
- glBindTexture(Target, ID);
-end;
-
-
-procedure TglBitmap.Unbind(DisableTextureUnit: Boolean);
-begin
- if DisableTextureUnit then
- glDisable(Target);
-
- glBindTexture(Target, 0);
-end;
-
-
-procedure TglBitmap.GetPixel(const Pos: TglBitmapPixelPosition;
- var Pixel: TglBitmapPixelData);
-begin
- if Assigned (fGetPixelFunc) then
- fGetPixelFunc(Pos, Pixel);
-end;
-
-
-procedure TglBitmap.SetPixel (const Pos: TglBitmapPixelPosition;
- const Pixel: TglBitmapPixelData);
-begin
- if Assigned (fSetPixelFunc) then
- fSetPixelFunc(Pos, Pixel);
-end;
-
-
-procedure TglBitmap.CreateID;
-begin
- // Generate Texture
- if ID <> 0 then
- glDeleteTextures(1, @ID);
-
- glGenTextures(1, @ID);
-
- Bind(False);
-end;
-
-
-procedure TglBitmap.SetupParameters(var BuildWithGlu: Boolean);
-begin
- // Set up parameters
- SetWrap(fWrapS, fWrapT, fWrapR);
- SetFilter(fFilterMin, fFilterMag);
- SetAnisotropic(fAnisotropic);
- SetBorderColor(fBorderColor[0], fBorderColor[1], fBorderColor[2], fBorderColor[3]);
-
- // Mip Maps generation Mode
- BuildWithGlu := False;
-
- if (MipMap = mmMipmap) then begin
- if (GL_VERSION_1_4 or GL_SGIS_generate_mipmap) then
- glTexParameteri(Target, GL_GENERATE_MIPMAP, GL_TRUE)
- else
- BuildWithGlu := True;
- end else
- if (MipMap = mmMipmapGlu) then
- BuildWithGlu := True;
-end;
-
-
-procedure TglBitmap.SelectFormat(DataFormat: TglBitmapInternalFormat; var glFormat, glInternalFormat, glType: Cardinal; CanConvertImage: Boolean = True);
-
- procedure Check12;
- begin
- if not GL_VERSION_1_2 then
- raise EglBitmapUnsupportedInternalFormat.Create('SelectFormat - You need at least OpenGL 1.2 to support these format.');
- end;
-
-begin
- glType := GL_UNSIGNED_BYTE;
-
- // selecting Format
- case DataFormat of
- ifAlpha:
- glFormat := GL_ALPHA;
- ifLuminance:
- glFormat := GL_LUMINANCE;
- ifDepth8:
- glFormat := GL_DEPTH_COMPONENT;
- ifLuminanceAlpha:
- glFormat := GL_LUMINANCE_ALPHA;
- ifBGR8:
- begin
- if (GL_VERSION_1_2 or GL_EXT_bgra) then begin
- glFormat := GL_BGR;
- end else begin
- if CanConvertImage then
- ConvertTo(ifRGB8);
- glFormat := GL_RGB;
- end;
- end;
- ifBGRA8:
- begin
- if (GL_VERSION_1_2 or GL_EXT_bgra) then begin
- glFormat := GL_BGRA;
- end else begin
- if CanConvertImage then
- ConvertTo(ifRGBA8);
- glFormat := GL_RGBA;
- end;
- end;
- ifRGB8:
- glFormat := GL_RGB;
- ifRGBA8:
- glFormat := GL_RGBA;
- ifRGBA4:
- begin
- Check12;
- glFormat := GL_BGRA;
- glType := GL_UNSIGNED_SHORT_4_4_4_4_REV;
- end;
- ifRGB5A1:
- begin
- Check12;
- glFormat := GL_BGRA;
- glType := GL_UNSIGNED_SHORT_1_5_5_5_REV;
- end;
- ifRGB10A2:
- begin
- Check12;
- glFormat := GL_BGRA;
- glType := GL_UNSIGNED_INT_2_10_10_10_REV;
- end;
- ifR5G6B5:
- begin
- Check12;
- glFormat := GL_RGB;
- glType := GL_UNSIGNED_SHORT_5_6_5;
- end;
- else
- glFormat := 0;
- end;
-
- // Selecting InternalFormat
- case DataFormat of
- ifDXT1, ifDXT3, ifDXT5:
- begin
- if GL_EXT_texture_compression_s3tc then begin
- case DataFormat of
- ifDXT1:
- glInternalFormat := GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- ifDXT3:
- glInternalFormat := GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- ifDXT5:
- glInternalFormat := GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
- end;
- end else begin
- // Compression isn't supported so convert to RGBA
- if CanConvertImage then
- ConvertTo(ifRGBA8);
- glFormat := GL_RGBA;
- glInternalFormat := GL_RGBA8;
- end;
- end;
- ifAlpha:
- begin
- case Format of
- tf4BitsPerChanel:
- glInternalFormat := GL_ALPHA4;
- tf8BitsPerChanel:
- glInternalFormat := GL_ALPHA8;
- tfCompressed:
- begin
- if (GL_ARB_texture_compression or GL_VERSION_1_3) then
- glInternalFormat := GL_COMPRESSED_ALPHA
- else
- glInternalFormat := GL_ALPHA;
- end;
- else
- glInternalFormat := GL_ALPHA;
- end;
- end;
- ifLuminance:
- begin
- case Format of
- tf4BitsPerChanel:
- glInternalFormat := GL_LUMINANCE4;
- tf8BitsPerChanel:
- glInternalFormat := GL_LUMINANCE8;
- tfCompressed:
- begin
- if (GL_ARB_texture_compression or GL_VERSION_1_3) then
- glInternalFormat := GL_COMPRESSED_LUMINANCE
- else
- glInternalFormat := GL_LUMINANCE;
- end;
- else
- glInternalFormat := GL_LUMINANCE;
- end;
- end;
- ifDepth8:
- begin
- glInternalFormat := GL_DEPTH_COMPONENT;
- end;
- ifLuminanceAlpha:
- begin
- case Format of
- tf4BitsPerChanel:
- glInternalFormat := GL_LUMINANCE4_ALPHA4;
- tf8BitsPerChanel:
- glInternalFormat := GL_LUMINANCE8_ALPHA8;
- tfCompressed:
- begin
- if (GL_ARB_texture_compression or GL_VERSION_1_3) then
- glInternalFormat := GL_COMPRESSED_LUMINANCE_ALPHA
- else
- glInternalFormat := GL_LUMINANCE_ALPHA;
- end;
- else
- glInternalFormat := GL_LUMINANCE_ALPHA;
- end;
- end;
- ifBGR8, ifRGB8:
- begin
- case Format of
- tf4BitsPerChanel:
- glInternalFormat := GL_RGB4;
- tf8BitsPerChanel:
- glInternalFormat := GL_RGB8;
- tfCompressed:
- begin
- if (GL_ARB_texture_compression or GL_VERSION_1_3) then begin
- glInternalFormat := GL_COMPRESSED_RGB
- end else begin
- if (GL_EXT_texture_compression_s3tc) then
- glInternalFormat := GL_COMPRESSED_RGB_S3TC_DXT1_EXT
- else
- glInternalFormat := GL_RGB;
- end;
- end;
- else
- glInternalFormat := GL_RGB;
- end;
- end;
- ifBGRA8, ifRGBA8, ifRGBA4, ifRGB5A1, ifRGB10A2, ifR5G6B5:
- begin
- case Format of
- tf4BitsPerChanel:
- glInternalFormat := GL_RGBA4;
- tf8BitsPerChanel:
- glInternalFormat := GL_RGBA8;
- tfCompressed:
- begin
- if (GL_ARB_texture_compression or GL_VERSION_1_3) then begin
- glInternalFormat := GL_COMPRESSED_RGBA
- end else begin
- if (GL_EXT_texture_compression_s3tc) then
- glInternalFormat := GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
- else
- glInternalFormat := GL_RGBA;
- end;
- end;
- else
- glInternalFormat := GL_RGBA;
- end;
- end;
- end;
-end;
-
-
-function TglBitmap.FlipHorz: Boolean;
-begin
- Result := False;
-end;
-
-
-function TglBitmap.FlipVert: Boolean;
-begin
- Result := False;
-end;
-
-
-procedure TglBitmap.FreeData;
-begin
- SetDataPointer(nil, ifEmpty);
-end;