当前位置: 首页>>代码示例>>Java>>正文


Java GlStateManager.generateTexture方法代码示例

本文整理汇总了Java中net.minecraft.client.renderer.GlStateManager.generateTexture方法的典型用法代码示例。如果您正苦于以下问题:Java GlStateManager.generateTexture方法的具体用法?Java GlStateManager.generateTexture怎么用?Java GlStateManager.generateTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.client.renderer.GlStateManager的用法示例。


在下文中一共展示了GlStateManager.generateTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: glGenTextures

import net.minecraft.client.renderer.GlStateManager; //导入方法依赖的package包/类
public static int glGenTextures()
{
    return GlStateManager.generateTexture();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:TextureUtil.java

示例2: setup

import net.minecraft.client.renderer.GlStateManager; //导入方法依赖的package包/类
/**
 * Sets up the character data and textures.
 *
 * @param characterData The array of character data that should be filled.
 * @param type          The font type. (Regular, Bold, and Italics)
 */
private CharacterData[] setup(CharacterData[] characterData, int type) {
    // Quickly generates the colors.
    generateColors();

    // Changes the type of the font to the given type.
    Font font = this.font.deriveFont(type);

    // An image just to get font data.
    BufferedImage utilityImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);

    // The graphics of the utility image.
    Graphics2D utilityGraphics = (Graphics2D) utilityImage.getGraphics();

    // Sets the font of the utility image to the font.
    utilityGraphics.setFont(font);

    // The font metrics of the utility image.
    FontMetrics fontMetrics = utilityGraphics.getFontMetrics();

    // Iterates through all the characters in the character set of the font renderer.
    for (int index = 0; index < characterData.length; index++) {
        // The character at the current index.
        char character = (char) index;

        // The width and height of the character according to the font.
        Rectangle2D characterBounds = fontMetrics.getStringBounds(character + "", utilityGraphics);

        // The width of the character texture.
        float width = (float) characterBounds.getWidth() + (2 * MARGIN);

        // The height of the character texture.
        float height = (float) characterBounds.getHeight();

        // The image that the character will be rendered to.
        BufferedImage characterImage = new BufferedImage(MathHelper.ceiling_double_int(width), MathHelper.ceiling_double_int(height), BufferedImage.TYPE_INT_ARGB);

        // The graphics of the character image.
        Graphics2D graphics = (Graphics2D) characterImage.getGraphics();

        // Sets the font to the input font/
        graphics.setFont(font);

        // Sets the color to white with no alpha.
        graphics.setColor(new Color(255, 255, 255, 0));

        // Fills the entire image with the color above, makes it transparent.
        graphics.fillRect(0, 0, characterImage.getWidth(), characterImage.getHeight());

        // Sets the color to white to draw the character.
        graphics.setColor(Color.WHITE);

        // Enables anti-aliasing so the font doesn't have aliasing.
        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, this.fractionalMetrics ? RenderingHints.VALUE_FRACTIONALMETRICS_ON : RenderingHints.VALUE_FRACTIONALMETRICS_OFF);

        // Draws the character.
        graphics.drawString(character + "", MARGIN, fontMetrics.getAscent());

        // Generates a new texture id.
        int textureId = GlStateManager.generateTexture();

        // Allocates the texture in opengl.
        createTexture(textureId, characterImage);

        // Initiates the character data and stores it in the data array.
        characterData[index] = new CharacterData(character, characterImage.getWidth(), characterImage.getHeight(), textureId);
    }

    // Returns the filled character data array.
    return characterData;
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:80,代码来源:TTFFontRenderer.java


注:本文中的net.minecraft.client.renderer.GlStateManager.generateTexture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。