housekeeping
This commit is contained in:
@@ -38,6 +38,21 @@ void Bitmap::Create(int width, int height, int depth, uchar *data) {
|
||||
surface_->pixels = pixel_data_;
|
||||
}
|
||||
|
||||
void Bitmap::Create(int width, int height, int depth, int size) {
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
depth_ = depth;
|
||||
surface_ = SDL_CreateRGBSurfaceWithFormat(0, width, height, depth,
|
||||
SDL_PIXELFORMAT_INDEX8);
|
||||
// Default grayscale palette
|
||||
for (int i = 0; i < 8; i++) {
|
||||
surface_->format->palette->colors[i].r = i * 31;
|
||||
surface_->format->palette->colors[i].g = i * 31;
|
||||
surface_->format->palette->colors[i].b = i * 31;
|
||||
}
|
||||
surface_->pixels = pixel_data_;
|
||||
}
|
||||
|
||||
void Bitmap::CreateTexture(std::shared_ptr<SDL_Renderer> renderer) {
|
||||
texture_ = SDL_CreateTextureFromSurface(renderer.get(), surface_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user