コード例 #1
0
ファイル: gl_hooks_tracer.c プロジェクト: se210/tracy
void glDrawArrays.@precall()
{
    int maxIndex = first + count - 1, i;
    int maxTextureUnit = GET_INT(TRS_CTX_CTEXUNIT_MAX);
    void* origUnit = GET(TRS_CTX_CTEXUNIT);
    
    /* Save all the enabled arrays that are not bound to any buffers */
    SAVE_ARRAY(GET_BOOL(TRS_CTX_VERTEX_ENABLED)      && GET(TRS_CTX_VERTEX_BINDING) == 0,      GET(TRS_CTX_VERTEX_POINTER),      GET_INT(TRS_CTX_VERTEX_STRIDE),      GET_INT(TRS_CTX_VERTEX_TYPE),      GET_INT(TRS_CTX_VERTEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_NORMAL_ENABLED)      && GET(TRS_CTX_NORMAL_BINDING) == 0,      GET(TRS_CTX_NORMAL_POINTER),      GET_INT(TRS_CTX_NORMAL_STRIDE),      GET_INT(TRS_CTX_NORMAL_TYPE),      3);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_COLOR_ENABLED)       && GET(TRS_CTX_COLOR_BINDING) == 0,       GET(TRS_CTX_COLOR_POINTER),       GET_INT(TRS_CTX_COLOR_STRIDE),       GET_INT(TRS_CTX_COLOR_TYPE),       GET_INT(TRS_CTX_COLOR_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_POINTSIZE_ENABLED)   && GET(TRS_CTX_POINTSIZE_BINDING) == 0,   GET(TRS_CTX_POINTSIZE_POINTER),   GET_INT(TRS_CTX_POINTSIZE_STRIDE),   GET_INT(TRS_CTX_POINTSIZE_TYPE),   1);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_MATRIXINDEX_ENABLED) && GET(TRS_CTX_MATRIXINDEX_BINDING) == 0, GET(TRS_CTX_MATRIXINDEX_POINTER), GET_INT(TRS_CTX_MATRIXINDEX_STRIDE), GET_INT(TRS_CTX_MATRIXINDEX_TYPE), GET_INT(TRS_CTX_MATRIXINDEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_WEIGHT_ENABLED)      && GET(TRS_CTX_WEIGHT_BINDING) == 0,      GET(TRS_CTX_WEIGHT_POINTER),      GET_INT(TRS_CTX_WEIGHT_STRIDE),      GET_INT(TRS_CTX_WEIGHT_TYPE),      GET_INT(TRS_CTX_WEIGHT_SIZE));

    maxTextureUnit = TR_MAX(GL_TEXTURE0, maxTextureUnit);
    for (i = GL_TEXTURE0; i < maxTextureUnit + 1; i++)
    {
        SET(TRS_CTX_CTEXUNIT, i);
        SAVE_ARRAY(GET_BOOL(TRS_CTX_CTEXUNIT_TEXCOORD_ENABLED) && GET(TRS_CTX_CTEXUNIT_TEXCOORD_BINDING) == 0,
                   GET(TRS_CTX_CTEXUNIT_TEXCOORD_POINTER),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_STRIDE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_TYPE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_SIZE));
    }
    SET(TRS_CTX_CTEXUNIT, origUnit);
}
コード例 #2
0
ファイル: gl_hooks_tracer.c プロジェクト: se210/tracy
void glDrawElements.@precall()
{
    int maxIndex = 0, i;
    const void *indexData = indices;
    int maxTextureUnit = GET_INT(TRS_CTX_CTEXUNIT_MAX);
    void* origUnit = GET(TRS_CTX_CTEXUNIT);
    void* origBuffer = GET(TRS_CTX_BUFFER);
        
    /* See if an element array buffer is bound */
    SET(TRS_CTX_BUFFER, GL_ELEMENT_ARRAY_BUFFER);
    if (GET(TRS_CTX_BUFFER_HANDLE))
    {
        const TRbyte* pointer = (const TRbyte*)GET(TRS_CTX_BUFFER_HANDLE_DATA);
        TRuint offset = (TRuint)indexData;
        indexData = (void*)(pointer + offset);
    }
    SET(TRS_CTX_BUFFER, origBuffer);
    
    /* Find out the minimum and maximum indices for this draw call */
    if (indexData)
    {
        if (type == GL_UNSIGNED_BYTE)
        {
            const unsigned char* d = (const unsigned char*)indexData;
            for (i = 0; i < count; i++)
            {
                if (d[i] > maxIndex) maxIndex = d[i];
            }
        }
        else if (type == GL_UNSIGNED_SHORT)
        {
            const unsigned short* d = (const unsigned short*)indexData;
            for (i = 0; i < count; i++)
            {
                if (d[i] > maxIndex) maxIndex = d[i];
            }
        }
    }

    /* Save all the enabled arrays */
    SAVE_ARRAY(GET_BOOL(TRS_CTX_VERTEX_ENABLED)      && GET(TRS_CTX_VERTEX_BINDING) == 0,      GET(TRS_CTX_VERTEX_POINTER),      GET_INT(TRS_CTX_VERTEX_STRIDE),      GET_INT(TRS_CTX_VERTEX_TYPE),      GET_INT(TRS_CTX_VERTEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_NORMAL_ENABLED)      && GET(TRS_CTX_NORMAL_BINDING) == 0,      GET(TRS_CTX_NORMAL_POINTER),      GET_INT(TRS_CTX_NORMAL_STRIDE),      GET_INT(TRS_CTX_NORMAL_TYPE),      3);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_COLOR_ENABLED)       && GET(TRS_CTX_COLOR_BINDING) == 0,       GET(TRS_CTX_COLOR_POINTER),       GET_INT(TRS_CTX_COLOR_STRIDE),       GET_INT(TRS_CTX_COLOR_TYPE),       GET_INT(TRS_CTX_COLOR_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_POINTSIZE_ENABLED)   && GET(TRS_CTX_POINTSIZE_BINDING) == 0,   GET(TRS_CTX_POINTSIZE_POINTER),   GET_INT(TRS_CTX_POINTSIZE_STRIDE),   GET_INT(TRS_CTX_POINTSIZE_TYPE),   1);
    SAVE_ARRAY(GET_BOOL(TRS_CTX_MATRIXINDEX_ENABLED) && GET(TRS_CTX_MATRIXINDEX_BINDING) == 0, GET(TRS_CTX_MATRIXINDEX_POINTER), GET_INT(TRS_CTX_MATRIXINDEX_STRIDE), GET_INT(TRS_CTX_MATRIXINDEX_TYPE), GET_INT(TRS_CTX_MATRIXINDEX_SIZE));
    SAVE_ARRAY(GET_BOOL(TRS_CTX_WEIGHT_ENABLED)      && GET(TRS_CTX_WEIGHT_BINDING) == 0,      GET(TRS_CTX_WEIGHT_POINTER),      GET_INT(TRS_CTX_WEIGHT_STRIDE),      GET_INT(TRS_CTX_WEIGHT_TYPE),      GET_INT(TRS_CTX_WEIGHT_SIZE));

    maxTextureUnit = TR_MAX(GL_TEXTURE0, maxTextureUnit);
    for (i = GL_TEXTURE0; i < maxTextureUnit + 1; i++)
    {
        SET(TRS_CTX_CTEXUNIT, i);
        SAVE_ARRAY(GET_BOOL(TRS_CTX_CTEXUNIT_TEXCOORD_ENABLED) && GET(TRS_CTX_CTEXUNIT_TEXCOORD_BINDING) == 0,
                   GET(TRS_CTX_CTEXUNIT_TEXCOORD_POINTER),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_STRIDE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_TYPE),
                   GET_INT(TRS_CTX_CTEXUNIT_TEXCOORD_SIZE));
    }
    SET(TRS_CTX_CTEXUNIT, origUnit);
}
コード例 #3
0
ファイル: decomp_list.c プロジェクト: rafaelcoelho/rohc
/**
 * @brief Get the XI information, ie. the X bit and the index value
 *
 * @param ps                    The PS bit
 * @param xi_index              The index of the XI
 * @param xi_1                  The XI 1 field if PS = 1 (4-bit XI)
 * @param data                  The data to parse
 * @param[out] is_item_present  Whether the XI item shall be present or not
 * @return                      The value of the XI index
 */
static uint8_t rohc_list_get_xi_type_2or3(const int ps,
                                          const size_t xi_index,
                                          const uint8_t xi_1,
                                          const uint8_t *const data,
                                          bool *const is_item_present)
{
	uint8_t xi_value;

	/* extract the value of the XI index */
	if(ps == 1)
	{
		/* ROHC header contains 8-bit XIs */
		*is_item_present = GET_BOOL(GET_BIT_7(data + xi_index));
		xi_value = GET_BIT_0_6(data + xi_index);
	}
	else
	{
		/* ROHC header contains 4-bit XIs: encoding type 2 and 3 store XI #1
		 * in their first byte, so next XIs are shifted by 4 bits */

		/* which type of XI do we parse ? first one, odd one or even one ? */
		if(xi_index == 0)
		{
			/* first XI is stored in the first byte of the header */
			*is_item_present = GET_BOOL(GET_BIT_3(&xi_1));
			xi_value = GET_BIT_0_2(&xi_1);
		}
		else if((xi_index % 2) != 0)
		{
			/* handle odd XI, ie. XI stored in MSB */
			*is_item_present = GET_BOOL(GET_BIT_7(data + (xi_index - 1) / 2));
			xi_value = GET_BIT_4_6(data + (xi_index - 1) / 2);
		}
		else
		{
			/* handle even XI, ie. XI stored in LSB */
			*is_item_present = GET_BOOL(GET_BIT_3(data + (xi_index - 1) / 2));
			xi_value = GET_BIT_0_2(data + (xi_index - 1) / 2);
		}
	}

	return xi_value;
}
コード例 #4
0
ファイル: decomp_list.c プロジェクト: rafaelcoelho/rohc
/**
 * @brief Get the XI information, ie. the X bit and the index value
 *
 * @param ps                    The PS bit
 * @param xi_index              The index of the XI
 * @param data                  The data to parse
 * @param[out] is_item_present  Whether the XI item shall be present or not
 * @return                      The value of the XI index
 */
static uint8_t rohc_list_get_xi_type_0(const int ps,
                                       const size_t xi_index,
                                       const uint8_t *const data,
                                       bool *const is_item_present)
{
	uint8_t xi_value;

	/* extract the value of the XI index */
	if(ps == 1)
	{
		/* ROHC header contains 8-bit XIs */
		*is_item_present = GET_BOOL(GET_BIT_7(data + xi_index));
		xi_value = GET_BIT_0_6(data + xi_index);
	}
	else
	{
		/* ROHC header contains 4-bit XIs: encoding type 0 stores XI #1
		 * with all other XIs */

		/* which type of XI do we parse ? even or odd one ? */
		if((xi_index % 2) == 0)
		{
			/* handle even XI, ie. XI stored in MSB */
			*is_item_present = GET_BOOL(GET_BIT_7(data + xi_index / 2));
			xi_value = GET_BIT_4_6(data + xi_index / 2);
		}
		else
		{
			/* handle odd XI, ie. XI stored in LSB */
			*is_item_present = GET_BOOL(GET_BIT_3(data + xi_index / 2));
			xi_value = GET_BIT_0_2(data + xi_index / 2);
		}
	}

	return xi_value;
}
コード例 #5
0
ファイル: enna_config.c プロジェクト: enna-project/enna
static void
cfg_main_section_load (const char *section)
{
    const char *value;
    int i;

    GET_STRING(theme);
    GET_STRING(engine);
    GET_STRING(verbosity);
    GET_STRING(log_file);

    GET_INT(idle_timeout);
    GET_INT(fullscreen);
    GET_INT(slideshow_delay);

    GET_BOOL(display_mouse);

    GET_TUPLE(music_filters, "music_ext");
    GET_TUPLE(video_filters, "video_ext");
    GET_TUPLE(photo_filters, "photo_ext");
}
コード例 #6
0
ファイル: mainwindow.cpp プロジェクト: 1nv4d3r5/subsurface
void MainWindow::readSettings()
{
	QVariant v;
	QSettings s;

	s.beginGroup("Units");
	if (s.value("unit_system").toString() == "metric") {
		prefs.unit_system = METRIC;
		prefs.units = SI_units;
	} else if (s.value("unit_system").toString() == "imperial") {
		prefs.unit_system = IMPERIAL;
		prefs.units = IMPERIAL_units;
	} else {
		prefs.unit_system = PERSONALIZE;
		GET_UNIT("length", length, units::FEET, units::METERS);
		GET_UNIT("pressure", pressure, units::PSI, units::BAR);
		GET_UNIT("volume", volume, units::CUFT, units::LITER);
		GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
		GET_UNIT("weight", weight, units::LBS, units::KG);
	}
	s.endGroup();
	s.beginGroup("DisplayListColumns");
	GET_BOOL("CYLINDER", visible_cols.cylinder);
	GET_BOOL("TEMPERATURE", visible_cols.temperature);
	GET_BOOL("TOTALWEIGHT", visible_cols.totalweight);
	GET_BOOL("SUIT", visible_cols.suit);
	GET_BOOL("NITROX", visible_cols.nitrox);
	GET_BOOL("OTU", visible_cols.otu);
	GET_BOOL("MAXCNS", visible_cols.maxcns);
	GET_BOOL("SAC", visible_cols.sac);
	s.endGroup();
	s.beginGroup("TecDetails");
	GET_BOOL("po2graph", pp_graphs.po2);
	GET_BOOL("pn2graph", pp_graphs.pn2);
	GET_BOOL("phegraph", pp_graphs.phe);
	GET_DOUBLE("po2threshold", pp_graphs.po2_threshold);
	GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
	GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
	GET_BOOL("mod", mod);
	GET_DOUBLE("modppO2", mod_ppO2);
	GET_BOOL("ead", ead);
	GET_BOOL("redceiling", profile_red_ceiling);
	GET_BOOL("dcceiling", profile_dc_ceiling);
	GET_BOOL("calcceiling", profile_calc_ceiling);
	GET_BOOL("calcceiling3m", calc_ceiling_3m_incr);
	GET_BOOL("calcalltissues", calc_all_tissues);
	GET_INT("gflow", gflow);
	GET_INT("gfhigh", gfhigh);
	set_gf(prefs.gflow, prefs.gfhigh);
	s.endGroup();

	s.beginGroup("Display");
	v = s.value(QString("divelist_font"));
	if (v.isValid())
		prefs.divelist_font = strdup(v.toString().toUtf8().data());
}
コード例 #7
0
ファイル: mainwindow.cpp プロジェクト: levisjani/subsurface
void MainWindow::readSettings()
{
	QVariant v;
	QSettings s;

	s.beginGroup("Units");
	if (s.value("unit_system").toString() == "metric") {
		prefs.unit_system = METRIC;
		prefs.units = SI_units;
	} else if (s.value("unit_system").toString() == "imperial") {
		prefs.unit_system = IMPERIAL;
		prefs.units = IMPERIAL_units;
	} else {
		prefs.unit_system = PERSONALIZE;
		GET_UNIT("length", length, units::FEET, units::METERS);
		GET_UNIT("pressure", pressure, units::PSI, units::BAR);
		GET_UNIT("volume", volume, units::CUFT, units::LITER);
		GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
		GET_UNIT("weight", weight, units::LBS, units::KG);
	}
	GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS);
	s.endGroup();
	s.beginGroup("TecDetails");
	GET_BOOL("po2graph", pp_graphs.po2);
	GET_BOOL("pn2graph", pp_graphs.pn2);
	GET_BOOL("phegraph", pp_graphs.phe);
	GET_DOUBLE("po2threshold", pp_graphs.po2_threshold);
	GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
	GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
	GET_BOOL("mod", mod);
	GET_DOUBLE("modppO2", mod_ppO2);
	GET_BOOL("ead", ead);
	GET_BOOL("redceiling", profile_red_ceiling);
	GET_BOOL("dcceiling", profile_dc_ceiling);
	GET_BOOL("calcceiling", profile_calc_ceiling);
	GET_BOOL("calcceiling3m", calc_ceiling_3m_incr);
	GET_BOOL("calcalltissues", calc_all_tissues);
	GET_INT("gflow", gflow);
	GET_INT("gfhigh", gfhigh);
	set_gf(prefs.gflow, prefs.gfhigh);
	GET_BOOL("show_time", show_time);
	GET_BOOL("show_sac", show_sac);
	s.endGroup();

	s.beginGroup("Display");
	v = s.value(QString("divelist_font"));
	if (v.isValid())
		prefs.divelist_font = strdup(v.toString().toUtf8().data());
}
コード例 #8
0
ファイル: download.c プロジェクト: heshamsafi/dwb
static gboolean
download_spawn_external(const char *uri, const char *filename, WebKitDownload *download)
{
    char **argv;
    int argc;
    gboolean ret = true;
    GError *error = NULL;
    char *newcommand = NULL;

    char *command = g_strdup(GET_CHAR("download-external-command"));
    WebKitNetworkRequest *request = webkit_download_get_network_request(download);
    const char *referer = soup_get_header_from_request(request, "Referer");
    const char *user_agent = soup_get_header_from_request(request, "User-Agent");

    char *proxy = GET_CHAR("proxy-url");
    gboolean has_proxy = GET_BOOL("proxy");

    GSList *list = g_slist_prepend(NULL, dwb_navigation_new("DWB_URI", uri));
    list = g_slist_prepend(list, dwb_navigation_new("DWB_FILENAME", filename));
    list = g_slist_prepend(list, dwb_navigation_new("DWB_COOKIES", dwb.files[FILES_COOKIES]));


    if ( (newcommand = util_string_replace(command, "dwb_uri", uri)) )
    {
        g_free(command);
        command = newcommand;
    }
    if ( (newcommand = util_string_replace(command, "dwb_cookies", dwb.files[FILES_COOKIES])) )
    {
        g_free(command);
        command = newcommand;
    }
    if ( (newcommand = util_string_replace(command, "dwb_output", filename)) )
    {
        g_free(command);
        command = newcommand;
    }
    if (referer != NULL)
    {
        list = g_slist_prepend(list, dwb_navigation_new("DWB_REFERER", referer));
    }
    if ( (newcommand = util_string_replace(command, "dwb_referer", referer == NULL ? "" : referer)) )
    {
        g_free(command);
        command = newcommand;
    }
    if ( (newcommand = util_string_replace(command, "dwb_proxy", proxy == NULL && has_proxy ? "" : proxy)) )
    {
        g_free(command);
        command = newcommand;
    }
    if (user_agent != NULL)
        list = g_slist_prepend(list, dwb_navigation_new("DWB_USER_AGENT", user_agent));

    list = g_slist_prepend(list, dwb_navigation_new("DWB_MIME_TYPE", dwb.state.mimetype_request));
    if (proxy != NULL && has_proxy)
        list = g_slist_prepend(list, dwb_navigation_new("DWB_PROXY", proxy));


    g_shell_parse_argv(command, &argc, &argv, NULL);
    g_free(command);
    if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, (GSpawnChildSetupFunc)dwb_setup_environment, list, NULL, &error))
    {
        perror(error->message);
        ret = false;
    }
    g_strfreev(argv);
    return ret;
}
コード例 #9
0
ファイル: spycfg.c プロジェクト: ABratovic/open-watcom-v2
/*
 * SaveSpyConfig - write configuration to a profile file
 */
void SaveSpyConfig( char *fname )
{
    char        *str;
    char        c;
    int         i, j, k;
    char        buf[10];

    str = alloca( TotalMessageArraySize + 1 );
    if( fname == NULL ) {
        fname = iniPath;
        SaveLogConfig( fname, spyApp );
        SaveMonoFont( spyApp, fname );

#define GET_BOOL(x)  (((x)!=0) ? "" : "0")
        itoa( SpyMainWndInfo.xpos, buf, 10 );
        WritePrivateProfileString( spyApp, "wnd_xpos", buf, fname );
        itoa( SpyMainWndInfo.ypos, buf, 10 );
        WritePrivateProfileString( spyApp, "wnd_ypos", buf, fname );
        itoa( SpyMainWndInfo.xsize, buf, 10 );
        WritePrivateProfileString( spyApp, "wnd_xsize", buf, fname );
        itoa( SpyMainWndInfo.ysize, buf, 10 );
        WritePrivateProfileString( spyApp, "wnd_ysize", buf, fname );
        WritePrivateProfileString( spyApp, "wnd_topmost", GET_BOOL( SpyMainWndInfo.on_top ), fname );
        WritePrivateProfileString( spyApp, "show_hint", GET_BOOL( SpyMainWndInfo.show_hints ), fname );
        WritePrivateProfileString( spyApp, "show_toolbar", GET_BOOL( SpyMainWndInfo.show_toolbar ), fname );
#undef GET_BOOL
    }

    if( fname != iniPath || AutoSaveConfig ) {
        /*
         * what specific messages to watch
         */
        for( j = 0, i = 0; j < ClassMessagesSize; j++ ) {
            for( k = 0; k < ClassMessages[j].message_array_size; k++ ) {
                if( ClassMessages[j].message_array[k].bits[M_WATCH] ) {
                    c = '1';
                } else {
                    c = '0';
                }
                str[i++] = c;
            }
        }
        str[TotalMessageArraySize] = 0;
        WritePrivateProfileString( spyApp, "watch", str, fname );

        /*
         * what specific messages to stop on
         */
        for( j = 0, i = 0; j < ClassMessagesSize; j++ ) {
            for( k = 0; k < ClassMessages[j].message_array_size; k++ ) {
                if( ClassMessages[j].message_array[k].bits[M_STOPON] ) {
                    c = '1';
                } else {
                    c = '0';
                }
                str[i++] = c;
            }
        }
        str[TotalMessageArraySize] = 0;
        WritePrivateProfileString( spyApp, "stopon", str, fname );

        /*
         * what message classes to watch
         */
        for( i = 0; i < FILTER_ENTRIES; i++ ) {
            if( Filters[i].flag[M_WATCH] ) {
                c = '1';
            } else {
                c = '0';
            }
            str[i] = c;
        }
        str[FILTER_ENTRIES] = 0;
        WritePrivateProfileString( spyApp, "watchclasses", str, fname );

        /*
         * what message classes to stopon
         */
        for( i = 0; i < FILTER_ENTRIES; i++ ) {
            if( Filters[i].flag[M_STOPON] ) {
                c = '1';
            } else {
                c = '0';
            }
            str[i] = c;
        }
        str[FILTER_ENTRIES] = 0;
        WritePrivateProfileString( spyApp, "stoponclasses", str, fname );
    }

    /*
     * save misc info
     */
    if( AutoSaveConfig ) {
        c = '1';
    } else {
        c = '0';
    }
    str[0] = c;
    str[1] = 0;
    WritePrivateProfileString( spyApp, "autosavecfg", str, fname );

} /* SaveSpyConfig */
コード例 #10
0
void PreferencesDialog::loadSettings()
{
    // This code was on the mainwindow, it should belong nowhere, but since we dind't
    // correctly fixed this code yet ( too much stuff on the code calling preferences )
    // force this here.

    QSettings s;
    QVariant v;
    s.beginGroup("Units");
    if (s.value("unit_system").toString() == "metric") {
        prefs.unit_system = METRIC;
        prefs.units = SI_units;
    } else if (s.value("unit_system").toString() == "imperial") {
        prefs.unit_system = IMPERIAL;
        prefs.units = IMPERIAL_units;
    } else {
        prefs.unit_system = PERSONALIZE;
        GET_UNIT("length", length, units::FEET, units::METERS);
        GET_UNIT("pressure", pressure, units::PSI, units::BAR);
        GET_UNIT("volume", volume, units::CUFT, units::LITER);
        GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
        GET_UNIT("weight", weight, units::LBS, units::KG);
    }
    GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS);
    s.endGroup();
    s.beginGroup("TecDetails");
    GET_BOOL("po2graph", pp_graphs.po2);
    GET_BOOL("pn2graph", pp_graphs.pn2);
    GET_BOOL("phegraph", pp_graphs.phe);
    GET_DOUBLE("po2threshold", pp_graphs.po2_threshold);
    GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold);
    GET_DOUBLE("phethreshold", pp_graphs.phe_threshold);
    GET_BOOL("mod", mod);
    GET_DOUBLE("modppO2", mod_ppO2);
    GET_BOOL("ead", ead);
    GET_BOOL("redceiling", profile_red_ceiling);
    GET_BOOL("dcceiling", profile_dc_ceiling);
    GET_BOOL("calcceiling", profile_calc_ceiling);
    GET_BOOL("calcceiling3m", calc_ceiling_3m_incr);
    GET_BOOL("calcndltts", calc_ndl_tts);
    GET_BOOL("calcalltissues", calc_all_tissues);
    GET_INT("gflow", gflow);
    GET_INT("gfhigh", gfhigh);
    GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
    GET_BOOL("zoomed_plot", zoomed_plot);
    set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
    GET_BOOL("show_sac", show_sac);
    GET_BOOL("display_unused_tanks", display_unused_tanks);
    s.endGroup();

    s.beginGroup("GeneralSettings");
    GET_TXT("default_filename", default_filename);
    GET_TXT("default_cylinder", default_cylinder);
    s.endGroup();

    s.beginGroup("Display");
    QFont defaultFont = s.value("divelist_font", qApp->font()).value<QFont>();
    defaultFont.setPointSizeF(s.value("font_size", qApp->font().pointSizeF()).toFloat());
    qApp->setFont(defaultFont);

    GET_TXT("divelist_font", divelist_font);
    GET_INT("font_size", font_size);
    if (prefs.font_size < 0)
        prefs.font_size = defaultFont.pointSizeF();
    GET_INT("displayinvalid", display_invalid_dives);
    s.endGroup();
}
コード例 #11
0
ファイル: print.c プロジェクト: adrmcintyre/wisp
void internal_generic_output(FILE* fp, CELL cell, int strict, int tab)
{
	switch(GET_TYPE(cell)) {
	case T_VOID:
		fputs("#<void>", fp);
		break;

	case T_NULL:
		fputs("()", fp);
		break;

	case T_UNDEFINED:
		fputs("#<undefined>", fp);
		break;

	case T_EMPTY:
		fputs("#<empty>", fp);
		break;

	case T_BOOL:
		fputs(GET_BOOL(cell) ? "#t" : "#f", fp);
		break;

	case T_CHAR:
		{
			CHAR ch = GET_CHAR(cell);
			if (strict) {
				switch(ch) {
				case ' ':  fputs("#\\space",     fp); break;
				case 0:    fputs("#\\nul",       fp); break;
				case 27:   fputs("#\\escape",    fp); break;
				case 127:  fputs("#\\rubout",    fp); break;
				case '\a': fputs("#\\alarm",     fp); break;
				case '\b': fputs("#\\backspace", fp); break;
				case '\f': fputs("#\\page",      fp); break;
				case '\n': fputs("#\\newline",   fp); break;
				case '\r': fputs("#\\return",    fp); break;
				case '\t': fputs("#\\tab",       fp); break;
				case '\v': fputs("#\\vtab",      fp); break;
				default:   fprintf(fp, "#\\%c", ch); break;
				}
			}
			else {
				fputc(ch, fp);
			}
		}
		break;

	case T_INT:
		fprintf(fp, "%d", GET_INT(cell));
		break;

    case T_BIGINT:
        fprintf(fp, "%lld", GET_BIGINT(cell));
        break;

	case T_FLOAT:
		fprintf(fp, "%f", GET_FLOAT(cell));
		break;

	case T_STRING:
		{
			STRING* p = GET_STRING(cell);
			size_t len = p->len;
			char* data = p->data;
			if (strict) {
				// FIXME -- make this more efficient, and escape other special chars?
				fputc('"', fp);
				while(len--) {
					char ch = *data++;
					if (ch == '"' || ch == '\\') {
						fputc('\\', fp);
					}
					fputc(ch, fp);
				}
				fputc('"', fp);
			}
			else {
				fwrite(data, 1, len, fp);
			}
		}
		break;

	case T_NAME:
		{
			NAME* p = GET_NAME(cell);
			if (p->gensym) {
				fprintf(fp, "#_%d", p->gensym);
			}
			else {
				fwrite(GET_NAME(cell)->data, 1, GET_NAME(cell)->len, fp);
			}
		}
		break;

	case T_KEYWORD:
		{
			KEYWORD* p = GET_KEYWORD(cell);
            fwrite(p->data, 1, p->len, fp);
            fputc(':', fp);
		}
		break;

	case T_SLOT:
		fprintf(fp, "#<slot:%d>", GET_SLOT(cell));
		break;

    // FIXME - arbitrary recursion
	case T_CONS:
		fputc('(', fp);
		if (tab) ++tab;
		int did = 0;
		while(1) {
			int pair = CONSP(CAR(cell));
			if (!did && tab && pair && !CONSP(CAR(CAR(cell)))) { fprintf(fp, "\n%*s", (tab-1)*2, ""); }
			internal_generic_output(fp, CAR(cell), strict, tab);
			cell = CDR(cell);
			if (NULLP(cell)) {
				break;
			}
			did = (tab && pair);
			if (did) { fprintf(fp, "\n%*s", (tab-1)*2, ""); }
			else fputc(' ', fp);
			if (!CONSP(cell)) {
				fputs(". ", fp);
				internal_generic_output(fp, cell, strict, tab);
				break;
			}
		}
		fputc(')', fp);
		break;

    // FIXME - arbitrary recursion
	case T_VECTOR:
		{
			VECTOR *vec = GET_VECTOR(cell);
			fputs("#(", fp);
			if (vec->len > 0) {
				int i = 0;
				internal_generic_output(fp, vec->data[i++], strict, tab);
				while(i < vec->len) {
					fputc(' ', fp);
					internal_generic_output(fp, vec->data[i++], strict, tab);
				}
			}
			fputc(')', fp);
			break;
		}

	case T_FUNC:
		fprintf(fp, "#<primitive:%s>", GET_FUNC(cell)->name);
		break;

	case T_COMPILED_LAMBDA:
		fprintf(fp, "#<compiled-lambda:0x%08x>", AS_LITERAL(cell));
		break;
		{
			if (tab) ++tab;
			COMPILED_LAMBDA *l = GET_COMPILED_LAMBDA(cell);
			fprintf(fp, "#<%s %d%s:%d/%d",
					l->is_macro ? "macro" : "lambda",
					l->argc, l->rest ? "+" : "",
					l->depth,
					l->max_slot);

			if (tab) { fprintf(fp, "\n%*s", (tab-1)*2, ""); }
			else { fputc(' ', fp); }

			internal_generic_output(fp, l->body, strict, tab);
			fputc('>', fp);
		}
		break;
		
	case T_CLOSURE:
		fprintf(fp, "#<closure:0x%08x>", AS_LITERAL(cell));
		break;
		{
			if (tab) ++tab;
			CLOSURE *c = GET_CLOSURE(cell);
			fprintf(fp, "#<closure ");
			if (tab) { fprintf(fp, "\n%*s", (tab-1)*2, ""); }
			internal_print_env(fp, c->env);
			if (tab) { fprintf(fp, "\n%*s", (tab-1)*2, ""); }
			fputc(' ', fp);
			internal_generic_output(fp, c->compiled_lambda, strict, tab);
			fputc('>', fp);
		}
		break;

	case T_EXCEPTION:
		fputs("#<exception:", fp);
		fwrite(GET_EXCEPTION(cell)->data, 1, GET_EXCEPTION(cell)->len, fp);
		fputc('>', fp);
		break;

	case T_REIFIED_CONTINUATION:
		fprintf(fp, "#<continuation:0x%08x>", (int)GET_REIFIED_CONTINUATION(cell)->cont);
		break;

	case T_STACK_FRAME:
		{
			STACK_FRAME* p = GET_STACK_FRAME(cell);
			fputs("#<stack-frame [", fp);
			int i;
			for(i = 0; i < p->len; ++i) {
				if (i) fputc(' ', fp);
				fprintf(fp, "0x%08x", (int)p->cells[i]);
			}
			fputs("]>", fp);
		}
		break;

	case T_ENV:
		fprintf(fp, "#<env:count=%d>", GET_ENV(cell)->count);
		break;

	case T_RELOC:
		fprintf(fp, "#<reloc:0x%08x>", (int)GET_RELOC(cell));
		break;

    case T_PORT:
        fprintf(fp, "#<port:%s>", GET_PORT(cell)->data);
        break;

    case T_DB_CONNECTION:
        fprintf(fp, "#<db-connection>");
        break;

    case T_DB_RESULT:
        fprintf(fp, "#<db-result>");
        break;

    case T_RECORD:
        fprintf(fp, "#<record>");
        break;

	default:
		fprintf(fp, "#<%s-%02x:%08x>",
			IS_LITERAL(cell) ? "literal" : "pointer",
			GET_TYPE(cell),
			AS_LITERAL(cell)
		);
		break;
	}
}
コード例 #12
0
//----------------------------------------------------------------------------------------------------------------------
// vogl_devel_dump_internal_texture_formats
// This func is only for testing various internal GL format related API's
// This func is used to generate vogl_internal_texture_formats.inc
//----------------------------------------------------------------------------------------------------------------------
void vogl_devel_dump_internal_texture_formats(const vogl_context_info &context_info)
{
    VOGL_FUNC_TRACER

    VOGL_CHECK_GL_ERROR;

    vogl_scoped_binding_state orig_texture;
    orig_texture.save_textures(&context_info);

    vogl_scoped_state_saver state_saver(cGSTPixelStore, cGSTPixelTransfer);

    vogl_reset_pixel_store_states();
    vogl_reset_pixel_transfer_states(context_info);

#if 0
	// silly experiment
	{
		GLuint handle;
		ACTUAL_GL_ENTRYPOINT(glGenTextures)(1, &handle);
		VOGL_CHECK_GL_ERROR;

		ACTUAL_GL_ENTRYPOINT(glBindTexture)(GL_TEXTURE_2D, handle);
		VOGL_CHECK_GL_ERROR;

		for (uint32_t i = 0; i < 256; i++)
		{
			uint8_t vals[4] = { i, 0, 0, 0 };
			//ACTUAL_GL_ENTRYPOINT(glTexImage2D)(GL_TEXTURE_2D, 0, GL_R8_SNORM, 1, 1, 0, GL_RED, GL_BYTE, vals);

			//float vals[1] = { ( i - 128.0f) / 127.0f };
			//float vals[1] = { i / 255.0f };

			//ACTUAL_GL_ENTRYPOINT(glPixelTransferf)(GL_RED_SCALE, .5f);
			//ACTUAL_GL_ENTRYPOINT(glPixelTransferf)(GL_RED_BIAS, 0.5f);

			ACTUAL_GL_ENTRYPOINT(glTexImage2D)(GL_TEXTURE_2D, 0, GL_RGB8UI, 1, 1, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, vals);

			//ACTUAL_GL_ENTRYPOINT(glPixelTransferf)(GL_RED_SCALE, 1.0f);
			//ACTUAL_GL_ENTRYPOINT(glPixelTransferf)(GL_RED_BIAS, 0.0f);

			VOGL_CHECK_GL_ERROR;

			uint16_t gvals[4] = { 0, 0, 0, 0 };
			ACTUAL_GL_ENTRYPOINT(glGetTexImage)(GL_TEXTURE_2D, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, gvals);
			VOGL_CHECK_GL_ERROR;

			printf("%u %u %u %u, %u %u %u %u\n", vals[0], vals[1], vals[2], vals[3],
			       gvals[0], gvals[1], gvals[2], gvals[3]);
		}


		ACTUAL_GL_ENTRYPOINT(glDeleteTextures)(1, &handle);
	}
#endif

    typedef vogl::map<GLenum, vogl_internal_tex_format> tex_format_map;
    tex_format_map internal_formats;

    // Iterate through the base internal fmts, which need some special handling (argh) because the actual internal fmt != the requested internal fmt
    GLenum base_internal_formats[] =
        {
            GL_DEPTH_COMPONENT,
            GL_DEPTH_STENCIL,
            GL_ALPHA,
            GL_RED,
            GL_RG,
            GL_RGB,
            GL_RGBA,
            GL_LUMINANCE,
            GL_LUMINANCE_ALPHA,
            GL_INTENSITY,
            GL_SLUMINANCE,
            GL_SLUMINANCE_ALPHA,
            GL_SRGB,
            GL_SRGB_ALPHA
        };

    for (uint32_t i = 0; i < VOGL_ARRAY_SIZE(base_internal_formats); i++)
    {
        printf("%s\n", get_gl_enums().find_gl_name(base_internal_formats[i]));

        GLuint handle;
        GL_ENTRYPOINT(glGenTextures)(1, &handle);
        VOGL_CHECK_GL_ERROR;

        GLenum target = GL_TEXTURE_2D;

        GL_ENTRYPOINT(glBindTexture)(target, handle);

        GLenum base_internal_fmt = base_internal_formats[i];

        vogl_internal_tex_format f;
        GL_ENTRYPOINT(glGetInternalformativ)(target, base_internal_fmt, GL_GET_TEXTURE_IMAGE_TYPE, sizeof(f.m_optimum_get_image_type), (GLint *)&f.m_optimum_get_image_type);
        GL_ENTRYPOINT(glGetInternalformativ)(target, base_internal_fmt, GL_GET_TEXTURE_IMAGE_FORMAT, sizeof(f.m_optimum_get_image_fmt), (GLint *)&f.m_optimum_get_image_fmt);
        VOGL_CHECK_GL_ERROR;

        GLenum &get_fmt = f.m_optimum_get_image_fmt;
        GLenum &get_type = f.m_optimum_get_image_type;

        // manual fixups, ARGH
        switch (base_internal_fmt)
        {
            case GL_DEPTH_COMPONENT:
            {
                get_fmt = GL_DEPTH_COMPONENT;
                get_type = GL_FLOAT;
                break;
            }
            case GL_RG:
            {
                get_fmt = GL_RG;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_RGB:
            {
                get_fmt = GL_RGB;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_RED:
            {
                get_fmt = GL_RED;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_COMPRESSED_LUMINANCE:
            {
                get_fmt = GL_LUMINANCE;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_COMPRESSED_LUMINANCE_ALPHA:
            {
                get_fmt = GL_LUMINANCE_ALPHA;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_COMPRESSED_RGB:
            {
                get_fmt = GL_RGBA;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_COMPRESSED_RGBA:
            {
                get_fmt = GL_RGBA;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_LUMINANCE_ALPHA:
            {
                get_fmt = GL_LUMINANCE_ALPHA;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_SLUMINANCE_ALPHA:
            {
                get_fmt = GL_LUMINANCE_ALPHA;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_SRGB:
            {
                get_fmt = GL_RGB;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            case GL_SRGB_ALPHA:
            {
                get_fmt = GL_RGBA;
                get_type = GL_UNSIGNED_BYTE;
                break;
            }
            default:
            {
                break;
            }
        }

        VOGL_VERIFY(get_fmt != GL_NONE);
        VOGL_VERIFY(get_type != GL_NONE);

        GL_ENTRYPOINT(glTexImage2D)(target, 0, base_internal_fmt, 32, 32, 0, get_fmt, get_type, NULL);
        VOGL_VERIFY(!vogl_check_gl_error());

//bool any_gl_errors = false;

#define GET_INT(dst, gl_enum)                                                  \
    do                                                                         \
    {                                                                          \
        int values[4];                                                         \
        utils::zero_object(values);                                            \
        GL_ENTRYPOINT(glGetTexLevelParameteriv)(target, 0, (gl_enum), values); \
        (dst) = values[0];                                                     \
    } while (0)

#define GET_BOOL(dst, gl_enum)                                                 \
    do                                                                         \
    {                                                                          \
        int values[4];                                                         \
        utils::zero_object(values);                                            \
        GL_ENTRYPOINT(glGetTexLevelParameteriv)(target, 0, (gl_enum), values); \
        (dst) = values[0] != 0;                                                \
    } while (0)


        GLenum actual_internal_fmt;
        GET_INT(actual_internal_fmt, GL_TEXTURE_INTERNAL_FORMAT);

        f.m_tex_image_flags = ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
        f.m_fmt = base_internal_fmt;
        f.m_actual_internal_fmt = actual_internal_fmt;
        f.m_name = get_gl_enums().find_name(base_internal_fmt, "gl");

        GET_INT(f.m_comp_sizes[cTCRed], GL_TEXTURE_RED_SIZE);
        GET_INT(f.m_comp_sizes[cTCGreen], GL_TEXTURE_GREEN_SIZE);
        GET_INT(f.m_comp_sizes[cTCBlue], GL_TEXTURE_BLUE_SIZE);
        GET_INT(f.m_comp_sizes[cTCAlpha], GL_TEXTURE_ALPHA_SIZE);
        GET_INT(f.m_comp_sizes[cTCStencil], GL_TEXTURE_STENCIL_SIZE);
        GET_INT(f.m_comp_sizes[cTCDepth], GL_TEXTURE_DEPTH_SIZE);
        GET_INT(f.m_comp_sizes[cTCIntensity], GL_TEXTURE_INTENSITY_SIZE);
        GET_INT(f.m_comp_sizes[cTCLuminance], GL_TEXTURE_LUMINANCE_SIZE);

        GET_INT(f.m_comp_types[cTCRed], GL_TEXTURE_RED_TYPE);
        GET_INT(f.m_comp_types[cTCGreen], GL_TEXTURE_GREEN_TYPE);
        GET_INT(f.m_comp_types[cTCBlue], GL_TEXTURE_BLUE_TYPE);
        GET_INT(f.m_comp_types[cTCAlpha], GL_TEXTURE_ALPHA_TYPE);
        GET_INT(f.m_comp_types[cTCDepth], GL_TEXTURE_DEPTH_TYPE);
        GET_INT(f.m_comp_types[cTCIntensity], GL_TEXTURE_INTENSITY_TYPE);
        GET_INT(f.m_comp_types[cTCLuminance], GL_TEXTURE_LUMINANCE_TYPE);

        GET_INT(f.m_shared_size, GL_TEXTURE_SHARED_SIZE);
        GET_BOOL(f.m_compressed, GL_TEXTURE_COMPRESSED);

        printf("base_internal_fmt: %s get_fmt: %s get_type: %s, actual_internal_fmt: %s compressed: %u\n",
               get_gl_enums().find_gl_name(base_internal_fmt), get_gl_enums().find_gl_name(get_fmt), get_gl_enums().find_gl_name(get_type),
               get_gl_enums().find_gl_name(actual_internal_fmt),
               f.m_compressed);
#undef GET_INT
#undef GET_BOOL

        //VOGL_ASSERT(!any_gl_errors);

        VOGL_ASSERT(f.m_actual_internal_fmt != GL_NONE);
        VOGL_ASSERT(f.m_optimum_get_image_fmt != GL_NONE);
        VOGL_ASSERT(f.m_optimum_get_image_type != GL_NONE);

        VOGL_ASSERT(!f.m_compressed);
        VOGL_ASSERT(!ktx_is_compressed_ogl_fmt(f.m_fmt) && !ktx_is_compressed_ogl_fmt(f.m_actual_internal_fmt));
        VOGL_ASSERT(ktx_get_ogl_compressed_base_internal_fmt(f.m_fmt) == 0 && ktx_get_ogl_compressed_base_internal_fmt(f.m_actual_internal_fmt) == 0);

        if (!internal_formats.insert(base_internal_fmt, f).second)
        {
            internal_formats.find_value(base_internal_fmt)->m_tex_image_flags |= ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
        }

        GL_ENTRYPOINT(glBindTexture)(target, 0);
        VOGL_CHECK_GL_ERROR;

        GL_ENTRYPOINT(glDeleteTextures)(1, &handle);
        VOGL_CHECK_GL_ERROR;
    }

    for (uint32_t t = 0; t < 5; t++)
    {
        GLenum target = GL_NONE;
        switch (t)
        {
            case 0:
            {
                target = GL_TEXTURE_1D;
                break;
            }
            case 1:
            {
                target = GL_TEXTURE_2D;
                break;
            }
            case 2:
            {
                target = GL_TEXTURE_3D;
                break;
            }
            case 3:
            {
                target = GL_TEXTURE_2D_MULTISAMPLE;
                break;
            }
            case 4:
            {
                target = GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
                break;
            }
            default:
            {
                VOGL_ASSERT_ALWAYS;
                break;
            }
        }

        for (uint32_t fmt = 0; fmt <= 0xFFFF; fmt++)
        {
            GLuint handle;
            GL_ENTRYPOINT(glGenTextures)(1, &handle);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glBindTexture)(target, handle);

            vogl_debug_message_control(context_info, GL_INVALID_ENUM, false);
            vogl_debug_message_control(context_info, GL_INVALID_OPERATION, false);

            bool failed = false;

            switch (t)
            {
                case 0:
                {
                    GL_ENTRYPOINT(glTexStorage1D)(target, 1, fmt, 32);
                    failed = vogl_check_gl_error_suppress_message();
                    break;
                }
                case 1:
                {
                    GL_ENTRYPOINT(glTexStorage2D)(target, 1, fmt, 32, 32);
                    failed = vogl_check_gl_error_suppress_message();
                    break;
                }
                case 2:
                {
                    GL_ENTRYPOINT(glTexStorage3D)(target, 1, fmt, 32, 32, 32);
                    failed = vogl_check_gl_error_suppress_message();
                    break;
                }
                case 3:
                {
                    GL_ENTRYPOINT(glTexStorage2DMultisample)(target, 2, fmt, 32, 32, GL_TRUE);
                    failed = vogl_check_gl_error_suppress_message();
                    break;
                }
                case 4:
                {
                    GL_ENTRYPOINT(glTexStorage3DMultisample)(target, 2, fmt, 32, 32, 2, GL_TRUE);
                    failed = vogl_check_gl_error_suppress_message();
                    break;
                }
            }

            vogl_debug_message_control(context_info, GL_INVALID_ENUM, true);
            vogl_debug_message_control(context_info, GL_INVALID_OPERATION, true);

            if (failed)
                continue;

            bool any_gl_errors = false;
            VOGL_NOTE_UNUSED(any_gl_errors);

            vogl_internal_tex_format f;
            f.m_tex_image_flags = (1 << t);
            f.m_fmt = fmt;
            f.m_actual_internal_fmt = fmt; // this assumes the actual internal fmt will match here!
            f.m_name = get_gl_enums().find_name(fmt, "gl");

#define GET_INT(dst, gl_enum)                                                  \
    do                                                                         \
    {                                                                          \
        int values[4];                                                         \
        utils::zero_object(values);                                            \
        GL_ENTRYPOINT(glGetTexLevelParameteriv)(target, 0, (gl_enum), values); \
        (dst) = values[0];                                                     \
    } while (0)

#define GET_BOOL(dst, gl_enum)                                                 \
    do                                                                         \
    {                                                                          \
        int values[4];                                                         \
        utils::zero_object(values);                                            \
        GL_ENTRYPOINT(glGetTexLevelParameteriv)(target, 0, (gl_enum), values); \
        (dst) = values[0] != 0;                                                \
    } while (0)

            GLenum internal_fmt;
            GET_INT(internal_fmt, GL_TEXTURE_INTERNAL_FORMAT);
            VOGL_ASSERT(internal_fmt == fmt);
            GET_INT(f.m_comp_sizes[cTCRed], GL_TEXTURE_RED_SIZE);
            GET_INT(f.m_comp_sizes[cTCGreen], GL_TEXTURE_GREEN_SIZE);
            GET_INT(f.m_comp_sizes[cTCBlue], GL_TEXTURE_BLUE_SIZE);
            GET_INT(f.m_comp_sizes[cTCAlpha], GL_TEXTURE_ALPHA_SIZE);
            GET_INT(f.m_comp_sizes[cTCStencil], GL_TEXTURE_STENCIL_SIZE);
            GET_INT(f.m_comp_sizes[cTCDepth], GL_TEXTURE_DEPTH_SIZE);
            GET_INT(f.m_comp_sizes[cTCIntensity], GL_TEXTURE_INTENSITY_SIZE);
            GET_INT(f.m_comp_sizes[cTCLuminance], GL_TEXTURE_LUMINANCE_SIZE);

            GET_INT(f.m_comp_types[cTCRed], GL_TEXTURE_RED_TYPE);
            GET_INT(f.m_comp_types[cTCGreen], GL_TEXTURE_GREEN_TYPE);
            GET_INT(f.m_comp_types[cTCBlue], GL_TEXTURE_BLUE_TYPE);
            GET_INT(f.m_comp_types[cTCAlpha], GL_TEXTURE_ALPHA_TYPE);
            GET_INT(f.m_comp_types[cTCDepth], GL_TEXTURE_DEPTH_TYPE);
            GET_INT(f.m_comp_types[cTCIntensity], GL_TEXTURE_INTENSITY_TYPE);
            GET_INT(f.m_comp_types[cTCLuminance], GL_TEXTURE_LUMINANCE_TYPE);

            GET_INT(f.m_shared_size, GL_TEXTURE_SHARED_SIZE);
            GET_BOOL(f.m_compressed, GL_TEXTURE_COMPRESSED);
#undef GET_INT
#undef GET_BOOL

            VOGL_ASSERT(!any_gl_errors);

            GL_ENTRYPOINT(glGetInternalformativ)(target, fmt, GL_GET_TEXTURE_IMAGE_TYPE, sizeof(f.m_optimum_get_image_type), (GLint *)&f.m_optimum_get_image_type);
            GL_ENTRYPOINT(glGetInternalformativ)(target, fmt, GL_GET_TEXTURE_IMAGE_FORMAT, sizeof(f.m_optimum_get_image_fmt), (GLint *)&f.m_optimum_get_image_fmt);
            VOGL_CHECK_GL_ERROR;

            if (f.m_compressed)
            {
                f.m_optimum_get_image_fmt = GL_RGBA;
                f.m_optimum_get_image_type = GL_UNSIGNED_BYTE;
            }
            else
            {
#define HANDLE_FMT(gl_enum, fmt, type)     \
    case gl_enum:                          \
    {                                      \
        f.m_optimum_get_image_fmt = fmt;   \
        f.m_optimum_get_image_type = type; \
        break;                             \
    }
                bool unhandled = false;
                switch (fmt)
                {
                    HANDLE_FMT(GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV);
                    HANDLE_FMT(GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV);
                    HANDLE_FMT(GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
                    HANDLE_FMT(GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
                    HANDLE_FMT(GL_INTENSITY32F_ARB, GL_RED, GL_FLOAT);

                    HANDLE_FMT(2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(3, GL_RGB, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_LUMINANCE6_ALPHA2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_LUMINANCE12_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_LUMINANCE12_ALPHA12, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_LUMINANCE16_ALPHA16, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT);

                    HANDLE_FMT(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_RGB8I, GL_RGB_INTEGER, GL_BYTE);
                    HANDLE_FMT(GL_RGB10, GL_RGB, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_RGB12, GL_RGB, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_RGBA12, GL_RGB, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_RG16, GL_RG, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_RG16F, GL_RG, GL_HALF_FLOAT);
                    HANDLE_FMT(GL_RG32F, GL_RG, GL_FLOAT);

                    HANDLE_FMT(GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_SLUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_BYTE);

                    HANDLE_FMT(GL_RGB32I, GL_RGB_INTEGER, GL_INT);
                    HANDLE_FMT(GL_RGB16I, GL_RGB_INTEGER, GL_SHORT);

                    HANDLE_FMT(GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT);
                    HANDLE_FMT(GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT);
                    HANDLE_FMT(GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_INT);
                    HANDLE_FMT(GL_SIGNED_RGBA8_NV, GL_RGBA, GL_BYTE);
                    HANDLE_FMT(GL_SIGNED_RGB8_NV, GL_RGB, GL_BYTE);
                    HANDLE_FMT(GL_SIGNED_LUMINANCE8_ALPHA8_NV, GL_LUMINANCE_ALPHA, GL_BYTE);
                    HANDLE_FMT(GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV, GL_RGBA, GL_BYTE);
                    HANDLE_FMT(GL_RG8_SNORM, GL_RG, GL_BYTE);
                    HANDLE_FMT(GL_RGB8_SNORM, GL_RGB, GL_BYTE);
                    HANDLE_FMT(GL_RG16_SNORM, GL_RG, GL_SHORT);
                    HANDLE_FMT(GL_RGB16_SNORM, GL_RGB, GL_SHORT);

                    HANDLE_FMT(GL_RGB32F, GL_RGB, GL_FLOAT);
                    HANDLE_FMT(GL_RGB16F, GL_RGB, GL_HALF_FLOAT);

                    // TODO: Research oddball formats
                    HANDLE_FMT(GL_PALETTE4_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_PALETTE4_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_PALETTE8_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE);
                    HANDLE_FMT(GL_PALETTE8_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_BYTE);

                    HANDLE_FMT(GL_HILO16_NV, GL_NONE, GL_NONE);
                    HANDLE_FMT(GL_SIGNED_HILO16_NV, GL_NONE, GL_NONE);
                    HANDLE_FMT(GL_DSDT8_MAG8_INTENSITY8_NV, GL_NONE, GL_NONE);
                    HANDLE_FMT(GL_HILO8_NV, GL_NONE, GL_NONE);
                    HANDLE_FMT(GL_SIGNED_HILO8_NV, GL_NONE, GL_NONE);
                    HANDLE_FMT(GL_DSDT8_NV, GL_NONE, GL_NONE);
                    HANDLE_FMT(GL_DSDT8_MAG8_NV, GL_NONE, GL_NONE);

                    default:
                        unhandled = true;
                        break;
                }

                if ((unhandled) && ((f.m_optimum_get_image_fmt == GL_NONE) || (f.m_optimum_get_image_type == GL_NONE)))
                {
                    printf("INVALID: %s %s %s\n", f.m_name.get_ptr(), get_gl_enums().find_name(f.m_optimum_get_image_fmt, "gl"), get_gl_enums().find_name(f.m_optimum_get_image_type, "gl"));
                }
            }

#undef HANDLE_FMT

            VOGL_ASSERT(f.m_actual_internal_fmt != GL_NONE);

            if ((f.m_optimum_get_image_fmt == GL_NONE) || (f.m_optimum_get_image_type == GL_NONE))
                vogl_warning_printf("Don't have an optimal get format/type for internal format %s\n", get_gl_enums().find_gl_name(fmt));

            VOGL_ASSERT(fmt != GL_LUMINANCE);

            VOGL_ASSERT(f.m_fmt == f.m_actual_internal_fmt);
            if (!f.m_compressed)
            {
                VOGL_ASSERT(!ktx_is_compressed_ogl_fmt(f.m_fmt) && !ktx_is_compressed_ogl_fmt(f.m_actual_internal_fmt));
                VOGL_ASSERT(ktx_get_ogl_compressed_base_internal_fmt(f.m_fmt) == 0 && ktx_get_ogl_compressed_base_internal_fmt(f.m_actual_internal_fmt) == 0);
            }
            else
            {
                VOGL_ASSERT(ktx_is_compressed_ogl_fmt(f.m_actual_internal_fmt));
                VOGL_ASSERT(ktx_get_ogl_compressed_base_internal_fmt(f.m_actual_internal_fmt) != 0);
            }

            if (!internal_formats.insert(fmt, f).second)
            {
                internal_formats.find_value(fmt)->m_tex_image_flags |= (1 << t);
            }

            GL_ENTRYPOINT(glBindTexture)(target, 0);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glDeleteTextures)(1, &handle);
            VOGL_CHECK_GL_ERROR;
        }
    }

    const char *pOutput_filename = "internal_texture_formats.inc";
    FILE *pFile = vogl_fopen(pOutput_filename, "w");
    VOGL_VERIFY(pFile);
    if (!pFile)
        return;

    for (tex_format_map::const_iterator it = internal_formats.begin(); it != internal_formats.end(); ++it)
    {
        vogl_internal_tex_format fmt(it->second);

        uint32_t actual_size = 0;

        if (!fmt.m_compressed)
        {
            VOGL_ASSERT(!ktx_is_compressed_ogl_fmt(fmt.m_fmt));
            VOGL_ASSERT(ktx_get_ogl_compressed_base_internal_fmt(fmt.m_fmt) == 0);
        }
        else
        {
            VOGL_ASSERT(ktx_is_compressed_ogl_fmt(fmt.m_fmt));
            VOGL_ASSERT(ktx_get_ogl_compressed_base_internal_fmt(fmt.m_fmt) != 0);
        }

        if ((!fmt.m_compressed) && (fmt.m_optimum_get_image_fmt != GL_NONE) && (fmt.m_optimum_get_image_type != GL_NONE))
        {
            GLuint handle;
            GL_ENTRYPOINT(glGenTextures)(1, &handle);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glBindTexture)(GL_TEXTURE_2D, handle);
            VOGL_CHECK_GL_ERROR;

            uint8_t vals[128];
            utils::zero_object(vals);
            vals[1] = 64;
            GL_ENTRYPOINT(glTexImage2D)(GL_TEXTURE_2D, 0, fmt.m_fmt, 1, 1, 0, fmt.m_optimum_get_image_fmt, fmt.m_optimum_get_image_type, vals);
            if (vogl_check_gl_error())
            {
                printf("glTexImage2D FAILED: %s %s %s\n", fmt.m_name.get_ptr(), get_gl_enums().find_name(fmt.m_optimum_get_image_fmt, "gl"), get_gl_enums().find_name(fmt.m_optimum_get_image_type, "gl"));
            }

            uint8_t gvals[128];
            memset(gvals, 0xCD, sizeof(gvals));
            GL_ENTRYPOINT(glGetTexImage)(GL_TEXTURE_2D, 0, fmt.m_optimum_get_image_fmt, fmt.m_optimum_get_image_type, gvals);

            uint32_t actual_size0 = 0;
            for (actual_size0 = 0; actual_size0 < sizeof(gvals); actual_size0++)
                if (gvals[actual_size0] == 0xCD)
                    break;

            memset(gvals, 0x12, sizeof(gvals));
            GL_ENTRYPOINT(glGetTexImage)(GL_TEXTURE_2D, 0, fmt.m_optimum_get_image_fmt, fmt.m_optimum_get_image_type, gvals);

            uint32_t actual_size1 = 0;
            for (actual_size1 = 0; actual_size1 < sizeof(gvals); actual_size1++)
                if (gvals[actual_size1] == 0x12)
                    break;

            VOGL_VERIFY(actual_size0 == actual_size1);

            //printf("glGetTexImage() wrote %u bytes\n", actual_size0);

            if (vogl_check_gl_error()) // || gvals[1] != vals[1])
            {
                printf("glGetTexImage() failed: %s %s %s\n", fmt.m_name.get_ptr(), get_gl_enums().find_name(fmt.m_optimum_get_image_fmt, "gl"), get_gl_enums().find_name(fmt.m_optimum_get_image_type, "gl"));
            }

            GL_ENTRYPOINT(glBindTexture)(GL_TEXTURE_2D, 0);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glDeleteTextures)(1, &handle);

            actual_size = actual_size0;

            uint32_t s = vogl_get_image_format_size_in_bytes(fmt.m_optimum_get_image_fmt, fmt.m_optimum_get_image_type);
            VOGL_VERIFY(s);
            if (s != actual_size0)
            {
                VOGL_VERIFY(0);
            }

            vogl::ktx_texture ktx_tex;
            GLenum img_fmt;
            GLenum img_type;
            img_fmt = fmt.m_optimum_get_image_fmt;
            img_type = fmt.m_optimum_get_image_type;

            uint32_t block_dim, bytes_per_block;
            bool success = ktx_get_ogl_fmt_desc(img_fmt, img_type, block_dim, bytes_per_block);
            VOGL_VERIFY(success);
            VOGL_VERIFY(block_dim == 1);
            VOGL_VERIFY(bytes_per_block == actual_size);

            if (!ktx_tex.init_2D(1, 1, 1, fmt.m_fmt, img_fmt, img_type))
            {
                printf("ktx_texture::init_2D() failed: %s %s %s\n", fmt.m_name.get_ptr(), get_gl_enums().find_name(fmt.m_optimum_get_image_fmt, "gl"), get_gl_enums().find_name(fmt.m_optimum_get_image_type, "gl"));
            }
        }
        else if (fmt.m_compressed)
        {
            GLuint handle;
            GL_ENTRYPOINT(glGenTextures)(1, &handle);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glBindTexture)(GL_TEXTURE_2D, handle);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glTexStorage2D)(GL_TEXTURE_2D, 1, fmt.m_fmt, 1, 1);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glGetTexLevelParameteriv)(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, (GLint *)&actual_size);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glBindTexture)(GL_TEXTURE_2D, 0);
            VOGL_CHECK_GL_ERROR;

            GL_ENTRYPOINT(glDeleteTextures)(1, &handle);
            VOGL_CHECK_GL_ERROR;

            uint32_t block_width = 0, block_height = 0, block_size = 0;
            GL_ENTRYPOINT(glGetInternalformativ)(GL_TEXTURE_2D, fmt.m_fmt, GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, sizeof(int), reinterpret_cast<GLint *>(&block_width));
            GL_ENTRYPOINT(glGetInternalformativ)(GL_TEXTURE_2D, fmt.m_fmt, GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT, sizeof(int), reinterpret_cast<GLint *>(&block_height));
            GL_ENTRYPOINT(glGetInternalformativ)(GL_TEXTURE_2D, fmt.m_fmt, GL_TEXTURE_COMPRESSED_BLOCK_SIZE, sizeof(int), reinterpret_cast<GLint *>(&block_size));
            VOGL_CHECK_GL_ERROR;

            if (block_size == actual_size * 8U)
                block_size /= 8;

            uint32_t block_dim, bytes_per_block;
            bool success = ktx_get_ogl_fmt_desc(fmt.m_fmt, GL_UNSIGNED_BYTE, block_dim, bytes_per_block);
            if ((!success) || (block_dim != block_width) || (block_dim != block_height) || (bytes_per_block != actual_size) || (bytes_per_block != block_size))
            {
                printf("ktx_get_ogl_fmt_desc on compressed format failed: %s %s %s %u %i %i %i\n", fmt.m_name.get_ptr(), get_gl_enums().find_name(fmt.m_optimum_get_image_fmt, "gl"), get_gl_enums().find_name(fmt.m_optimum_get_image_type, "gl"), actual_size, block_width, block_height, block_size);
            }

            fmt.m_block_width = block_width;
            fmt.m_block_height = block_height;

            vogl::ktx_texture ktx_tex;
            if (!ktx_tex.init_2D(1, 1, 1, fmt.m_fmt, GL_NONE, GL_NONE))
            {
                printf("ktx_texture::init_2D() compressed failed: %s %s %s\n", fmt.m_name.get_ptr(), get_gl_enums().find_name(fmt.m_optimum_get_image_fmt, "gl"), get_gl_enums().find_name(fmt.m_optimum_get_image_type, "gl"));
            }
        }

        fmt.m_image_bytes_per_pixel_or_block = actual_size;

        fprintf(pFile, "   vogl_internal_tex_format(0x%04X, \"%s\", 0x%04X,\n", fmt.m_fmt, fmt.m_name.get_ptr(), fmt.m_actual_internal_fmt);

        fprintf(pFile, "      ");
        for (uint32_t i = 0; i < cTCTotalComponents; i++)
            fprintf(pFile, "%u, ", fmt.m_comp_sizes[i]);
        fprintf(pFile, "\n");

        fprintf(pFile, "      ");
        for (uint32_t i = 0; i < cTCTotalComponents; i++)
            fprintf(pFile, "%s, ", get_gl_enums().find_name(fmt.m_comp_types[i], "gl"));
        fprintf(pFile, "\n");

        fprintf(pFile, "      %u, 0x%02X, %u, \n", fmt.m_shared_size, fmt.m_tex_image_flags, fmt.m_compressed);
        fprintf(pFile, "      %s, %s, %u, %u, %u),\n",
                get_gl_enums().find_name(fmt.m_optimum_get_image_fmt, "gl"),
                get_gl_enums().find_name(fmt.m_optimum_get_image_type, "gl"),
                fmt.m_image_bytes_per_pixel_or_block,
                fmt.m_block_width, fmt.m_block_height);

#if 0
        uint32_t tex_formats_count;
        static const vogl_internal_tex_format *tex_formats = get_vogl_internal_texture_formats(&tex_formats_count);
		for (uint32_t q = 0; q < tex_formats_count; q++)
		{
			if (tex_formats[q].m_fmt == fmt.m_fmt)
			{
				if (!tex_formats[q].compare(fmt))
				{
					VOGL_ASSERT_ALWAYS;
				}
				break;
			}
		}
		if (q == tex_formats_count)
		{
			VOGL_ASSERT_ALWAYS;
		}
#endif
    }

    vogl_fclose(pFile);

    printf("Wrote file %s\n", pOutput_filename);
}