55 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
63 glGenTextures(1, &
id);
64 glBindTexture(GL_TEXTURE_2D,
id);
65 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
66 i->getWidth(), i->getHeight(), 0,
67 GL_RGBA, GL_UNSIGNED_BYTE, i->getData());
68 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
69 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
72 glBindTexture(GL_TEXTURE_2D, 0);
85 double sizeX1,
double sizeY1,
86 double sizeX2,
double sizeY2) {
90 glEnable(GL_TEXTURE_2D);
91 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
92 glDisable(GL_CULL_FACE);
94 glDisable(GL_LIGHTING);
95 glDisable(GL_COLOR_MATERIAL);
96 glDisable(GL_TEXTURE_GEN_S);
97 glDisable(GL_TEXTURE_GEN_T);
98 glDisable(GL_ALPHA_TEST);
100 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
101 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
102 glBindTexture(GL_TEXTURE_2D, which);
103 glBegin(GL_TRIANGLE_STRIP);
105 glVertex2d(sizeX1, sizeY1);
107 glVertex2d(sizeX1, sizeY2);
109 glVertex2d(sizeX2, sizeY1);
111 glVertex2d(sizeX2, sizeY2);
113 glBindTexture(GL_TEXTURE_2D, 0);
114 glEnable(GL_DEPTH_TEST);
124 i->mirror(
false,
true);
131 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