diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /platform/windows/context_gl_win.cpp | |
parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) |
A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
Diffstat (limited to 'platform/windows/context_gl_win.cpp')
-rw-r--r-- | platform/windows/context_gl_win.cpp | 126 |
1 files changed, 59 insertions, 67 deletions
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index 7a81dfef77..d737502bf5 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -45,25 +45,21 @@ //#include "drivers/opengl/glwrapper.h" //#include "ctxgl_procaddr.h" -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -typedef HGLRC (APIENTRY* PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int*); - +typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *); void ContextGL_Win::release_current() { - - wglMakeCurrent(hDC,NULL); - + wglMakeCurrent(hDC, NULL); } - void ContextGL_Win::make_current() { - wglMakeCurrent(hDC,hRC); + wglMakeCurrent(hDC, hRC); } int ContextGL_Win::get_window_width() { @@ -98,10 +94,9 @@ static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { void ContextGL_Win::set_use_vsync(bool p_use) { if (wglSwapIntervalEXT) { - wglSwapIntervalEXT(p_use?1:0); + wglSwapIntervalEXT(p_use ? 1 : 0); } - use_vsync=p_use; - + use_vsync = p_use; } bool ContextGL_Win::is_using_vsync() const { @@ -109,112 +104,109 @@ bool ContextGL_Win::is_using_vsync() const { return use_vsync; } -#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define _WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 Error ContextGL_Win::initialize() { - static PIXELFORMATDESCRIPTOR pfd= { - sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor + static PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, - PFD_DRAW_TO_WINDOW | // Format Must Support Window - PFD_SUPPORT_OPENGL | // Format Must Support OpenGL - PFD_DOUBLEBUFFER, + PFD_DRAW_TO_WINDOW | // Format Must Support Window + PFD_SUPPORT_OPENGL | // Format Must Support OpenGL + PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 24, - 0, 0, 0, 0, 0, 0, // Color Bits Ignored - 0,// No Alpha Buffer - 0,// Shift Bit Ignored - 0,// No Accumulation Buffer - 0, 0, 0, 0,// Accumulation Bits Ignored - 24,// 24Bit Z-Buffer (Depth Buffer) - 0,// No Stencil Buffer - 0,// No Auxiliary Buffer + 0, 0, 0, 0, 0, 0, // Color Bits Ignored + 0, // No Alpha Buffer + 0, // Shift Bit Ignored + 0, // No Accumulation Buffer + 0, 0, 0, 0, // Accumulation Bits Ignored + 24, // 24Bit Z-Buffer (Depth Buffer) + 0, // No Stencil Buffer + 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer - 0,// Reserved - 0, 0, 0 // Layer Masks Ignored + 0, // Reserved + 0, 0, 0 // Layer Masks Ignored }; - if (!(hDC=GetDC(hWnd))) { - MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return ERR_CANT_CREATE; // Return FALSE + if (!(hDC = GetDC(hWnd))) { + MessageBox(NULL, "Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return ERR_CANT_CREATE; // Return FALSE } - if (!(pixel_format=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? + if (!(pixel_format = ChoosePixelFormat(hDC, &pfd))) // Did Windows Find A Matching Pixel Format? { - MessageBox(NULL,"Can't Find A Suitable pixel_format.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return ERR_CANT_CREATE; // Return FALSE + MessageBox(NULL, "Can't Find A Suitable pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return ERR_CANT_CREATE; // Return FALSE } - if(!SetPixelFormat(hDC,pixel_format,&pfd)) // Are We Able To Set The Pixel Format? + if (!SetPixelFormat(hDC, pixel_format, &pfd)) // Are We Able To Set The Pixel Format? { - MessageBox(NULL,"Can't Set The pixel_format.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return ERR_CANT_CREATE; // Return FALSE + MessageBox(NULL, "Can't Set The pixel_format.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return ERR_CANT_CREATE; // Return FALSE } - if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? + if (!(hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? { - MessageBox(NULL,"Can't Create A Temporary GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return ERR_CANT_CREATE; // Return FALSE + MessageBox(NULL, "Can't Create A Temporary GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return ERR_CANT_CREATE; // Return FALSE } - wglMakeCurrent(hDC,hRC); + wglMakeCurrent(hDC, hRC); if (opengl_3_context) { int attribs[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 3,//we want a 3.3 context - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - //and it shall be forward compatible so that we can only use up to date functionality - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB|_WGL_CONTEXT_DEBUG_BIT_ARB, - 0}; //zero indicates the end of the array + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + //and it shall be forward compatible so that we can only use up to date functionality + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | _WGL_CONTEXT_DEBUG_BIT_ARB, + 0 + }; //zero indicates the end of the array PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; //pointer to the method - wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB"); + wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - if(wglCreateContextAttribsARB == NULL) //OpenGL 3.0 is not supported + if (wglCreateContextAttribsARB == NULL) //OpenGL 3.0 is not supported { - MessageBox(NULL,"Cannot get Proc Adress for CreateContextAttribs", "ERROR",MB_OK|MB_ICONEXCLAMATION); + MessageBox(NULL, "Cannot get Proc Adress for CreateContextAttribs", "ERROR", MB_OK | MB_ICONEXCLAMATION); wglDeleteContext(hRC); return ERR_CANT_CREATE; } HGLRC new_hRC; - if (!(new_hRC=wglCreateContextAttribsARB(hDC,0, attribs))) - { + if (!(new_hRC = wglCreateContextAttribsARB(hDC, 0, attribs))) { wglDeleteContext(hRC); - MessageBox(NULL,"Can't Create An OpenGL 3.3 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return ERR_CANT_CREATE; // Return false + MessageBox(NULL, "Can't Create An OpenGL 3.3 Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return ERR_CANT_CREATE; // Return false } - wglMakeCurrent(hDC,NULL); + wglMakeCurrent(hDC, NULL); wglDeleteContext(hRC); - hRC=new_hRC; + hRC = new_hRC; - if (!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context + if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context { - MessageBox(NULL,"Can't Activate The GL 3.3 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return ERR_CANT_CREATE; // Return FALSE + MessageBox(NULL, "Can't Activate The GL 3.3 Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + return ERR_CANT_CREATE; // Return FALSE } printf("Activated GL 3.3 context"); } - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress ("wglSwapIntervalEXT"); + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); //glWrapperInit(wrapper_get_proc_address); return OK; } -ContextGL_Win::ContextGL_Win(HWND hwnd,bool p_opengl_3_context) { +ContextGL_Win::ContextGL_Win(HWND hwnd, bool p_opengl_3_context) { - opengl_3_context=p_opengl_3_context; - hWnd=hwnd; - use_vsync=false; + opengl_3_context = p_opengl_3_context; + hWnd = hwnd; + use_vsync = false; } ContextGL_Win::~ContextGL_Win() { - - } - #endif |