50 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
58 glGenTextures(1, &
id);
59 glBindTexture(GL_TEXTURE_2D,
id);
60 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
61 i->getWidth(), i->getHeight(), 0,
62 GL_RGBA, GL_UNSIGNED_BYTE, i->getData());
63 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
65 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
66 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
67 glBindTexture(GL_TEXTURE_2D, 0);
84 glEnable(GL_TEXTURE_2D);
85 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
86 glDisable(GL_CULL_FACE);
88 glDisable(GL_LIGHTING);
89 glDisable(GL_COLOR_MATERIAL);
90 glDisable(GL_TEXTURE_GEN_S);
91 glDisable(GL_TEXTURE_GEN_T);
92 glDisable(GL_ALPHA_TEST);
94 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
95 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
96 glBindTexture(GL_TEXTURE_2D, which);
97 glBegin(GL_TRIANGLE_STRIP);
99 glVertex2d(sizeX1, sizeY1);
101 glVertex2d(sizeX1, sizeY2);
103 glVertex2d(sizeX2, sizeY1);
105 glVertex2d(sizeX2, sizeY2);
107 glBindTexture(GL_TEXTURE_2D, 0);
108 glEnable(GL_DEPTH_TEST);
119 i->mirror(
false,
true);
128 WRITE_ERROR(
"Could not load '" + filename +
"'.\n" + e.what());
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
static GUIGlID add(FXImage *i)
Adds a texture to use.
static std::map< std::string, int > myTextures
mapping from image paths to decals (initialization on first use)
static void clearTextures()
clears loaded textures
static FXbool scalePower2(FXImage *image, int maxSize=(2<< 29))
static GUIMainWindow * getInstance()
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
static bool myAllowTextures
whether textures are drawn
static FXImage * loadImage(FXApp *a, const std::string &file)
static int getMaxTextureSize()
return maximum number of pixels in x and y direction