From 499414520fb55d1ef5ec16eba9eb1b3f7ee2e19a Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Sun, 1 Jun 2014 23:49:53 +0200 Subject: static scope for compilation unit private functions --- test/Makefile | 28 +++++++++++++++++++------- test/layered.c | 61 +++++++++++++++++++++++++-------------------------------- test/layered.rc | 2 +- test/manifest | 21 -------------------- wglarb.c | 6 +++--- wglarb.h | 2 +- 6 files changed, 53 insertions(+), 67 deletions(-) delete mode 100644 test/manifest diff --git a/test/Makefile b/test/Makefile index cd497b0..059b790 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,13 +1,27 @@ -TARGET=x86_64-w64-mingw32 -CC=-$(TARGET)-gcc +TARGET64=x86_64-w64-mingw32 +TARGET32=mingw32 +CC64=-$(TARGET64)-gcc +CC32=-$(TARGET32)-gcc CFLAGS=-static-libgcc -static-libstdc++ -I.. LIBS=-lopengl32 -lgdi32 -lkernel32 -WINDRES=$(TARGET)-windres +WINDRES64=$(TARGET64)-windres +WINDRES32=$(TARGET32)-windres -layered.exe: layered.c layered_rc.o - $(CC) $(CFLAGS) -o layered.exe layered.c layered_rc.o ../wglarb.c $(LIBS) -Wl,--subsystem,windows +.PHONY: all +all: layered64.exe layered32.exe + +layered64.exe: layered.c layered64_rc.o + $(CC64) $(CFLAGS) -o layered64.exe layered.c layered64_rc.o ../wglarb.c $(LIBS) -Wl,--subsystem,windows + +layered32.exe: layered.c layered32_rc.o + $(CC32) $(CFLAGS) -o layered32.exe layered.c layered32_rc.o ../wglarb.c $(LIBS) -Wl,--subsystem,windows + + +layered64_rc.o: layered.rc manifest.xml + $(WINDRES64) --input layered.rc --output layered64_rc.o + +layered32_rc.o: layered.rc manifest.xml + $(WINDRES32) --input layered.rc --output layered32_rc.o -layered_rc.o: layered.rc manifest - $(WINDRES) --input layered.rc --output layered_rc.o diff --git a/test/layered.c b/test/layered.c index 7a83da0..80f25cf 100644 --- a/test/layered.c +++ b/test/layered.c @@ -72,7 +72,6 @@ HWND OpenGLWindowCreate( rect.bottom = CW_USEDEFAULT; } - fprintf(stderr, "creating proper window...\n"); HWND hWnd = CreateWindowEx( dwExStyle, @@ -87,14 +86,12 @@ HWND OpenGLWindowCreate( NULL, hInstance, NULL); - if(!hWnd) { return NULL; } SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)ViewProc); - fprintf(stderr, "retrieving proper DC...\n"); HDC hDC = GetDC(hWnd); if(!hDC) { fprintf(stderr, "error retrieving proper DC\n"); @@ -119,7 +116,6 @@ HWND OpenGLWindowCreate( }; INT iPF; - fprintf(stderr, "choosing proper pixelformat...\n"); UINT num_formats_choosen; if( !wglarb_ChoosePixelFormatARB( hDC, @@ -142,7 +138,6 @@ HWND OpenGLWindowCreate( * sane, we're nice people after all - it doesn't hurt if this fails. */ DescribePixelFormat(hDC, iPF, sizeof(pfd), &pfd); - fprintf(stderr, "setting proper pixelformat...\n"); if( !SetPixelFormat(hDC, iPF, &pfd) ) { fprintf(stderr, "error setting proper pixel format\n"); ReleaseDC(hWnd, hDC); @@ -151,7 +146,6 @@ HWND OpenGLWindowCreate( return NULL; } - fprintf(stderr, "creating proper OpenGL context...\n"); int context_attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 2, WGL_CONTEXT_MINOR_VERSION_ARB, 1, @@ -166,27 +160,20 @@ HWND OpenGLWindowCreate( } ReleaseDC(hWnd, hDC); -#if 1 - if( !(dwStyle & WS_CHILD) ) { - if( hDwmAPI_DLL ) { - if( impl_DwmEnableBlurBehindWindow ) { - DWM_BLURBEHIND bb = {0}; - bb.dwFlags = DWM_BB_ENABLE; - bb.fEnable = TRUE; - bb.hRgnBlur = NULL; - impl_DwmEnableBlurBehindWindow(hWnd, &bb); - } - - if( impl_DwmExtendFrameIntoClientArea ) { - MARGINS margins = {-1}; - impl_DwmExtendFrameIntoClientArea(hWnd, &margins); - } + if( hDwmAPI_DLL ) { + if( impl_DwmEnableBlurBehindWindow ) { + DWM_BLURBEHIND bb = {0}; + bb.dwFlags = DWM_BB_ENABLE; + bb.fEnable = TRUE; + bb.hRgnBlur = NULL; + impl_DwmEnableBlurBehindWindow(hWnd, &bb); } - else { - SetLayeredWindowAttributes(hWnd, 0, 0xff, LWA_ALPHA); + + if( impl_DwmExtendFrameIntoClientArea ) { + MARGINS margins = {-1}; + impl_DwmExtendFrameIntoClientArea(hWnd, &margins); } } -#endif return hWnd; @@ -309,17 +296,23 @@ int main(int argc, char *argv[]) MSG msg; BOOL bRet; - hDwmAPI_DLL = LoadLibrary("dwmapi.dll"); - if( hDwmAPI_DLL ) { - impl_DwmEnableBlurBehindWindow = - (procp_DwmEnableBlurBehindWindow) - GetProcAddress(hDwmAPI_DLL, "DwmEnableBlurBehindWindow"); - - impl_DwmExtendFrameIntoClientArea = - (procp_DwmExtendFrameIntoClientArea) - GetProcAddress(hDwmAPI_DLL, "DwmExtendFrameIntoClientArea"); - } + OSVERSIONINFO os_vinfo; + memset(&os_vinfo, 0, sizeof(os_vinfo)); + os_vinfo.dwOSVersionInfoSize = sizeof(os_vinfo); + GetVersionEx(&os_vinfo); + if( 6 <= os_vinfo.dwMajorVersion ) { + hDwmAPI_DLL = LoadLibrary("dwmapi.dll"); + if( hDwmAPI_DLL ) { + impl_DwmEnableBlurBehindWindow = + (procp_DwmEnableBlurBehindWindow) + GetProcAddress(hDwmAPI_DLL, "DwmEnableBlurBehindWindow"); + + impl_DwmExtendFrameIntoClientArea = + (procp_DwmExtendFrameIntoClientArea) + GetProcAddress(hDwmAPI_DLL, "DwmExtendFrameIntoClientArea"); + } + } HWND hWndGL = OpenGLWindowCreate( "Test", "TestWnd", diff --git a/test/layered.rc b/test/layered.rc index 187387c..7c46d6e 100644 --- a/test/layered.rc +++ b/test/layered.rc @@ -1,3 +1,3 @@ #include "winuser.h" -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST manifest +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST manifest.xml diff --git a/test/manifest b/test/manifest deleted file mode 100644 index f8b9bdc..0000000 --- a/test/manifest +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/wglarb.c b/wglarb.c index 744db0b..306cc73 100644 --- a/wglarb.c +++ b/wglarb.c @@ -28,7 +28,7 @@ THE SOFTWARE. static HWND wglarb_intermediary_hWnd = 0; -BOOL wglarb_intermediary_create_Wnd(void) +static BOOL wglarb_intermediary_create_Wnd(void) { HINSTANCE const hInstance = GetModuleHandle(NULL); @@ -61,7 +61,7 @@ BOOL wglarb_intermediary_create_Wnd(void) static HDC wglarb_intermediary_hDC = 0; -BOOL wglarb_intermediary_create_DC(void) +static BOOL wglarb_intermediary_create_DC(void) { if( !wglarb_intermediary_hWnd && !wglarb_intermediary_create_Wnd() ) { @@ -78,7 +78,7 @@ BOOL wglarb_intermediary_create_DC(void) static HGLRC wglarb_intermediary_hRC = 0; -BOOL wglarb_intermediary_create_RC(void) +static BOOL wglarb_intermediary_create_RC(void) { if( !wglarb_intermediary_hDC && !wglarb_intermediary_create_DC() ) { diff --git a/wglarb.h b/wglarb.h index c056115..8c2b883 100644 --- a/wglarb.h +++ b/wglarb.h @@ -24,7 +24,7 @@ THE SOFTWARE. #ifndef WGLARB_H #define WGLARB_H -// #include +#include #include HGLRC WINAPI wglarb_CreateContextAttribsARB( -- cgit v1.2.3