gfx cleanup
This commit is contained in:
@@ -235,6 +235,11 @@ void Bitmap::Create(int width, int height, int depth, const Bytes &data) {
|
||||
|
||||
void Bitmap::Create(int width, int height, int depth, int format,
|
||||
const Bytes &data) {
|
||||
if (data.empty()) {
|
||||
SDL_Log("Bitmap data is empty\n");
|
||||
active_ = false;
|
||||
return;
|
||||
}
|
||||
active_ = true;
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
@@ -246,6 +251,11 @@ void Bitmap::Create(int width, int height, int depth, int format,
|
||||
SDL_CreateRGBSurfaceWithFormat(0, width_, height_, depth_,
|
||||
GetSnesPixelFormat(format)),
|
||||
SDL_Surface_Deleter());
|
||||
if (surface_ == nullptr) {
|
||||
SDL_Log("SDL_CreateRGBSurfaceWithFormat failed: %s\n", SDL_GetError());
|
||||
active_ = false;
|
||||
return;
|
||||
}
|
||||
surface_->pixels = pixel_data_;
|
||||
active_ = true;
|
||||
}
|
||||
@@ -355,7 +365,7 @@ absl::Status Bitmap::ApplyPalette(const SnesPalette &palette) {
|
||||
sdl_palette->colors[i].a = pal_color.rgb().w;
|
||||
}
|
||||
SDL_LockSurface(surface_.get());
|
||||
SDL_RETURN_IF_ERROR()
|
||||
// SDL_RETURN_IF_ERROR()
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -379,7 +389,7 @@ absl::Status Bitmap::ApplyPaletteFromPaletteGroup(const SnesPalette &palette,
|
||||
}
|
||||
}
|
||||
SDL_LockSurface(surface_.get());
|
||||
SDL_RETURN_IF_ERROR()
|
||||
// SDL_RETURN_IF_ERROR()
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -404,7 +414,7 @@ absl::Status Bitmap::ApplyPaletteWithTransparent(const SnesPalette &palette,
|
||||
i++;
|
||||
}
|
||||
SDL_LockSurface(surface_.get());
|
||||
SDL_RETURN_IF_ERROR()
|
||||
// SDL_RETURN_IF_ERROR()
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ class Bitmap {
|
||||
bool modified_ = false;
|
||||
void *texture_pixels = nullptr;
|
||||
|
||||
uchar *pixel_data_;
|
||||
uint8_t *pixel_data_ = nullptr;
|
||||
Bytes data_;
|
||||
|
||||
std::vector<uint8_t> png_data_;
|
||||
|
||||
@@ -151,14 +151,14 @@ class SnesPalette {
|
||||
|
||||
void operator()(int i, const SnesColor& color) {
|
||||
if (i >= colors.size()) {
|
||||
std::cout << SNESPalette: Index out of bounds << std::endl;
|
||||
std::cout << "SNESPalette: Index out of bounds" << std::endl;
|
||||
}
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
void operator()(int i, const ImVec4& color) {
|
||||
if (i >= colors.size()) {
|
||||
std::cout << SNESPalette: Index out of bounds << std::endl;
|
||||
std::cout << "SNESPalette: Index out of bounds" << std::endl;
|
||||
return;
|
||||
}
|
||||
colors[i].set_rgb(color);
|
||||
|
||||
Reference in New Issue
Block a user