housekeeping

This commit is contained in:
scawful
2022-07-08 23:52:11 -04:00
parent 260f9d5166
commit e9c8152453
10 changed files with 77 additions and 99 deletions

View File

@@ -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_);
}