/** * gdk_gl_init: * @argc: Address of the <parameter>argc</parameter> parameter of your * main() function. Changed if any arguments were handled. * @argv: Address of the <parameter>argv</parameter> parameter of * main(). Any parameters understood by gdk_gl_init() are stripped * before return. * * Call this function before using any other GdkGLExt functions in your * applications. It will initialize everything needed to operate the * library and parses some standard command line options. @argc and * @argv are adjusted accordingly so your own code will never see those * standard arguments. * * <note><para>This function will terminate your program if it was * unable to initialize the library for some reason. If you want your * program to fall back to a textual interface you want to call * gdk_gl_init_check() instead.</para></note> **/ void gdk_gl_init (int *argc, char ***argv) { if (!gdk_gl_init_check (argc, argv)) g_error ("GdkGLExt library initialization fails."); }
struct OpenGL* allocateOpenGL(int nblocks) { if (!initialized) { int fakeargc = 1; char *fakeargv[] = { "", NULL }; if (!gdk_gl_init_check(&fakeargc, &fakeargv)) { fprintf(stderr, "Cannot init GDKGL"); return NULL; } initialized = 1; } OpenGL* ogl = (OpenGL*) calloc(sizeof(OpenGL), 1); //printf("ogl alloc=%p\n", ogl); ogl->nblocks = nblocks; ogl->indices = (unsigned short *) malloc(sizeof(unsigned short) * 49152 * 4); ogl->vertices = (unsigned short *) malloc(sizeof(unsigned short) * 49152 * 2); int r, c; int idx = 0; for (r = 0; r < 192; r++) { int nr = r < 191 ? r + 1 : r; for (c = 0; c < 256; c++) { ogl->indices[idx++] = r * 256 + c; ogl->indices[idx++] = nr * 256 + c; ogl->indices[idx++] = nr * 256 + c + 1; ogl->indices[idx++] = r * 256 + c + 1; ogl->vertices[(r * 256 + c) * 2] = c; ogl->vertices[(r * 256 + c) * 2 + 1] = r; } } return ogl; }
/** * gtk_gl_init_check: * @argc: (inout): Address of the <parameter>argc</parameter> parameter of your * <function>main()</function> function. Changed if any arguments * were handled. * @argv: (array length=argc) (inout) (allow-none): Address of the <parameter>argv</parameter> parameter of * <function>main()</function>. Any parameters understood by * gtk_gl_init() are stripped before return. * * This function does the same work as gtk_gl_init() with only * a single change: It does not terminate the program if the library can't be * initialized. Instead it returns %FALSE on failure. * * This way the application can fall back to some other means of communication * with the user - for example a curses or command line interface. * * Return value: %TRUE if the GUI has been successfully initialized, * %FALSE otherwise. **/ gboolean gtk_gl_init_check (int *argc, char ***argv) { /* Init GdkGLExt library. */ if (!gdk_gl_init_check (argc, argv)) return FALSE; /* Parse args and init GtkGLExt library. */ gtk_gl_parse_args (argc, argv); return TRUE; }
void OpenGLExampleX11::StaticInitialize() { int c = 0; gdk_gl_init_check(&c, NULL); }
/*! \brief main() is the typical main function in a C program, it performs all core initialization, loading of all main parameters, initializing handlers and entering gtk_main to process events until program close \param argc is the count of command line arguments \param argv is the array of command line args \returns TRUE */ gint main(gint argc, gchar ** argv) { Serial_Params *serial_params = NULL; GAsyncQueue *queue = NULL; GCond *cond = NULL; GMutex *mutex = NULL; gint id = 0; setlocale(LC_ALL,""); #ifdef __WIN32__ bindtextdomain(PACKAGE, "C:\\Program Files\\MegaTunix\\dist\\locale"); #else bindtextdomain(PACKAGE, LOCALEDIR); #endif textdomain (PACKAGE); #ifdef DEBUG printf("This is a debug release, Git hash: %s\n",MTX_GIT_HASH); #endif if(!g_thread_supported()) g_thread_init(NULL); gdk_threads_init(); gtk_init(&argc, &argv); glade_init(); gdk_gl_init_check(&argc, &argv); gl_ability = gtk_gl_init_check(&argc, &argv); global_data = g_new0(gconstpointer, 1); /* Condition variables */ cond = g_cond_new(); DATA_SET(global_data,"statuscounts_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"io_dispatch_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"gui_dispatch_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"pf_dispatch_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"rtv_thread_cond",cond); /* Mutexes */ mutex = g_mutex_new(); DATA_SET(global_data,"serio_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"rtt_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"rtv_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"dash_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"statuscounts_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"io_dispatch_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"gui_dispatch_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"pf_dispatch_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"rtv_thread_mutex",mutex); /* For testing if gettext works printf(_("Hello World!\n")); */ /* Build table of strings to enum values */ build_string_2_enum_table(); serial_params = (Serial_Params *)g_malloc0(sizeof(Serial_Params)); DATA_SET(global_data,"serial_params",serial_params); handle_args(argc,argv); /* handle CLI arguments */ /* This will exit mtx if the locking fails! */ create_mtx_lock(); open_debug(); /* Open debug log */ /* Allocate memory */ init(); /* Initialize global vars */ make_mtx_dirs(); /* Create config file dirs if missing */ /* Create Message passing queues */ queue = g_async_queue_new(); DATA_SET_FULL(global_data,"io_data_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"slave_msg_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"pf_dispatch_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"gui_dispatch_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"io_repair_queue",queue,g_async_queue_unref); read_config(); setup_gui(); gtk_rc_parse_string("style \"override\"\n{\n\tGtkTreeView::horizontal-separator = 0\n\tGtkTreeView::vertical-separator = 0\n}\nwidget_class \"*\" style \"override\""); id = g_timeout_add_full(-50,16,(GSourceFunc)pf_dispatcher,NULL,NULL); DATA_SET(global_data,"pf_dispatcher_id",GINT_TO_POINTER(id)); id = g_timeout_add_full(-35,35,(GSourceFunc)gui_dispatcher,NULL,NULL); DATA_SET(global_data,"gui_dispatcher_id",GINT_TO_POINTER(id)); id = g_timeout_add(1000,(GSourceFunc)flush_binary_logs,NULL); DATA_SET(global_data,"binlog_flush_id",GINT_TO_POINTER(id)); sleep_calib(); /* Check for first_time flag, if so, run first tiem wizard, otherwise load personality choice */ gdk_threads_add_timeout(500,(GSourceFunc)check_for_first_time,NULL); DATA_SET(global_data,"ready",GINT_TO_POINTER(TRUE)); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); return (0) ; }