Changeset 5380 in orxonox.OLD for branches/2d-recalc/src
- Timestamp:
- Oct 15, 2005, 1:49:17 AM (19 years ago)
- Location:
- branches/2d-recalc/src/lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2d-recalc/src/lib/graphics/graphics_engine.cc
r5347 r5380 301 301 glMatrixMode(GL_PROJECTION_MATRIX); 302 302 glLoadIdentity(); 303 glViewport(0,0,width,height); 303 glViewport(0,0,width,height); // Reset The Current Viewport 304 304 } 305 305 … … 421 421 glLoadIdentity(); 422 422 423 glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);423 glOrtho(0.0, 1, 1, 0.0, 0.0, 1.0); 424 424 425 425 glMatrixMode(GL_MODELVIEW); … … 565 565 this->geTextCFPS->setName("curFPS"); 566 566 this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT); 567 this->geTextCFPS->setAbsCoor2D (5, 15);567 this->geTextCFPS->setAbsCoor2Dpx(5, 15); 568 568 } 569 569 if (this->geTextMaxFPS == NULL) … … 572 572 this->geTextMaxFPS->setName("MaxFPS"); 573 573 this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT); 574 this->geTextMaxFPS->setAbsCoor2D (5, 40);574 this->geTextMaxFPS->setAbsCoor2Dpx(5, 40); 575 575 } 576 576 if (this->geTextMinFPS == NULL) … … 579 579 this->geTextMinFPS->setName("MinFPS"); 580 580 this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT); 581 this->geTextMinFPS->setAbsCoor2D (5, 65);581 this->geTextMinFPS->setAbsCoor2Dpx(5, 65); 582 582 } 583 583 } -
branches/2d-recalc/src/lib/graphics/render2D/element_2d.cc
r5378 r5380 221 221 else if (!strcmp(layer, "below-all")) 222 222 this->setLayer(E2D_BELOW_ALL); 223 } 224 225 226 void Element2D::setSize2Dpx(int x, int y) 227 { 228 this->setSize2D((float)(x)/(float)GraphicsEngine::getInstance()->getResolutionX(), (float)(y)/(float)GraphicsEngine::getInstance()->getResolutionY()); 229 } 230 231 232 void Element2D::setSizeX2Dpx(int x) 233 { 234 this->setSizeX2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX()); 235 } 236 237 238 void Element2D::setSizeY2Dpx(int y) 239 { 240 this->setSizeY2D((float)y/(float)GraphicsEngine::getInstance()->getResolutionY()); 241 } 242 243 int Element2D::getSizeX2Dpx() const 244 { 245 return (int)((float)this->getSizeX2D()*GraphicsEngine::getInstance()->getResolutionX()); 246 } 247 248 int Element2D::getSizeY2Dpx() const 249 { 250 return (int)((float)this->getSizeY2D()*GraphicsEngine::getInstance()->getResolutionY()); 223 251 } 224 252 -
branches/2d-recalc/src/lib/graphics/render2D/element_2d.h
r5378 r5380 100 100 101 101 inline void setSize2D(float x, float y) { this->sizeX = x, this->sizeY = y; }; 102 void setSize2Dpx(int x, int y); 102 103 inline void setSizeX2D(float x) { this->sizeX = x; }; 104 void setSizeX2Dpx(int x); 103 105 inline void setSizeY2D(float y) { this->sizeY = y; }; 106 void setSizeY2Dpx(int y); 104 107 inline float getSizeX2D() const { return this->sizeX; }; 108 int getSizeX2Dpx() const; 105 109 inline float getSizeY2D() const { return this->sizeY; }; 110 int getSizeY2Dpx() const; 106 111 107 112 // LIKE PNODE -
branches/2d-recalc/src/lib/graphics/text_engine/text.cc
r5376 r5380 29 29 /** 30 30 * creates a new Text Element 31 * @param textSize the size of the font to be displayed. 31 32 * @param fontFile the Font to render this text in 32 33 * @param type The renderType to display this font in … … 39 40 this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE); 40 41 this->setType(type); 41 this->s ize = textSize;42 this->setSizeY2Dpx(textSize); 42 43 } 43 44 … … 71 72 this->blending = TEXT_DEFAULT_BLENDING; 72 73 this->color = TEXT_DEFAULT_COLOR; 73 this->s ize = TEXT_DEFAULT_SIZE;74 this->setSizeY2Dpx(TEXT_DEFAULT_SIZE); 74 75 this->setType(TEXT_RENDER_DYNAMIC); 75 76 … … 250 251 glBegin(GL_QUADS); 251 252 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]); 252 glVertex2d(posX, - tmpGlyph->bearingY * this-> size);253 glVertex2d(posX, - tmpGlyph->bearingY * this->getSizeY2D()); 253 254 glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]); 254 glVertex2d(posX, (tmpGlyph->height - tmpGlyph->bearingY)*this-> size);255 glVertex2d(posX, (tmpGlyph->height - tmpGlyph->bearingY)*this->getSizeY2D()); 255 256 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]); 256 glVertex2d(posX+tmpGlyph->width*this-> size, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);257 glVertex2d(posX+tmpGlyph->width*this->getSizeY2D(), (tmpGlyph->height - tmpGlyph->bearingY)*this->getSizeY2D()); 257 258 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); 258 glVertex2d(posX+tmpGlyph->width*this-> size, - tmpGlyph->bearingY*this->size);259 glVertex2d(posX+tmpGlyph->width*this->getSizeY2D(), - tmpGlyph->bearingY*this->getSizeY2D()); 259 260 glEnd(); 260 261 glEndList(); 261 posX += tmpGlyph->width*this-> size;262 posX += tmpGlyph->width*this->getSizeY2D(); 262 263 } 263 264 tmpText++; … … 298 299 PRINT(0)("=== TEXT: %s ===\n", this->externText); 299 300 300 if (this->getBindNode())301 PRINT(0)("is bind to %s; ref=%p\n", this->getBindNode()->getName(), this->getBindNode());302 301 PRINT(0)("Color: %0.2f %0.2f %0.2f\n", this->color.x, this->color.y, this->color.z); 303 302 } -
branches/2d-recalc/src/lib/graphics/text_engine/text.h
r5378 r5380 55 55 public: 56 56 Text(const char* fontFile, unsigned int fontSize = TEXT_DEFAULT_SIZE, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC); 57 Text(const char* fontFile, float fontSize); 57 58 ~Text(); 58 59 void init(); … … 69 70 void setColor(float r, float g, float b) { this->color = Vector(r, g, b); }; 70 71 /** sets the Size of the Font */ 71 void setSize(float size) { this->size = size; }; 72 /** @returns the Size of the Text */ 73 // void getSize(float &x, float& y) const { return this->size; }; 72 inline void setTextSize(unsigned int size) { this->setSizeY2Dpx(size); }; 74 73 75 74 void setType(TEXT_RENDER_TYPE type); … … 92 91 Vector color; //!< The color of the font. 93 92 float blending; //!< The blending intensity. 94 float size; //!< The size of the Font.95 93 96 94 // placement in openGL -
branches/2d-recalc/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc
r5373 r5380 200 200 /** 201 201 * draws the ImageScreen to the screenbuffer 202 * @todo redesign this whole function, as it is deprecated. 202 203 */ 203 204 void GLMenuImageScreen::draw () … … 209 210 210 211 /* screen size */ 211 int screenWidth =GraphicsEngine::getInstance()->getResolutionX();212 int screenHeight =GraphicsEngine::getInstance()->getResolutionY();213 214 int imageWidth = (int)(screenWidth * this->scaleX);215 int imageHeight = (int)(screenHeight * this->scaleY);216 217 int offsetX = (int)(this->offsetX * screenWidth);218 int offsetY = (int)(this->offsetY * screenHeight);212 float screenWidth = 1;//GraphicsEngine::getInstance()->getResolutionX(); 213 float screenHeight = 1;//GraphicsEngine::getInstance()->getResolutionY(); 214 215 float imageWidth = (screenWidth * this->scaleX); 216 float imageHeight = (screenHeight * this->scaleY); 217 218 float offsetX = (this->offsetX * screenWidth); 219 float offsetY = (this->offsetY * screenHeight); 219 220 220 221 /* loadbar pos */ 221 int barX = (int)(this->barX *screenWidth);222 int barY = (int)(this->barY *screenHeight);223 int barW = (int)(this->barW *screenWidth);224 int barH = (int)(this->barH *screenHeight);222 float barX = (this->barX *screenWidth); 223 float barY = (this->barY *screenHeight); 224 float barW = (this->barW *screenWidth); 225 float barH = (this->barH *screenHeight); 225 226 226 227 float val = (float)this->currentValue/(float)this->maxValue; … … 234 235 backMat->select(); 235 236 glBegin(GL_TRIANGLE_STRIP); 236 glTexCoord2i(0, 1); glVertex2 i(offsetX, offsetY + imageHeight);237 glTexCoord2i(1, 1); glVertex2 i(offsetX +imageWidth, offsetY + imageHeight);238 glTexCoord2i(0, 0); glVertex2 i(offsetX, offsetY);239 glTexCoord2i(1, 0); glVertex2 i(offsetX + imageWidth, offsetY);237 glTexCoord2i(0, 1); glVertex2f(offsetX, offsetY + imageHeight); 238 glTexCoord2i(1, 1); glVertex2f(offsetX +imageWidth, offsetY + imageHeight); 239 glTexCoord2i(0, 0); glVertex2f(offsetX, offsetY); 240 glTexCoord2i(1, 0); glVertex2f(offsetX + imageWidth, offsetY); 240 241 glEnd(); 241 242 … … 244 245 glBegin(GL_LINE_LOOP); 245 246 glColor3f(1.0, 1.0, 1.0); 246 glVertex2 i(barX - 2, barY - 2);247 glVertex2 i(barX + barW + 2, barY - 2);248 glVertex2 i(barX + barW + 2, barY + barH + 2);249 glVertex2 i(barX - 2, barY + barH + 2);247 glVertex2f(barX - .01, barY - .01); 248 glVertex2f(barX + barW + .01, barY - .01); 249 glVertex2f(barX + barW + .01, barY + barH + .01); 250 glVertex2f(barX - .01, barY + barH + .01); 250 251 glColor3f(1.0, 1.0, 1.0); 251 252 glEnd(); … … 254 255 barMat->select(); 255 256 glBegin(GL_TRIANGLE_STRIP); 256 glTexCoord2f(0, 1); glVertex2 i(barX, barY + barH);257 glTexCoord2f(val, 1); glVertex2 i(barX + (int)(val * this->barW * (float)screenWidth), barY + barH);258 glTexCoord2f(0, 0); glVertex2 i(barX, barY);259 glTexCoord2f(val, 0); glVertex2 i(barX + (int)(val * this->barW * (float)screenWidth), barY);257 glTexCoord2f(0, 1); glVertex2f(barX, barY + barH); 258 glTexCoord2f(val, 1); glVertex2f(barX + (val * this->barW * (float)screenWidth), barY + barH); 259 glTexCoord2f(0, 0); glVertex2f(barX, barY); 260 glTexCoord2f(val, 0); glVertex2f(barX + (val * this->barW * (float)screenWidth), barY); 260 261 glEnd(); 261 262 … … 263 264 glBegin(GL_QUADS); 264 265 glColor3f(0.0, 0.0, 0.0); 265 glVertex2 i(barX, barY);266 glVertex2 i(barX + barWidth, barY);267 glVertex2 i(barX + barWidth, barY + barHeight);268 glVertex2 i(barX, barY + barHeight);266 glVertex2f(barX, barY); 267 glVertex2f(barX + barWidth, barY); 268 glVertex2f(barX + barWidth, barY + barHeight); 269 glVertex2f(barX, barY + barHeight); 269 270 glColor3f(1.0, 1.0, 1.0); 270 271 glEnd(); … … 273 274 glBegin(GL_QUADS); 274 275 glColor3f(0.0, 0.0, 0.0); 275 glVertex2 i(barX-1, barY-1);276 glVertex2 i(barX + barWidth +1, barY-1);277 glVertex2 i(barX + barWidth+1, barY + barHeight+1);278 glVertex2 i(barX - 1, barY + barHeight +1);276 glVertex2f(barX-1, barY-1); 277 glVertex2f(barX + barWidth +1, barY-1); 278 glVertex2f(barX + barWidth+1, barY + barHeight+1); 279 glVertex2f(barX - 1, barY + barHeight +1); 279 280 glColor3f(1.0, 1.0, 1.0); 280 281 glEnd(); -
branches/2d-recalc/src/lib/shell/shell.cc
r5377 r5380 81 81 this->backgroundMaterial = new Material; 82 82 // Element2D and generals 83 this->setAbsCoor2D(3, -400); 84 this->textSize = 20; 85 this->lineSpacing = 0; 83 this->textSize = .001; 84 this->lineSpacing = .001; 86 85 this->bActive = false; 87 86 this->fontFile = new char[strlen(SHELL_DEFAULT_FONT)+1]; … … 93 92 this->setTextColor(SHELL_DEFAULT_TEXT_COLOR); 94 93 this->setBackgroundColor(SHELL_DEFAULT_BACKGROUND_COLOR); 95 94 this->setRelCoor2D(0,-this->shellHeight, 0); 96 95 // register the shell at the ShellBuffer 97 96 ShellBuffer::getInstance()->registerShell(this); … … 128 127 129 128 EventHandler::getInstance()->setState(ES_SHELL); 130 this->setRelCoorSoft2D(0, 0, 1, 5);129 this->setRelCoorSoft2D(0, 0, 0, 5); 131 130 132 131 tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator(); … … 250 249 if (this->shellInput != NULL) 251 250 { 252 this->shellInput->setSize (this->textSize);251 this->shellInput->setSizeY2D(this->textSize); 253 252 this->shellInput->setColor(this->textColor[0], this->textColor[1], this->textColor[2]); 254 253 this->shellInput->setBlending(this->textColor[3]); 255 this->shellInput->setRelCoor2D( 5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize);254 this->shellInput->setRelCoor2D(.005, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize); 256 255 } 257 256 … … 262 261 if (this->bufferText[i] != NULL) 263 262 { 264 this->bufferText[i]->setSize (this->textSize);263 this->bufferText[i]->setSizeY2D(this->textSize); 265 264 this->bufferText[i]->setColor(this->textColor[0], this->textColor[1], this->textColor[2]); 266 265 this->bufferText[i]->setBlending(this->textColor[3]); … … 269 268 } 270 269 } 271 this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1); 272 270 this->shellHeight = (float)(this->textSize + this->lineSpacing) * (bufferDisplaySize+1.0); 273 271 } 274 272 … … 365 363 */ 366 364 lastText->setRelDir2D(-90); 367 lastText->setRelDirSoft2D(0, 1 0);368 lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1 000,0,0));365 lastText->setRelDirSoft2D(0, 1); 366 lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1,0,0)); 369 367 lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10); 370 368 … … 478 476 479 477 glTexCoord2f(1, 0); 480 glVertex2f( GraphicsEngine::getInstance()->getResolutionX()- this->getAbsCoor2D().x, this->getAbsCoor2D().y );478 glVertex2f(1 - this->getAbsCoor2D().x, this->getAbsCoor2D().y ); 481 479 482 480 glTexCoord2f(0, 1); … … 484 482 485 483 glTexCoord2f(1, 1); 486 glVertex2f( GraphicsEngine::getInstance()->getResolutionX()- this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);484 glVertex2f(1 - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight); 487 485 488 486 glEnd(); -
branches/2d-recalc/src/lib/shell/shell.h
r5374 r5380 92 92 // GENERAL 93 93 bool bActive; //!< If the shell is active. 94 unsigned intshellHeight; //!< The hight of the Shell in Pixels.95 unsigned intlineSpacing; //!< The Spacing between lines.96 unsigned inttextSize; //!< The size of the text.94 float shellHeight; //!< The hight of the Shell in Pixels. 95 float lineSpacing; //!< The Spacing between lines. 96 float textSize; //!< The size of the text. 97 97 float textColor[4]; //!< The text's color [r,g,b,a]. 98 98 char* fontFile; //!< The file containing the font.
Note: See TracChangeset
for help on using the changeset viewer.