freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] freetype opengl texture


From: zill
Subject: Re: [ft-devel] freetype opengl texture
Date: Fri, 10 Aug 2007 13:05:39 -0700 (PDT)

I've got it actually drawing some scrambled up images now.  Which is good
because now I know that all I need to figure out is the glTexImage2D
parameters.

here is the whole code right now:
bool Engine::ft_render_glyph(char c)
{
        FT_UInt glyph_index = FT_Get_Char_Index(ft_face, c);

        FT_UInt error = FT_Load_Glyph(ft_face, glyph_index, FT_LOAD_DEFAULT);
        if (error)
        {
                return false;
        }

        error = FT_Render_Glyph(ft_face->glyph, FT_RENDER_MODE_NORMAL);
        if (error)
        {
                return false;
        }

        int width  = power2(ft_face->glyph->bitmap.width);
        int height = power2(ft_face->glyph->bitmap.rows);

        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, 1, width, height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, &ft_face->glyph->bitmap.buffer);

        return true;
}



Christian Demmer wrote:
> 
> zill wrote:
>>FreeType specifically says it should be glyph->bitmap and if I change it,
it
>>throws all kind of errors at me.
> 
> Please check the definition of the bitmap struct. I think Freetype
> contains no advice how to load an OpenGL texture. 
> 
>>  I changed to the power of two, and it is
>>still giving me blank images, not that that would cause that anyways.  Why
>>is nothing being stored in the bitmap?
> 
>>> Should this be &ft_face->glyph->bitmap->buffer?
> 
> Sorry, I missed this typo (C is not my native language :-) the & is
> wrong; buffer is a pointer.
> 
> Greetings, Christian
> 
> 
> _______________________________________________
> Freetype-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/freetype-devel
> 
> 

-- 
View this message in context: 
http://www.nabble.com/freetype-opengl-texture-tf4243821.html#a12098165
Sent from the Freetype - Dev mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]