Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to Use wglUseFontOutlines in AutoHotkey


  • Please log in to reply
No replies to this topic
a_k1ee
  • Members
  • 2 posts
  • Last active: Mar 19 2015 10:22 AM
  • Joined: 11 Mar 2015

Hi, Can anyone tell me how to use truetype fonts in OpenGL?

I already used Bitmap fonts but since i can't rotate the text I have to use tuetype fonts.

here is the part of my code that doesn't work!

FontList := DllCall("opengl32\glGenLists","Int",256)
hFont := DllCall("CreateFont","Int",MyFontSize,"Int",0,"Int",0,"Int",0,"Int",900,"UInt",1,"UInt",0,"UInt",0,"UInt",0,"UInt",4,"UInt",0,"UInt",4,"UInt",0,"Str",MyFontType)
hTempFont := DllCall("SelectObject","UInt",hDC,"UInt",hFont)
VarSetCapacity(GlyphMetrics,1,256) 
DllCall("opengl32\wglUseFontOutlines" . (A_IsUnicode ? "W" : "A"),"UInt",hDC,"UInt",0,"UInt",256,"UInt",FontList, "Float", 1.0, "Float", 1.0,"WGL_FONT_POLYGONS",GlyphMetrics)

DllCall("SelectObject","UInt",hDC,"UInt",hTempFont)
DllCall("DeleteObject","UInt",hFont)
TextType := A_IsUnicode ? 0x1403 : 0x1401 ;GL_UNSIGNED_SHORT, GL_UNSIGNED_BYTE
DllCall("opengl32\glListBase","UInt",FontList)
TextAngle:=45.0
DllCall("opengl32\glLoadIdentity")
DllCall("opengl32\glColor3f", "Float", 0.0, "Float", .0, "Float", .0)
DllCall("opengl32\glRotatef", "Float",TextAngle , "Float", 0.0,"Float", 0.0, "Float", 1.0)
DrawText := MyOpglText
DllCall("opengl32\glRasterPos3f","Float",TextLocX,"Float",TextLocY,"Float",1)  
DllCall("opengl32\glCallLists","Int",StrLen(DrawText),"UInt",TextType,Ptr,&DrawText)