Results 1 to 4 of 4

Thread: OpenGl & TTF [SOLVED]

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    My translation so far is:

    Code:
    procedure Font.Draw(X,Y: Int64; Txt: String; Clr: Colour);
    var
        SS: pSdl_Surface;
        Tex: Gluint;
        
    begin
      
        New(SS);
        
        SS := TTF_RenderText_Blended(Pointer_, PChar(Txt), Clr.Sdl^);
         
        glGenTextures(1, @Tex);
        glBindTexture(GL_TEXTURE_2D, Tex);
     
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SS^.w, SS^.h, 0, GL_EXT_BGRA, GL_UNSIGNED_BYTE, SS^.pixels);
     
        glBegin(GL_QUADS);
            glTexCoord2d(0, 0); glVertex3d(X, Y, 0);
            glTexCoord2d(1, 0); glVertex3d(X+SS^.w, Y, 0);
            glTexCoord2d(1, 1); glVertex3d(X+SS^.w, Y+SS^.h, 0);
            glTexCoord2d(0, 1); glVertex3d(X, Y+SS^.h, 0);
        glEnd();
     
        glDeleteTextures(1, @Tex);
        sdl_freesurface(SS);
        
    end;
    And surprise surprise, it does not work...

    Edit: one of the reasons behind this is that ttf_openfont does not load anything to the pointer as some extensive testing revealde. Are there any ways to get this to work? I've tried telling it the absolute path, case sensitive and etc but still no luck. has anyone else had this error?
    Last edited by code_glitch; 14-01-2011 at 10:45 PM.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •