Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
This is an extract of a commit, minimally edited to ensure it compiles.

Closes #1078.
Related to #197.
  • Loading branch information
cosier authored and elmindreda committed Sep 19, 2017
1 parent 765cc1a commit 5fc7ae7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 22 deletions.
4 changes: 4 additions & 0 deletions docs/window.dox
Expand Up @@ -287,6 +287,10 @@ __GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
buffered. You nearly always want to use double buffering. This is a hard
constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.

@anchor GLFW_TRANSPARENT_hint
__GLFW_TRANSPARENT__ specifies whether the framebuffer will support transparency
in the background. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.


@subsubsection window_hints_mtr Monitor related hints

Expand Down
7 changes: 6 additions & 1 deletion include/GLFW/glfw3.h
Expand Up @@ -787,7 +787,6 @@ extern "C" {
* Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
*/
#define GLFW_CENTER_CURSOR 0x00020009
#define GLFW_TRANSPARENT 0x0002000A

/*! @brief Framebuffer bit depth hint.
*
Expand Down Expand Up @@ -869,6 +868,12 @@ extern "C" {
* Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
*/
#define GLFW_DOUBLEBUFFER 0x00021010
/*! @brief Framebuffer transparency hint.
*
* Framebuffer transparency [hint](@ref GLFW_TRANSPARENT_hint).
*/
#define GLFW_TRANSPARENT 0x00021011

/*! @brief Context client API hint and attribute.
*
* Context client API [hint](@ref GLFW_CLIENT_API_hint) and
Expand Down
2 changes: 1 addition & 1 deletion src/cocoa_window.m
Expand Up @@ -1085,7 +1085,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
if (wndconfig->ns.retina)
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];

if (window->transparent)
if (_glfw.hints.framebuffer.transparent)
{
[window->ns.object setOpaque:NO];
[window->ns.object setBackgroundColor:[NSColor clearColor]];
Expand Down
4 changes: 2 additions & 2 deletions src/egl_context.c
Expand Up @@ -493,7 +493,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
if (ctxconfig->share)
share = ctxconfig->share->context.egl.handle;

if (!chooseEGLConfig(ctxconfig, fbconfig, &config, window->transparent))
if (!chooseEGLConfig(ctxconfig, fbconfig, &config, fbconfig->transparent))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
Expand Down Expand Up @@ -738,7 +738,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
EGLint visualID = 0, count = 0;
const long vimask = VisualScreenMask | VisualIDMask;

if (!chooseEGLConfig(ctxconfig, fbconfig, &native, wndconfig->transparent))
if (!chooseEGLConfig(ctxconfig, fbconfig, &native, fbconfig->transparent))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
Expand Down
4 changes: 2 additions & 2 deletions src/glx_context.c
Expand Up @@ -477,7 +477,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
if (ctxconfig->share)
share = ctxconfig->share->context.glx.handle;

if (!chooseGLXFBConfig(fbconfig, &native, window->transparent))
if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
Expand Down Expand Up @@ -665,7 +665,7 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
GLXFBConfig native;
XVisualInfo* result;

if (!chooseGLXFBConfig(fbconfig, &native, wndconfig->transparent))
if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent))
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
Expand Down
3 changes: 1 addition & 2 deletions src/internal.h
Expand Up @@ -299,7 +299,6 @@ struct _GLFWwndconfig
GLFWbool resizable;
GLFWbool visible;
GLFWbool decorated;
GLFWbool transparent;
GLFWbool focused;
GLFWbool autoIconify;
GLFWbool floating;
Expand Down Expand Up @@ -360,6 +359,7 @@ struct _GLFWfbconfig
int samples;
GLFWbool sRGB;
GLFWbool doublebuffer;
GLFWbool transparent;
uintptr_t handle;
};

Expand Down Expand Up @@ -403,7 +403,6 @@ struct _GLFWwindow
// Window settings and state
GLFWbool resizable;
GLFWbool decorated;
GLFWbool transparent;
GLFWbool autoIconify;
GLFWbool floating;
GLFWbool shouldClose;
Expand Down
2 changes: 1 addition & 1 deletion src/nsgl_context.m
Expand Up @@ -296,7 +296,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
return GLFW_FALSE;
}

if (window->transparent)
if (fbconfig->transparent)
{
GLint opaque = 0;
[window->context.nsgl.object setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
Expand Down
13 changes: 7 additions & 6 deletions src/wgl_context.c
Expand Up @@ -85,7 +85,7 @@ static int choosePixelFormat(_GLFWwindow* window,
_GLFWfbconfig* u = usableConfigs + usableCount;
PIXELFORMATDESCRIPTOR pfd;

if (window->transparent) {
if (fbconfig->transparent) {
if (!DescribePixelFormat(window->context.wgl.dc,
n,
sizeof(PIXELFORMATDESCRIPTOR),
Expand Down Expand Up @@ -168,7 +168,7 @@ static int choosePixelFormat(_GLFWwindow* window,
{
// Get pixel format attributes through legacy PFDs

if (!window->transparent && DescribePixelFormat(window->context.wgl.dc,
if (!fbconfig->transparent && DescribePixelFormat(window->context.wgl.dc,
n,
sizeof(PIXELFORMATDESCRIPTOR),
&pfd))
Expand Down Expand Up @@ -217,8 +217,7 @@ static int choosePixelFormat(_GLFWwindow* window,
}
// Reiterate the selection loop without looking for transparency supporting
// formats if no matching pixelformat for a transparent window were found.
if (window->transparent && !usableCount) {
window->transparent = GLFW_FALSE;
if (fbconfig->transparent && !usableCount) {
free(usableConfigs);
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: No pixel format found for transparent window. Ignoring transparency.");
Expand Down Expand Up @@ -803,10 +802,12 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
}
}

if (window->transparent)
if (fbconfig->transparent)
{
if (!setupTransparentWindow(window))
window->transparent = GLFW_FALSE;
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to setup window as transparent as requested");

}

window->context.makeCurrent = makeContextCurrentWGL;
Expand Down
11 changes: 4 additions & 7 deletions src/window.c
Expand Up @@ -147,6 +147,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
fbconfig = _glfw.hints.framebuffer;
ctxconfig = _glfw.hints.context;
wndconfig = _glfw.hints.window;
fbconfig.transparent = _glfw.hints.framebuffer.transparent ? GLFW_TRUE : GLFW_FALSE;

wndconfig.width = width;
wndconfig.height = height;
Expand Down Expand Up @@ -180,7 +181,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->monitor = (_GLFWmonitor*) monitor;
window->resizable = wndconfig.resizable;
window->decorated = wndconfig.decorated;
window->transparent = wndconfig.transparent;
window->autoIconify = wndconfig.autoIconify;
window->floating = wndconfig.floating;
window->cursorMode = GLFW_CURSOR_NORMAL;
Expand Down Expand Up @@ -250,7 +250,6 @@ void glfwDefaultWindowHints(void)
_glfw.hints.window.resizable = GLFW_TRUE;
_glfw.hints.window.visible = GLFW_TRUE;
_glfw.hints.window.decorated = GLFW_TRUE;
_glfw.hints.window.transparent = GLFW_FALSE;
_glfw.hints.window.focused = GLFW_TRUE;
_glfw.hints.window.autoIconify = GLFW_TRUE;

Expand Down Expand Up @@ -317,6 +316,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_DOUBLEBUFFER:
_glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_TRANSPARENT:
_glfw.hints.framebuffer.transparent = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_SAMPLES:
_glfw.hints.framebuffer.samples = value;
return;
Expand All @@ -329,9 +331,6 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_DECORATED:
_glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_TRANSPARENT:
_glfw.hints.window.transparent = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_FOCUSED:
_glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE;
return;
Expand Down Expand Up @@ -733,8 +732,6 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->resizable;
case GLFW_DECORATED:
return window->decorated;
case GLFW_TRANSPARENT:
return window->transparent;
case GLFW_FLOATING:
return window->floating;
case GLFW_AUTO_ICONIFY:
Expand Down

0 comments on commit 5fc7ae7

Please sign in to comment.