linux上使用glx例子,c++ - X11 / GLX - 全屏模式? - 堆栈内存溢出

我发现freeglut全屏效果很好,即使在托管基于着色器的opengl应用程序里面也是如此。 这里是被调用的内部代码(X11分支......)。 HTH

#define _NET_WM_STATE_TOGGLE 2

static int fghResizeFullscrToggle(void)

{

XWindowAttributes attributes;

if(glutGet(GLUT_FULL_SCREEN)) {

/* restore original window size */

SFG_Window *win = fgStructure.CurrentWindow;

fgStructure.CurrentWindow->State.NeedToResize = GL_TRUE;

fgStructure.CurrentWindow->State.Width = win->State.OldWidth;

fgStructure.CurrentWindow->State.Height = win->State.OldHeight;

} else {

/* resize the window to cover the entire screen */

XGetWindowAttributes(fgDisplay.Display,

fgStructure.CurrentWindow->Window.Handle,

&attributes);

/*

* The "x" and "y" members of "attributes" are the window's coordinates

* relative to its parent, i.e. to the decoration window.

*/

XMoveResizeWindow(fgDisplay.Display,

fgStructure.CurrentWindow->Window.Handle,

-attributes.x,

-attributes.y,

fgDisplay.ScreenWidth,

fgDisplay.ScreenHeight);

}

return 0;

}

static int fghEwmhFullscrToggle(void)

{

XEvent xev;

long evmask = SubstructureRedirectMask | SubstructureNotifyMask;

if(!fgDisplay.State || !fgDisplay.StateFullScreen) {

return -1;

}

xev.type = ClientMessage;

xev.xclient.window = fgStructure.CurrentWindow->Window.Handle;

xev.xclient.message_type = fgDisplay.State;

xev.xclient.format = 32;

xev.xclient.data.l[0] = _NET_WM_STATE_TOGGLE;

xev.xclient.data.l[1] = fgDisplay.StateFullScreen;

xev.xclient.data.l[2] = 0; /* no second property to toggle */

xev.xclient.data.l[3] = 1; /* source indication: application */

xev.xclient.data.l[4] = 0; /* unused */

if(!XSendEvent(fgDisplay.Display, fgDisplay.RootWindow, 0, evmask, &xev)) {

return -1;

}

return 0;

}

static int fghToggleFullscreen(void)

{

/* first try the EWMH (_NET_WM_STATE) method ... */

if(fghEwmhFullscrToggle() != -1) {

return 0;

}

/* fall back to resizing the window */

if(fghResizeFullscrToggle() != -1) {

return 0;

}

return -1;

}

#endif /* TARGET_HOST_POSIX_X11 */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值