Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3456 in orxonox.OLD for orxonox/trunk/src/sfont


Ignore:
Timestamp:
Mar 4, 2005, 10:01:43 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: FontSet addapted the fontset some more
doxygen-tags
name

Location:
orxonox/trunk/src/sfont
Files:
2 moved

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/sfont/fontset.cc

    r3455 r3456  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
     3
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11   ### File Specific:
     12   main-programmer: Benjamin Grauer
     13   co-programmer: ...
     14
     15   ***
     16   * This file is extended to the needs of the orxonox-project.         *
     17   * The main difference to the version of Marius is, that textures get *
     18   * loaded by orxonox Texture-class, and that the comments are set up, *
     19   * in doxygen style                                                   *
     20   * the Copyright of the original file is below this copyright, and we *
     21   * hope not to offend Marius through this.                            *
     22                                                                      ***
     23
     24*/
     25
    126/***************************************************************************
    227                          cone3dfont.cpp  -  description
     
    1641 ***************************************************************************/
    1742
    18 #include "cone3dfont.h"
     43
     44#include "fontset.h"
    1945#include <stdarg.h>
    2046
    2147#include "../importer/texture.h"
    2248
    23 int Cone3DFont::SetSize(float x, float y)       // Set the size of the font
     49/**
     50    \brief initializes a new fontset
     51*/
     52FontSet::FontSet()
     53{
     54  this->sizex=1.0f;
     55  this->sizey=1.0f;
     56  this->font = NULL;
     57}
     58
     59/**
     60    \brief initializes a new fontset with a texture for the font
     61    \param fontFile The fontfile to load
     62*/
     63FontSet::FontSet(char* fontFile)
     64{
     65  this->sizex=1.0f;
     66  this->sizey=1.0f;
     67  this->font = NULL;
     68 
     69}
     70
     71/**
     72   \brief deletes the Fontset by freeing all allocated space
     73   and then deleting the Texture.
     74*/
     75FontSet::~FontSet()
     76{
     77  killFont();
     78  // delete the texture;
     79  delete font;
     80}
     81
     82/**
     83   \brief sets the size of the font
     84   \param x the width of the font
     85   \param y the height of the font
     86*/
     87int FontSet::setSize(float x, float y)
    2488{
    2589  sizex=x;
     
    2993}
    3094
    31 int Cone3DFont::BuildFont(char *file)          // Build Our Font Display List
     95/**
     96   \brief builds the fontset
     97   \param file the name of the file to get the fontset from.
     98*/
     99int FontSet::buildFont(char *file)
    32100{
    33101  int loop1;
    34102  float cx, cy;
    35103 
     104  if (!font)
     105    delete font;
    36106  font = new Texture();
    37107  font->loadImage(file);
     
    61131}
    62132
    63 int Cone3DFont::KillFont(GLvoid)                          // Delete The Font From Memory
     133/**
     134   \brief deletes the display lists.
     135*/
     136int FontSet::killFont(void)                          // Delete The Font From Memory
    64137{
    65138  glDeleteLists(base,256);                       // Delete All 256 Display Lists
     
    67140}
    68141
    69 int Cone3DFont::PrintText(GLint x, GLint y, char type, char *fmt,...)// Where The Printing Happens
     142/**
     143   \brief prints out some text
     144   \param x most left coordinate of the text.
     145   \param y the top coordinate of the text
     146   \param type Type of text
     147   \param fmt The text to display
     148   \param ... more text
     149*/
     150int FontSet::printText(int x, int y, char type, char *fmt,...)// Where The Printing Happens
    70151{
    71152  char    text[1024];                            // Holds Our String
  • orxonox/trunk/src/sfont/fontset.h

    r3455 r3456  
    1 /***************************************************************************
    2                           cone3dfont.h  -  description
    3                              -------------------
    4     copyright            : (C) 2001 by Marius Andra aka Cone3D
    5     email                : marius@hot.ee
    6     ICQ                  : 43999510
    7  ***************************************************************************/
     1/*!
     2    \file fontset.h
     3    \brief Handles the display of Text.
     4*/
    85
    9 /***************************************************************************
    10  *                                                                         *
    11  *   This program is free software; you can redistribute it and/or modify  *
    12  *   it under the terms of the GNU General Public License as published by  *
    13  *   the Free Software Foundation; either version 2 of the License, or     *
    14  *   (at your option) any later version.                                   *
    15  *                                                                         *
    16  ***************************************************************************/
    17 /*
     6/**
    187  This file is extended to the needs of the orxonox-project.
    198  The main difference to the version of Marius is, that textures get
     
    2312class Texture;
    2413
     14//! A class to handle a FontSet.
     15/**
     16   A fontset is an entire Alphabet (256 entries) of one font.
     17   It is made by creating a file containing a matrix with 256
     18   little pictures in it, displaying the letters of this alphabet.
     19   Then these letters are projected onto Quads, which can be aranged
     20   in a sorted order, to display some text
    2521
    26 class Cone3DFont
     22   usage:
     23   1. initialize the Class by loading the source-font-picture
     24   2. set the size
     25   3. write some text with printText
     26   4. delete the class again.
     27*/
     28class FontSet
    2729{
    28 public:
    29   Cone3DFont() {sizex=1.0f; sizey=1.0f;};
    30         ~Cone3DFont() {KillFont();};
    31   int BuildFont(char *file);
    32   int PrintText(int x, int y, char type, char *fmt, ...);
    33   int KillFont();
    34   int SetSize(float x, float y);
    35 
    36   //  Cone3DTGA font;
    37 private:
    38   int base;
    39   float sizex,sizey;
    40   Texture* font;
     30 public:
     31  FontSet();
     32  FontSet(char *file);
     33  ~FontSet();
     34 
     35  int buildFont(char* fontFile);
     36  int printText(int x, int y, char type, char *fmt, ...);
     37  int killFont(void);
     38  int setSize(float x, float y);
     39 
     40 private:
     41  int base;          //!< Save the glLists here.
     42  float sizex;       //!< the width of the text.
     43  float sizey;       //!< the height of the text.
     44  Texture* font;     //!< texture of the font.
    4145
    4246};
Note: See TracChangeset for help on using the changeset viewer.