Hi,

I'm currently working on this bug. And probably will do an NMU soon to
fix this bug.

I rewrite the texfont.cpp and texfont.h by using plib. I am enclosing
these files for reference.

Regards,
 Ying-Chun Liu

-- 
                                                PaulLiu(Ying-Chun Liu)
E-mail address: [EMAIL PROTECTED]
/*
    replacement for non-free texfont.cpp for openuniverse
    Copyright (C) 2008 PaulLiu(Ying-Chun Liu).

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include "texfont.h"
#include "ou.h"

static int plib_init_flag=(1==0);

static void init_plib() {
  if (!plib_init_flag) {
    fntInit();
    plib_init_flag=(1==1);
  }
}


TexFont* txfLoadFont (char* filename) {
  TexFont* ret=NULL;
  char newfilename[1024];

  init_plib();

  ret = (TexFont*)malloc (sizeof(TexFont));
  memset(ret,0,sizeof(TexFont));

  memset(newfilename,0,sizeof(newfilename));
  snprintf(newfilename,sizeof(newfilename)-1,"%s/%s",fontpath,filename);
  ret->plibtexfont = new fntTexFont(newfilename);

  ret->tgi = (TexGlyphInfo*)malloc(sizeof(TexGlyphInfo));
  memset(ret->tgi,0,sizeof(TexGlyphInfo));
  ret->tgi->width = 3;
  ret->tgi->advance = 3;
  ret->tgi->height = 12;

  ret->plibrenderer = new fntRenderer();
  ret->plibrenderer->setFont(ret->plibtexfont);
  return ret;
}

GLuint txfEstablishTexture(TexFont* f,GLuint b,GLboolean c)
{
  init_plib();
  return 0;
}

void txfBindFontTexture(TexFont* f)
{
  init_plib();
}

void txfUnloadFont(TexFont* f)
{
  init_plib();
  if (f!=NULL) {
    if (f->plibrenderer!=NULL) {
      delete f->plibrenderer;
      f->plibrenderer=NULL;
    }
    if (f->tgi != NULL) {
      free(f->tgi);
      f->tgi=NULL;
    }
    if (f->plibtexfont!=NULL) {
      delete f->plibtexfont;
      f->plibtexfont=NULL;
    }
    free(f);
  }
}

void txfRenderString(TexFont* f,char* string,int string_len) {
  init_plib();
  f->plibrenderer->begin();
  f->plibrenderer->puts(string);
  f->plibrenderer->end();
}
/*
    replacement for non-free texfont.cpp for openuniverse
    Copyright (C) 2008 PaulLiu(Ying-Chun Liu).

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef __PAULLIU_TEXFONT_H__
#define __PAULLIU_TEXFONT_H__

#include <fnt.h>
#include <GL/gl.h>

typedef struct {
  unsigned char width;
  unsigned char height;
  signed char advance;
} TexGlyphInfo;

typedef struct {
  TexGlyphInfo* tgi;
  fntTexFont* plibtexfont;
  fntRenderer* plibrenderer;
} TexFont;

extern TexFont* txfLoadFont(char*);
extern void txfUnloadFont(TexFont*);
extern GLuint txfEstablishTexture(TexFont*,GLuint,GLboolean);
extern void txfBindFontTexture(TexFont*);
extern void txfRenderString(TexFont*,char*,int);

#endif

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to