Changeset 3715 in orxonox.OLD for orxonox/branches/textEngine/src/lib/graphics/font
- Timestamp:
- Apr 3, 2005, 9:55:33 PM (20 years ago)
- Location:
- orxonox/branches/textEngine/src/lib/graphics/font
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
r3714 r3715 55 55 #include <string.h> 56 56 57 #include "p_node.h" 58 #include "vector.h" 57 59 #include "debug.h" 58 60 … … 128 130 this->currentText = new Text; 129 131 132 this->currentText->bindNode = NULL; 130 133 this->currentText->text = NULL; 131 134 this->currentText->texture = 0; … … 171 174 } 172 175 176 void GLFont::setBindNode(PNode* bindNode) 177 { 178 this->currentText->bindNode = bindNode; 179 } 180 181 173 182 /** 174 183 \brief Sets a new Text to the font … … 245 254 void GLFont::draw(void) 246 255 { 256 GLdouble modMat[16]; 257 GLint viewPort[4]; 258 glGetDoublev(GL_PROJECTION_MATRIX, this->projMat); 259 glGetDoublev(GL_MODELVIEW_MATRIX, modMat); 260 glGetIntegerv(GL_VIEWPORT, viewPort); 247 261 this->enter2DMode(); 262 263 264 Vector pos; 265 if (this->currentText->bindNode) 266 { 267 GLdouble x = this->currentText->bindNode->getAbsCoor().x; 268 GLdouble y = this->currentText->bindNode->getAbsCoor().y; 269 GLdouble z = this->currentText->bindNode->getAbsCoor().z; 270 GLdouble tmp[3]; 271 gluProject(x, y, z, modMat, projMat, viewPort, tmp, tmp+1, tmp+2); 272 printf("test %f %f %f,\n", tmp[0], tmp[1], tmp[2]); 273 pos.x = tmp[0]; 274 pos.y = tmp[1]; 275 pos.z = tmp[2]; 276 } 248 277 249 278 glBindTexture(GL_TEXTURE_2D, this->currentText->texture); 250 279 glEnable(GL_TEXTURE_2D); 251 280 glBegin(GL_QUADS); 252 281 253 282 glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV); 254 glVertex2i( 20, 20);283 glVertex2i(pos.x, pos.y ); 255 284 256 285 glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV); 257 glVertex2i( 20+this->currentText->textPosSize.w, 20);286 glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y ); 258 287 259 288 glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV); 260 glVertex2i( 20+this->currentText->textPosSize.w, 20+this->currentText->textPosSize.h);289 glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h); 261 290 262 291 glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV); 263 glVertex2i( 20, 20+this->currentText->textPosSize.h);292 glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h); 264 293 265 294 glEnd(); … … 555 584 556 585 } 586 587 588 void m_inverse(const float *m, float *out) 589 { 590 float det; 591 det= m[0]*m[5]*m[10]; 592 det+= m[4]*m[9]*m[2]; 593 det+= m[8]*m[1]*m[6]; 594 det-= m[8]*m[5]*m[2]; 595 det-= m[4]*m[1]*m[10]; 596 det-= m[0]*m[9]*m[6]; 597 598 if(det!= 0.0) 599 det=1.0/det; 600 out[0]= (m[5]*m[10]-m[9]*m[6])*det; 601 out[1]= -(m[1]*m[10]-m[9]*m[2])*det; 602 out[2]= (m[1]*m[6]-m[5]*m[2])*det; 603 out[3]= 0.0; 604 out[4]= -(m[4]*m[10]-m[8]*m[6])*det; 605 out[5]= (m[0]*m[10]-m[8]*m[2])*det; 606 out[6]= -(m[0]*m[6]-m[4]*m[2])*det; 607 out[7]= 0.0; 608 out[8]= (m[4]*m[9]-m[8]*m[5])*det; 609 out[9]= -(m[0]*m[9]-m[8]*m[1])*det; 610 out[10]= (m[0]*m[5]-m[4]*m[1])*det; 611 out[11]= 0.0; 612 out[12]=- (m[12]*out[0]+m[13]*out[4]+m[14]*out[8]); 613 out[13]=- (m[12]*out[1]+m[13]*out[5]+m[14]*out[9]); 614 out[14]=- (m[12]*out[2]+m[13]*out[6]+m[14]*out[10]); 615 out[15]= 1.0; 616 } 617 618 619 Vector mvMult(const float *mat, const Vector* vec) 620 { 621 Vector tmp; 622 tmp.x = mat[0]*vec->x+mat[1]*vec->y+mat[2]*vec->z; 623 tmp.y = mat[4]*vec->x+mat[5]*vec->y+mat[6]*vec->z; 624 tmp.z = mat[8]*vec->x+mat[9]*vec->y+mat[10]*vec->z; 625 return tmp; 626 } -
orxonox/branches/textEngine/src/lib/graphics/font/glfont.h
r3714 r3715 10 10 #include "SDL_ttf.h" 11 11 12 // FORWARD DECLARATION 12 #include "vector.h" 13 14 // FORWARD DECLARATION 15 class PNode; 13 16 template<class T> class tList; 17 14 18 15 19 /* some default values */ … … 20 24 #define FONT_DEFAULT_COLOR_B 256 //!< the default red blue (color) of the text 21 25 #define FONT_NUM_COLORS 256 //!< The number of colors. 22 23 26 24 27 … … 57 60 virtual ~GLFont(); 58 61 62 // general 59 63 static void enableFonts(void); 60 64 static void disableFonts(void); 61 65 66 // font 62 67 bool setFont(const char* fontFile); 63 void setText(const char* text);64 65 void setStyle(char* renderStyle);66 68 void setSize(unsigned int fontSize); 67 69 void setColor(Uint8 r, Uint8 g, Uint8 b); 70 71 // text 72 void setBindNode(PNode* bindNode); 73 void setText(const char* text); 74 void setStyle(char* renderStyle); 68 75 void setPosition(int x, int y); 69 70 76 void createTexture(void); 71 77 … … 73 79 74 80 private: 81 // general purpose 82 GLdouble projMat[16]; //!< The Projection Matrix 83 75 84 // information about the Font 76 85 TTF_Font* font; //!< The font we use for this. … … 88 97 SDL_Rect textPosSize; //!< An SDL-Rectangle representing the position and size of the Text on the screen. 89 98 int renderStyle; //!< The Renderstyle 99 100 PNode* bindNode; //!< A node the Text is bind to. (if NULL thr node will not be bound to anything.) 90 101 }; 91 102 tList<Text>* textList; … … 113 124 }; 114 125 126 void m_inverse(const float *m, float *out); 127 Vector mvMult(const float *mat, const Vector* vec); 115 128 #endif /* _GLFONT_H */
Note: See TracChangeset
for help on using the changeset viewer.