# Class TglBitmap2D

Description | Hierarchy | Fields | Methods | Properties

## Unit

glBitmap

## Declaration

`type TglBitmap2D = class(TglBitmap)`

## Description

wrapper class for 2-dimensional textures (OpenGL target = GL_TEXTURE_2D)

## Hierarchy

- TObject
- TglBitmap
- TglBitmap2D

## Overview

### Fields

| `fLines: array of PByte;`

### Methods

| `function GetScanline(const aIndex: Integer): Pointer;`
| `procedure SetDataPointer(var aData: PByte; const aFormat: TglBitmapFormat; const aWidth: Integer = - 1; const aHeight: Integer = - 1); override;`
| `procedure UploadData(const aTarget: GLenum);`
| `procedure AfterConstruction; override;`
| `procedure GrabScreen(const aTop, aLeft, aRight, aBottom: Integer; const aFormat: TglBitmapFormat);`
| `procedure GenTexture(const aTestTextureSize: Boolean = true); override;`
| `function FlipHorz: Boolean; override;`
| `function FlipVert: Boolean; override;`
| `procedure GenerateNormalMap(const aFunc: TglBitmapNormalMapFunc = nm3x3; const aScale: Single = 2; const aUseAlpha: Boolean = false);`

### Properties

| `property Width;`
| `property Height;`
| `property Scanline[constaIndex:Integer]: Pointer read GetScanline;`

## Description

### Fields

| `fLines: array of PByte;`
array to store scanline entry points in

### Methods

| `function GetScanline(const aIndex: Integer): Pointer;`

get a specific scanline

###### Parameters

aIndex
  index of the scanline to return

###### Returns

scanline at position aIndex or `Nil`

| `procedure SetDataPointer(var aData: PByte; const aFormat: TglBitmapFormat; const aWidth: Integer = - 1; const aHeight: Integer = - 1); override;`

set data pointer of texture data

###### Parameters

aData
  pointer to new texture data (be carefull, aData could be freed by this function)
aFormat
  format of the data stored at aData
aWidth
  width of the texture data
aHeight
  height of the texture data

| `procedure UploadData(const aTarget: GLenum);`

upload the texture data to video card

###### Parameters

aTarget
  target o upload data to (e.g. GL_TEXTURE_2D)
aBuildWithGlu
  use glu functions to build mipmaps

| `procedure AfterConstruction; override;`
this method is called after constructor and initializes the object

| `procedure GrabScreen(const aTop, aLeft, aRight, aBottom: Integer; const aFormat: TglBitmapFormat);`

copy a part of the frame buffer top the texture

###### Parameters

aTop
  topmost pixel to copy
aLeft
  leftmost pixel to copy
aRight
  rightmost pixel to copy
aBottom
  bottommost pixel to copy
aFormat
  format to store data in

| `procedure GenTexture(const aTestTextureSize: Boolean = true); override;`

generate texture (create texture object if not exist, set texture parameters and upload data)

###### Parameters

aTestTextureSize
  check the size of the texture and throw exception if something is wrong

| `function FlipHorz: Boolean; override;`

flip texture horizontally

###### Returns

`True` on success, `False` otherwise

| `function FlipVert: Boolean; override;`

flip texture vertically

###### Returns

`True` on success, `False` otherwise

| `procedure GenerateNormalMap(const aFunc: TglBitmapNormalMapFunc = nm3x3; const aScale: Single = 2; const aUseAlpha: Boolean = false);`

create normal map from texture data

###### Parameters

aFunc
  normal map function to generate normalmap with
aScale
  scale of the normale stored in the normal map
aUseAlpha
  generate normalmap from alpha channel data (if present)

### Properties

| `property Width;`
actual width of the texture

| `property Height;`
actual height of the texture

| `property Scanline[constaIndex:Integer]: Pointer read GetScanline;`
scanline to access texture data directly

Generated by PasDoc 0.13.0 on 2014-12-21 15:05:48