Jump to content

On-screen text messages


psychoanima
 Share

Recommended Posts

You have to manage your fonts just like any asset.

window = Window:Create("font example",0,0,400,300)
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
light = DirectionalLight:Create()
light:SetRotation(45,45,0)
box = Model:Box()
box:SetPosition(0,0,3)
box:SetColor(1,0,0,1)
	
lilfont = context:GetFont()
medfont = Font:Load("Fonts/arial.ttf", 24, Font.Smooth)
bigfont = Font:Load("Fonts/arial.ttf", 48, Font.Smooth)

while window:KeyDown(Key.Escape)==false do
	if window:Closed() then break end

	box:Turn(Time:GetSpeed()*0.5,Time:GetSpeed()*0.5,0)
	
	Time:Update()
	world:Update()
	world:Render()
	context:SetBlendMode(Blend.Alpha)
	context:DrawText(string.format("FPS: %.2f",Time:UPS()),0,10)
	context:SetFont(bigfont)
	context:DrawText("BIG FONT",0,30)
	context:SetFont(medfont)
	context:DrawText("MEDIUM FONT",0,80)
	context:SetFont(lilfont)
	context:SetBlendMode(Blend.Solid)
	context:Sync(true)
end

 

font.jpg

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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...