| 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 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI | 
|---|
| 17 |  | 
|---|
| 18 | #include "glgui_image.h" | 
|---|
| 19 |  | 
|---|
| 20 | namespace OrxGui | 
|---|
| 21 | { | 
|---|
| 22 |  | 
|---|
| 23 |   /** | 
|---|
| 24 |    * standard constructor | 
|---|
| 25 |   */ | 
|---|
| 26 |   GLGuiImage::GLGuiImage () | 
|---|
| 27 |   { | 
|---|
| 28 |     this->init(); | 
|---|
| 29 |  | 
|---|
| 30 |   } | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 |   /** | 
|---|
| 34 |    * standard deconstructor | 
|---|
| 35 |   */ | 
|---|
| 36 |   GLGuiImage::~GLGuiImage() | 
|---|
| 37 |   { | 
|---|
| 38 |   } | 
|---|
| 39 |  | 
|---|
| 40 |   /** | 
|---|
| 41 |    * initializes the GUI-element | 
|---|
| 42 |    */ | 
|---|
| 43 |   void GLGuiImage::init() | 
|---|
| 44 |   { | 
|---|
| 45 |     this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage"); | 
|---|
| 46 |  | 
|---|
| 47 |     this->frontMaterial().setDiffuseMap(this->texture); | 
|---|
| 48 |     this->frontMaterial().setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 
|---|
| 49 |  | 
|---|
| 50 |     this->resize(); | 
|---|
| 51 |   } | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 |   void GLGuiImage::loadImageFromTexture(const Texture& texture) | 
|---|
| 55 |   { | 
|---|
| 56 |     this->frontMaterial().setDiffuseMap(texture); | 
|---|
| 57 |     this->frontMaterial().setDiffuse(1,1,1); | 
|---|
| 58 |   } | 
|---|
| 59 |  | 
|---|
| 60 |   void GLGuiImage::loadImageFromFile(const std::string& fileName) | 
|---|
| 61 |   { | 
|---|
| 62 |     this->texture.loadImage(fileName); | 
|---|
| 63 |   } | 
|---|
| 64 |  | 
|---|
| 65 |   void GLGuiImage::loadImageFromSDLSurface(SDL_Surface* surface) | 
|---|
| 66 |   { | 
|---|
| 67 |     //this->texture.loadSurface(surface); | 
|---|
| 68 |   } | 
|---|
| 69 |  | 
|---|
| 70 |   void GLGuiImage::loadImageFromDisplayList(GLuint texture) | 
|---|
| 71 |   { | 
|---|
| 72 | //    this->texture.setTexture(texture); | 
|---|
| 73 |   } | 
|---|
| 74 |  | 
|---|
| 75 |   void GLGuiImage::resize() | 
|---|
| 76 |   { | 
|---|
| 77 |     this->frontRect().setTopLeft(this->borderLeft(), this->borderTop()); | 
|---|
| 78 |     this->frontRect().setSize(this->getSizeX2D() - (borderLeft() + borderRight()), this->getSizeY2D() - (borderTop() + borderBottom()) ); | 
|---|
| 79 |     GLGuiWidget::resize(); | 
|---|
| 80 |   } | 
|---|
| 81 |  | 
|---|
| 82 |  | 
|---|
| 83 |   /** | 
|---|
| 84 |    * @brief draws the GLGuiImage | 
|---|
| 85 |    */ | 
|---|
| 86 |   void GLGuiImage::draw() const | 
|---|
| 87 |   { | 
|---|
| 88 |     this->beginDraw(); | 
|---|
| 89 |     GLGuiWidget::draw(); | 
|---|
| 90 |  | 
|---|
| 91 |     this->frontMaterial().select(); | 
|---|
| 92 |     this->drawRect(this->frontRect()); | 
|---|
| 93 |     this->endDraw(); | 
|---|
| 94 |   } | 
|---|
| 95 | } | 
|---|