X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcdisplayinfo.C;h=62d58338fd648ba13844e17b19b7c5c3189b9608;hb=a6b1f3c0c5c17c3a26758abc46bcb46100308c66;hp=91f240d4429d709fe76e57da28914956d886cf44;hpb=258b919564933c544cc13c01060f44177a6aff91;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/guicast/bcdisplayinfo.C b/cinelerra-5.1/guicast/bcdisplayinfo.C index 91f240d4..62d58338 100644 --- a/cinelerra-5.1/guicast/bcdisplayinfo.C +++ b/cinelerra-5.1/guicast/bcdisplayinfo.C @@ -41,6 +41,7 @@ int BC_DisplayInfo::bottom_border = -1; int BC_DisplayInfo::right_border = -1; int BC_DisplayInfo::auto_reposition_x = -1; int BC_DisplayInfo::auto_reposition_y = -1; +int BC_DisplayInfo::gl_max_texture_size = -1; char BC_DisplayInfo::gl_shader_version[64] = { 0, }; BC_DisplayInfo::BC_DisplayInfo(const char *display_name, int show_error) @@ -51,6 +52,12 @@ BC_DisplayInfo::BC_DisplayInfo(const char *display_name, int show_error) xinerama_screens = -1; xinerama_info = 0; init_window(display_name, show_error); +#ifdef HAVE_GL + ncfgs = 0; + fb_cfgs = 0; + cfg = 0; + vis_info = 0; +#endif } BC_DisplayInfo::~BC_DisplayInfo() @@ -108,6 +115,21 @@ int BC_DisplayInfo::xinerama_geometry(int screen, int &x, int &y, int &w, int &h return 0; } +int BC_DisplayInfo::xinerama_big_screen() +{ + int screens = get_xinerama_screens(); + int best = 0, ret = -1; + for( int k=screens; --k>=0; ) { + int w = xinerama_info[k].width, h = xinerama_info[k].height; + int sz = w * h; + if( sz > best ) { + ret = xinerama_info[k].screen_number; + best = sz; + } + } + return ret; +} + static void get_top_coords(Display *display, Window win, int &px,int &py, int &tx,int &ty) { Window *pcwin = 0; unsigned int ncwin = 0; @@ -133,11 +155,8 @@ static void get_top_coords(Display *display, Window win, int &px,int &py, int &t #ifdef HAVE_GL -int BC_DisplayInfo::gl_probe() +int BC_DisplayInfo::gl_fb_config() { - int ncfgs = 0; - XVisualInfo *vis_info = 0; - GLXFBConfig *fb_cfgs = 0, cfg = 0; #if 0 // find prefered config via glxinfo: mesa_hack static int attribs[] = { @@ -206,16 +225,27 @@ int BC_DisplayInfo::gl_probe() printf("%s\n", "BC_DisplayInfo::gl_fb_config failed"); cfg = 0; } + return 0; +} + +int BC_DisplayInfo::gl_probe(Window win) +{ GLXContext glx_ctx = !cfg ? 0 : glXCreateNewContext(display, cfg, GLX_RGBA_TYPE, 0, True); - if( glx_ctx && glXMakeContextCurrent(display, None, None, glx_ctx) ) { + GLXWindow glx_win = !cfg ? 0 : + glXCreateWindow(display, cfg, win, 0); + if( glx_ctx && glx_win && + glXMakeContextCurrent(display, glx_win, glx_win, glx_ctx) ) { const char *shader_version = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); if( shader_version ) strncpy(gl_shader_version, shader_version, sizeof(gl_shader_version)); } + gl_max_texture_size = 0; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max_texture_size); glXMakeContextCurrent(display, None, None, 0); if( glx_ctx ) glXDestroyContext(display, glx_ctx); + if( glx_win ) glXDestroyWindow(display, glx_win); if( fb_cfgs ) XFree(fb_cfgs); if( vis_info ) XFree(vis_info); return 0; @@ -228,6 +258,9 @@ void BC_DisplayInfo::test_window(int &x_out, int &y_out, int &x_out2, int &y_out { #ifdef SINGLE_THREAD BC_Display::lock_display("BC_DisplayInfo::test_window"); +#endif +#ifdef HAVE_GL + gl_fb_config(); #endif x_out = 0; y_out = 0; @@ -236,11 +269,12 @@ void BC_DisplayInfo::test_window(int &x_out, int &y_out, int &x_out2, int &y_out x_out2 = 0; y_out2 = 0; - unsigned long mask = CWEventMask | CWWinGravity | CWBackPixel; + unsigned long mask = CWEventMask | CWWinGravity | CWBackPixel | CWColormap; XSetWindowAttributes attr; attr.event_mask = StructureNotifyMask; attr.win_gravity = SouthEastGravity; attr.background_pixel = BlackPixel(display, scrnum); + attr.colormap = XCreateColormap(display, rootwin, vis, AllocNone); Window win = XCreateWindow(display, rootwin, x_in, y_in, TEST_SIZE, TEST_SIZE, 0, depth, InputOutput, @@ -303,6 +337,9 @@ void BC_DisplayInfo::test_window(int &x_out, int &y_out, int &x_out2, int &y_out // x_out,y_out, x_out1,y_out1, x_out2,y_out2); //printf("\nx_in,y_in=%d,%d\n", x_in,y_in); +#ifdef HAVE_GL + gl_probe(win); +#endif XDestroyWindow(display, win); XFlush(display); XSync(display, 0); @@ -310,9 +347,6 @@ void BC_DisplayInfo::test_window(int &x_out, int &y_out, int &x_out2, int &y_out x_out = MAX(0, MIN(x_out, 48)); y_out = MAX(0, MIN(y_out, 48)); -#ifdef HAVE_GL - gl_probe(); -#endif #ifdef SINGLE_THREAD BC_Display::unlock_display(); #endif @@ -357,6 +391,12 @@ int BC_DisplayInfo::get_bottom_border() return bottom_border; } +int BC_DisplayInfo::get_gl_max_texture_size() +{ + init_borders(); + return gl_max_texture_size; +} + const char *BC_DisplayInfo::get_gl_shader_version() { init_borders();