1 /***************************************************************************
2 * Copyright (C) 2004 by E.Ros *
3 * rosenric@dei.unipd.it *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 ***************************************************************************/
12 #ifndef FIRESAVER_WRITER_H
13 #define FIRESAVER_WRITER_H
16 #include <q3ptrlist.h>
23 Symbol( unsigned int textureNumber
, float l
, float t
, float r
, float b
)
24 : scale((r
- l
) / (b
- t
)), texNum(textureNumber
), L(l
), T(1-t
), R(r
), B(1-b
)
26 v1
[0] = -scale
; v1
[1] = 1;
27 v2
[0] = -scale
; v2
[1] = -1;
28 v3
[0] = scale
; v3
[1] = 1;
29 v4
[0] = scale
; v4
[1] = -1;
34 inline void renderSymbol()
36 //draw the symbol and update "cursor"'s position
37 glBindTexture( GL_TEXTURE_2D
, texNum
);
38 glTranslatef( scale
, 0, 0 );
39 glBegin( GL_TRIANGLE_STRIP
);
49 glTranslatef( scale
, 0, 0 );
53 float v1
[2], v2
[2], v3
[2], v4
[2];
54 unsigned int texNum
; //number of texture to activate
55 float L
, T
, R
, B
; //coordinates for mapping
63 Word( const char * text
, QMap
<char, Symbol
*> * map
, float scale
= 1.0 );
65 inline void renderWord( double dT
);
69 float width
, scale
, cX
, cY
;
71 float activateTime
, lifeTime
, currentTime
;
73 Q3PtrList
<Symbol
> symbolList
;
83 Writer( QString descFileName
);
86 //types of effects implemented
87 enum effectType
{ NoEffect
= 0, Sequence
, Fun1
, Fun2
};
89 //call this function to add a sentence to the renderer
90 void spawnWords( QString phrase
, effectType fx
= NoEffect
);
92 //called to get the words on screen using OpenGL
93 //Note: the context must be set up. Words are drawn on XY plane
94 //inside a rectangle with 10 units's side.
95 void render( double dT
);
98 //misc utility functions
99 bool loadMap( QString
);
101 //texture 'references' used by GL to delete allocated textures
103 unsigned int texArray
[16];
105 //list of words and map of symbols
106 Q3PtrList
<Word
> wordList
;
107 QMap
<char, Symbol
*> symbolMap
;
109 //disables standard constructor