Java 类org.lwjgl.stb.STBTTBakedChar 实例源码

项目:gl3DGE    文件:TrueTypeFont.java   
public TrueTypeFont(String path, int fontSize){
    this.fontSize = fontSize;

    cdata = STBTTBakedChar.malloc(96);
    try {
        ByteBuffer ttf = IOUtil.ioResourceToByteBuffer(path, 160 * 1024);

        ByteBuffer bitmap = BufferUtils.createByteBuffer(BITMAP_SIZE * BITMAP_SIZE);
        stbtt_BakeFontBitmap(ttf, fontSize, bitmap, BITMAP_SIZE, BITMAP_SIZE, 32, cdata);

        tex = new SamplerMap(BITMAP_SIZE, BITMAP_SIZE, SamplerMap.TEX_DEFAULT);
        tex.texImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_SIZE, BITMAP_SIZE, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    loadShader();
}
项目:gl3DGE    文件:TrueTypeFont.java   
public TrueTypeFont(String path, int fontSize){
    this.fontSize = fontSize;

    cdata = STBTTBakedChar.malloc(96);
    try {
        ByteBuffer ttf = IOUtil.ioResourceToByteBuffer(path, 160 * 1024);

        ByteBuffer bitmap = BufferUtils.createByteBuffer(BITMAP_SIZE * BITMAP_SIZE);
        stbtt_BakeFontBitmap(ttf, fontSize, bitmap, BITMAP_SIZE, BITMAP_SIZE, 32, cdata);

        tex = new SamplerMap(BITMAP_SIZE, BITMAP_SIZE, SamplerMap.TEX_DEFAULT);
        tex.texImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_SIZE, BITMAP_SIZE, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    loadShader();
}
项目:LD38    文件:UIFont.java   
public UIFont(String path, float fontHeight){
    ByteBuffer data = ResourceLoader.getBytes(path);

    cdata = STBTTBakedChar.malloc(96);

    ByteBuffer bitmap = BufferUtils.createByteBuffer(512 * 512);
    STBTruetype.stbtt_BakeFontBitmap(data, 32, bitmap, 512, 512, 32, cdata);

    texId = GL11.glGenTextures();

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA, 512, 512, 0, GL11.GL_ALPHA, GL11.GL_UNSIGNED_BYTE, bitmap);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
}
项目:Point-Engine    文件:Font.java   
/**
 * @param font The .ttf file to load
 * @param size The size in screen pixels that this font will be rendered in.
 */
public Font(String font, int size) {
    this.texID = glGenTextures();
    this.cdata = STBTTBakedChar.malloc(96);
    this.size = size;
    this.ttf = Util.readFile(Settings.RESOURCE_PATH + font);

    ByteBuffer bitmap = BufferUtils.createByteBuffer(BITMAP_W * BITMAP_H);
    stbtt_BakeFontBitmap(ttf, size, bitmap, BITMAP_W, BITMAP_H, 32, cdata);

    glBindTexture(GL_TEXTURE_2D, texID);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_W, BITMAP_H, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
项目:SwingGL    文件:TrueTypeFont.java   
/**
 * The constructor that creates the font from the given file at the given height.
 *
 * @param filePath   - The path to file including the file type
 * @param fontHeight - The height (size) of the font
 */
public TrueTypeFont(String filePath, int fontHeight) {
    this.fontHeight = fontHeight;

    long startTime = 0L;
    if (Debug.enabled)
        startTime = System.nanoTime();

    textureID = glGenTextures();
    cdata = STBTTBakedChar.mallocBuffer(96);

    try {
        ByteBuffer ttf = IOUtil.ioResourceToByteBuffer(filePath, 160 * 1024);

        ByteBuffer bitmap = BufferUtils.createByteBuffer(BITMAP_W * BITMAP_H);
        STBTruetype.stbtt_BakeFontBitmap(ttf, fontHeight, bitmap, BITMAP_W, BITMAP_H, 32, cdata);

        glBindTexture(GL_TEXTURE_2D, textureID);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_W, BITMAP_H, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    xbuf = BufferUtils.createFloatBuffer(1);
    ybuf = BufferUtils.createFloatBuffer(1);
    quad = STBTTAlignedQuad.malloc();

    if (Debug.enabled) {
        long endTime = System.nanoTime();
        Debug.println(" Loaded font: " + filePath + "\n\tFont height: " + fontHeight + "px" + "\n\tLoad time: " + Debug.noNotation.format((endTime -
                startTime) / 1000000000.0) + "s", Debug.ANSI_CYAN);
    }
}
项目:gl3DGE    文件:TrueTypeFont.java   
public STBTTBakedChar.Buffer getCData(){
    return cdata;
}
项目:gl3DGE    文件:TrueTypeFont.java   
public STBTTBakedChar.Buffer getCData(){
    return cdata;
}