remove old sdl_deleter from Controller
This commit is contained in:
@@ -330,7 +330,7 @@ void Controller::OnInput() {
|
|||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
switch (event.window.event) {
|
switch (event.window.event) {
|
||||||
case SDL_WINDOWEVENT_CLOSE:
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
CloseWindow();
|
active_ = false;
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
ChangeWindowSizeEvent(event);
|
ChangeWindowSizeEvent(event);
|
||||||
@@ -404,14 +404,14 @@ absl::Status Controller::CreateSDL_Window() {
|
|||||||
int screenWidth = displayMode.w * 0.8;
|
int screenWidth = displayMode.w * 0.8;
|
||||||
int screenHeight = displayMode.h * 0.8;
|
int screenHeight = displayMode.h * 0.8;
|
||||||
|
|
||||||
window_ = std::unique_ptr<SDL_Window, sdl_deleter>(
|
window_ = std::unique_ptr<SDL_Window, core::SDL_Deleter>(
|
||||||
SDL_CreateWindow("Yet Another Zelda3 Editor", // window title
|
SDL_CreateWindow("Yet Another Zelda3 Editor", // window title
|
||||||
SDL_WINDOWPOS_UNDEFINED, // initial x position
|
SDL_WINDOWPOS_UNDEFINED, // initial x position
|
||||||
SDL_WINDOWPOS_UNDEFINED, // initial y position
|
SDL_WINDOWPOS_UNDEFINED, // initial y position
|
||||||
screenWidth, // width, in pixels
|
screenWidth, // width, in pixels
|
||||||
screenHeight, // height, in pixels
|
screenHeight, // height, in pixels
|
||||||
SDL_WINDOW_RESIZABLE),
|
SDL_WINDOW_RESIZABLE),
|
||||||
sdl_deleter());
|
core::SDL_Deleter());
|
||||||
if (window_ == nullptr) {
|
if (window_ == nullptr) {
|
||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
absl::StrFormat("SDL_CreateWindow: %s\n", SDL_GetError()));
|
absl::StrFormat("SDL_CreateWindow: %s\n", SDL_GetError()));
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "imgui/backends/imgui_impl_sdl2.h"
|
#include "imgui/backends/imgui_impl_sdl2.h"
|
||||||
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
#include "imgui/backends/imgui_impl_sdlrenderer2.h"
|
||||||
#include "imgui/imconfig.h"
|
#include "imgui/imconfig.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui/imgui_internal.h"
|
#include "imgui/imgui_internal.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/platform/renderer.h"
|
#include "app/core/platform/renderer.h"
|
||||||
@@ -56,22 +55,6 @@ class Controller : public ExperimentFlags {
|
|||||||
auto window() -> SDL_Window * { return window_.get(); }
|
auto window() -> SDL_Window * { return window_.get(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct sdl_deleter {
|
|
||||||
void operator()(SDL_Window *p) const {
|
|
||||||
if (p) {
|
|
||||||
SDL_DestroyWindow(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void operator()(SDL_Renderer *p) const {
|
|
||||||
if (p) {
|
|
||||||
SDL_DestroyRenderer(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); }
|
|
||||||
};
|
|
||||||
|
|
||||||
void CloseWindow() { active_ = false; }
|
|
||||||
|
|
||||||
friend int ::main(int argc, char **argv);
|
friend int ::main(int argc, char **argv);
|
||||||
|
|
||||||
bool active_;
|
bool active_;
|
||||||
|
|||||||
Reference in New Issue
Block a user