56 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
64 glGenTextures(1, &
id);
65 glBindTexture(GL_TEXTURE_2D,
id);
66 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
67 i->getWidth(), i->getHeight(), 0,
68 GL_RGBA, GL_UNSIGNED_BYTE, i->getData());
69 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
72 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
73 glBindTexture(GL_TEXTURE_2D, 0);
86 double sizeX1,
double sizeY1,
87 double sizeX2,
double sizeY2) {
91 glEnable(GL_TEXTURE_2D);
92 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
93 glDisable(GL_CULL_FACE);
95 glDisable(GL_LIGHTING);
96 glDisable(GL_COLOR_MATERIAL);
97 glDisable(GL_TEXTURE_GEN_S);
98 glDisable(GL_TEXTURE_GEN_T);
99 glDisable(GL_ALPHA_TEST);
101 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
102 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
103 glBindTexture(GL_TEXTURE_2D, which);
104 glBegin(GL_TRIANGLE_STRIP);
106 glVertex2d(sizeX1, sizeY1);
108 glVertex2d(sizeX1, sizeY2);
110 glVertex2d(sizeX2, sizeY1);
112 glVertex2d(sizeX2, sizeY2);
114 glBindTexture(GL_TEXTURE_2D, 0);
115 glEnable(GL_DEPTH_TEST);
125 i->mirror(
false,
true);
132 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