Sign in to follow this  
Toji

OpenGL Borderless OpenGL Window (Not fullscreen)

Recommended Posts

Simple question, and one that probably will be solved by some obscure win32 flag that I don't know. Can one create a borderless OpenGL window in Win32? I've been trying to create a window using WS_POPUP|WS_VISIBLE, but while the program shows up in the task bar but the window itself never displays. Any suggestions? Here's my (simple simple) window creation code
[source lang=cpp]
WNDCLASSEX wc;
wc.cbSize        = sizeof(WNDCLASSEX);
wc.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = hInst;
wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName  = NULL;
wc.lpszClassName = "GLSimple";
wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc)) { 
	return 0; 
}
    
hwnd = CreateWindowEx(
	NULL, 
        "GLSimple",
        "OpenGL Simple Example",
        WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
        CW_USEDEFAULT, CW_USEDEFAULT, 
	CW_USEDEFAULT, CW_USEDEFAULT,
        (HWND) NULL, (HMENU) NULL, hInst, (LPVOID) NULL);

if(hwnd == NULL) { 
	return 0; 
}

Share this post


Link to post
Share on other sites
Well you learn something new every day, no? Thanks for the speedy reply, that worked wonderfully! Crazy, crazy Win32...

Share this post


Link to post
Share on other sites
Create the window with normal borders then do something like (Pseudo):


// Get current styles
long lWS = GetWindowLong(WS) // for current WS style.
long lWSEX = GetWindowLong(WS_EX) //for current WS_EX style.

// Bitwise OR the flags you don't want (WS_OVERLAPPEDWINDOW etc.)
lWS =| ~WS_OVERLAPPEDWINDOW
lWSEX =| ~WS_EX_WHATEVERELSE

// Add the flags you want.
lWS =& WS_POPUP
lWSEX =& WS_EX_WHATEVERELSE

// Set the new styles:
SetWindowLong(lWS)
SetWindowLong(lWSEX)

//Update window
SetWindowPos( )


It's what I use to toggle between fullscreen and bordered windows.

Share this post


Link to post
Share on other sites
Smit: &= will never set bit if it already isn't there: 0101 & 0011 = 0001
You need to swap &= with |= in your post.

Share this post


Link to post
Share on other sites
Quote:
Original post by Smit
Create the window with normal borders then do something like (Pseudo):


// Get current styles
long lWS = GetWindowLong(WS) // for current WS style.
long lWSEX = GetWindowLong(WS_EX) //for current WS_EX style.

// Bitwise /*OR*/AND the flags you don't want (WS_OVERLAPPEDWINDOW etc.)
lWS /*=|*/ &= ~WS_OVERLAPPEDWINDOW
lWSEX /*=|*/ &= ~WS_EX_WHATEVERELSE

// Add the flags you want.
lWS /*=&*/ |= WS_POPUP
lWSEX /*=&*/ |= WS_EX_WHATEVERELSE

// Set the new styles:
SetWindowLong(lWS)
SetWindowLong(lWSEX)

//Update window
SetWindowPos( )


It's what I use to toggle between fullscreen and bordered windows.

The way you had it would do the opposite.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this