Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/importer/texture.h @ 3655

Last change on this file since 3655 was 3655, checked in by bensch, 19 years ago

orxonox/trunk: moved protoclass to folder proto
added protosingleton
added resourceManager
modiefied some stuff to work better

File size: 2.6 KB
Line 
1/*!
2  \file texture.h
3  \brief Contains the texture class, that handles the reading of Images into Texutre-files.
4
5  \todo free SDL-surface when deleting Material.
6  \todo delete imgNameWithPath after use creation.
7*/
8
9#ifndef _TEXTURE_H
10#define _TEXTURE_H
11
12#include "glincl.h"
13
14#include "debug.h"
15
16#ifdef HAVE_SDL_SDL_IMAGE_H
17#include <SDL/SDL_image.h>
18#else
19// IMAGE LIBS //
20#ifdef HAVE_JPEGLIB_H
21extern "C"{         // This has to be done, because not a c++ lib
22#include <jpeglib.h>
23}
24#endif /* HAVE_JPEGLIB_H */
25#ifdef HAVE_PNG_H
26#include <png.h>
27#endif /* HAVE_PNG_H */
28#endif /* HAVE_SDL_SDL_IMAGE_H */
29
30
31
32//! Class to handle lists of paths.
33/**
34   \todo Ability to return Paths by itself.
35
36   It is simple to use, and good, for all PathList you want.
37   just create a new Pathlist, and add Paths.
38*/
39class PathList
40{
41 private:
42  PathList();
43  static PathList* firstPath; //!< A static Pointer to the first PathList in the List.
44 public:
45  PathList(char* pName);
46  ~PathList();
47  static PathList* getInstance(void);
48 
49  void addPath (char* pName);
50  char* pathName;              //!< The Name of the current Path.
51  PathList* next;              //!< Pointer to the next Pathlist.
52};
53
54//! A Class, that reads in Textures from different fileformats.
55class Texture
56{
57 private:
58  //! Struct to handle Infos about an Image
59  struct Image
60  {
61    int rowSpan;    //!< The count of the rows this Image has.
62    GLuint width;   //!< The width of the Image.
63    GLuint height;  //!< The height of the Image.
64    GLuint bpp;     //!< BytesPerPixel
65    GLenum format;  //!< The Format of the PixelData
66    GLuint type;    //!< Type of the Image.
67    GLubyte *data;  //!< The Image Data comes here! DANGER: uncompressed data.
68  };
69  Image* pImage;    //!< The data of an Image
70  GLuint texture;   //!< The Texture-ID of opengl from this Texture.
71  SDL_Surface* map; //!< The map SDL initializes for this element.
72  char* searchTextureInPaths(const char* texName) const;
73  inline void swap(unsigned char &a, unsigned char &b);
74 public:
75  Texture(void);
76  Texture(const char* imageName);
77  ~Texture(void);
78  /** \returns The textureID of this texture.  */
79  inline GLuint getTexture(void) {return this->texture;} 
80  bool loadTexToGL (Image* pImage);
81
82  bool loadImage(const char* imageName);
83#ifndef HAVE_SDL_SDL_IMAGE_H
84
85  bool loadBMP (char* bmpName);
86
87  bool loadJPG (char* jpgName);
88
89  /// TGA ///
90
91  bool loadTGA(const char * tgaName);
92  bool loadUncompressedTGA(const char * filename, FILE * fTGA);
93  bool loadCompressedTGA(const char * filename, FILE * fTGA);
94
95  bool loadPNG(const char* pngName);
96#endif
97
98
99};
100
101
102
103#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.