package window

//#cgo CFLAGS: -IF:/Coding/GoModule/cgo
//#cgo LDFLAGS: -LF:/Coding/GoModule/cgo -lsdl2
//
import "C"
import (
	"github.com/veandco/go-sdl2/sdl"
	"github.com/vkngwrapper/core/v2"
)

type FSDLWindow struct {
	loader core.VulkanLoader
	window *sdl.Window
	width  int32
	height int32
}

func NewSDLWindow(width, height int32) *FSDLWindow {
	return &FSDLWindow{
		width:  width,
		height: height,
	}
}
func CreateLoaderFromSDL() *core.VulkanLoader {
	loader, err := core.CreateLoaderFromProcAddr(sdl.VulkanGetVkGetInstanceProcAddr())
	if err != nil {
		panic(err)
	}
	return loader
}
func (w *FSDLWindow) CreateWindow() error {
	if err := sdl.Init(sdl.INIT_VIDEO); err != nil {
		return err
	}
	window, err := sdl.CreateWindow("Vulkan", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, w.width, w.height, sdl.WINDOW_SHOWN|sdl.WINDOW_VULKAN|sdl.WINDOW_RESIZABLE)
	if err != nil {
		return err
	}
	w.window = window
	return nil
}
func (w *FSDLWindow) GetInstance() *sdl.Window {
	return w.window
}
