// =====================================================================================================================
//  fennec, a free and open source game engine
//  Copyright © 2025 - 2026  Medusa Slockbower
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================


#include <fennec/platform/linux/wayland/window.h>
#include <fennec/platform/linux/wayland/egl/surface.h>
#include <fennec/platform/linux/wayland/lib/wayland.h>

namespace fennec
{

wayland_eglsurface::wayland_eglsurface(wayland_window* win, eglcontext* ctx)
	: eglsurface(
		win, ctx,
		wl_egl_window_create(
			static_cast<wl_surface*>(win->get_native_handle()),
			win->get_config().rect.size.x, win->get_config().rect.size.y
		)
	) {
}

wayland_eglsurface::~wayland_eglsurface() {
	wl_egl_window_destroy(static_cast<wl_egl_window*>(_eglwindow));
}

void wayland_eglsurface::resize(const ivec2& size) {
	wl_egl_window_resize(static_cast<wl_egl_window*>(_eglwindow), size.x, size.y, 0, 0);
}

}
