1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D 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 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <GLEXT/GLFont2dStorage.h>
22 #include <common/DefinesAssert.h>
26 unsigned int GLFont2dStorage::totalCharacterBlocks_(0);
28 GLFont2dStorage::CharEntry::CharEntry() :
29 texture(0), displaylist(0)
34 GLFont2dStorage::CharEntry::~CharEntry()
36 if (displaylist
!= 0) glDeleteLists(displaylist
, 1);
37 if (texture
!= 0) glDeleteTextures(1, &texture
);
40 GLFont2dStorage::StorageBlock::StorageBlock()
42 entries
= new CharEntry
[256];
45 GLFont2dStorage::StorageBlock::~StorageBlock()
50 GLFont2dStorage::GLFont2dStorage()
52 blocks_
= new StorageBlock
*[40];
53 for (int i
=0; i
<40; i
++) blocks_
[i
] = 0;
56 GLFont2dStorage::~GLFont2dStorage()
58 for (int i
=0; i
<40; i
++) delete blocks_
[i
];
62 GLFont2dStorage::CharEntry
*GLFont2dStorage::getEntry(unsigned int character
)
64 unsigned int blockCount
= character
>> 8;
65 unsigned int remainderCount
= character
& 0xFF;
67 if (blockCount
>= 40) return getEntry('?');
70 StorageBlock
*block
= blocks_
[blockCount
];
73 block
= new StorageBlock();
74 blocks_
[blockCount
] = block
;
75 totalCharacterBlocks_
++;
79 CharEntry
*entry
= &block
->entries
[remainderCount
];