2 * Copyright 2009, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Alexandre Deckner <alex@zappotek.com>
9 #include "BitmapTexture.h"
18 BitmapTexture::BitmapTexture(BBitmap
* bitmap
)
26 BitmapTexture::~BitmapTexture()
32 BitmapTexture::_Load(BBitmap
* bitmap
) {
36 glGenTextures(1, &fId
);
37 glBindTexture(GL_TEXTURE_2D
, fId
);
38 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
39 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
40 glTexImage2D(GL_TEXTURE_2D
, 0, 4,
41 (int) bitmap
->Bounds().Width() + 1,
42 (int) bitmap
->Bounds().Height() + 1,
43 0, GL_BGRA
, GL_UNSIGNED_BYTE
,
46 printf("BitmapTexture::_Load, loaded texture %u "
47 "(%" B_PRIi32
", %" B_PRIi32
", %" B_PRIi32
"bits)\n",
48 fId
, (int32
) bitmap
->Bounds().Width(),
49 (int32
) bitmap
->Bounds().Height(),
50 8 * bitmap
->BytesPerRow() / (int)bitmap
->Bounds().Width());