- // load texture
- tex := TglBitmap2D.Create;
- tex.LoadFromFile(ExtractFilePath(ApplicationName) + '../textures/BMP_24_RGB8.bmp');
- tex.GenTexture;
+ tex := TglBitmap2D.Create; // create texture object
+ data := TglBitmapData.Create; // create texture data object
+ try
+ data.LoadFromFile( // load texture data from file
+ ExtractFilePath(ApplicationName) +
+ '../textures/BMP_24_RGB8.bmp');
+ tex.UploadData(data); // upload data to video card
+ finally
+ FreeAndNil(data); // after upload is done, the data object could be freed to save memory
+ end;