Jump to content

(Get)CurrentFont() and (Get)CurrentShader() functions


Masterxilo
 Share

Recommended Posts

  • 1 month later...

+1, for this and ALL possible Get accessors Josh could think of. We seriously are lacking many. For instance, get if a framework effect is enabled. I know I can store it myself in an additional variable, but it's just slopping coding IMHO.

Link to comment
Share on other sites

Here is simple example howto write FontManager for LE in BMX.

 

Class:

Type TFontManager

Field fonts:TMap
Field CurrentFont:TGLFont

Method New()
	Self.fonts = New TMap
	Local def:TGLFont = LoadFont("incbin::Arial9")
	Self.fonts.Insert("Arial9", def)
End Method

Method AddFont(fname:String)
	Local fnt:TGLFont = LoadFont("abstract::" + fname)
	Self.fonts.Insert(fname, fnt)

	? Debug
		Print("FONT: " + fname + " loaded.")
	?

End Method

Method RemoveFont(fname:String)
	Self.Fonts.Remove(fname)
End Method

Method SetCurrentFont(fname:String)
	Self.CurrentFont = TGLFont(Self.fonts.ValueForKey(fname))
	SetFont(Self.CurrentFont)
End Method

Method GetCurrentFont:TGLFont()
	Return Self.CurrentFont
End Method


end type

 

sample:

...
Global Fonts:TFontManager = New TFontManager
...
Fonts.AddFont("courier_new_8_bold")
Fonts.AddFont("courier_new_8_normal")
Fonts.AddFont("verdana_10_normal")
Fonts.AddFont("verdana_10_bold")
...

Fonts.SetCurrentFont("courier_new_8_normal")
DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16 * 2)
Fonts.SetCurrentFont("courier_new_8_bold")
DrawText("FPS: " + UPS(), 10, GraphicsHeight() - 16)
...
' get current font
Local actualfont:TGLFont = Fonts.GetCurrentFont()

...
'set default font back
Fonts.SetCurrentFont("Arial9")

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...