diff --git a/dlib/platform.d b/dlib/platform.d index 2944ecd..e1f0705 100644 --- a/dlib/platform.d +++ b/dlib/platform.d @@ -641,12 +641,7 @@ WindowError() enum i32 GL_CORE_PROFILE = 0x00000001; bool -CreateWindow( - bool create_gl_context = false, - i32 gl_major_version = 4, - i32 gl_minor_version = 6, - i32 gl_profile = GL_CORE_PROFILE - )(PlatformWindow* window, string name, u32 width, u32 height) +CreateWindow(PlatformWindow* window, string name, u32 width, u32 height) { PlatformWindow wnd = { w: width, @@ -691,80 +686,17 @@ CreateWindow( StructureNotifyMask | PropertyChangeMask; - static if(create_gl_context) - { - import opengl; - const i32[] visual_attributes = [ - GLX_X_RENDERABLE, true, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_ALPHA_SIZE, 8, - GLX_DEPTH_SIZE, 24, - GLX_STENCIL_SIZE, 8, - GLX_DOUBLEBUFFER, true, - None, - ]; - - i32 fb_count; - GLXFBConfig* fb_config = glXChooseFBConfig(window.display, window.screen_id, visual_attributes.ptr, &fb_count); - - if(fb_config == null || fb_count == 0) - { - Errf("Failed to retrieve GL framebuffer config"); - return false; - } - - GLXFBConfig chosen_fb_config = fb_config[0]; - XFree(fb_config); - - XVisualInfo* visual_info = glXGetVisualFromFBConfig(window.display, chosen_fb_config); - if(visual_info == null) - { - Errf("Failed to get GL visual"); - return false; - } - - XSetWindowAttributes set_window_attrs = { - colormap: XCreateColormap(window.display, RootWindow(window.display, visual_info.screen), visual_info.visual, AllocNone), - border_pixel: 0, - event_mask: event_mask, - }; - - window.window = XCreateWindow( - window.display, - window.root_window, - 0, - 0, - width, - height, - 0, - visual_info.depth, - InputOutput, - visual_info.visual, - value_mask | CWColormap, - &set_window_attrs - ); - - XFree(visual_info); - } - else - { - window.window = XCreateSimpleWindow( - window.display, - window.root_window, - 0, - 0, - width, - height, - 0, - XBlackPixel(window.display, window.screen_id), - XBlackPixel(window.display, window.screen_id) - ); - } + window.window = XCreateSimpleWindow( + window.display, + window.root_window, + 0, + 0, + width, + height, + 0, + XBlackPixel(window.display, window.screen_id), + XBlackPixel(window.display, window.screen_id) + ); if(window.window == None) { @@ -815,41 +747,6 @@ CreateWindow( XFlush(window.display); - static if(create_gl_context) - { - import opengl; - - glXCreateContextAttribsARB = cast(typeof(glXCreateContextAttribsARB))glXGetProcAddressARB(cast(u8*)r"glXCreateContexAttribsARB"); - if(!glXCreateContextAttribsARB) - { - Errf("glXCreateContextAttribsARB function not found"); - return false; - } - - enum GLX_CONTEXT_MAJOR_VERSION = 0x2091; - enum GLX_CONTEXT_MINOR_VERSION = 0x2092; - enum GLX_CONTEXT_PROFILE_MASK_ARB = 0x9126; - - const(i32[]) context_attributes = [ - GLX_CONTEXT_MAJOR_VERSION, gl_major_version, - GLX_CONTEXT_MINOR_VERSION, gl_minor_version, - GLX_CONTEXT_PROFILE_MASK_ARB, gl_profile, - None, - ]; - - window.glx_context = glXCreateContextAttribsARB(window.display, chosen_fb_config, null, True, context_attributes.ptr); - - if(!window.glx_context) - { - Errf("Failed to create OpenGL context"); - return false; - } - - glXMakeCurrent(window.display, window.window, window.glx_context); - - GLLoadFuncs(); - } - return true; }