Sign in to follow this  

freetype buffers on nehe sample owerloading weh used multiple font right?

Recommended Posts

this is the modified edition of nehegl sample 43 . the problem comes when i try to reload a font at runtime. its not releasing the bufers . simply invalidates imao and creates new buffers. what all its do is something like x=new trash[sizeof(trash)]; FT_Done_Face looks like doing like this FT_Done_Face(Face){ trash=Face; Face=new Face[sizeof(trash)]; } [code> FT_Library library; FT_Face face; char ch; FT_Glyph glyph; FT_BitmapGlyph bitmap_glyph ; inline int next_p2 ( int a ){int rval=1;while(rval<a) rval<<=1;return rval;} int width ,height; FT_Bitmap bitmap; int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { /**testcode...*/ int h=16; FT_Init_FreeType( &library ) ; FT_New_Face( library, "Test.ttf", 0, &face ); FT_Set_Char_Size( face, h << 6, h << 6, 96, 96); ch='4';//current fiont FT_Load_Glyph( face, FT_Get_Char_Index( face, ch ), FT_LOAD_DEFAULT ); //_Get_Glyph( face->glyph, &glyph ); //FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, 0, 1 ); //bitmap_glyph = (FT_BitmapGlyph)glyph; // //This reference will make accessing the bitmap easier ////bitmap=bitmap_glyph->bitmap; // width = next_p2( bitmap_glyph->bitmap.width ); // height = next_p2( bitmap_glyph->bitmap.rows ); // //c<<width <<"--"<<height <<"\n"; //Allocate memory for the texture data. /// GLubyte* expanded_data = new GLubyte[ 2 * width * height]; /**end of testcode...!*/ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(0.0f,0.0f,-1.0f); // Move One Unit Into The Screen // Blue Text glColor3ub(0,0,0xff); // Position The WGL Text On The Screen glRasterPos2f(-0.40f, 0.35f); glPrint("Active WGL Bitmap Text With NeHe - %7.2f", cnt1); // Print GL Text To The Screen // Here We Print Some Text Using Our FreeType Font // The only really important command is the actual print() call, // but for the sake of making the results a bit more interesting // I have put in some code to rotate and scale the text. // Red text glColor3ub(0xff,0,0); glPushMatrix(); glLoadIdentity(); glRotatef(cnt1,0,0,1); glScalef(1,.8+.3*cos(cnt1/5),1); glTranslatef(-180,0,0); freetype::print(our_font, 320, 240, "Active FreeType Text - %7.2f", cnt1); glPopMatrix(); //Uncomment this to test out print's ability to handle newlines. //freetype::print(our_font, 320, 200, "Here\nthere\nbe\n\nnewlines\n.", cnt1); cnt1+=0.051f; // Increase The First Counter cnt2+=0.005f; // Increase The First Counter FT_Done_Face(face); FT_Done_FreeType(library); //buffers going out blah blah blah sht. thats a lie ... //hehe this question asked for different problem later :P but this is different. //and for the record other problem fixed . return TRUE; // Everything Went OK }

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this