• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Portability of PowerBASIC applications - GRAPHIC FONTS

Started by Chris Holbrook, August 26, 2013, 01:01:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chris Holbrook

The essentials are now in place in my retro form class using OpenGL. 2D basics from Walt Decker's excellent intro in the PowerBASIC forums, font handling from NeHe's lesson 13, José's version. I'm absolutely sure that it won't work on Debian, but that's a problem for later!

Patrice Terrier

From the BassBox BBplugin.inc


    SUB BBP_DrawGLText (BYVAL glWnd AS LONG, UseFont AS ZGLFONT, BYVAL x AS LONG, BYVAL y AS LONG, zTxt AS ASCIIZ, BYVAL ARGB AS LONG)
        LOCAL rc AS RECT, A, R, G, B AS BYTE, WasTexture, WasLighting AS LONG
        LOCAL AlphaCoef AS SINGLE
       
        CALL GetClientRect(glWnd, rc)
   
        WasTexture = glIsEnabled(%GL_TEXTURE_2D)
        IF WasTexture THEN CALL glDisable(%GL_TEXTURE_2D)        ' Turn off textures, didn't want our text textured
        WasLighting = glIsEnabled(%GL_LIGHTING)
        IF WasLighting THEN CALL glDisable(%GL_LIGHTING)         ' Disable Lighting
   
        CALL glMatrixMode(%GL_PROJECTION)
        CALL glPushMatrix()
        CALL glLoadIdentity()
        CALL glOrtho(0, rc.nRight, rc.nBottom, 0, 0, 1)

        CALL glMatrixMode(%GL_MODELVIEW)
        CALL glPushMatrix()
        CALL glLoadIdentity()

        CALL glTranslatef(0.375, 0.375, 0)
   
      ' Set color
        CALL BBP_SplitColorARGB(ARGB, A, R, G, B)
        'AlphaCoef = A / 255
        'R = R / AlphaCoef
        'G = G / AlphaCoef
        'B = B / AlphaCoef
        CALL glColor4ub(R, G, B, A)

      ' Set X,Y location
        CALL glRasterPos2i(x, y + (UseFont.fontHeight - 4)) '// 09-07-2011
      ' Draw the text
        CALL glPushAttrib(%GL_LIST_BIT)                           ' Pushes The Display List Bits
             CALL glListBase(UseFont.fontBase - UseFont.charStart)' Sets The Base Character to 0
             CALL glCallLists(LEN(zTxt), %GL_UNSIGNED_BYTE, zTxt) ' Draws The Display List Text
        CALL glPopAttrib()                                        ' Pops The Display List Bits
   
        CALL glPopMatrix()
        CALL glMatrixMode(%GL_PROJECTION)
        CALL glPopMatrix()
        CALL glMatrixMode(%GL_MODELVIEW)
   
        IF WasTexture THEN CALL glEnable(%GL_TEXTURE_2D)          ' Enable texture mode
        IF WasLighting THEN CALL glEnable(%GL_LIGHTING)           ' Enable Lighting
   
        CALL glColor3f(1, 1, 1)                                   ' Back to default color
   
    END SUB
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Brice Manuel