HashLink as a target: Exposing SDL_WINDOW_RESIZABLE

Modifying libs/sdl/sdl.c I was able to disable window resizing, but how would I go about exposing it so it can be turned on or off via build command?

I guess you’d have to change signature of winCreate() static method in Window.hx class to take one more bool parameter:

static function winCreate( width : Int, height : Int, resizable : Bool = true ) : WinPtr

plus you will need to change win_create method in sdl.c:

DEFINE_PRIM(TWIN, win_create, _I32 _I32 _BOOL);

...

HL_PRIM SDL_Window *HL_NAME(win_create)(int width, int height, bool resizable) {
	SDL_Window *w;
	// force window to match device resolution on mobile
#ifdef	HL_MOBILE
	SDL_DisplayMode displayMode;
	SDL_GetDesktopDisplayMode(0, &displayMode);
	w = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
#else
	Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
	if (resizable)
	{
		flags = flags | SDL_WINDOW_RESIZABLE;
	}
	w = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags);
#endif
...

(see https://wiki.libsdl.org/SDL_WindowFlags)

And you could add setter and getter to window’s resizable property by using SDL’s SDL_SetWindowResizable method (https://wiki.libsdl.org/SDL_SetWindowResizable):

In Window.hx:

public function setResizable(value:Bool)
{
	winSetResizable(win, value);
}

static function winSetResizable(win : WinPtr, value : Bool) {
		
}

In sdl.c:

DEFINE_PRIM(_VOID, win_set_resizable, TWIN _BOOL);

HL_PRIM void HL_NAME(win_set_resizable)(SDL_Window *win, bool resizable) {

SDL_SetWindowResizable (win, resizable);

}

i’m sorry if my code contains errors but i can’t compile sdl projects on my machine

oh, and i forgot to tell that you will need to add also a compiler define which will set default value for winCreate() method in Window.hx.

So this means that you will have to make some changes to hlsdl lib itself

I see! Thanks for the thorough response, I’ll try it on my own when I get the chance.