Differences between revisions 2 and 3
Revision 2 as of 2008-07-17 01:09:18
Size: 376
Comment:
Revision 3 as of 2008-07-17 01:17:32
Size: 1001
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
=== Using FTGL in python in EMAN2 ===

Programmers have to create an instance of an EMFTGL object, for instance as a member variable:
Line 11: Line 15:

Note that the EMFTGL has default values for all of its parameters, so you don't necessary have to call any of the setter functions to render text. Note that in general you want to limit the number of times you call the setter functions, because they cause FTGL to regenerate a FTFont class and this is not a trivial expense.

Then to render text use a command similar to the following in your paint function:

{{{
self.font_renderer.render_string("Important Information")
}}}

Using FTGL in python in EMAN2

Programmers have to create an instance of an EMFTGL object, for instance as a member variable:

self.font_renderer = EMFTGL()
self.font_renderer.set_face_size(16)
self.font_renderer.set_using_display_lists(True)
self.font_renderer.set_depth(32) # only applicable if font mode is EXTRUDE
self.font_renderer.set_font_mode(FTGLFontMode.TEXTURE) # or EXTRUDE, or PIMAP
#self.font_renderer.set_font_file_name("/usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf")

Note that the EMFTGL has default values for all of its parameters, so you don't necessary have to call any of the setter functions to render text. Note that in general you want to limit the number of times you call the setter functions, because they cause FTGL to regenerate a FTFont class and this is not a trivial expense.

Then to render text use a command similar to the following in your paint function:

self.font_renderer.render_string("Important Information")

Eman2UsingFTGL (last edited 2022-02-18 00:29:09 by TunayDurmaz)