Jump to content
  • Advertisement
Sign in to follow this  
Toji

OpenGL Borderless OpenGL Window (Not fullscreen)

This topic is 4349 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!