Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/gui/gl/glgui_image.cc @ 8584

Last change on this file since 8584 was 8584, checked in by bensch, 18 years ago

orxonox/gui: more implemented inside of the State, not it looks worse than before :(

File size: 2.1 KB
RevLine 
[4744]1/*
[1853]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.
[1855]10
11   ### File Specific:
[5360]12   main-programmer: Benjamin Grauer
[1855]13   co-programmer: ...
[1853]14*/
15
[5360]16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
[1853]17
[5366]18#include "glgui_image.h"
[1853]19
[8448]20#include "debug.h"
21
[7779]22namespace OrxGui
[3365]23{
[4320]24
[7779]25  /**
26   * standard constructor
27  */
28  GLGuiImage::GLGuiImage ()
29  {
30    this->init();
[1853]31
[7779]32  }
[1853]33
[5360]34
[7779]35  /**
36   * standard deconstructor
37  */
38  GLGuiImage::~GLGuiImage()
39  {
40  }
[5360]41
[7779]42  /**
43   * initializes the GUI-element
44   */
45  void GLGuiImage::init()
46  {
[8035]47    this->setClassID(CL_GLGUI_IMAGE, "GLGuiImage");
[5360]48
[8448]49    this->_imageMaterial.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[8035]50
51    this->resize();
[7779]52  }
[5360]53
[8035]54
55  void GLGuiImage::loadImageFromTexture(const Texture& texture)
56  {
[8448]57    this->_imageMaterial.setDiffuseMap(texture);
[8035]58  }
59
60  void GLGuiImage::loadImageFromFile(const std::string& fileName)
61  {
[8448]62    this->_imageMaterial.setDiffuseMap(fileName);
[8035]63  }
64
65  void GLGuiImage::loadImageFromSDLSurface(SDL_Surface* surface)
66  {
[8448]67    this->_imageMaterial.setDiffuseMap(Texture(surface));
[8035]68  }
69
70  void GLGuiImage::loadImageFromDisplayList(GLuint texture)
71  {
[8448]72    PRINTF(2)("SORRY NOT IMPLEMENTED\n");
73//    this->_imageMaterial.setTexture(texture);
[8035]74  }
75
[8448]76  void GLGuiImage::updateFrontColor()
77  {
[8584]78    this->_imageMaterial.setDiffuseColor(style().foregroundColor());
[8448]79  }
80
[8035]81  void GLGuiImage::resize()
82  {
[8584]83    this->_imagePlane.setTopLeft(style().borderLeft(), style().borderTop());
84    this->_imagePlane.setSize(this->getSizeX2D() - (style().borderLeft() + style().borderRight()), this->getSizeY2D() - (style().borderTop() + style().borderBottom()) );
[8035]85    GLGuiWidget::resize();
86  }
87
88
[7779]89  /**
[8035]90   * @brief draws the GLGuiImage
[7779]91   */
[8035]92  void GLGuiImage::draw() const
[7779]93  {
[8035]94    this->beginDraw();
95    GLGuiWidget::draw();
96
[8448]97    this->_imageMaterial.select();
98    this->drawRect(this->_imagePlane);
[8035]99    this->endDraw();
[7779]100  }
[5360]101}
Note: See TracBrowser for help on using the repository browser.