Borderless graphics modes

BlitzMax Forums/BlitzMax Module Tweaks/Borderless graphics modes

dan_upright(Posted 2014) [#1]
Thanks to col, I've managed to get borderless windows working under all three graphics drivers on win32.

In brl.mod/graphics.mod/graphics.bmx, insert the following at line 48:
Const GRAPHICS_BORDERLESS = $40

In brl.mod/dxgraphics.mod/d3d9graphics.bmx, change this section at line 148:
		If depth
			wstyle=WS_VISIBLE|WS_POPUP
		Else
			wstyle=WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX
		EndIf

To:
		If depth
			wstyle=WS_VISIBLE|WS_POPUP
		Else
			If flags & GRAPHICS_BORDERLESS Then
				wstyle = WS_VISIBLE | WS_POPUP
			Else
				wstyle = WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
			End If
		EndIf

In brl.mod/dxgraphics.mod/d3d7graphics.bmx, change this section at line 290:
			Local style=WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX

To:
			Local style=WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX
			If flags & GRAPHICS_BORDERLESS Then style = WS_VISIBLE | WS_POPUP

And in brl.mod/glgraphics.mod/glgraphics.win32.c make the following two changes, first at line 8:
enum{
	_BACKBUFFER=	0x2,
	_ALPHABUFFER=	0x4,
	_DEPTHBUFFER=	0x8,
	_STENCILBUFFER=	0x10,
	_ACCUMBUFFER=	0x20,
};

Becomes:
enum{
	_BACKBUFFER=	0x2,
	_ALPHABUFFER=	0x4,
	_DEPTHBUFFER=	0x8,
	_STENCILBUFFER=	0x10,
	_ACCUMBUFFER=	0x20,
	_BORDERLESS=	0x40,
};

And at line 322:
		hwnd_style=WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX;

Becomes:
		hwnd_style=WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX;
		if (flags && _BORDERLESS) {
			hwnd_style = WS_POPUP;
		}

If anyone knows how to add this for opengl on linux or mac (and more importantly, can test it on linux or mac), please speak up.


degac(Posted 2014) [#2]
Nice feature, it could be useful.

I suggest you to contact Brucey to add this improvements to the 'public' version of BMax

https://github.com/maxmods

It would be better if your solutions was multiplatform (OSX,Linux not only win32)


dan_upright(Posted 2014) [#3]
It would be better if your solutions was multiplatform (OSX,Linux not only win32)

Like I said, even if I tried to add cross platform solutions, I couldn't try them out so I'm a bit stuck there. If anyone has a mac or linux box to try stuff out on, I'll happily have a guess at a solution.


Derron(Posted 2014) [#4]
Glad Mark Sibly had the same problem for linux:

http://www.blitzbasic.com/Community/posts.php?topic=68003


As glgraphics.linux.c line 277 is:
swa.override_redirect=True;
line 274 is:
swa.border_pixel=0;
which defines something like a "system color"-border.

I assume that the "borderless window" is already defined. To make it an dragable one one would have to handle it on its own.


Another option is what was suggested by ephemient:
http://stackoverflow.com/questions/1904445/borderless-windows-on-linux

But this also seems more or less try to solve the problem of "removing decorations" - which is done in BlitzMax-fullscreen already.


bye
Ron


dan_upright(Posted 2014) [#5]
Ok, in brl.mod/glgraphics.mod/glgraphics.linux.c make the following two changes, first at line 41:
enum{
	FLAGS_BACKBUFFER=	0x2,
	FLAGS_ALPHABUFFER=	0x4,
	FLAGS_DEPTHBUFFER=	0x8,
	FLAGS_STENCILBUFFER=0x10,
	FLAGS_ACCUMBUFFER=	0x20,
	FLAGS_FULLSCREEN=0x80000000
};

Becomes:
enum{
	FLAGS_BACKBUFFER=	0x2,
	FLAGS_ALPHABUFFER=	0x4,
	FLAGS_DEPTHBUFFER=	0x8,
	FLAGS_STENCILBUFFER=0x10,
	FLAGS_ACCUMBUFFER=	0x20,
	FLAGS_BORDERLESS=	0x40,
	FLAGS_FULLSCREEN=0x80000000
};

struct MwmHints {
    unsigned long flags;
    unsigned long functions;
    unsigned long decorations;
    long input_mode;
    unsigned long status;
};
enum {
    MWM_HINTS_FUNCTIONS = (1L << 0),
    MWM_HINTS_DECORATIONS =  (1L << 1),

    MWM_FUNC_ALL = (1L << 0),
    MWM_FUNC_RESIZE = (1L << 1),
    MWM_FUNC_MOVE = (1L << 2),
    MWM_FUNC_MINIMIZE = (1L << 3),
    MWM_FUNC_MAXIMIZE = (1L << 4),
    MWM_FUNC_CLOSE = (1L << 5)
};

And then at line 345:
		//Set window min/max size		

Becomes:
		//Make window borderless
		if (flags && FLAGS_BORDERLESS) {
			Atom mwmHintsProperty = XInternAtom(xdisplay, "_MOTIF_WM_HINTS", 0);
			struct MwmHints hints;
			hints.flags = MWM_HINTS_DECORATIONS;
			hints.decorations = 0;
			XChangeProperty(xdisplay, window, mwmHintsProperty, mwmHintsProperty, 32, PropModeReplace, (unsigned char *)&hints, 5);
		}

		//Set window min/max size		

This works for me on Ubuntu 14.04.


Derron(Posted 2014) [#6]
Now it misses MacOS and I would try to push the complete patch to the mentioned .git of brucey.


bye
Ron


d-bug(Posted 2014) [#7]
Now it misses MacOS...

Nope!

Step 1: In brl.mod/glgraphics.mod/glgraphics.macos.m find the following lines:
enum{
	FLAGS_BACKBUFFER=	0x2,
	FLAGS_ALPHABUFFER=	0x4,
	FLAGS_DEPTHBUFFER=	0x8,
	FLAGS_STENCILBUFFER=0x10,
	FLAGS_ACCUMBUFFER=	0x20,
	FLAGS_FULLSCREEN=	0x80000000
};

...and change them to:
enum{
	FLAGS_BACKBUFFER=	0x2,
	FLAGS_ALPHABUFFER=	0x4,
	FLAGS_DEPTHBUFFER=	0x8,
	FLAGS_STENCILBUFFER=0x10,
	FLAGS_ACCUMBUFFER=	0x20,
	FLAGS_BORDERLESS=	0x40,
	FLAGS_FULLSCREEN=	0x80000000
};


Step 2: Find the following lines (in the same file as above):
		window=[[BBGLWindow alloc]
			initWithContentRect:NSMakeRect( 0,0,width,height )
			styleMask:NSTitledWindowMask|NSClosableWindowMask
			backing:NSBackingStoreBuffered
			defer:YES];

...and change them to:
		NSUInteger m = NSTitledWindowMask|NSClosableWindowMask;
		if (flags & FLAGS_BORDERLESS) m = NSBorderlessWindowMask;
		window=[[BBGLWindow alloc]
			initWithContentRect:NSMakeRect( 0,0,width,height )
			styleMask:m
			backing:NSBackingStoreBuffered
			defer:YES];


Thats it!


dan_upright(Posted 2014) [#8]
Nice, thanks for providing that mate.


Zethrax(Posted 2014) [#9]
Here's a full screen borderless widowed mode I did for Blitz3D a while back. You might find something useful in there. Also note the code in there for resynching a game after returning from an Alt-Tab.

http://www.blitzbasic.com/codearcs/codearcs.php?code=3076


Grey Alien(Posted 2015) [#10]
I notice that borderless on Mac still shows the Apple bat along the top with the application name, clock, battery status etc. Also if you move the mouse over the bottom of the screen the task bar pops up. Is that how it is supposed to be?

It does appear to be a borderless window at least but it doesn't cover the whole screen is what I'm saying.

Yeah it's the same as this: https://github.com/ValveSoftware/Dota-2/issues/310

Maybe there's a way to force the window on top like the WS_POPUP part of the Windows code?


Brucey(Posted 2015) [#11]
It does appear to be a borderless window at least but it doesn't cover the whole screen is what I'm saying.

It's quite possible to do full-screen windows (without the menu bar) on OS X. SDL manages this rather well. (and I believe wxWidgets has flags for that too).


Grey Alien(Posted 2015) [#12]
Aha well at least we know it's possible then. So there must be a mod tweak for that but I'm out of my depth with Mac code. At least I can understand the Windows API and C++ a little bit.